summaryrefslogtreecommitdiffstats
path: root/framework/src/entitymodel.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-01 17:33:03 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-01 17:33:03 +0200
commit3a4adb790b4d3bef746f5ad88ef073ef821053fa (patch)
tree93e43200989c3f2a44073851139e3d144c0ea4c3 /framework/src/entitymodel.h
parent8d5f8e5fd00d092941c55ffcc5b50c84dbd635f2 (diff)
downloadkube-3a4adb790b4d3bef746f5ad88ef073ef821053fa.tar.gz
kube-3a4adb790b4d3bef746f5ad88ef073ef821053fa.zip
Query for the list of calendars
Diffstat (limited to 'framework/src/entitymodel.h')
-rw-r--r--framework/src/entitymodel.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/framework/src/entitymodel.h b/framework/src/entitymodel.h
new file mode 100644
index 00000000..b8a0417e
--- /dev/null
+++ b/framework/src/entitymodel.h
@@ -0,0 +1,74 @@
1/*
2 Copyright (c) 2018 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#pragma once
21#include "kube_export.h"
22#include <QSharedPointer>
23#include <QSortFilterProxyModel>
24
25namespace Sink {
26 class Query;
27}
28
29class KUBE_EXPORT EntityModel : public QSortFilterProxyModel
30{
31 Q_OBJECT
32
33 Q_PROPERTY (QString accountId READ accountId WRITE setAccountId)
34 Q_PROPERTY (QString type READ type WRITE setType)
35 Q_PROPERTY (QStringList roles READ roles WRITE setRoles)
36 Q_PROPERTY (QVariantMap filter READ filter WRITE setFilter)
37
38public:
39 enum Status {
40 NoStatus,
41 InProgressStatus,
42 ErrorStatus,
43 SuccessStatus,
44 };
45 Q_ENUMS(Status)
46
47 EntityModel(QObject *parent = Q_NULLPTR);
48 ~EntityModel();
49
50 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
51
52 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
53
54 void setAccountId(const QString &);
55 QString accountId() const;
56
57 void setType(const QString &);
58 QString type() const;
59
60 void setRoles(const QStringList &);
61 QStringList roles() const;
62
63 void setFilter(const QVariantMap &);
64 QVariantMap filter() const;
65
66private:
67 void runQuery(const Sink::Query &query);
68 void updateQuery();
69 QSharedPointer<QAbstractItemModel> mModel;
70 QHash<int, QByteArray> mRoleNames;
71 QHash<QByteArray, int> mRoles;
72 QString mAccountId;
73 QString mType;
74};