┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-08-26 08:08:11 +0200
committerPeter Penz <[email protected]>2011-08-26 08:09:50 +0200
commit26648a0264ad726682901b2f9c9b5bd92dedb782 (patch)
tree085614d7562d8cdb90f5976392727f1dd756fb5f /src
parenta14d8bf655917dcf806e22bdfafb03a35f5c8680 (diff)
Fix issue that removing an item is not recognized
Thanks to Tirtha Chatterjee for the patch! REVIEW: 102435
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp2
-rw-r--r--src/tests/kfileitemmodeltest.cpp14
-rw-r--r--src/tests/testdir.cpp10
-rw-r--r--src/tests/testdir.h2
4 files changed, 27 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 189aa75e0..f36ab8380 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -517,7 +517,7 @@ void KFileItemModel::removeItems(const KFileItemList& items)
foreach (const KFileItem& itemToRemove, sortedItems) {
const int previousTargetIndex = targetIndex;
while (targetIndex < m_sortedItems.count()) {
- if (m_sortedItems.at(targetIndex) == itemToRemove) {
+ if (m_sortedItems.at(targetIndex).url() == itemToRemove.url()) {
break;
}
++targetIndex;
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 7315083fa..091632eab 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -41,6 +41,7 @@ private slots:
void testDefaultSortRole();
void testDefaultGroupRole();
void testNewItems();
+ void testRemoveItems();
void testModelConsistencyWhenInsertingItems();
void testItemRangeConsistencyWhenInsertingItems();
void testExpandItems();
@@ -124,6 +125,19 @@ void KFileItemModelTest::testNewItems()
QVERIFY(isModelConsistent());
}
+void KFileItemModelTest::testRemoveItems()
+{
+ m_testDir->createFile("a.txt");
+ m_dirLister->openUrl(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QCOMPARE(m_model->count(), 1);
+
+ m_testDir->removeFile("a.txt");
+ m_dirLister->updateDirectory(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout));
+ QCOMPARE(m_model->count(), 0);
+}
+
void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
{
QSKIP("Temporary disabled", SkipSingle);
diff --git a/src/tests/testdir.cpp b/src/tests/testdir.cpp
index 5e961d2ab..a7f3cd4dc 100644
--- a/src/tests/testdir.cpp
+++ b/src/tests/testdir.cpp
@@ -93,6 +93,16 @@ void TestDir::createDir(const QString& path, const QDateTime& time)
Q_ASSERT(QFile::exists(absolutePath));
}
+void TestDir::removeFile(const QString& path)
+{
+ QString absolutePath = path;
+ QFileInfo fileInfo(absolutePath);
+ if (!fileInfo.isAbsolute()) {
+ absolutePath = name() + path;
+ }
+ QFile::remove(absolutePath);
+}
+
void TestDir::makePathAbsoluteAndCreateParents(QString& path)
{
QFileInfo fileInfo(path);
diff --git a/src/tests/testdir.h b/src/tests/testdir.h
index bcaa034b5..80e519e6b 100644
--- a/src/tests/testdir.h
+++ b/src/tests/testdir.h
@@ -49,6 +49,8 @@ public:
void createFiles(const QStringList& files);
void createDir(const QString& path, const QDateTime& time = QDateTime());
+ void removeFile(const QString& path);
+
private:
void makePathAbsoluteAndCreateParents(QString& path);