File indexing completed on 2024-11-24 04:41:36
0001 /* 0002 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org> 0003 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> 0004 SPDX-FileCopyrightText: 2010 Andras Mantia <andras@kdab.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <KCalendarCore/Incidence> 0012 0013 #include <Akonadi/CollectionCalendar> 0014 #include <Akonadi/Item> 0015 0016 #include <QDateTime> 0017 #include <QList> 0018 #include <QMap> 0019 #include <QStandardItemModel> 0020 0021 namespace EventViews 0022 { 0023 class TimelineSubItem; 0024 0025 class TimelineItem : public QObject 0026 { 0027 Q_OBJECT 0028 public: 0029 TimelineItem(const Akonadi::CollectionCalendar::Ptr &calendar, uint index, QStandardItemModel *model, QObject *parent); 0030 ~TimelineItem() override; 0031 0032 void insertIncidence(const Akonadi::Item &incidence, const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime()); 0033 void removeIncidence(const Akonadi::Item &incidence); 0034 0035 void moveItems(const Akonadi::Item &incidence, int delta, int duration); 0036 0037 void setColor(const QColor &color); 0038 0039 [[nodiscard]] Akonadi::CollectionCalendar::Ptr calendar() const; 0040 0041 private: 0042 Akonadi::CollectionCalendar::Ptr mCalendar; 0043 QMap<Akonadi::Item::Id, QList<QStandardItem *>> mItemMap; 0044 QStandardItemModel *const mModel; 0045 QColor mColor; 0046 const uint mIndex; 0047 }; 0048 0049 class TimelineSubItem : public QStandardItem 0050 { 0051 public: 0052 TimelineSubItem(const Akonadi::Item &incidence, TimelineItem *parent); 0053 ~TimelineSubItem() override; 0054 0055 [[nodiscard]] Akonadi::Item incidence() const 0056 { 0057 return mIncidence; 0058 } 0059 0060 [[nodiscard]] QDateTime originalStart() const 0061 { 0062 return mStart; 0063 } 0064 0065 void setOriginalStart(const QDateTime &dt) 0066 { 0067 mStart = dt; 0068 } 0069 0070 void setStartTime(const QDateTime &dt); 0071 [[nodiscard]] QDateTime startTime() const; 0072 0073 void setEndTime(const QDateTime &dt); 0074 [[nodiscard]] QDateTime endTime() const; 0075 0076 [[nodiscard]] TimelineItem *parent() const 0077 { 0078 return mParent; 0079 } 0080 0081 void updateToolTip(); 0082 0083 private: 0084 Akonadi::Item mIncidence; 0085 QDateTime mStart; 0086 TimelineItem *const mParent = nullptr; 0087 bool mToolTipNeedsUpdate; 0088 }; 0089 }