Implement viewOptions logic in QTableViewPrivate.

This is similar to the patch 05aa8c6c12
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>
This commit is contained in:
Stephen Kelly 2012-10-23 14:03:05 +02:00 committed by The Qt Project
parent 1550c46179
commit 92c739cf50
3 changed files with 23 additions and 3 deletions

View 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();
}
/*!

View 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);

View 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"