From 3578e05b293c1cc53582109001b20f02c7a1eeb7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 30 Jan 2012 00:52:34 +0000 Subject: Merge QStyleOption*V{2,3,4} classes together In order to keep binary compatibility, Qt 4 introduced V{2,3,4} classes for QStyleOption subclasses. They're simple, low level containers for various members with public access (no accessors required). In Qt 5.0 we can break BC, so this patch moves the members from the derived classes into the ``base'' ones. The ``base'' ones get a version bump matching the highest version available, and the V{2,3,4} classes become typedefs. This change can cause problems in code that used QStyleOption directly, especially QStyleOptionViewItem, because the old V4 fields get default initialization but the QStyle subclasses detect that the option is a V4 option and expect all fields to be properly initialized. The fix in such places is to properly initialize all fields. Task-number: QTBUG-23522 Change-Id: I2f782da09ca5cc8c4cbafc07448fb0d33153a251 Reviewed-by: Lars Knoll --- tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp') diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 746b721cb0..2b52f5f234 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -1033,6 +1033,9 @@ void tst_QItemDelegate::editorEvent() QStyleOptionViewItem option; option.rect = rect; option.state |= QStyle::State_Enabled; + // mimic QStyledItemDelegate::initStyleOption logic + option.features |= QStyleOptionViewItem::HasCheckIndicator | QStyleOptionViewItem::HasDisplay; + option.checkState = Qt::CheckState(checkState); const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; QPoint pos = inCheck ? qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0) : QPoint(200,200); @@ -1181,6 +1184,9 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck() QTest::qWaitForWindowShown(&view); QStyleOptionViewItem option; option.rect = view.visualRect(model.index(0, 0)); + // mimic QStyledItemDelegate::initStyleOption logic + option.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator; + option.checkState = Qt::CheckState(model.index(0, 0).data(Qt::CheckStateRole).toInt()); const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0); -- cgit v1.2.3