diff options
author | Gerald Combs <gerald@zing.org> | 2016-06-25 10:12:21 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-06-26 06:23:59 +0000 |
commit | 5e8649bd59f2acac3a95c158f2ecba179ef6ae27 (patch) | |
tree | 831ca0075092bcf9ba810a289475927d9166d500 /ui/qt | |
parent | 4addfc67b4cd35601d5f9c5ce134f23ea145934a (diff) | |
download | wireshark-5e8649bd59f2acac3a95c158f2ecba179ef6ae27.tar.gz |
Qt: Don't use QStyleOptionViewItemV4.
It was deprecated in Qt 5.7. Just use QStyleOptionViewItem.
Change-Id: I890305a11393940e21bdc68d90ca6602ade16769
Reviewed-on: https://code.wireshark.org/review/16137
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/percent_bar_delegate.cpp | 26 | ||||
-rw-r--r-- | ui/qt/related_packet_delegate.cpp | 44 | ||||
-rw-r--r-- | ui/qt/sparkline_delegate.cpp | 16 |
3 files changed, 47 insertions, 39 deletions
diff --git a/ui/qt/percent_bar_delegate.cpp b/ui/qt/percent_bar_delegate.cpp index ae763d2462..76517de85e 100644 --- a/ui/qt/percent_bar_delegate.cpp +++ b/ui/qt/percent_bar_delegate.cpp @@ -32,8 +32,8 @@ static const double bar_blend_ = 0.15; void PercentBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QStyleOptionViewItemV4 optv4 = option; - QStyledItemDelegate::initStyleOption(&optv4, index); + QStyleOptionViewItem option_vi = option; + QStyledItemDelegate::initStyleOption(&option_vi, index); QStyledItemDelegate::paint(painter, option, index); @@ -50,23 +50,23 @@ void PercentBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op if (QApplication::style()->objectName().contains("vista")) { // QWindowsVistaStyle::drawControl does this internally. Unfortunately there // doesn't appear to be a more general way to do this. - optv4.palette.setColor(QPalette::All, QPalette::HighlightedText, - optv4.palette.color(QPalette::Active, QPalette::Text)); + option_vi.palette.setColor(QPalette::All, QPalette::HighlightedText, + option_vi.palette.color(QPalette::Active, QPalette::Text)); } - QColor bar_color = ColorUtils::alphaBlend(optv4.palette.windowText(), - optv4.palette.window(), bar_blend_); - QPalette::ColorGroup cg = optv4.state & QStyle::State_Enabled + QColor bar_color = ColorUtils::alphaBlend(option_vi.palette.windowText(), + option_vi.palette.window(), bar_blend_); + QPalette::ColorGroup cg = option_vi.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(optv4.state & QStyle::State_Active)) + if (cg == QPalette::Normal && !(option_vi.state & QStyle::State_Active)) cg = QPalette::Inactive; - if (optv4.state & QStyle::State_Selected) { - painter->setPen(optv4.palette.color(cg, QPalette::HighlightedText)); - bar_color = ColorUtils::alphaBlend(optv4.palette.color(cg, QPalette::Window), - optv4.palette.color(cg, QPalette::Highlight), + if (option_vi.state & QStyle::State_Selected) { + painter->setPen(option_vi.palette.color(cg, QPalette::HighlightedText)); + bar_color = ColorUtils::alphaBlend(option_vi.palette.color(cg, QPalette::Window), + option_vi.palette.color(cg, QPalette::Highlight), bar_blend_); } else { - painter->setPen(optv4.palette.color(cg, QPalette::Text)); + painter->setPen(option_vi.palette.color(cg, QPalette::Text)); } QRect pct_rect = option.rect; diff --git a/ui/qt/related_packet_delegate.cpp b/ui/qt/related_packet_delegate.cpp index 1ab1eb2994..0107ea2264 100644 --- a/ui/qt/related_packet_delegate.cpp +++ b/ui/qt/related_packet_delegate.cpp @@ -49,16 +49,24 @@ RelatedPacketDelegate::RelatedPacketDelegate(QWidget *parent) : void RelatedPacketDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QStyleOptionViewItemV4 optv4 = option; - QStyledItemDelegate::initStyleOption(&optv4, index); - int em_w = optv4.fontMetrics.height(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QStyleOptionViewItemV4 option_vi = option; +#else + QStyleOptionViewItem option_vi = option; +#endif + QStyledItemDelegate::initStyleOption(&option_vi, index); + int em_w = option_vi.fontMetrics.height(); int en_w = (em_w + 1) / 2; - int line_w = (optv4.fontMetrics.lineWidth()); + int line_w = (option_vi.fontMetrics.lineWidth()); - optv4.features |= QStyleOptionViewItemV4::HasDecoration; - optv4.decorationSize.setHeight(1); - optv4.decorationSize.setWidth(em_w); - QStyledItemDelegate::paint(painter, optv4, index); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + option_vi.features |= QStyleOptionViewItemV4::HasDecoration; +#else + option_vi.features |= QStyleOptionViewItem::HasDecoration; +#endif + option_vi.decorationSize.setHeight(1); + option_vi.decorationSize.setWidth(em_w); + QStyledItemDelegate::paint(painter, option_vi, index); guint32 setup_frame = 0, last_frame = 0; if (conv_) { @@ -77,30 +85,30 @@ void RelatedPacketDelegate::paint(QPainter *painter, const QStyleOptionViewItem if (QApplication::style()->objectName().contains("vista")) { // QWindowsVistaStyle::drawControl does this internally. Unfortunately there // doesn't appear to be a more general way to do this. - optv4.palette.setColor(QPalette::All, QPalette::HighlightedText, optv4.palette.color(QPalette::Active, QPalette::Text)); + option_vi.palette.setColor(QPalette::All, QPalette::HighlightedText, option_vi.palette.color(QPalette::Active, QPalette::Text)); } - QPalette::ColorGroup cg = optv4.state & QStyle::State_Enabled + QPalette::ColorGroup cg = option_vi.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; QColor fg; - if (cg == QPalette::Normal && !(optv4.state & QStyle::State_Active)) + if (cg == QPalette::Normal && !(option_vi.state & QStyle::State_Active)) cg = QPalette::Inactive; - if (optv4.state & QStyle::State_Selected) { - fg = optv4.palette.color(cg, QPalette::HighlightedText); + if (option_vi.state & QStyle::State_Selected) { + fg = option_vi.palette.color(cg, QPalette::HighlightedText); } else { - fg = optv4.palette.color(cg, QPalette::Text); + fg = option_vi.palette.color(cg, QPalette::Text); } - fg = ColorUtils::alphaBlend(fg, optv4.palette.color(cg, QPalette::Base), 0.5); + fg = ColorUtils::alphaBlend(fg, option_vi.palette.color(cg, QPalette::Base), 0.5); QPen line_pen(fg); line_pen.setWidth(line_w); line_pen.setJoinStyle(Qt::RoundJoin); painter->setPen(line_pen); - painter->translate(optv4.rect.x(), optv4.rect.y()); + painter->translate(option_vi.rect.x(), option_vi.rect.y()); painter->translate(en_w + 0.5, 0.5); painter->setRenderHint(QPainter::Antialiasing, true); - int height = optv4.rect.height(); + int height = option_vi.rect.height(); // Uncomment to make the boundary visible. // painter->save(); @@ -185,7 +193,7 @@ void RelatedPacketDelegate::paint(QPainter *painter, const QStyleOptionViewItem } case FT_FRAMENUM_NONE: default: - painter->drawEllipse(QPointF(0.0, optv4.rect.height() / 2), 2, 2); + painter->drawEllipse(QPointF(0.0, option_vi.rect.height() / 2), 2, 2); } } diff --git a/ui/qt/sparkline_delegate.cpp b/ui/qt/sparkline_delegate.cpp index 3cc4069192..b4e565cc0d 100644 --- a/ui/qt/sparkline_delegate.cpp +++ b/ui/qt/sparkline_delegate.cpp @@ -59,25 +59,25 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt idx = idx + step_w; } - QStyleOptionViewItemV4 optv4 = option; - QStyledItemDelegate::initStyleOption(&optv4, index); + QStyleOptionViewItem option_vi = option; + QStyledItemDelegate::initStyleOption(&option_vi, index); painter->save(); if (QApplication::style()->objectName().contains("vista")) { // QWindowsVistaStyle::drawControl does this internally. Unfortunately there // doesn't appear to be a more general way to do this. - optv4.palette.setColor(QPalette::All, QPalette::HighlightedText, optv4.palette.color(QPalette::Active, QPalette::Text)); + option_vi.palette.setColor(QPalette::All, QPalette::HighlightedText, option_vi.palette.color(QPalette::Active, QPalette::Text)); } - QPalette::ColorGroup cg = optv4.state & QStyle::State_Enabled + QPalette::ColorGroup cg = option_vi.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(optv4.state & QStyle::State_Active)) + if (cg == QPalette::Normal && !(option_vi.state & QStyle::State_Active)) cg = QPalette::Inactive; - if (optv4.state & QStyle::State_Selected) { - painter->setPen(optv4.palette.color(cg, QPalette::HighlightedText)); + if (option_vi.state & QStyle::State_Selected) { + painter->setPen(option_vi.palette.color(cg, QPalette::HighlightedText)); } else { - painter->setPen(optv4.palette.color(cg, QPalette::Text)); + painter->setPen(option_vi.palette.color(cg, QPalette::Text)); } painter->setRenderHint(QPainter::Antialiasing, true); |