File indexing completed on 2024-11-24 04:50:39
0001 // SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com> 0002 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: LGPL-3.0-or-later 0004 0005 #pragma once 0006 0007 #include <Akonadi/ETMCalendar> 0008 #include <QAction> 0009 #include <QObject> 0010 0011 class Importer : public QObject 0012 { 0013 Q_OBJECT 0014 Q_PROPERTY(bool calendarImportInProgress MEMBER m_calendarImportInProgress NOTIFY calendarImportInProgressChanged) 0015 Q_PROPERTY(QList<QUrl> calendarFilesToImport MEMBER m_calendarFilesToImport NOTIFY calendarFilesToImportChanged) 0016 Q_PROPERTY(QUrl currentFile MEMBER m_currentFile NOTIFY currentFileChanged) 0017 Q_PROPERTY(QAction *importAction READ importAction WRITE setImportAction NOTIFY importActionChanged) 0018 Q_PROPERTY(Akonadi::ETMCalendar::Ptr calendar MEMBER m_calendar NOTIFY calendarChanged) 0019 Q_PROPERTY(QString importErrorMessage READ importErrorMessage NOTIFY importErrorMessageChanged) 0020 0021 public: 0022 explicit Importer(QObject *parent = nullptr); 0023 0024 Q_INVOKABLE void importCalendarFromUrl(const QUrl &url, bool merge, qint64 collectionId = -1); 0025 QString importErrorMessage(); 0026 0027 QAction *importAction() const; 0028 void setImportAction(QAction *importAction); 0029 0030 Q_SIGNALS: 0031 void importActionChanged(); 0032 void importStarted(); 0033 void importFinished(); 0034 void importCalendar(); 0035 void importCalendarFromFile(const QUrl &url); 0036 void importIntoExistingFinished(bool success, int total); 0037 void importIntoNewFinished(bool success); 0038 void importErrorMessageChanged(); 0039 void calendarImportInProgressChanged(); 0040 void calendarFilesToImport(); 0041 void currentFileChanged(); 0042 void calendarChanged(); 0043 void calendarFilesToImportChanged(); 0044 0045 private: 0046 Akonadi::ETMCalendar::Ptr m_calendar; 0047 QString m_importErrorMessage; 0048 bool m_calendarImportInProgress = false; 0049 QList<QUrl> m_calendarFilesToImport; 0050 QAction *m_importAction = nullptr; 0051 QUrl m_currentFile; 0052 };