KCalUtils

dndfactory.h
Go to the documentation of this file.
1/*
2 This file is part of the kcalutils library.
3
4 SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org>
5 SPDX-FileCopyrightText: 2001, 2002, 2003 Cornelius Schumacher <schumacher@kde.org>
6 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 SPDX-FileCopyrightText: 2008 Thomas Thrainer <tom_t@gmx.at>
8
9 SPDX-License-Identifier: LGPL-2.0-or-later
10*/
11/**
12 @file
13 This file is part of the API for handling calendar data and
14 defines the DndFactory class.
15
16 @author Preston Brown <pbrown@kde.org>
17 @author Cornelius Schumacher <schumacher@kde.org>
18 @author Reinhold Kainhofer <reinhold@kainhofer.com>
19*/
20#pragma once
21
22#include "kcalutils_export.h"
23
24#include <KCalendarCore/Calendar>
25#include <KCalendarCore/Event>
26#include <KCalendarCore/Todo>
27
28#include <QDateTime>
29
30#include <memory>
31
32class QDrag;
33class QDropEvent;
34class QMimeData;
35
36namespace KCalUtils
37{
38class DndFactoryPrivate;
39/**
40 @brief
41 vCalendar/iCalendar Drag-and-Drop object factory.
42
43 This class implements functions to create Drag and Drop objects used for
44 Drag-and-Drop and Copy-and-Paste.
45*/
46class KCALUTILS_EXPORT DndFactory
47{
48public:
49 enum PasteFlag {
50 FlagTodosPasteAtDtStart = 1, /**< If the cloned incidence is a to-do, the date/time passed
51 to DndFactory::pasteIncidence() will change dtStart if this
52 flag is on, changes dtDue otherwise. */
53 FlagPasteAtOriginalTime = 2 /**< If set, incidences will be pasted at the specified date
54 but will preserve their original time */
55 };
56
57 Q_DECLARE_FLAGS(PasteFlags, PasteFlag)
58
59 explicit DndFactory(const KCalendarCore::Calendar::Ptr &cal);
60
62
63 /**
64 Create the calendar that is contained in the drop event's data.
65 */
66 KCalendarCore::Calendar::Ptr createDropCalendar(QDropEvent *de);
67
68 /**
69 Create the calendar that is contained in the mime data.
70 */
71 static KCalendarCore::Calendar::Ptr createDropCalendar(const QMimeData *md);
72
73 /**
74 Create the mime data for the whole calendar.
75 */
76 [[nodiscard]] QMimeData *createMimeData();
77
78 /**
79 Create a drag object for the whole calendar.
80 */
81 QDrag *createDrag(QObject *owner);
82
83 /**
84 Create the mime data for a single incidence.
85 */
86 QMimeData *createMimeData(const KCalendarCore::Incidence::Ptr &incidence);
87
88 /**
89 Create a drag object for a single incidence.
90 */
91 QDrag *createDrag(const KCalendarCore::Incidence::Ptr &incidence, QObject *owner);
92
93 /**
94 Create Todo object from mime data.
95 */
96 KCalendarCore::Todo::Ptr createDropTodo(const QMimeData *md);
97
98 /**
99 Create Todo object from drop event.
100 */
101 KCalendarCore::Todo::Ptr createDropTodo(QDropEvent *de);
102
103 /**
104 Create Event object from mime data.
105 */
106 KCalendarCore::Event::Ptr createDropEvent(const QMimeData *md);
107
108 /**
109 Create Event object from drop event.
110 */
111 KCalendarCore::Event::Ptr createDropEvent(QDropEvent *de);
112
113 /**
114 Cut the incidence to the clipboard.
115 */
116 void cutIncidence(const KCalendarCore::Incidence::Ptr &);
117
118 /**
119 Copy the incidence to clipboard/
120 */
121 bool copyIncidence(const KCalendarCore::Incidence::Ptr &);
122
123 /**
124 Cuts a list of @p incidences to the clipboard.
125 */
126 bool cutIncidences(const KCalendarCore::Incidence::List &incidences);
127
128 /**
129 Copies a list of @p incidences to the clipboard.
130 */
131 bool copyIncidences(const KCalendarCore::Incidence::List &incidences);
132
133 /**
134 This function clones the incidences that are in the clipboard and sets the clone's
135 date/time to the specified @p newDateTime.
136
137 @see pasteIncidence()
138 */
139 KCalendarCore::Incidence::List pasteIncidences(const QDateTime &newDateTime = QDateTime(), PasteFlags pasteOptions = PasteFlags());
140
141 /**
142 This function clones the incidence that's in the clipboard and sets the clone's
143 date/time to the specified @p newDateTime.
144
145 @param newDateTime The new date/time that the incidence will have. If it's an event
146 or journal, DTSTART will be set. If it's a to-do, DTDUE is set.
147 If you wish another behaviour, like changing DTSTART on to-dos, specify
148 @p pasteOptions. If newDateTime is invalid the original incidence's dateTime
149 will be used, regardless of @p pasteOptions.
150
151 @param pasteOptions Control how @p newDateTime changes the incidence's dates. @see PasteFlag.
152
153 @return A pointer to the cloned incidence.
154 */
155 KCalendarCore::Incidence::Ptr pasteIncidence(const QDateTime &newDateTime = QDateTime(), PasteFlags pasteOptions = PasteFlags());
156
157private:
158 //@cond PRIVATE
159 Q_DISABLE_COPY(DndFactory)
160 std::unique_ptr<DndFactoryPrivate> const d;
161 //@endcond
162};
163}
vCalendar/iCalendar Drag-and-Drop object factory.
Definition dndfactory.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.