From 3a4adb790b4d3bef746f5ad88ef073ef821053fa Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 1 Aug 2018 17:33:03 +0200 Subject: Query for the list of calendars --- framework/src/entitymodel.h | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 framework/src/entitymodel.h (limited to 'framework/src/entitymodel.h') 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 @@ +/* + Copyright (c) 2018 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#pragma once +#include "kube_export.h" +#include +#include + +namespace Sink { + class Query; +} + +class KUBE_EXPORT EntityModel : public QSortFilterProxyModel +{ + Q_OBJECT + + Q_PROPERTY (QString accountId READ accountId WRITE setAccountId) + Q_PROPERTY (QString type READ type WRITE setType) + Q_PROPERTY (QStringList roles READ roles WRITE setRoles) + Q_PROPERTY (QVariantMap filter READ filter WRITE setFilter) + +public: + enum Status { + NoStatus, + InProgressStatus, + ErrorStatus, + SuccessStatus, + }; + Q_ENUMS(Status) + + EntityModel(QObject *parent = Q_NULLPTR); + ~EntityModel(); + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + + QHash roleNames() const Q_DECL_OVERRIDE; + + void setAccountId(const QString &); + QString accountId() const; + + void setType(const QString &); + QString type() const; + + void setRoles(const QStringList &); + QStringList roles() const; + + void setFilter(const QVariantMap &); + QVariantMap filter() const; + +private: + void runQuery(const Sink::Query &query); + void updateQuery(); + QSharedPointer mModel; + QHash mRoleNames; + QHash mRoles; + QString mAccountId; + QString mType; +}; -- cgit v1.2.3