summaryrefslogtreecommitdiff
path: root/tests/auto/testplugin
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-27 20:23:57 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-27 22:10:06 +0200
commitabe319c9cb811832bb4c9c95290564dfa7b3603a (patch)
treee93b7e554b3cd497b86f0be3bd46450a91ea088e /tests/auto/testplugin
parentefdd81ce80b018b7b5779876e94f1b722af7fb9a (diff)
parent69b3136bae16897492d27558c5909cd61a5e598e (diff)
downloadqtquickcontrols-abe319c9cb811832bb4c9c95290564dfa7b3603a.tar.gz
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp Change-Id: I0b6018fdac65a5385136e4c3561fba1c52ecd32e
Diffstat (limited to 'tests/auto/testplugin')
-rw-r--r--tests/auto/testplugin/testcppmodels.h52
-rw-r--r--tests/auto/testplugin/testplugin.cpp1
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/testplugin/testcppmodels.h b/tests/auto/testplugin/testcppmodels.h
index cb1cfb4f..03b598c4 100644
--- a/tests/auto/testplugin/testcppmodels.h
+++ b/tests/auto/testplugin/testcppmodels.h
@@ -88,6 +88,58 @@ private:
QList<TestObject> m_testobject;
};
+class TestFetchAppendModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ explicit TestFetchAppendModel(QObject *parent = 0)
+ : QAbstractListModel(parent) { }
+
+ virtual int rowCount(const QModelIndex &parent) const
+ {
+ if (parent.isValid()) {
+ return 0;
+ }
+
+ return m_data.size();
+ }
+ virtual QVariant data(const QModelIndex &index, int role) const
+ {
+ if (!index.isValid() || role != Qt::DisplayRole) {
+ return QVariant();
+ }
+
+ return QVariant::fromValue(index.row());
+ }
+
+ virtual bool canFetchMore(const QModelIndex &parent) const
+ {
+ Q_UNUSED(parent)
+
+ return true;
+ }
+ virtual void fetchMore(const QModelIndex & parent)
+ {
+ Q_UNUSED(parent)
+
+ addMoreData();
+ }
+
+private:
+ void addMoreData()
+ {
+ static const int insertCount = 20;
+
+ beginInsertRows(QModelIndex(), m_data.size(), m_data.size() + insertCount - 1);
+ for (int i = 0; i < insertCount; i++) {
+ m_data.append(int());
+ }
+ endInsertRows();
+ }
+
+ QList<int> m_data;
+};
+
#endif // TESTCPPMODELS_H
diff --git a/tests/auto/testplugin/testplugin.cpp b/tests/auto/testplugin/testplugin.cpp
index 45573d92..039a59e0 100644
--- a/tests/auto/testplugin/testplugin.cpp
+++ b/tests/auto/testplugin/testplugin.cpp
@@ -40,6 +40,7 @@ void TestPlugin::registerTypes(const char *uri)
qmlRegisterType<TestObject>(uri, 1, 0, "TestObject");
qmlRegisterType<TestItemModel>(uri, 1, 0, "TestItemModel");
qmlRegisterType<TestModel>(uri, 1, 0, "TreeModel");
+ qmlRegisterType<TestFetchAppendModel>(uri, 1, 0, "TestFetchAppendModel");
}
void TestPlugin::initializeEngine(QQmlEngine *engine, const char * /*uri*/)