diff options
author | Minijackson <minijackson@riseup.net> | 2018-05-14 16:19:43 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-05-15 11:36:32 +0200 |
commit | b234c6c74ba76e8d58ab9a55ab1054eb761697e1 (patch) | |
tree | 116d2ec96bb51919ae7c1c274b31178f1faf059b /framework/src/domain/daylongeventmodel.h | |
parent | d353ec997f06891455dce9b51333687da670a03e (diff) | |
download | kube-b234c6c74ba76e8d58ab9a55ab1054eb761697e1.tar.gz kube-b234c6c74ba76e8d58ab9a55ab1054eb761697e1.zip |
Implement DayLongEventModel and integrate it to calendar
Diffstat (limited to 'framework/src/domain/daylongeventmodel.h')
-rw-r--r-- | framework/src/domain/daylongeventmodel.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/framework/src/domain/daylongeventmodel.h b/framework/src/domain/daylongeventmodel.h new file mode 100644 index 00000000..a4a291df --- /dev/null +++ b/framework/src/domain/daylongeventmodel.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | Copyright (c) 2018 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | Copyright (c) 2018 Christian Mollekopf <mollekopf@kolabsys.com> | ||
4 | Copyright (c) 2018 Rémi Nicole <minijackson@riseup.net> | ||
5 | |||
6 | This library is free software; you can redistribute it and/or modify it | ||
7 | under the terms of the GNU Library General Public License as published by | ||
8 | the Free Software Foundation; either version 2 of the License, or (at your | ||
9 | option) any later version. | ||
10 | |||
11 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
14 | License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU Library General Public License | ||
17 | along with this library; see the file COPYING.LIB. If not, write to the | ||
18 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
19 | 02110-1301, USA. | ||
20 | */ | ||
21 | |||
22 | #pragma once | ||
23 | #include "kube_export.h" | ||
24 | #include <sink/applicationdomaintype.h> | ||
25 | |||
26 | #include <QList> | ||
27 | #include <QSharedPointer> | ||
28 | #include <QSortFilterProxyModel> | ||
29 | #include <QVector> | ||
30 | |||
31 | class KUBE_EXPORT DayLongEventModel : public QSortFilterProxyModel | ||
32 | { | ||
33 | Q_OBJECT | ||
34 | |||
35 | Q_PROPERTY(QVariant start READ periodStart WRITE setPeriodStart) | ||
36 | Q_PROPERTY(int length READ periodLength WRITE setPeriodLength) | ||
37 | |||
38 | public: | ||
39 | using Event = Sink::ApplicationDomain::Event; | ||
40 | |||
41 | enum Roles | ||
42 | { | ||
43 | Summary = Qt::UserRole + 1, | ||
44 | Description, | ||
45 | StartDate, | ||
46 | Duration, | ||
47 | }; | ||
48 | Q_ENUM(Roles); | ||
49 | |||
50 | DayLongEventModel(QObject *parent = nullptr); | ||
51 | ~DayLongEventModel() = default; | ||
52 | |||
53 | QHash<int, QByteArray> roleNames() const override; | ||
54 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||
55 | |||
56 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; | ||
57 | |||
58 | QDate periodStart() const; | ||
59 | void setPeriodStart(const QDate &); | ||
60 | void setPeriodStart(const QVariant &); | ||
61 | int periodLength() const; | ||
62 | void setPeriodLength(int); | ||
63 | |||
64 | private: | ||
65 | QSharedPointer<QAbstractItemModel> eventModel; | ||
66 | |||
67 | QDate mPeriodStart; | ||
68 | int mPeriodLength = 7; | ||
69 | }; | ||