summaryrefslogtreecommitdiff
path: root/ui/qt/percent_bar_delegate.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-09-21 10:32:40 -0700
committerGerald Combs <gerald@wireshark.org>2015-09-21 18:40:44 +0000
commit9a02bd0c39ae0cf02c7cee9c00b4991f0f92adb2 (patch)
tree8dd00048fc0f1838e6b82ba5a3226c7aa4d8eb9a /ui/qt/percent_bar_delegate.cpp
parent460ae03ec3cac3240d4ba7914956f65b9c331d9c (diff)
downloadwireshark-9a02bd0c39ae0cf02c7cee9c00b4991f0f92adb2.tar.gz
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 <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/percent_bar_delegate.cpp')
-rw-r--r--ui/qt/percent_bar_delegate.cpp9
1 files changed, 8 insertions, 1 deletions
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")) {