summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/itemmodels/qstringlistmodel
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-12-23 13:13:08 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-28 06:33:32 +0100
commit613d0e407e80f6439951597592523ac772f4c87c (patch)
treeaa36da19f52273788611e55f90acae2f99b72288 /tests/auto/corelib/itemmodels/qstringlistmodel
parent9f843918f27024181925b53b013666cc75e2d2e2 (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')
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h5
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro6
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp30
3 files changed, 13 insertions, 28 deletions
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h
index f3ed3c1793..a95de96008 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h
@@ -38,11 +38,11 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <QObject>
#include <QModelIndex>
#include <qdebug.h>
-
QT_FORWARD_DECLARE_CLASS(QStringListModel)
class QModelListener : public QObject
@@ -56,7 +56,7 @@ public:
virtual ~QModelListener() { }
void setTestData(QStringList *pAboutToStringlist, QStringList *pExpectedStringlist, QStringListModel *pModel)
- {
+ {
m_pAboutToStringlist = pAboutToStringlist;
m_pExpectedStringlist = pExpectedStringlist;
m_pModel = pModel;
@@ -70,6 +70,5 @@ private:
public slots:
void rowsAboutToBeRemovedOrInserted(const QModelIndex & parent, int start, int end );
void rowsRemovedOrInserted(const QModelIndex & parent, int start, int end );
-
};
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro b/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro
index ecdd30cae2..821a48038b 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro
@@ -2,8 +2,4 @@ CONFIG += testcase
TARGET = tst_qstringlistmodel
QT += widgets testlib
HEADERS += qmodellistener.h
-
-SOURCES += tst_qstringlistmodel.cpp
-
-
-
+SOURCES += tst_qstringlistmodel.cpp
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"
-