diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-05 15:04:00 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-05 15:04:00 +0200 |
commit | 4b1798f0cdf87361869e7cf2b341acacd056c410 (patch) | |
tree | 3ff780641acdcb20b81f9b41533afd50a2525d38 /framework/src/domain/outboxmodel.h | |
parent | 71721aa4f3e85bea1a2fe504e86d99f80a3106a9 (diff) | |
download | kube-4b1798f0cdf87361869e7cf2b341acacd056c410.tar.gz kube-4b1798f0cdf87361869e7cf2b341acacd056c410.zip |
Moved cpp code into src directory
Diffstat (limited to 'framework/src/domain/outboxmodel.h')
-rw-r--r-- | framework/src/domain/outboxmodel.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/framework/src/domain/outboxmodel.h b/framework/src/domain/outboxmodel.h new file mode 100644 index 00000000..4be9c7f8 --- /dev/null +++ b/framework/src/domain/outboxmodel.h | |||
@@ -0,0 +1,77 @@ | |||
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 <sink/store.h> | ||
24 | #include <sink/notifier.h> | ||
25 | |||
26 | #include <QSortFilterProxyModel> | ||
27 | #include <QSharedPointer> | ||
28 | #include <QStringList> | ||
29 | |||
30 | class OutboxModel : public QSortFilterProxyModel | ||
31 | { | ||
32 | Q_OBJECT | ||
33 | |||
34 | Q_PROPERTY (int count READ count NOTIFY countChanged) | ||
35 | Q_PROPERTY (int status READ status NOTIFY statusChanged) | ||
36 | |||
37 | public: | ||
38 | enum Status { | ||
39 | NoStatus, | ||
40 | PendingStatus, | ||
41 | InProgressStatus, | ||
42 | ErrorStatus | ||
43 | }; | ||
44 | Q_ENUMS(Status) | ||
45 | |||
46 | OutboxModel(QObject *parent = Q_NULLPTR); | ||
47 | ~OutboxModel(); | ||
48 | |||
49 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||
50 | |||
51 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; | ||
52 | |||
53 | enum Roles { | ||
54 | Subject = Qt::UserRole + 1, | ||
55 | Date, | ||
56 | Status, | ||
57 | Id, | ||
58 | MimeMessage, | ||
59 | DomainObject | ||
60 | }; | ||
61 | |||
62 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | ||
63 | |||
64 | void runQuery(const Sink::Query &query); | ||
65 | |||
66 | int count() const; | ||
67 | int status() const; | ||
68 | |||
69 | signals: | ||
70 | void statusChanged(); | ||
71 | void countChanged(); | ||
72 | |||
73 | private: | ||
74 | QSharedPointer<QAbstractItemModel> mModel; | ||
75 | QSharedPointer<Sink::Notifier> mNotifier; | ||
76 | int mStatus; | ||
77 | }; | ||