summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-09-16 05:10:45 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-09-16 05:10:45 (GMT)
commit21fb7f2ba9140eb579ad3ad376671fc59275451d (patch)
tree5efa1ebacf4211de2ee3c2235987f0ef3674eec5 /tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
parentecc6bf398772191dee846cb690747ee9c48ffff0 (diff)
parent0537750396ea519bbdf2b0fed086d535fc8c53b7 (diff)
downloadQt-21fb7f2ba9140eb579ad3ad376671fc59275451d.zip
Qt-21fb7f2ba9140eb579ad3ad376671fc59275451d.tar.gz
Qt-21fb7f2ba9140eb579ad3ad376671fc59275451d.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Compile fix for static build using mingw. Models with a single role may not update due to "modelData" conflict. Fix test. Fix bug in 34b805d66c09fb324d1b6a7bcf259e8743ef3894 Fix Symbian def files for 6454f4db1697af1d36ad4c0ea83ccd0bb490fd39 Fix Symbian def files for 34b805d66c09fb324d1b6a7bcf259e8743ef3894 crashfix for tst_qdeclarativeanimations::badTypes() Add missing images for dynamiclist example. Compile with QT_NO_GESTURES. Give file and line error information for errors in dummydata. Restore any absolute geometry changed by AnchorChanges when returning Export QDeclarativeScriptAction Completing the interface for children/data/resources Unit tests for Bauhaus enablers This patch allows modifications on PropertyChanges on the fly
Diffstat (limited to 'tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 95ef4fc..d73a872 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -75,6 +75,39 @@ static void initStandardTreeModel(QStandardItemModel *model)
model->insertRow(2, item);
}
+class SingleRoleModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ SingleRoleModel(QObject *parent = 0) {
+ QHash<int, QByteArray> roles;
+ roles.insert(Qt::DisplayRole , "name");
+ setRoleNames(roles);
+ list << "one" << "two" << "three" << "four";
+ }
+
+public slots:
+ void set(int idx, QString string) {
+ list[idx] = string;
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+protected:
+ int rowCount(const QModelIndex &parent = QModelIndex()) const {
+ return list.count();
+ }
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
+ if (role == Qt::DisplayRole)
+ return list.at(index.row());
+ return QVariant();
+ }
+
+private:
+ QStringList list;
+};
+
+
class tst_qdeclarativevisualdatamodel : public QObject
{
Q_OBJECT
@@ -86,6 +119,7 @@ private slots:
void updateLayout();
void childChanged();
void objectListModel();
+ void singleRole();
private:
QDeclarativeEngine engine;
@@ -282,6 +316,54 @@ void tst_qdeclarativevisualdatamodel::objectListModel()
QCOMPARE(name->text(), QString("Changed"));
}
+void tst_qdeclarativevisualdatamodel::singleRole()
+{
+ {
+ QDeclarativeView view;
+
+ SingleRoleModel model;
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole1.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+ {
+ QDeclarativeView view;
+
+ SingleRoleModel model;
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole2.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+}
+
template<typename T>
T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index)
{