aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-07-10 17:01:52 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-25 02:15:15 +0200
commit7daab8039abc32ab5be5706a08cb58905fe0e0b6 (patch)
tree9ceb8afdeb37ac4d9bc089545e73e31040b847e4 /src/qml/qml
parentb355aacb6e5c4f9b7ebb317125409ea0959d11d6 (diff)
Remove QListModelInterface.
Implement ListModel and XmlListModel using QAbstractListModel instead. Task-number: QTBUG-15728 Change-Id: I14e03d90883d341f4b1d89c1e9fc9dc1534fde78 Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qlistmodelinterface.cpp104
-rw-r--r--src/qml/qml/qlistmodelinterface_p.h83
-rw-r--r--src/qml/qml/qml.pri2
-rw-r--r--src/qml/qml/qquicklistmodel.cpp106
-rw-r--r--src/qml/qml/qquicklistmodel_p.h17
-rw-r--r--src/qml/qml/qquicklistmodel_p_p.h6
-rw-r--r--src/qml/qml/qquicklistmodelworkeragent.cpp29
-rw-r--r--src/qml/qml/qquicklistmodelworkeragent_p.h4
8 files changed, 99 insertions, 252 deletions
diff --git a/src/qml/qml/qlistmodelinterface.cpp b/src/qml/qml/qlistmodelinterface.cpp
deleted file mode 100644
index 3ea0d3f155..0000000000
--- a/src/qml/qml/qlistmodelinterface.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclaractive module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlistmodelinterface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QListModelInterface
- \brief The QListModelInterface class can be subclassed to provide C++ models to QQuickGraphics Views
-
- This class is comprised primarily of pure virtual functions which
- you must implement in a subclass. You can then use the subclass
- as a model for a QQuickGraphics view, such as a QQuickListView.
-*/
-
-/*! \fn QListModelInterface::QListModelInterface(QObject *parent)
- Constructs a QListModelInterface with the specified \a parent.
-*/
-
- /*! \fn QListModelInterface::QListModelInterface(QObjectPrivate &dd, QObject *parent)
-
- \internal
- */
-
-/*! \fn QListModelInterface::~QListModelInterface()
- The destructor is virtual.
- */
-
-/*! \fn int QListModelInterface::count() const
- Returns the number of data entries in the model.
-*/
-
-/*! \fn QVariant QListModelInterface::data(int index, int role) const
- Returns the data at the given \a index for the specified \a roles.
-*/
-
-/*! \fn QList<int> QListModelInterface::roles() const
- Returns the list of roles for which the list model interface
- provides data.
-*/
-
-/*! \fn QString QListModelInterface::toString(int role) const
- Returns a string description of the specified \a role.
-*/
-
-/*! \fn void QListModelInterface::itemsInserted(int index, int count)
- Emit this signal when \a count items are inserted at \a index.
- */
-
-/*! \fn void QListModelInterface::itemsRemoved(int index, int count)
- Emit this signal when \a count items are removed at \a index.
- */
-
-/*! \fn void QListModelInterface::itemsMoved(int from, int to, int count)
- Emit this signal when \a count items are moved from index \a from
- to index \a to.
- */
-
-/*! \fn void QListModelInterface::itemsChanged(int index, int count, const QList<int> &roles)
- Emit this signal when \a count items at \a index have had their
- \a roles changed.
- */
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/qlistmodelinterface_p.h b/src/qml/qml/qlistmodelinterface_p.h
deleted file mode 100644
index c644ce88e6..0000000000
--- a/src/qml/qml/qlistmodelinterface_p.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLISTMODELINTERFACE_H
-#define QLISTMODELINTERFACE_H
-
-#include <QtCore/QHash>
-#include <QtCore/QVariant>
-
-#include <private/qtqmlglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class Q_QML_PRIVATE_EXPORT QListModelInterface : public QObject
-{
- Q_OBJECT
- public:
- QListModelInterface(QObject *parent = 0) : QObject(parent) {}
- virtual ~QListModelInterface() {}
-
- virtual int count() const = 0;
- virtual QVariant data(int index, int role) const = 0;
-
- virtual QList<int> roles() const = 0;
- virtual QString toString(int role) const = 0;
-
- Q_SIGNALS:
- void itemsInserted(int index, int count);
- void itemsRemoved(int index, int count);
- void itemsMoved(int from, int to, int count);
- void itemsChanged(int index, int count, const QList<int> &roles);
-
- protected:
- QListModelInterface(QObjectPrivate &dd, QObject *parent)
- : QObject(dd, parent) {}
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif //QTREEMODELINTERFACE_H
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index fbbdc84539..e7286c25fb 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -45,7 +45,6 @@ SOURCES += \
$$PWD/qqmlimport.cpp \
$$PWD/qqmllist.cpp \
$$PWD/qqmllocale.cpp \
- $$PWD/qlistmodelinterface.cpp \
$$PWD/qqmlabstractexpression.cpp \
$$PWD/qqmljavascriptexpression.cpp \
$$PWD/qqmlabstractbinding.cpp \
@@ -119,7 +118,6 @@ HEADERS += \
$$PWD/qqmlnullablevalue_p_p.h \
$$PWD/qqmlscriptstring_p.h \
$$PWD/qqmllocale_p.h \
- $$PWD/qlistmodelinterface_p.h \
$$PWD/qqmlcomponentattached_p.h \
$$PWD/qqmlabstractexpression_p.h \
$$PWD/qqmljavascriptexpression_p.h \
diff --git a/src/qml/qml/qquicklistmodel.cpp b/src/qml/qml/qquicklistmodel.cpp
index e865d847a8..11aa372ee5 100644
--- a/src/qml/qml/qquicklistmodel.cpp
+++ b/src/qml/qml/qquicklistmodel.cpp
@@ -45,6 +45,7 @@
#include <private/qqmljsast_p.h>
#include <private/qqmljsengine_p.h>
+
#include <private/qqmlcustomparser_p.h>
#include <private/qqmlscript_p.h>
#include <private/qqmlengine_p.h>
@@ -55,8 +56,6 @@
#include <QtCore/qstack.h>
#include <QXmlStreamReader>
-Q_DECLARE_METATYPE(QListModelInterface *)
-
QT_BEGIN_NAMESPACE
// Set to 1024 as a debugging aid - easier to distinguish uids from indices of elements/models.
@@ -408,7 +407,7 @@ ListModel *ListModel::getListProperty(int elementIndex, const ListLayout::Role &
return e->getListProperty(role);
}
-void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QList<int> *roles, QV8Engine *eng)
+void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QVector<int> *roles, QV8Engine *eng)
{
ListElement *e = elements[elementIndex];
@@ -595,7 +594,7 @@ int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const Q
roleIndex = e->setVariantProperty(*r, data);
if (roleIndex != -1 && e->m_objectCache) {
- QList<int> roles;
+ QVector<int> roles;
roles << roleIndex;
e->m_objectCache->updateValues(roles);
}
@@ -1226,7 +1225,7 @@ void ModelObject::updateValues()
}
}
-void ModelObject::updateValues(const QList<int> &roles)
+void ModelObject::updateValues(const QVector<int> &roles)
{
int roleCount = roles.count();
for (int i=0 ; i < roleCount ; ++i) {
@@ -1264,7 +1263,7 @@ void ModelNodeMetaObject::propertyWritten(int index)
int roleIndex = m_obj->m_model->m_listModel->setExistingProperty(m_obj->m_elementIndex, propName, v, eng);
if (roleIndex != -1) {
- QList<int> roles;
+ QVector<int> roles;
roles << roleIndex;
m_obj->m_model->emitItemsChanged(m_obj->m_elementIndex, 1, roles);
}
@@ -1278,7 +1277,7 @@ DynamicRoleModelNode::DynamicRoleModelNode(QQuickListModel *owner, int uid) : m_
DynamicRoleModelNode *DynamicRoleModelNode::create(const QVariantMap &obj, QQuickListModel *owner)
{
DynamicRoleModelNode *object = new DynamicRoleModelNode(owner, uidCounter.fetchAndAddOrdered(1));
- QList<int> roles;
+ QVector<int> roles;
object->updateValues(obj, roles);
return object;
}
@@ -1308,7 +1307,7 @@ void DynamicRoleModelNode::sync(DynamicRoleModelNode *src, DynamicRoleModelNode
}
}
-void DynamicRoleModelNode::updateValues(const QVariantMap &object, QList<int> &roles)
+void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int> &roles)
{
const QList<QString> &keys = object.keys();
@@ -1410,7 +1409,8 @@ void DynamicRoleModelNodeMetaObject::propertyWritten(int index)
int roleIndex = parentModel->m_roles.indexOf(QString::fromLatin1(name(index).constData()));
if (elementIndex != -1 && roleIndex != -1) {
- QList<int> roles;
+
+ QVector<int> roles;
roles << roleIndex;
parentModel->emitItemsChanged(elementIndex, 1, roles);
@@ -1515,7 +1515,7 @@ QQuickListModelParser::ListInstruction *QQuickListModelParser::ListModelData::in
*/
QQuickListModel::QQuickListModel(QObject *parent)
-: QListModelInterface(parent)
+: QAbstractListModel(parent)
{
m_mainThread = true;
m_primary = true;
@@ -1530,7 +1530,7 @@ QQuickListModel::QQuickListModel(QObject *parent)
}
QQuickListModel::QQuickListModel(const QQuickListModel *owner, ListModel *data, QV8Engine *eng, QObject *parent)
-: QListModelInterface(parent)
+: QAbstractListModel(parent)
{
m_mainThread = owner->m_mainThread;
m_primary = false;
@@ -1545,7 +1545,7 @@ QQuickListModel::QQuickListModel(const QQuickListModel *owner, ListModel *data,
}
QQuickListModel::QQuickListModel(QQuickListModel *orig, QQuickListModelWorkerAgent *agent)
-: QListModelInterface(agent)
+: QAbstractListModel(agent)
{
m_mainThread = false;
m_primary = true;
@@ -1671,10 +1671,13 @@ void QQuickListModel::sync(QQuickListModel *src, QQuickListModel *target, QHash<
}
}
-void QQuickListModel::emitItemsChanged(int index, int count, const QList<int> &roles)
+void QQuickListModel::emitItemsChanged(int index, int count, const QVector<int> &roles)
{
+ if (count <= 0)
+ return;
+
if (m_mainThread) {
- emit itemsChanged(index, count, roles);
+ emit dataChanged(createIndex(index, 0), createIndex(index + count - 1, 0), roles);;
} else {
int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
m_agent->data.changedChange(uid, index, count, roles);
@@ -1683,9 +1686,13 @@ void QQuickListModel::emitItemsChanged(int index, int count, const QList<int> &r
void QQuickListModel::emitItemsRemoved(int index, int count)
{
+ if (count <= 0)
+ return;
+
if (m_mainThread) {
- emit itemsRemoved(index, count);
- emit countChanged();
+ beginRemoveRows(QModelIndex(), index, index + count - 1);
+ endRemoveRows();
+ emit countChanged();
} else {
int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
if (index == 0 && count == this->count())
@@ -1696,8 +1703,12 @@ void QQuickListModel::emitItemsRemoved(int index, int count)
void QQuickListModel::emitItemsInserted(int index, int count)
{
+ if (count <= 0)
+ return;
+
if (m_mainThread) {
- emit itemsInserted(index, count);
+ beginInsertRows(QModelIndex(), index, index + count - 1);
+ endInsertRows();
emit countChanged();
} else {
int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
@@ -1707,8 +1718,12 @@ void QQuickListModel::emitItemsInserted(int index, int count)
void QQuickListModel::emitItemsMoved(int from, int to, int n)
{
+ if (n <= 0)
+ return;
+
if (m_mainThread) {
- emit itemsMoved(from, to, n);
+ beginMoveRows(QModelIndex(), from, from + n - 1, QModelIndex(), to > from ? to + n : to);
+ endMoveRows();
} else {
int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
m_agent->data.moveChange(uid, from, n, to);
@@ -1724,33 +1739,21 @@ QQuickListModelWorkerAgent *QQuickListModel::agent()
return m_agent;
}
-QList<int> QQuickListModel::roles() const
+QModelIndex QQuickListModel::index(int row, int column, const QModelIndex &parent) const
{
- QList<int> rolesArray;
-
- if (m_dynamicRoles) {
- for (int i=0 ; i < m_roles.count() ; ++i)
- rolesArray << i;
- } else {
- for (int i=0 ; i < m_listModel->roleCount() ; ++i)
- rolesArray << i;
- }
-
- return rolesArray;
+ return row >= 0 && row < count() && column == 0 && !parent.isValid()
+ ? createIndex(row, column)
+ : QModelIndex();
}
-QString QQuickListModel::toString(int role) const
+int QQuickListModel::rowCount(const QModelIndex &parent) const
{
- QString roleName;
-
- if (m_dynamicRoles) {
- roleName = m_roles[role];
- } else {
- const ListLayout::Role &r = m_listModel->getExistingRole(role);
- roleName = r.name;
- }
+ return !parent.isValid() ? count() : 0;
+}
- return roleName;
+QVariant QQuickListModel::data(const QModelIndex &index, int role) const
+{
+ return data(index.row(), role);
}
QVariant QQuickListModel::data(int index, int role) const
@@ -1768,6 +1771,23 @@ QVariant QQuickListModel::data(int index, int role) const
return v;
}
+QHash<int, QByteArray> QQuickListModel::roleNames() const
+{
+ QHash<int, QByteArray> roleNames;
+
+ if (m_dynamicRoles) {
+ for (int i = 0 ; i < m_roles.count() ; ++i)
+ roleNames.insert(i, m_roles.at(i).toUtf8());
+ } else {
+ for (int i = 0 ; i < m_listModel->roleCount() ; ++i) {
+ const ListLayout::Role &r = m_listModel->getExistingRole(i);
+ roleNames.insert(i, r.name.toUtf8());
+ }
+ }
+
+ return roleNames;
+}
+
/*!
\qmlproperty bool QtQuick2::ListModel::dynamicRoles
@@ -2147,7 +2167,7 @@ void QQuickListModel::set(int index, const QQmlV8Handle &handle)
emitItemsInserted(index, 1);
} else {
- QList<int> roles;
+ QVector<int> roles;
if (m_dynamicRoles) {
m_modelObjects[index]->updateValues(engine()->variantMapFromJS(object), roles);
@@ -2187,7 +2207,7 @@ void QQuickListModel::setProperty(int index, const QString& property, const QVar
m_roles.append(property);
}
if (m_modelObjects[index]->setValue(property.toUtf8(), value)) {
- QList<int> roles;
+ QVector<int> roles;
roles << roleIndex;
emitItemsChanged(index, 1, roles);
}
@@ -2195,7 +2215,7 @@ void QQuickListModel::setProperty(int index, const QString& property, const QVar
int roleIndex = m_listModel->setOrCreateProperty(index, property, value);
if (roleIndex != -1) {
- QList<int> roles;
+ QVector<int> roles;
roles << roleIndex;
emitItemsChanged(index, 1, roles);
diff --git a/src/qml/qml/qquicklistmodel_p.h b/src/qml/qml/qquicklistmodel_p.h
index 2941de9148..827831e11e 100644
--- a/src/qml/qml/qquicklistmodel_p.h
+++ b/src/qml/qml/qquicklistmodel_p.h
@@ -50,7 +50,7 @@
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QVariant>
-#include "qlistmodelinterface_p.h"
+#include <QtCore/qabstractitemmodel.h>
#include <private/qv8engine_p.h>
#include <private/qpodvector_p.h>
@@ -64,7 +64,7 @@ class QQuickListModelWorkerAgent;
class ListModel;
class ListLayout;
-class Q_QML_PRIVATE_EXPORT QQuickListModel : public QListModelInterface
+class Q_QML_PRIVATE_EXPORT QQuickListModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
@@ -74,10 +74,13 @@ public:
QQuickListModel(QObject *parent=0);
~QQuickListModel();
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
- virtual int count() const;
- virtual QVariant data(int index, int role) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent) const;
+ int rowCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QHash<int,QByteArray> roleNames() const;
+
+ QVariant data(int index, int role) const;
+ int count() const;
Q_INVOKABLE void clear();
Q_INVOKABLE void remove(QQmlV8Function *args);
@@ -142,7 +145,7 @@ private:
static void sync(QQuickListModel *src, QQuickListModel *target, QHash<int, QQuickListModel *> *targetModelHash);
static QQuickListModel *createWithOwner(QQuickListModel *newOwner);
- void emitItemsChanged(int index, int count, const QList<int> &roles);
+ void emitItemsChanged(int index, int count, const QVector<int> &roles);
void emitItemsRemoved(int index, int count);
void emitItemsInserted(int index, int count);
void emitItemsMoved(int from, int to, int n);
diff --git a/src/qml/qml/qquicklistmodel_p_p.h b/src/qml/qml/qquicklistmodel_p_p.h
index a006721f9c..3214213bba 100644
--- a/src/qml/qml/qquicklistmodel_p_p.h
+++ b/src/qml/qml/qquicklistmodel_p_p.h
@@ -89,7 +89,7 @@ public:
static DynamicRoleModelNode *create(const QVariantMap &obj, QQuickListModel *owner);
- void updateValues(const QVariantMap &object, QList<int> &roles);
+ void updateValues(const QVariantMap &object, QVector<int> &roles);
QVariant getValue(const QString &name)
{
@@ -162,7 +162,7 @@ public:
}
void updateValues();
- void updateValues(const QList<int> &roles);
+ void updateValues(const QVector<int> &roles);
QQuickListModel *m_model;
int m_elementIndex;
@@ -329,7 +329,7 @@ public:
return elements.count();
}
- void set(int elementIndex, v8::Handle<v8::Object> object, QList<int> *roles, QV8Engine *eng);
+ void set(int elementIndex, v8::Handle<v8::Object> object, QVector<int> *roles, QV8Engine *eng);
void set(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng);
int append(v8::Handle<v8::Object> object, QV8Engine *eng);
diff --git a/src/qml/qml/qquicklistmodelworkeragent.cpp b/src/qml/qml/qquicklistmodelworkeragent.cpp
index c50b348a4a..63c6bd49e7 100644
--- a/src/qml/qml/qquicklistmodelworkeragent.cpp
+++ b/src/qml/qml/qquicklistmodelworkeragent.cpp
@@ -65,23 +65,23 @@ void QQuickListModelWorkerAgent::Data::clearChange(int uid)
void QQuickListModelWorkerAgent::Data::insertChange(int uid, int index, int count)
{
- Change c = { uid, Change::Inserted, index, count, 0, QList<int>() };
+ Change c = { uid, Change::Inserted, index, count, 0, QVector<int>() };
changes << c;
}
void QQuickListModelWorkerAgent::Data::removeChange(int uid, int index, int count)
{
- Change c = { uid, Change::Removed, index, count, 0, QList<int>() };
+ Change c = { uid, Change::Removed, index, count, 0, QVector<int>() };
changes << c;
}
void QQuickListModelWorkerAgent::Data::moveChange(int uid, int index, int count, int to)
{
- Change c = { uid, Change::Moved, index, count, to, QList<int>() };
+ Change c = { uid, Change::Moved, index, count, to, QVector<int>() };
changes << c;
}
-void QQuickListModelWorkerAgent::Data::changedChange(int uid, int index, int count, const QList<int> &roles)
+void QQuickListModelWorkerAgent::Data::changedChange(int uid, int index, int count, const QVector<int> &roles)
{
Change c = { uid, Change::Changed, index, count, 0, roles };
changes << c;
@@ -215,16 +215,29 @@ bool QQuickListModelWorkerAgent::event(QEvent *e)
if (model) {
switch (change.type) {
case Change::Inserted:
- emit model->itemsInserted(change.index, change.count);
+ model->beginInsertRows(
+ QModelIndex(), change.index, change.index + change.count - 1);
+ model->endInsertRows();
break;
case Change::Removed:
- emit model->itemsRemoved(change.index, change.count);
+ model->beginRemoveRows(
+ QModelIndex(), change.index, change.index + change.count - 1);
+ model->endRemoveRows();
break;
case Change::Moved:
- emit model->itemsMoved(change.index, change.to, change.count);
+ model->beginMoveRows(
+ QModelIndex(),
+ change.index,
+ change.index + change.count - 1,
+ QModelIndex(),
+ change.to > change.index ? change.to + change.count : change.to);
+ model->endMoveRows();
break;
case Change::Changed:
- emit model->itemsChanged(change.index, change.count, change.roles);
+ emit model->dataChanged(
+ model->createIndex(change.index, 0),
+ model->createIndex(change.index + change.count - 1, 0),
+ change.roles);
break;
}
}
diff --git a/src/qml/qml/qquicklistmodelworkeragent_p.h b/src/qml/qml/qquicklistmodelworkeragent_p.h
index 24198b020c..bd805daced 100644
--- a/src/qml/qml/qquicklistmodelworkeragent_p.h
+++ b/src/qml/qml/qquicklistmodelworkeragent_p.h
@@ -122,7 +122,7 @@ private:
int index; // Inserted/Removed/Moved/Changed
int count; // Inserted/Removed/Moved/Changed
int to; // Moved
- QList<int> roles;
+ QVector<int> roles;
};
struct Data
@@ -133,7 +133,7 @@ private:
void insertChange(int uid, int index, int count);
void removeChange(int uid, int index, int count);
void moveChange(int uid, int index, int count, int to);
- void changedChange(int uid, int index, int count, const QList<int> &roles);
+ void changedChange(int uid, int index, int count, const QVector<int> &roles);
};
Data data;