From 455809b0e5d6e80406867aa8f5a74aa10a39bf35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Nicole?= Date: Tue, 15 May 2018 12:01:09 +0200 Subject: Implement DayLongEventModel and integrate it to the calendar Summary: Fixes T8697 Reviewers: cmollekopf Reviewed By: cmollekopf Tags: #kube Maniphest Tasks: T8697 Differential Revision: https://phabricator.kde.org/D12875 --- framework/src/domain/daylongeventmodel.h | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 framework/src/domain/daylongeventmodel.h (limited to 'framework/src/domain/daylongeventmodel.h') diff --git a/framework/src/domain/daylongeventmodel.h b/framework/src/domain/daylongeventmodel.h new file mode 100644 index 00000000..21bcbfba --- /dev/null +++ b/framework/src/domain/daylongeventmodel.h @@ -0,0 +1,69 @@ +/* + Copyright (c) 2018 Michael Bohlender + Copyright (c) 2018 Christian Mollekopf + Copyright (c) 2018 Rémi Nicole + + 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 +#include +#include +#include + +class KUBE_EXPORT DayLongEventModel : public QSortFilterProxyModel +{ + Q_OBJECT + + Q_PROPERTY(QVariant start READ periodStart WRITE setPeriodStart) + Q_PROPERTY(int length READ periodLength WRITE setPeriodLength) + +public: + using Event = Sink::ApplicationDomain::Event; + + enum Roles + { + Summary = Qt::UserRole + 1, + Description, + StartDate, + Duration, + }; + Q_ENUM(Roles); + + DayLongEventModel(QObject *parent = nullptr); + ~DayLongEventModel() = default; + + QHash roleNames() const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + + QDate periodStart() const; + void setPeriodStart(const QDate &); + void setPeriodStart(const QVariant &); + int periodLength() const; + void setPeriodLength(int); + +private: + QSharedPointer mModel; + + QDate mPeriodStart; + int mPeriodLength = 7; +}; -- cgit v1.2.3