]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge remote-tracking branch 'origin/KDE/4.10'
authorFrank Reininghaus <frank78ac@googlemail.com>
Tue, 19 Feb 2013 14:45:44 +0000 (15:45 +0100)
committerFrank Reininghaus <frank78ac@googlemail.com>
Tue, 19 Feb 2013 14:45:44 +0000 (15:45 +0100)
Conflicts:
dolphin/src/tests/kfileitemmodeltest.cpp
lib/konq/konq_operations.cpp

1  2 
src/kitemviews/kfileitemmodel.cpp
src/panels/places/placespanel.cpp
src/tests/kfileitemmodeltest.cpp

Simple merge
Simple merge
index c9f8a3468460b462f7b0fde835e4626db863ecdc,b76f4bee97319d379d3ca02301223395a7c5d591..483c5b2454c1ab0ace6570fb8f20a42383f70699
@@@ -79,8 -76,10 +79,9 @@@ private slots
      void testNameFilter();
      void testEmptyPath();
      void testRemoveHiddenItems();
+     void removeParentOfHiddenItems();
  
  private:
 -    bool isModelConsistent() const;
      QStringList itemsInModel() const;
  
  private:
@@@ -903,6 -850,79 +904,56 @@@ void KFileItemModelTest::testRemoveHidd
      m_model->setShowHiddenFiles(false);
  }
  
 -bool KFileItemModelTest::isModelConsistent() const
 -{
 -    if (m_model->m_items.count() != m_model->m_itemData.count()) {
 -        return false;
 -    }
 -
 -    for (int i = 0; i < m_model->count(); ++i) {
 -        const KFileItem item = m_model->fileItem(i);
 -        if (item.isNull()) {
 -            qWarning() << "Item" << i << "is null";
 -            return false;
 -        }
 -
 -        const int itemIndex = m_model->index(item);
 -        if (itemIndex != i) {
 -            qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
 -            return false;
 -        }
 -    }
 -
 -    return true;
 -}
 -
+ /**
+  * Verify that filtered items are removed when their parent is deleted.
+  */
+ void KFileItemModelTest::removeParentOfHiddenItems()
+ {
+     QSet<QByteArray> modelRoles = m_model->roles();
+     modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
+     m_model->setRoles(modelRoles);
+     QStringList files;
+     files << "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1";
+     m_testDir->createFiles(files);
+     m_model->loadDirectory(m_testDir->url());
+     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+     QCOMPARE(m_model->count(), 1); // Only "a/"
+     // Expand "a/".
+     m_model->setExpanded(0, true);
+     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+     QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/b/", "a/1"
+     // Expand "a/b/".
+     m_model->setExpanded(1, true);
+     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+     QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1"
+     // Expand "a/b/c/".
+     m_model->setExpanded(2, true);
+     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+     QCOMPARE(m_model->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1"
+     // Set a name filter that matches nothing -> only the expanded folders remain.
+     m_model->setNameFilter("xyz");
+     QCOMPARE(m_model->count(), 3);
+     QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c");
+     // Simulate the deletion of the directory "a/b/".
+     QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+     m_model->slotItemsDeleted(KFileItemList() << m_model->fileItem(1));
+     QCOMPARE(spyItemsRemoved.count(), 1);
+     QCOMPARE(m_model->count(), 1);
+     QCOMPARE(itemsInModel(), QStringList() << "a");
+     // Remove the filter -> only the file "a/1" should appear.
+     m_model->setNameFilter(QString());
+     QCOMPARE(m_model->count(), 2);
+     QCOMPARE(itemsInModel(), QStringList() << "a" << "1");
+ }
  QStringList KFileItemModelTest::itemsInModel() const
  {
      QStringList items;