aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-06 19:27:22 +0100
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-22 16:20:29 +0000
commit0271609d5136fa681306c2647973a26dadc7acb3 (patch)
tree4889a233a919266fbf38551a056cf8b49d7f2bd4 /src/qml/types
parentae1c3eba3e7e11a9b1ab4d18792c82c9bb6e62de (diff)
Remove QItemSelection value-type, use Array instead
We implement this by adding QItemSelection to the set of sequence types. Change-Id: Ia3db376c806d8f062639e22c7f4bf392f114c266 Reviewed-by: Stephen Kelly <steveire@gmail.com>
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qqmlitemmodels.qdoc24
-rw-r--r--src/qml/types/qqmlmodelindexvaluetype_p.h44
2 files changed, 4 insertions, 64 deletions
diff --git a/src/qml/types/qqmlitemmodels.qdoc b/src/qml/types/qqmlitemmodels.qdoc
index 70059b07c6..4e64aaa338 100644
--- a/src/qml/types/qqmlitemmodels.qdoc
+++ b/src/qml/types/qqmlitemmodels.qdoc
@@ -100,27 +100,11 @@
\section1 QItemSelection
- \l QItemSelection exposes the following properties and functions as part of
- its \l QList API:
+ Similarly to QModelIndexList, \l QItemSelection is exposed in QML as a JavaScript
+ array of QItemSelectionRanges. Conversions are automatically made from and to C++.
+ In fact, any JavaScript array can be converted back to QItemSelection, with
+ non-QItemSelectionRange objects replaced by empty QItemSelectionRanges.
- \list
- \li \b length : int
- \li object \b{at}(int i)
- \li void \b{append}(object o)
- \li void \b{prepend}(o)
- \li void \b{insert}(int i, object o)
- \li void \b{removeFirst}()
- \li void \b{removeLast}()
- \li void \b{removeAt}(int i)
- \endlist
-
- In addition, \l QItemSelection also exposes the following functions:
-
- \list
- \li void \b{select}(QModelIndex topLeft, QModelIndex bottomRight)
- \li bool \b{contains}(QModelIndex index)
- \li void \b{merge}(QItemSelection other, QItemSelectionModel::SelectionFlags command)
- \endlist
\sa ItemSelectionModel
*/
diff --git a/src/qml/types/qqmlmodelindexvaluetype_p.h b/src/qml/types/qqmlmodelindexvaluetype_p.h
index e36f7a0d1e..371335c9f3 100644
--- a/src/qml/types/qqmlmodelindexvaluetype_p.h
+++ b/src/qml/types/qqmlmodelindexvaluetype_p.h
@@ -150,50 +150,6 @@ public:
inline bool isEmpty() const { return v.isEmpty(); }
};
-template<typename V, typename T>
-QString q_listToString(const QList<T> &list, const QLatin1String &typeName)
-{
- QString result = typeName;
- result.append(QLatin1Char('('));
- for (typename QList<T>::size_type i = 0; i < list.count(); ++i) {
- if (i)
- result.append(QLatin1String(", "));
- result.append(reinterpret_cast<const V *>(&list.at(i))->toString());
- }
- return result.append(QLatin1Char(')'));
-}
-
-// Invokable QList<T> API forwarding for value types
-#define QLISTVALUETYPE_QML_API(T) \
- Q_PROPERTY(int length READ length FINAL) \
- Q_INVOKABLE T at(int i) { return v.at(i); } \
- Q_INVOKABLE void append(const T &o) { v.append(o); } \
- Q_INVOKABLE void prepend(const T &o) { v.prepend(o); } \
- Q_INVOKABLE void insert(int i, const T &o) { v.insert(i, o); } \
- Q_INVOKABLE void removeFirst() { v.removeFirst(); } \
- Q_INVOKABLE void removeLast() { v.removeLast(); } \
- Q_INVOKABLE void removeAt(int i) { v.removeAt(i); } \
- int length() const { return v.length(); }
-
-struct QQmlItemSelectionValueType
-{
- QItemSelection v;
-
- Q_GADGET
-
-public:
- Q_INVOKABLE QString toString()
- { return q_listToString<QQmlItemSelectionRangeValueType>(v, QLatin1String("QItemSelection")); }
- Q_INVOKABLE void select(const QModelIndex &topLeft, const QModelIndex &bottomRight)
- { v.select(topLeft, bottomRight); }
- Q_INVOKABLE bool contains(const QModelIndex &index) const
- { return v.contains(index); }
- Q_INVOKABLE void merge(const QItemSelection &other, int command)
- { v.merge(other, QItemSelectionModel::SelectionFlags(command)); }
-
- QLISTVALUETYPE_QML_API(QItemSelectionRange)
-};
-
#undef QLISTVALUETYPE_INVOKABLE_API
QT_END_NAMESPACE