Akonadi Calendar

icalimporter.h
1 /**
2  This file is part of the akonadi-calendar library.
3 
4  SPDX-FileCopyrightText: 2013 Sérgio Martins <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #pragma once
10 
11 #include "akonadi-calendar_export.h"
12 
13 #include <collection.h>
14 
15 #include <QObject>
16 #include <QString>
17 
18 /**
19  * A class to import ical calendar files into akonadi.
20  *
21  * @since 4.12
22  */
23 namespace Akonadi
24 {
25 class IncidenceChanger;
26 
27 class AKONADI_CALENDAR_EXPORT ICalImporter : public QObject
28 {
29  Q_OBJECT
30 public:
31  /**
32  * Constructs a new ICalImporter object. Use a different ICalImporter instance for each file you want to import.
33  *
34  * @param changer An existing IncidenceChanger, if 0, an internal one will be created.
35  * If you pass an existing one, you will be able to undo/redo import operations.
36  * @param parent Parent QObject.
37  */
38  explicit ICalImporter(Akonadi::IncidenceChanger *changer = nullptr, QObject *parent = nullptr);
39  ~ICalImporter();
40 
41  /**
42  * Translated error message.
43  * This is set when either importIntoExistingFinished() or importIntoNewResource() return false
44  * or when the corresponding signals are have success=false.
45  */
46  Q_REQUIRED_RESULT QString errorMessage() const;
47 
48 Q_SIGNALS:
49  /**
50  * Emitted after calling importIntoExistingResource()
51  * @param success Success of the operation.
52  * @param total Number of incidences included in the ical file.
53  *
54  * @see importIntoExistingResource(), errorMessage().
55  */
56  void importIntoExistingFinished(bool success, int total);
57 
58  /**
59  * Emitted after calling importIntoNewResource().
60  * If success is false, check errorMessage().
61  */
62  void importIntoNewFinished(bool success);
63 
64 public Q_SLOTS:
65 
66  /**
67  * Creates a new akonadi_ical_resource and configures it to use @p filename.
68  * @param filename ical absolute file path
69  * @return True if the job was started, in this case you should wait for the corresponding signal.
70  */
71  bool importIntoNewResource(const QString &filename);
72 
73  /**
74  * Imports an ical file into an existing resource.
75  * @param url Path of a local or remote file to import.
76  * @param collectionId The destination collection. If null, the user will be prompted for a destination.
77  *
78  * @return false if some basic validation happened, like insufficient permissions. Use errorMessage() to see
79  * what happened. The importIntoExistingFinished() signal won't be emitted in this case.
80  *
81  * true if the import job was started. importIntoExistingFinished() signal will be emitted in this case.
82  */
83  bool importIntoExistingResource(const QUrl &url, Collection collection);
84 
85 private:
86  class Private;
87  Private *const d;
88 };
89 }
90 
KCALUTILS_EXPORT QString errorMessage(const KCalendarCore::Exception &exception)
FreeBusyManager::Singleton.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jun 19 2021 23:12:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.