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/related_packet_delegate.cpp | |
parent | 4addfc67b4cd35601d5f9c5ce134f23ea145934a (diff) |
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/related_packet_delegate.cpp')
-rw-r--r-- | ui/qt/related_packet_delegate.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
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); } } |