]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge remote-tracking branch 'origin/KDE/4.10'
authorDawit Alemayehu <adawit@kde.org>
Thu, 20 Jun 2013 12:41:12 +0000 (08:41 -0400)
committerDawit Alemayehu <adawit@kde.org>
Thu, 20 Jun 2013 12:41:12 +0000 (08:41 -0400)
1  2 
src/kitemviews/kfileitemmodel.cpp
src/tests/kfileitemmodeltest.cpp

Simple merge
index 6c2a1465fc34d389000957a0446186a8d656a753,fd6c2be90a8df0f30ffed4fd6aa8647f6e0b235c..0ad7a378dd9870895aba143c75fb873b96fbb86f
@@@ -320,9 -319,48 +322,48 @@@ void KFileItemModelTest::testSetDataWit
      QCOMPARE(m_model->data(0).value("rating").toInt(), ratingIndex0);
      QCOMPARE(m_model->data(1).value("rating").toInt(), ratingIndex1);
      QCOMPARE(m_model->data(2).value("rating").toInt(), ratingIndex2);
 -    QVERIFY(isModelConsistent());
 +    QVERIFY(m_model->isConsistent());
  }
  
+ void KFileItemModelTest::testChangeSortRole()
+ {
+     QCOMPARE(m_model->sortRole(), QByteArray("text"));
+     QStringList files;
+     files << "a.txt" << "b.jpg" << "c.txt";
+     m_testDir->createFiles(files);
+     m_model->loadDirectory(m_testDir->url());
+     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+     QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.jpg" << "c.txt");
+     // Simulate that KFileItemModelRolesUpdater determines the mime type.
+     // Resorting the files by 'type' will only work immediately if their
+     // mime types are known.
+     for (int index = 0; index < m_model->count(); ++index) {
+         m_model->fileItem(index).determineMimeType();
+     }
+     // Now: sort by type.
+     QSignalSpy spyItemsMoved(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
+     m_model->setSortRole("type");
+     QCOMPARE(m_model->sortRole(), QByteArray("type"));
+     QVERIFY(!spyItemsMoved.isEmpty());
+     // The actual order of the files might depend on the translation of the
+     // result of KFileItem::mimeComment() in the user's language.
+     QStringList version1;
+     version1 << "b.jpg" << "a.txt" << "c.txt";
+     QStringList version2;
+     version2 << "a.txt" << "c.txt" << "b.jpg";
+     const bool ok1 = (itemsInModel() == version1);
+     const bool ok2 = (itemsInModel() == version2);
+     QVERIFY(ok1 || ok2);
+ }
  void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
  {
      //QSKIP("Temporary disabled", SkipSingle);