From 92c739cf50b18b8abdc1b30480b75cc6b27cf5bf Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Oct 2012 14:03:05 +0200 Subject: [PATCH] Implement viewOptions logic in QTableViewPrivate. This is similar to the patch 05aa8c6c12509cce87d1a3811c5ea1dd83fa0898 which was applied to QListView. Task-number: QTBUG-26548 Change-Id: I38ff07230673a93a32b01a7f1951d0378d94185b Reviewed-by: Giuseppe D'Angelo Reviewed-by: Oliver Wolff Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qtableview.cpp | 12 +++++++++--- src/widgets/itemviews/qtableview_p.h | 2 ++ .../widgets/itemviews/qtableview/tst_qtableview.cpp | 12 ++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index b337f7f87f..80abb050ee 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1290,14 +1290,20 @@ void QTableView::scrollContentsBy(int dx, int dy) } } +QStyleOptionViewItem QTableViewPrivate::viewOptions() const +{ + QStyleOptionViewItem option = QAbstractItemViewPrivate::viewOptions(); + option.showDecorationSelected = true; + return option; +} + /*! \reimp */ QStyleOptionViewItem QTableView::viewOptions() const { - QStyleOptionViewItem option = QAbstractItemView::viewOptions(); - option.showDecorationSelected = true; - return option; + Q_D(const QTableView); + return d->viewOptions(); } /*! diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 792f507252..fbad4edf71 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -150,6 +150,8 @@ public: void init(); void trimHiddenSelections(QItemSelectionRange *range) const; + QStyleOptionViewItem viewOptions() const; + inline bool isHidden(int row, int col) const { return verticalHeader->isSectionHidden(row) || horizontalHeader->isSectionHidden(col); diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 2fbd90a3fe..2bccb03845 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -199,6 +199,7 @@ private slots: void task234926_setHeaderSorting(); void changeHeaderData(); + void viewOptions(); }; // Testing get/set functions @@ -477,6 +478,10 @@ public: return QTableView::sizeHintForRow(row); } + QStyleOptionViewItem viewOptions() const { + return QTableView::viewOptions(); + } + bool checkSignalOrder; public slots: void currentChanged(QModelIndex , QModelIndex ) { @@ -4074,5 +4079,12 @@ void tst_QTableView::taskQTBUG_10169_sizeHintForRow() QCOMPARE(orderedHeight, reorderedHeight); } +void tst_QTableView::viewOptions() +{ + QtTestTableView view; + QStyleOptionViewItem options = view.viewOptions(); + QVERIFY(options.showDecorationSelected); +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc"