summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-06-11 23:23:38 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-06-11 23:23:38 (GMT)
commitb6cf52001e6c961f78fd3ebf19f09a94ddf52a97 (patch)
tree958b0660a1d6313db9841f77693dd26ba0da05ff /tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
parent344279da7e1cfbc4a28fd46931301d08ed9ef7d8 (diff)
parent66f34c40dbc52b76434db4ccac6c43101bd57e1e (diff)
downloadQt-b6cf52001e6c961f78fd3ebf19f09a94ddf52a97.zip
Qt-b6cf52001e6c961f78fd3ebf19f09a94ddf52a97.tar.gz
Qt-b6cf52001e6c961f78fd3ebf19f09a94ddf52a97.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts: src/gui/graphicsview/qgraphicswidget.cpp src/gui/painting/qdrawutil.cpp src/gui/painting/qpainterpath.cpp tools/qdoc3/test/qt-cpp-ignore.qdocconf tools/qdoc3/test/qt-inc.qdocconf
Diffstat (limited to 'tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp')
-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 84bda92..8067554 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;
@@ -1403,7 +1404,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;
}
@@ -1606,6 +1607,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"