diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-07-27 12:33:27 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-02 02:43:36 +0200 |
commit | f915ea135fe4bf74432ffa3e6041ea60d4268c67 (patch) | |
tree | eb10268a72d7e4494e7b02c215bc62d42fd82aa1 /tests/auto/quick/shared | |
parent | 8dabc28e4ea6fe7946ee7770ba39410c6d95bc1d (diff) |
Fix handling of changes to the root index of a VisualDataModel.
Store the root index as a QPersistentModelIndex so the index remains
valid as the model changes, and in the case the root index is
removed from the model invalidate the contents of the VisualDataModel
until a new root index or model is set.
Change-Id: I1cbc27f2068f99a02ff3d43373905dec7e35e900
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/shared')
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.cpp | 27 | ||||
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.h | 28 |
2 files changed, 28 insertions, 27 deletions
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 63da97b4f8..a58d75da63 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -45,33 +45,6 @@ #include <QtTest/QTest> -template<typename T> -static void qquickmodelviewstestutil_move(int from, int to, int n, T *items) -{ - if (from > to) { - // Only move forwards - flip if backwards moving - int tfrom = from; - int tto = to; - from = tto; - to = tto+n; - n = tfrom-tto; - } - - T replaced; - int i=0; - typename T::ConstIterator it=items->begin(); it += from+n; - for (; i<to-from; ++i,++it) - replaced.append(*it); - i=0; - it=items->begin(); it += from; - for (; i<n; ++i,++it) - replaced.append(*it); - typename T::ConstIterator f=replaced.begin(); - typename T::Iterator t=items->begin(); t += from; - for (; f != replaced.end(); ++f, ++t) - *t = *f; -} - QQuickView *QQuickViewTestUtil::createView() { QQuickView *window = new QQuickView(0); diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h index 771be0a890..31697e74c1 100644 --- a/tests/auto/quick/shared/viewtestutil.h +++ b/tests/auto/quick/shared/viewtestutil.h @@ -132,6 +132,33 @@ namespace QQuickViewTestUtil QList<int> indexes; bool valid; }; + + template<typename T> + static void qquickmodelviewstestutil_move(int from, int to, int n, T *items) + { + if (from > to) { + // Only move forwards - flip if backwards moving + int tfrom = from; + int tto = to; + from = tto; + to = tto+n; + n = tfrom-tto; + } + + T replaced; + int i=0; + typename T::ConstIterator it=items->begin(); it += from+n; + for (; i<to-from; ++i,++it) + replaced.append(*it); + i=0; + it=items->begin(); it += from; + for (; i<n; ++i,++it) + replaced.append(*it); + typename T::ConstIterator f=replaced.begin(); + typename T::Iterator t=items->begin(); t += from; + for (; f != replaced.end(); ++f, ++t) + *t = *f; + } } Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*) @@ -139,4 +166,5 @@ Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange) Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange) + #endif // QQUICKVIEWTESTUTIL_H |