Akonadi Calendar

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

KDE's Doxygen guidelines are available online.