summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-11-30 08:28:20 +0100
committerLiang Qi <liang.qi@qt.io>2017-11-30 09:16:58 +0100
commit87204c856ae3d8495c41af998ac196a12fe1c779 (patch)
tree5af64eaa3acde506d19fe4ab1c88b028a2197adf /tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
parent498ef7f9d77fca75bcba2f657aaac38c8dc78aea (diff)
parentd0812cbdabcff4d388334c499c23992cce98d4da (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/corelib/thread/qsemaphore.cpp tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Id35b535e88df63fdfe4007ea92ed4a39c4b6d707
Diffstat (limited to 'tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index f2279ea4d4..273e90e110 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -210,6 +210,7 @@ private slots:
void QTBUG12268_hiddenMovedSectionSorting();
void QTBUG14242_hideSectionAutoSize();
void QTBUG50171_visualRegionForSwappedItems();
+ void QTBUG53221_assertShiftHiddenRow();
void ensureNoIndexAtLength();
void offsetConsistent();
@@ -2384,6 +2385,54 @@ void tst_QHeaderView::QTBUG50171_visualRegionForSwappedItems()
headerView.testVisualRegionForSelection();
}
+class QTBUG53221_Model : public QAbstractItemModel
+{
+public:
+ void insertRowAtBeginning()
+ {
+ Q_EMIT layoutAboutToBeChanged();
+ m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.count()));
+ // Rows are always inserted at the beginning, so move all others.
+ foreach (const QModelIndex &persIndex, persistentIndexList())
+ {
+ // The vertical header view will have a persistent index stored here on the second call to insertRowAtBeginning.
+ changePersistentIndex(persIndex, index(persIndex.row() + 1, persIndex.column(), persIndex.parent()));
+ }
+ Q_EMIT layoutChanged();
+ }
+
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ return (role == Qt::DisplayRole) ? m_displayNames.at(index.row()) : QVariant();
+ }
+
+ QModelIndex index(int row, int column, const QModelIndex &) const override { return createIndex(row, column); }
+ QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); }
+ int rowCount(const QModelIndex &) const override { return m_displayNames.count(); }
+ int columnCount(const QModelIndex &) const override { return 1; }
+
+private:
+ QStringList m_displayNames;
+};
+
+void tst_QHeaderView::QTBUG53221_assertShiftHiddenRow()
+{
+ QTableView tableView;
+ QTBUG53221_Model modelTableView;
+ tableView.setModel(&modelTableView);
+
+ modelTableView.insertRowAtBeginning();
+ tableView.setRowHidden(0, true);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), true);
+ modelTableView.insertRowAtBeginning();
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), true);
+ modelTableView.insertRowAtBeginning();
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), false);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(2), true);
+}
+
void protected_QHeaderView::testVisualRegionForSelection()
{
QRegion r = visualRegionForSelection(QItemSelection(model()->index(1, 0), model()->index(1, 2)));