summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstandarditemmodel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qstandarditemmodel')
-rw-r--r--tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
index a530323..c7a0cd5 100644
--- a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -135,6 +135,7 @@ private slots:
void rootItemFlags();
void treeDragAndDrop();
+ void removeRowsAndColumns();
private:
QAbstractItemModel *m_model;
@@ -1405,7 +1406,7 @@ bool tst_QStandardItemModel::compareItems(QStandardItem *item1, QStandardItem *i
return true;
if (!item1 || !item2)
return false;
- if (item1->text() != item2->text()){
+ if (item1->text() != item2->text()){
qDebug() << item1->text() << item2->text();
return false;
}
@@ -1610,6 +1611,52 @@ void tst_QStandardItemModel::treeDragAndDrop()
}
}
+void tst_QStandardItemModel::removeRowsAndColumns()
+{
+#define VERIFY_MODEL \
+ for (int c = 0; c < col_list.count(); c++) \
+ for (int r = 0; r < row_list.count(); r++) \
+ QCOMPARE(model.item(r,c)->text() , row_list[r] + "x" + col_list[c]);
+
+ QVector<QString> row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',').toVector();
+ QVector<QString> col_list = row_list;
+ QStandardItemModel model;
+ for (int c = 0; c < col_list.count(); c++)
+ for (int r = 0; r < row_list.count(); r++)
+ model.setItem(r, c, new QStandardItem(row_list[r] + "x" + col_list[c]));
+ VERIFY_MODEL
+
+ row_list.remove(3);
+ model.removeRow(3);
+ VERIFY_MODEL
+
+ col_list.remove(5);
+ model.removeColumn(5);
+ VERIFY_MODEL
+
+ row_list.remove(2, 5);
+ model.removeRows(2, 5);
+ VERIFY_MODEL
+
+ col_list.remove(1, 6);
+ model.removeColumns(1, 6);
+ VERIFY_MODEL
+
+ QList<QStandardItem *> row_taken = model.takeRow(6);
+ QCOMPARE(row_taken.count(), col_list.count());
+ for (int c = 0; c < col_list.count(); c++)
+ QCOMPARE(row_taken[c]->text() , row_list[6] + "x" + col_list[c]);
+ row_list.remove(6);
+ VERIFY_MODEL
+
+ QList<QStandardItem *> col_taken = model.takeColumn(10);
+ QCOMPARE(col_taken.count(), row_list.count());
+ for (int r = 0; r < row_list.count(); r++)
+ QCOMPARE(col_taken[r]->text() , row_list[r] + "x" + col_list[10]);
+ col_list.remove(10);
+ VERIFY_MODEL
+}
+
QTEST_MAIN(tst_QStandardItemModel)
#include "tst_qstandarditemmodel.moc"