aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/folderlistmodel
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-09 16:25:58 +0200
committerGunnar Sletta <gunnar.sletta@jollamobile.com>2014-05-10 11:53:47 +0200
commit66646dd8c37adb488a79ab274b2396a649674e6d (patch)
treeb0f5ac752a52cec3de1d47692e09295197622dcd /src/imports/folderlistmodel
parentda15ea0f3b5805db657f13060c21efa78f10cde2 (diff)
parentd82a17b929dd88fe76258b0f801beaa1b2ee343e (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: .qmake.conf src/plugins/accessible/quick/quick.pro src/quick/items/qquickpincharea.cpp src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp src/quick/scenegraph/qsgthreadedrenderloop.cpp Manually adjusted for TestHTTPServer constructor change: tests/auto/quick/qquickimage/tst_qquickimage.cpp Change-Id: I5e58a7c08ea92d6fc5e3bce98571c54f7b2ce08f
Diffstat (limited to 'src/imports/folderlistmodel')
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index f8d43f0594..1f28d8009e 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -158,35 +158,28 @@ void QQuickFolderListModelPrivate::_q_directoryUpdated(const QString &directory,
Q_UNUSED(directory);
QModelIndex parent;
- if (data.size() > list.size()) {
- //File(s) removed. Since I do not know how many
- //or where I need to update the whole list from the first item.
- data = list;
- q->beginRemoveRows(parent, fromIndex, toIndex);
- q->endRemoveRows();
- if (list.size() > 0) {
- q->beginInsertRows(parent, fromIndex, list.size()-1);
- q->endInsertRows();
- }
- emit q->rowCountChanged();
- } else if (data.size() < list.size()) {
- //qDebug() << "File added. FromIndex: " << fromIndex << " toIndex: " << toIndex << " list size: " << list.size();
- //File(s) added. Calculate how many and insert
- //from the first changed one.
- toIndex = fromIndex + (list.size() - data.size()-1);
- q->beginInsertRows(parent, fromIndex, toIndex);
- q->endInsertRows();
- data = list;
- emit q->rowCountChanged();
+ if (data.size() == list.size()) {
QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
+ data = list;
emit q->dataChanged(modelIndexFrom, modelIndexTo);
} else {
- //qDebug() << "File has been updated";
- QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
- QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
+ // File(s) inserted or removed. Since I do not know how many
+ // or where, I need to update the whole list from the first item.
+ // This is a little pessimistic, but optimizing it would require
+ // more information in the signal from FileInfoThread.
+ if (data.size() > 0) {
+ q->beginRemoveRows(parent, 0, data.size() - 1);
+ q->endRemoveRows();
+ }
data = list;
- emit q->dataChanged(modelIndexFrom, modelIndexTo);
+ if (list.size() > 0) {
+ if (toIndex > list.size() - 1)
+ toIndex = list.size() - 1;
+ q->beginInsertRows(parent, 0, data.size() - 1);
+ q->endInsertRows();
+ }
+ emit q->rowCountChanged();
}
}