From 9a02bd0c39ae0cf02c7cee9c00b4991f0f92adb2 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Mon, 21 Sep 2015 10:32:40 -0700 Subject: Make it possible to disable PercentBarDelegate. Add a check to PercentBarDelegate to see if the caller set text for this item or did not set a valid double value. If either case is true, just draw the item normally and return. Change-Id: I028ee15d54f06f2cb16c6e5f1ef73c47b2886ccd Reviewed-on: https://code.wireshark.org/review/10600 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- ui/qt/percent_bar_delegate.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ui/qt/percent_bar_delegate.cpp') diff --git a/ui/qt/percent_bar_delegate.cpp b/ui/qt/percent_bar_delegate.cpp index 06ee6f422c..ae763d2462 100644 --- a/ui/qt/percent_bar_delegate.cpp +++ b/ui/qt/percent_bar_delegate.cpp @@ -34,10 +34,17 @@ void PercentBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op { QStyleOptionViewItemV4 optv4 = option; QStyledItemDelegate::initStyleOption(&optv4, index); - double value = index.data(Qt::UserRole).toDouble(); QStyledItemDelegate::paint(painter, option, index); + bool ok = false; + double value = index.data(Qt::UserRole).toDouble(&ok); + + if (!ok || !index.data(Qt::DisplayRole).toString().isEmpty()) { + // We don't have a valid value or the item has visible text. + return; + } + painter->save(); if (QApplication::style()->objectName().contains("vista")) { -- cgit v1.2.1