File indexing completed on 2024-05-12 05:10:42

0001 /*
0002   SPDX-FileCopyrightText: 2011-2012 Sérgio Martins <iamsergio@gmail.com>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "calendarbase.h"
0010 #include "incidencechanger.h"
0011 
0012 #include <QList>
0013 #include <QMultiHash>
0014 
0015 namespace Akonadi
0016 {
0017 class CalendarBasePrivate : public QObject
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit CalendarBasePrivate(CalendarBase *qq);
0022     ~CalendarBasePrivate() override;
0023 
0024     AKONADI_CALENDAR_EXPORT void internalInsert(const Akonadi::Item &item);
0025     AKONADI_CALENDAR_EXPORT void internalRemove(const Akonadi::Item &item);
0026 
0027     void deleteAllIncidencesOfType(const QString &mimeType);
0028 
0029     void handleUidChange(const Akonadi::Item &oldItem, const Akonadi::Item &newItem, const QString &newUid);
0030 
0031     // Checks if parent changed and adjust internal hierarchy info
0032     void handleParentChanged(const KCalendarCore::Incidence::Ptr &incidence);
0033 
0034 public Q_SLOTS:
0035     void slotDeleteFinished(int changeId, const QList<Akonadi::Item::Id> &itemIds, Akonadi::IncidenceChanger::ResultCode, const QString &errorMessage);
0036 
0037     void slotCreateFinished(int changeId, const Akonadi::Item &item, Akonadi::IncidenceChanger::ResultCode, const QString &errorMessage);
0038 
0039     void slotModifyFinished(int changeId, const Akonadi::Item &item, Akonadi::IncidenceChanger::ResultCode, const QString &errorMessage);
0040 
0041     void collectionFetchResult(KJob *job);
0042 
0043 Q_SIGNALS:
0044     void fetchFinished();
0045 
0046 public:
0047     QMultiHash<Akonadi::Collection::Id, Akonadi::Item> mItemsByCollection;
0048     QHash<Akonadi::Collection::Id, Akonadi::Collection> mCollections;
0049     QHash<KJob *, Akonadi::Collection::Id> mCollectionJobs;
0050     QHash<QString, Akonadi::Item::Id> mItemIdByUid;
0051     QHash<Akonadi::Item::Id, Akonadi::Item> mItemById;
0052     Akonadi::IncidenceChanger *const mIncidenceChanger;
0053     QHash<QString, QStringList> mParentUidToChildrenUid;
0054     Akonadi::Collection mCollectionForBatchInsertion;
0055     bool mBatchInsertionCancelled = false;
0056     bool mListensForNewItems = false; // does this model detect new item creations ?
0057     bool mLastCreationCancelled = false; // User pressed cancel in the collection selection dialog
0058 
0059     // Hash with uid->parentUid. When receiving onDataChanged() we need a way
0060     // to obtain the original RELATED-TO. Because RELATED-TO might have been modified
0061     // we can't trust the incidence stored in the calendar. ( Users of this class don't
0062     // operate on a incidence clone, they change the same incidence that's inside the calendar )
0063     QHash<QString, QString> mUidToParent;
0064 
0065 private:
0066     CalendarBase *const q;
0067 };
0068 }