Commit 7d369189 authored by Jonathan Marten's avatar Jonathan Marten
Browse files

Sort the "Recent Folder" list by most recently used

So that the most recently used folder appears at the top, and the
others follow in order.  Makes the list more usable for repeated
copies or moves to the same folder in KMail.  Also optimises the
case where the most recently used item is already at the top (no
need to write out config again).
parent 43050385
Pipeline #42740 passed with stage
in 12 minutes and 44 seconds
......@@ -100,15 +100,23 @@ QString RecentCollectionAction::actionName(QModelIndex index)
void RecentCollectionAction::addRecentCollection(Akonadi::StandardActionManager::Type type, Akonadi::Collection::Id id)
{
const QString newCollectionID = QString::number(id);
if (mListRecentCollection.isEmpty() ||
!mListRecentCollection.contains(newCollectionID)) {
if (mListRecentCollection.count() == s_maximumRecentCollection) {
mListRecentCollection.removeFirst();
if (mListRecentCollection.contains(newCollectionID)) {
// first() is safe to use if we get here
if (mListRecentCollection.first() == newCollectionID) {
// already most recently used, nothing to do
return;
}
mListRecentCollection.append(newCollectionID);
writeConfig();
fillRecentCollection(type, Akonadi::Collection::List());
mListRecentCollection.removeAll(newCollectionID);
}
mListRecentCollection.prepend(newCollectionID);
while (mListRecentCollection.count() > s_maximumRecentCollection) {
mListRecentCollection.removeLast();
}
writeConfig();
fillRecentCollection(type, Akonadi::Collection::List());
}
void RecentCollectionAction::writeConfig()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment