summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/daylongeventmodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/daylongeventmodel.h')
-rw-r--r--framework/src/domain/daylongeventmodel.h69
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
31class 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
38public:
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
64private:
65 QSharedPointer<QAbstractItemModel> eventModel;
66
67 QDate mPeriodStart;
68 int mPeriodLength = 7;
69};