diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-15 18:02:08 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-16 14:54:14 +0100 |
commit | 3a7ec69fb91d864b1ecaa3241a26b78c9a8b9430 (patch) | |
tree | 6cd459461ab1f2be11539869086b579f5c43a021 /framework/domain/folderlistmodel.cpp | |
parent | 630f45719a527f8ee739b03bc62f886badea6df3 (diff) | |
download | kube-3a7ec69fb91d864b1ecaa3241a26b78c9a8b9430.tar.gz kube-3a7ec69fb91d864b1ecaa3241a26b78c9a8b9430.zip |
Fixed folder sorting
Diffstat (limited to 'framework/domain/folderlistmodel.cpp')
-rw-r--r-- | framework/domain/folderlistmodel.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index 22a8b7f7..24dd41e7 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp | |||
@@ -20,11 +20,14 @@ | |||
20 | 20 | ||
21 | #include "folderlistmodel.h" | 21 | #include "folderlistmodel.h" |
22 | #include <sink/store.h> | 22 | #include <sink/store.h> |
23 | #include <sink/log.h> | ||
23 | #include <settings/settings.h> | 24 | #include <settings/settings.h> |
24 | 25 | ||
25 | using namespace Sink; | 26 | using namespace Sink; |
26 | using namespace Sink::ApplicationDomain; | 27 | using namespace Sink::ApplicationDomain; |
27 | 28 | ||
29 | SINK_DEBUG_AREA("folderlistmodel") | ||
30 | |||
28 | FolderListModel::FolderListModel(QObject *parent) : QSortFilterProxyModel() | 31 | FolderListModel::FolderListModel(QObject *parent) : QSortFilterProxyModel() |
29 | { | 32 | { |
30 | setDynamicSortFilter(true); | 33 | setDynamicSortFilter(true); |
@@ -97,22 +100,29 @@ static int getPriority(const Sink::ApplicationDomain::Folder &folder) | |||
97 | { | 100 | { |
98 | auto specialPurpose = folder.getSpecialPurpose(); | 101 | auto specialPurpose = folder.getSpecialPurpose(); |
99 | if (specialPurpose.contains(Sink::ApplicationDomain::SpecialPurpose::Mail::inbox)) { | 102 | if (specialPurpose.contains(Sink::ApplicationDomain::SpecialPurpose::Mail::inbox)) { |
100 | return 10; | 103 | return 5; |
101 | } | 104 | } else if (specialPurpose.contains(Sink::ApplicationDomain::SpecialPurpose::Mail::drafts)) { |
102 | if (!specialPurpose.isEmpty()) { | 105 | return 6; |
106 | } else if (specialPurpose.contains(Sink::ApplicationDomain::SpecialPurpose::Mail::sent)) { | ||
107 | return 7; | ||
108 | } else if (specialPurpose.contains(Sink::ApplicationDomain::SpecialPurpose::Mail::trash)) { | ||
109 | return 8; | ||
110 | } else if (!specialPurpose.isEmpty()) { | ||
103 | return 9; | 111 | return 9; |
104 | } | 112 | } |
105 | return 0; | 113 | return 10; |
106 | } | 114 | } |
107 | 115 | ||
108 | bool FolderListModel::lessThan(const QModelIndex &left, const QModelIndex &right) const | 116 | bool FolderListModel::lessThan(const QModelIndex &left, const QModelIndex &right) const |
109 | { | 117 | { |
110 | const auto leftFolder = left.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); | 118 | const auto leftFolder = left.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
111 | const auto rightFolder = right.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); | 119 | const auto rightFolder = right.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
112 | if (getPriority(*leftFolder) < getPriority(*rightFolder)) { | 120 | const auto leftPriority = getPriority(*leftFolder); |
113 | return true; | 121 | const auto rightPriority = getPriority(*rightFolder); |
122 | if (leftPriority == rightPriority) { | ||
123 | return leftFolder->getName() < rightFolder->getName(); | ||
114 | } | 124 | } |
115 | return leftFolder->getName() < rightFolder->getName(); | 125 | return leftPriority < rightPriority; |
116 | } | 126 | } |
117 | 127 | ||
118 | QVariant FolderListModel::accountId() const | 128 | QVariant FolderListModel::accountId() const |