From c501e09efacb8a60deb41f85f3402f6f4c041d95 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sun, 16 Aug 2020 13:55:11 +0200 Subject: Replace QAbstractItemView::viewOptions with initViewItemOption viewOptions returned a QStyleOptionViewItem object. Such a method can never support newer versions of the option structure. Most styleable QWidget classes provide a virtual method initStyleOption that initializes the option object passed in as a pointer, e.g QFrame, QAbstractSpinBox, or QComboBox. Follow that API convention, but name it initViewItemOption, as the QStyleOptionViewItem struct contains information about the item as well as the widget itelf. This is a source incompatible change that will go unnoticed unless existing subclasses mark their overrides as 'override', or call the removed QAbstractItemView::viewOption virtual function. [ChangeLog][QtWidgets][QAbstractItemView] The virtual viewOptions method that previously returned a QStyleOptionViewItem object has been renamed to initViewItemOption, and initializes a QStyleOptionViewItem object that's passed in through a pointer. Change-Id: Ie058702aed42d77274fa3c4abb43ba302e57e348 Reviewed-by: Richard Moe Gustavsen --- .../widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp | 4 ++-- tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp | 4 +++- tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 7 ++++--- tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp | 5 +++-- tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 3 ++- 5 files changed, 14 insertions(+), 9 deletions(-) (limited to 'tests/auto/widgets/itemviews') diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 02be27ffc7..2517d3bd5a 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -516,8 +516,8 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view) #if QT_CONFIG(draganddrop) if (!view->model()) view->startDrag(Qt::CopyAction); - - view->viewOptions(); + QStyleOptionViewItem option; + view->initViewItemOption(&option); view->setState(QAbstractItemView::NoState); QCOMPARE(view->state(), QAbstractItemView::NoState); diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 36ab1a64a6..155b5389fc 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -843,7 +843,9 @@ class FastEditItemView : public QTableView public: QWidget* fastEdit(const QModelIndex &i) // Consider this as QAbstractItemView::edit( ) { - QWidget *v = itemDelegate()->createEditor(viewport(), viewOptions(), i); + QStyleOptionViewItem option; + initViewItemOption(&option); + QWidget *v = itemDelegate()->createEditor(viewport(), option, i); if (v) itemDelegate()->setEditorData(v, i); return v; diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index f5fcc35084..238f5f3ffe 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -84,7 +84,7 @@ public: using QListView::setSelection; using QListView::setViewportMargins; using QListView::startDrag; - using QListView::viewOptions; + using QListView::initViewItemOption; QRegion getVisualRegionForSelection() const { return QListView::visualRegionForSelection(selectionModel()->selection()); @@ -2258,10 +2258,11 @@ void tst_QListView::testScrollToWithHidden() void tst_QListView::testViewOptions() { PublicListView view; - QStyleOptionViewItem options = view.viewOptions(); + QStyleOptionViewItem options; + view.initViewItemOption(&options); QCOMPARE(options.decorationPosition, QStyleOptionViewItem::Left); view.setViewMode(QListView::IconMode); - options = view.viewOptions(); + view.initViewItemOption(&options); QCOMPARE(options.decorationPosition, QStyleOptionViewItem::Top); } diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 8e2f5ba068..74f480c318 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -257,7 +257,7 @@ public: using QTableView::setSelection; using QTableView::selectedIndexes; using QTableView::sizeHintForRow; - using QTableView::viewOptions; + using QTableView::initViewItemOption; bool checkSignalOrder = false; public slots: @@ -4523,7 +4523,8 @@ void tst_QTableView::taskQTBUG_10169_sizeHintForRow() void tst_QTableView::viewOptions() { QtTestTableView view; - QStyleOptionViewItem options = view.viewOptions(); + QStyleOptionViewItem options; + view.initViewItemOption(&options); QVERIFY(options.showDecorationSelected); } diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 0c9c3dc3ad..3445e1edef 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -2490,7 +2490,8 @@ void tst_QTreeView::spanningItems() // size hint // every second row is un-spanned - QStyleOptionViewItem option = view.viewOptions(); + QStyleOptionViewItem option; + view.initViewItemOption(&option); int w = view.header()->sectionSizeHint(0); for (int i = 0; i < model.rowCount(QModelIndex()); ++i) { if (!view.isFirstColumnSpanned(i, QModelIndex())) { -- cgit v1.2.3