diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-12-23 13:13:08 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-28 06:33:32 +0100 |
commit | 613d0e407e80f6439951597592523ac772f4c87c (patch) | |
tree | aa36da19f52273788611e55f90acae2f99b72288 /tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp | |
parent | 9f843918f27024181925b53b013666cc75e2d2e2 (diff) |
Cleanup itemmodel autotests.
Bring the code closer to compliance with Qt's coding style guidelines
and eliminate excessive vertical whitespace.
Change-Id: Iaa29f8edf326ddb80cbadb6c18cca4fea88fd9b2
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp')
-rw-r--r-- | tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index d0da27d7f5..eab8851772 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include <QtTest/QtTest> #include <qabstractitemmodel.h> #include <qapplication.h> @@ -52,20 +51,17 @@ void QModelListener::rowsAboutToBeRemovedOrInserted(const QModelIndex & parent, int start, int end ) { - int i; - for (i = 0; start + i <= end; i++) - { + for (int i = 0; start + i <= end; i++) { QModelIndex mIndex = m_pModel->index(start + i, 0, parent); QVariant var = m_pModel->data(mIndex, Qt::DisplayRole); QString str = var.toString(); - + QCOMPARE(str, m_pAboutToStringlist->at(i)); } } void QModelListener::rowsRemovedOrInserted(const QModelIndex & parent, int , int) { - int i; // Can the rows that *are* removed be iterated now ? // What about rowsAboutToBeInserted - what will the indices be? @@ -74,18 +70,16 @@ void QModelListener::rowsRemovedOrInserted(const QModelIndex & parent, int , int // RemoveColumn. Does that also fire the rowsRemoved-family signals? - for (i = 0; i < m_pExpectedStringlist->size(); i++) - { + for (int i = 0; i < m_pExpectedStringlist->size(); i++) { QModelIndex mIndex = m_pModel->index(i, 0, parent); QVariant var = m_pModel->data(mIndex, Qt::DisplayRole); QString str = var.toString(); - + //qDebug() << "index: " << i << " start: " << start << "end: " << end; QCOMPARE(str, m_pExpectedStringlist->at(i)); } } - class tst_QStringListModel : public QObject { Q_OBJECT @@ -152,21 +146,20 @@ void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved() QStringListModel *model = new QStringListModel(input); QModelListener *pListener = new QModelListener(&aboutto, &res, model); - pListener->connect(model, SIGNAL( rowsAboutToBeRemoved(const QModelIndex & , int , int )), + pListener->connect(model, SIGNAL( rowsAboutToBeRemoved(const QModelIndex & , int , int )), pListener, SLOT( rowsAboutToBeRemovedOrInserted(const QModelIndex & , int , int )) ); - pListener->connect(model, SIGNAL( rowsRemoved(const QModelIndex & , int , int )), + pListener->connect(model, SIGNAL( rowsRemoved(const QModelIndex & , int , int )), pListener, SLOT( rowsRemovedOrInserted(const QModelIndex & , int , int )) ); model->removeRows(row,count); - // At this point, control goes to our connected slots inn this order: + // At this point, control goes to our connected slots inn this order: // 1. rowsAboutToBeRemovedOrInserted // 2. rowsRemovedOrInserted // Control returns here delete pListener; delete model; - } void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted_data() @@ -217,24 +210,21 @@ void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted() QStringListModel *model = new QStringListModel(input); QModelListener *pListener = new QModelListener(&aboutto, &res, model); - connect(model, SIGNAL( rowsAboutToBeInserted(const QModelIndex & , int , int )), + connect(model, SIGNAL( rowsAboutToBeInserted(const QModelIndex & , int , int )), pListener, SLOT( rowsAboutToBeRemovedOrInserted(const QModelIndex & , int , int )) ); - connect(model, SIGNAL( rowsInserted(const QModelIndex & , int , int )), + connect(model, SIGNAL( rowsInserted(const QModelIndex & , int , int )), pListener, SLOT( rowsRemovedOrInserted(const QModelIndex & , int , int )) ); model->insertRows(row,count); - // At this point, control goes to our connected slots inn this order: + // At this point, control goes to our connected slots inn this order: // 1. rowsAboutToBeRemovedOrInserted // 2. rowsRemovedOrInserted // Control returns here delete pListener; delete model; - } - QTEST_MAIN(tst_QStringListModel) #include "tst_qstringlistmodel.moc" - |