summaryrefslogtreecommitdiffstats
path: root/framework/mail/folderlistmodel.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-09 15:20:31 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-09 15:20:31 +0100
commitf5185c4799fe0e9c31a218dfc8310515ac921c2b (patch)
tree5524d7a85c8bf82890d79ec6d1bb82b5124fd3b3 /framework/mail/folderlistmodel.cpp
parentc9ccf868f5d533a07811b949577f772f618d2de3 (diff)
downloadkube-f5185c4799fe0e9c31a218dfc8310515ac921c2b.tar.gz
kube-f5185c4799fe0e9c31a218dfc8310515ac921c2b.zip
Moved framework/mail to framework/domain
Diffstat (limited to 'framework/mail/folderlistmodel.cpp')
-rw-r--r--framework/mail/folderlistmodel.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/framework/mail/folderlistmodel.cpp b/framework/mail/folderlistmodel.cpp
deleted file mode 100644
index ce6fb4fd..00000000
--- a/framework/mail/folderlistmodel.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net>
3 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
9
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
19*/
20
21#include "folderlistmodel.h"
22#include <sink/store.h>
23
24FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel()
25{
26 Sink::Query query;
27 query.liveQuery = true;
28 query.requestedProperties << "name" << "icon" << "parent";
29 query.parentProperty = "parent";
30 mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
31 setSourceModel(mModel.data());
32}
33
34FolderListModel::~FolderListModel()
35{
36
37}
38
39QHash< int, QByteArray > FolderListModel::roleNames() const
40{
41 QHash<int, QByteArray> roles;
42
43 roles[Name] = "name";
44 roles[Icon] = "icon";
45 roles[Id] = "id";
46 roles[DomainObject] = "domainObject";
47
48 return roles;
49}
50
51QVariant FolderListModel::data(const QModelIndex &idx, int role) const
52{
53 auto srcIdx = mapToSource(idx);
54 switch (role) {
55 case Name:
56 return srcIdx.sibling(srcIdx.row(), 0).data(Qt::DisplayRole).toString();
57 case Icon:
58 return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString();
59 case Id:
60 return srcIdx.data(Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier();
61 case DomainObject:
62 return srcIdx.data(Sink::Store::DomainObjectRole);
63 }
64 return QIdentityProxyModel::data(idx, role);
65}