mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Merge remote-tracking branch 'origin/KDE/4.10'
This commit is contained in:
commit
709d2b79fb
3 changed files with 49 additions and 4 deletions
|
@ -644,11 +644,11 @@ void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArr
|
|||
Q_UNUSED(previous);
|
||||
m_sortRole = typeForRole(current);
|
||||
|
||||
#ifdef KFILEITEMMODEL_DEBUG
|
||||
if (!m_requestRole[m_sortRole]) {
|
||||
kWarning() << "The sort-role has been changed to a role that has not been received yet";
|
||||
QSet<QByteArray> newRoles = m_roles;
|
||||
newRoles << current;
|
||||
setRoles(newRoles);
|
||||
}
|
||||
#endif
|
||||
|
||||
resortAllItems();
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ private slots:
|
|||
void testSetData();
|
||||
void testSetDataWithModifiedSortRole_data();
|
||||
void testSetDataWithModifiedSortRole();
|
||||
void testChangeSortRole();
|
||||
void testModelConsistencyWhenInsertingItems();
|
||||
void testItemRangeConsistencyWhenInsertingItems();
|
||||
void testExpandItems();
|
||||
|
@ -277,6 +278,8 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole()
|
|||
// Changing the value of a sort-role must result in
|
||||
// a reordering of the items.
|
||||
QCOMPARE(m_model->sortRole(), QByteArray("text"));
|
||||
m_model->setSortRole("rating");
|
||||
QCOMPARE(m_model->sortRole(), QByteArray("rating"));
|
||||
|
||||
QStringList files;
|
||||
files << "a.txt" << "b.txt" << "c.txt";
|
||||
|
@ -302,7 +305,6 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole()
|
|||
ratingC.insert("rating", 6);
|
||||
m_model->setData(2, ratingC);
|
||||
|
||||
m_model->setSortRole("rating");
|
||||
QCOMPARE(m_model->data(0).value("rating").toInt(), 2);
|
||||
QCOMPARE(m_model->data(1).value("rating").toInt(), 4);
|
||||
QCOMPARE(m_model->data(2).value("rating").toInt(), 6);
|
||||
|
@ -323,6 +325,45 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole()
|
|||
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);
|
||||
|
|
|
@ -385,6 +385,8 @@ KonqSessionManager::KonqSessionManager()
|
|||
|
||||
KonqSessionManager::~KonqSessionManager()
|
||||
{
|
||||
if (m_sessionConfig)
|
||||
QFile::remove(m_sessionConfig->name());
|
||||
delete m_sessionConfig;
|
||||
}
|
||||
|
||||
|
@ -444,6 +446,8 @@ void KonqSessionManager::autoSaveSession()
|
|||
m_autoSaveTimer.stop();
|
||||
|
||||
saveCurrentSessionToFile(m_sessionConfig);
|
||||
m_sessionConfig->sync();
|
||||
m_sessionConfig->markAsClean();
|
||||
|
||||
// Now that we have saved current session it's safe to remove our owned_by
|
||||
// directory
|
||||
|
|
Loading…
Reference in a new issue