1 /* 2 SPDX-FileCopyrightText: 2011-2012 Sérgio Martins <iamsergio@gmail.com> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include "calendarbase.h" 10 #include "incidencechanger.h" 11 12 #include <QMultiHash> 13 #include <QVector> 14 15 namespace Akonadi 16 { 17 class CalendarBasePrivate : public QObject 18 { 19 Q_OBJECT 20 public: 21 explicit CalendarBasePrivate(CalendarBase *qq); 22 ~CalendarBasePrivate() override; 23 24 void internalInsert(const Akonadi::Item &item); 25 void internalRemove(const Akonadi::Item &item); 26 27 void deleteAllIncidencesOfType(const QString &mimeType); 28 29 void handleUidChange(const Akonadi::Item &oldItem, const Akonadi::Item &newItem, const QString &newUid); 30 31 // Checks if parent changed and adjust internal hierarchy info 32 void handleParentChanged(const KCalendarCore::Incidence::Ptr &incidence); 33 34 public Q_SLOTS: 35 void slotDeleteFinished(int changeId, const QVector<Akonadi::Item::Id> &itemIds, Akonadi::IncidenceChanger::ResultCode, const QString &errorMessage); 36 37 void slotCreateFinished(int changeId, const Akonadi::Item &item, Akonadi::IncidenceChanger::ResultCode, const QString &errorMessage); 38 39 void slotModifyFinished(int changeId, const Akonadi::Item &item, Akonadi::IncidenceChanger::ResultCode, const QString &errorMessage); 40 41 void collectionFetchResult(KJob *job); 42 43 Q_SIGNALS: 44 void fetchFinished(); 45 46 public: 47 QMultiHash<Akonadi::Collection::Id, Akonadi::Item> mItemsByCollection; 48 QHash<Akonadi::Collection::Id, Akonadi::Collection> mCollections; 49 QHash<KJob *, Akonadi::Collection::Id> mCollectionJobs; 50 QHash<QString, Akonadi::Item::Id> mItemIdByUid; 51 QHash<Akonadi::Item::Id, Akonadi::Item> mItemById; 52 Akonadi::IncidenceChanger *const mIncidenceChanger; 53 QHash<QString, QStringList> mParentUidToChildrenUid; 54 Akonadi::Collection mCollectionForBatchInsertion; 55 bool mBatchInsertionCancelled = false; 56 bool mListensForNewItems = false; // does this model detect new item creations ? 57 bool mLastCreationCancelled = false; // User pressed cancel in the collection selection dialog 58 59 // Hash with uid->parentUid. When receiving onDataChanged() we need a way 60 // to obtain the original RELATED-TO. Because RELATED-TO might have been modified 61 // we can't trust the incidence stored in the calendar. ( Users of this class don't 62 // operate on a incidence clone, they change the same incidence that's inside the calendar ) 63 QHash<QString, QString> mUidToParent; 64 65 private: 66 CalendarBase *const q; 67 }; 68 } 69 70