Akonadi Calendar

calendarclipboard.h
1 /*
2  SPDX-FileCopyrightText: 2012 Sérgio Martins <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "akonadi-calendar_export.h"
10 #include "calendarbase.h"
11 
12 #include <KCalendarCore/Incidence>
13 #include <QObject>
14 
15 #include <memory>
16 
17 namespace Akonadi
18 {
19 class IncidenceChanger;
20 class CalendarClipboardPrivate;
21 
22 /**
23  * @short Class to copy or cut calendar incidences.
24  *
25  * @author Sérgio Martins <[email protected]>
26  * @since 4.11
27  */
28 class AKONADI_CALENDAR_EXPORT CalendarClipboard : public QObject
29 {
30  Q_OBJECT
31 public:
32  enum Mode {
33  SingleMode = 0, ///< Only the specified incidence is cut/copied.
34  RecursiveMode, ///< The specified incidence's children are also cut/copied
35  AskMode ///< The user is asked if he wants children to be cut/copied too
36  };
37 
38  /**
39  * Constructs a new CalendarClipboard.
40  * @param calendar calendar containing incidences
41  * @param changer incidence changer that will delete incidences while copying.
42  * If 0, an internal one will be created.
43  * @param parent QObject parent
44  */
45  explicit CalendarClipboard(const Akonadi::CalendarBase::Ptr &calendar, Akonadi::IncidenceChanger *changer = nullptr, QObject *parent = nullptr);
46  /**
47  * Destroys the CalendarClipboard instance.
48  */
49  ~CalendarClipboard() override;
50 
51  /**
52  * Copies the specified incidence into the clipboard and then deletes it from akonadi.
53  * The incidence must be present in the calendar.
54  * After it's deletion from akonadi, signal cutFinished() is emitted.
55  * @param incidence to cut
56  * @param mode how to treat child incidences. Defaults to #RecursiveMode
57  * @see cutFinished().
58  */
59  void cutIncidence(const KCalendarCore::Incidence::Ptr &incidence, CalendarClipboard::Mode mode = RecursiveMode);
60 
61  /**
62  * Copies the specified incidence into the clipboard.
63  * @param incidence the incidence to copy
64  * @param mode how to treat child incidences. Defaults to #RecursiveMode
65  * @return true on success
66  */
67  bool copyIncidence(const KCalendarCore::Incidence::Ptr &incidence, CalendarClipboard::Mode mode = RecursiveMode);
68 
69  /**
70  * Returns if there's any ical mime data available for pasting.
71  */
72  Q_REQUIRED_RESULT bool pasteAvailable() const;
73 
74 Q_SIGNALS:
75  /**
76  * Emitted after cutIncidences() finishes.
77  * @param success true if the cut was successful
78  * @param errorMessage if @p success if false, contains the error message, empty otherwise.
79  */
80  void cutFinished(bool success, const QString &errorMessage);
81 
82 private:
83  std::unique_ptr<CalendarClipboardPrivate> const d;
84 };
85 }
@ RecursiveMode
The specified incidence's children are also cut/copied.
Class to copy or cut calendar incidences.
FreeBusyManager::Singleton.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Sep 28 2022 03:52:06 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.