┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-05-22 18:34:25 +0200
committerFrank Reininghaus <[email protected]>2013-05-22 18:34:25 +0200
commit04e825d022c77baad3345269da7a210e95274f07 (patch)
treea42a3ac163647986a7aedf9371895730ce0112f3 /src
parentbf85483c99b549334cff3e83e861121748d5d5c1 (diff)
parent2f51debbea28973c6c9117a0aae806d41f83b03b (diff)
Merge remote-tracking branch 'origin/KDE/4.10'
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp4
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp7
-rw-r--r--src/tests/kfileitemmodeltest.cpp34
3 files changed, 41 insertions, 4 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 0289666ff..d30d9e5be 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -1327,10 +1327,6 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
data.insert("path", path);
}
- if (m_requestRole[IsExpandedRole]) {
- data.insert("isExpanded", false);
- }
-
if (m_requestRole[IsExpandableRole]) {
data.insert("isExpandable", item.isDir() && item.url() == item.targetUrl());
}
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 39d01e232..7cade10f5 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -630,6 +630,13 @@ void KFileItemModelRolesUpdater::slotDirWatchDirty(const QString& path)
if (getSizeRole || getIsExpandableRole) {
const int index = m_model->index(KUrl(path));
if (index >= 0) {
+ if (!m_model->fileItem(index).isDir()) {
+ // If INotify is used, KDirWatch issues the dirty() signal
+ // also for changed files inside the directory, even if we
+ // don't enable this behavior explicitly (see bug 309740).
+ return;
+ }
+
QHash<QByteArray, QVariant> data;
const int count = subItemsCount(path);
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 484ddee11..383575a97 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -78,6 +78,7 @@ private slots:
void testIndexForKeyboardSearch();
void testNameFilter();
void testEmptyPath();
+ void testRefreshExpandedItem();
void testRemoveHiddenItems();
void collapseParentOfHiddenItems();
void removeParentOfHiddenItems();
@@ -857,6 +858,39 @@ void KFileItemModelTest::testEmptyPath()
}
/**
+ * Verifies that the 'isExpanded' state of folders does not change when the
+ * 'refreshItems' signal is received, see https://bugs.kde.org/show_bug.cgi?id=299675.
+ */
+void KFileItemModelTest::testRefreshExpandedItem()
+{
+ QSet<QByteArray> modelRoles = m_model->roles();
+ modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
+ m_model->setRoles(modelRoles);
+
+ QStringList files;
+ files << "a/1" << "a/2" << "3" << "4";
+ m_testDir->createFiles(files);
+
+ m_model->loadDirectory(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QCOMPARE(m_model->count(), 3); // "a/", "3", "4"
+
+ m_model->setExpanded(0, true);
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QCOMPARE(m_model->count(), 5); // "a/", "a/1", "a/2", "3", "4"
+ QVERIFY(m_model->isExpanded(0));
+
+ QSignalSpy spyItemsChanged(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)));
+
+ const KFileItem item = m_model->fileItem(0);
+ m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(item, item));
+ QVERIFY(!spyItemsChanged.isEmpty());
+
+ QCOMPARE(m_model->count(), 5); // "a/", "a/1", "a/2", "3", "4"
+ QVERIFY(m_model->isExpanded(0));
+}
+
+/**
* Verify that removing hidden files and folders from the model does not
* result in a crash, see https://bugs.kde.org/show_bug.cgi?id=314046
*/