Implement viewOptions logic in QTableViewPrivate.
authorStephen Kelly <stephen.kelly@kdab.com>
Tue, 23 Oct 2012 12:03:05 +0000 (14:03 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 25 Oct 2012 12:10:04 +0000 (14:10 +0200)
This is similar to the patch 05aa8c6c12509cce87d1a3811c5ea1dd83fa0898
which was applied to QListView.

Task-number: QTBUG-26548
Change-Id: I38ff07230673a93a32b01a7f1951d0378d94185b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
src/widgets/itemviews/qtableview.cpp
src/widgets/itemviews/qtableview_p.h
tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp

index b337f7f..80abb05 100644 (file)
@@ -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();
 }
 
 /*!
index 792f507..fbad4ed 100644 (file)
@@ -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);
index 2fbd90a..2bccb03 100644 (file)
@@ -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"