summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/folderlistmodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/folderlistmodel.h')
-rw-r--r--framework/src/domain/folderlistmodel.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/framework/src/domain/folderlistmodel.h b/framework/src/domain/folderlistmodel.h
new file mode 100644
index 00000000..17645bb5
--- /dev/null
+++ b/framework/src/domain/folderlistmodel.h
@@ -0,0 +1,71 @@
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#pragma once
22
23#include <QObject>
24#include <QSortFilterProxyModel>
25#include <QSharedPointer>
26#include <QStringList>
27
28namespace Sink {
29 class Query;
30}
31
32class FolderListModel : public QSortFilterProxyModel
33{
34 Q_OBJECT
35
36 Q_PROPERTY (QVariant accountId READ accountId WRITE setAccountId)
37
38public:
39 enum Status {
40 NoStatus,
41 InProgressStatus,
42 ErrorStatus,
43 SuccessStatus,
44 };
45 Q_ENUMS(Status)
46
47 FolderListModel(QObject *parent = Q_NULLPTR);
48 ~FolderListModel();
49
50 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
51
52 enum Roles {
53 Name = Qt::UserRole + 1,
54 Icon,
55 Id,
56 DomainObject,
57 Status
58 };
59 Q_ENUMS(Roles)
60
61 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
62
63 void setAccountId(const QVariant &accountId);
64 QVariant accountId() const;
65protected:
66 bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
67
68private:
69 void runQuery(const Sink::Query &query);
70 QSharedPointer<QAbstractItemModel> mModel;
71};