File indexing completed on 2024-05-19 05:11:14
0001 /* 0002 SPDX-FileCopyrightText: 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 "akonadi-calendar_export.h" 0010 #include "calendarbase.h" 0011 0012 #include <KCalendarCore/Incidence> 0013 #include <QObject> 0014 0015 #include <memory> 0016 0017 namespace Akonadi 0018 { 0019 class IncidenceChanger; 0020 class CalendarClipboardPrivate; 0021 0022 /** 0023 * @short Class to copy or cut calendar incidences. 0024 * 0025 * @author Sérgio Martins <iamsergio@gmail.com> 0026 * @since 4.11 0027 */ 0028 class AKONADI_CALENDAR_EXPORT CalendarClipboard : public QObject 0029 { 0030 Q_OBJECT 0031 public: 0032 enum Mode { 0033 SingleMode = 0, ///< Only the specified incidence is cut/copied. 0034 RecursiveMode, ///< The specified incidence's children are also cut/copied 0035 AskMode ///< The user is asked if he wants children to be cut/copied too 0036 }; 0037 0038 /** 0039 * Constructs a new CalendarClipboard. 0040 * @param calendar calendar containing incidences 0041 * @param changer incidence changer that will delete incidences while copying. 0042 * If 0, an internal one will be created. 0043 * @param parent QObject parent 0044 */ 0045 explicit CalendarClipboard(const Akonadi::CalendarBase::Ptr &calendar, Akonadi::IncidenceChanger *changer = nullptr, QObject *parent = nullptr); 0046 /** 0047 * Destroys the CalendarClipboard instance. 0048 */ 0049 ~CalendarClipboard() override; 0050 0051 /** 0052 * Copies the specified incidence into the clipboard and then deletes it from akonadi. 0053 * The incidence must be present in the calendar. 0054 * After it's deletion from akonadi, signal cutFinished() is emitted. 0055 * @param incidence to cut 0056 * @param mode how to treat child incidences. Defaults to #RecursiveMode 0057 * @see cutFinished(). 0058 */ 0059 void cutIncidence(const KCalendarCore::Incidence::Ptr &incidence, CalendarClipboard::Mode mode = RecursiveMode); 0060 0061 /** 0062 * Copies the specified incidence into the clipboard. 0063 * @param incidence the incidence to copy 0064 * @param mode how to treat child incidences. Defaults to #RecursiveMode 0065 * @return true on success 0066 */ 0067 bool copyIncidence(const KCalendarCore::Incidence::Ptr &incidence, CalendarClipboard::Mode mode = RecursiveMode); 0068 0069 /** 0070 * Returns if there's any ical mime data available for pasting. 0071 */ 0072 [[nodiscard]] bool pasteAvailable() const; 0073 0074 Q_SIGNALS: 0075 /** 0076 * Emitted after cutIncidences() finishes. 0077 * @param success true if the cut was successful 0078 * @param errorMessage if @p success if false, contains the error message, empty otherwise. 0079 */ 0080 void cutFinished(bool success, const QString &errorMessage); 0081 0082 private: 0083 std::unique_ptr<CalendarClipboardPrivate> const d; 0084 }; 0085 }