CalendarSupport

attachmenthandler.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7/**
8 @file
9 This file is part of the API for handling calendar data and provides
10 static functions for dealing with calendar incidence attachments.
11
12 @author Allen Winter <winter@kde.org>
13*/
14#pragma once
15
16#include <KCalendarCore/Attachment>
17#include <KCalendarCore/Incidence>
18#include <KCalendarCore/ScheduleMessage>
19
20#include <QObject>
21
22#include <memory>
23
24class KJob;
25
26class QWidget;
27
28namespace CalendarSupport
29{
30class AttachmentHandlerPrivate;
31
32/**
33 @brief
34 Provides methods to handle incidence attachments.
35
36 Includes functions to view and save attachments.
37*/
39{
41public:
42 /**
43 * Constructs an AttachmentHandler.
44 * @param parent is the parent widget for the dialogs used by this class.
45 */
47 ~AttachmentHandler() override;
48
49 /**
50 * Finds the attachment in the user's calendar, by @p attachmentName and @p incidence.
51 *
52 * @param attachmentName is the name of the attachment
53 * @param incidence is a pointer to a valid Incidence object containing the attachment.
54 * @return a pointer to the Attachment object located; 0 if no such attachment could be found.
55 */
56 KCalendarCore::Attachment find(const QString &attachmentName, const KCalendarCore::Incidence::Ptr &incidence);
57
58 /**
59 * Finds the attachment in the user's calendar, by @p attachmentName and a scheduler message;
60 * in other words, this function is intended to retrieve attachments from calendar invitations.
61 *
62 * @param attachmentName is the name of the attachment
63 * @param message is a pointer to a valid ScheduleMessage object containing the attachment.
64 * @return a pointer to the Attachment object located; 0 if no such attachment could be found.
65 */
67
68 /**
69 * Launches a viewer on the specified attachment.
70 *
71 * @param attachment is a pointer to a valid Attachment object.
72 * @return true if the viewer program successfully launched; false otherwise.
73 */
74 bool view(const KCalendarCore::Attachment &attachment);
75
76 /**
77 * Launches a viewer on the specified attachment.
78 *
79 * @param attachmentName is the name of the attachment
80 * @param incidence is a pointer to a valid Incidence object containing the attachment.
81 * @return true if the attachment could be found and the viewer program successfully launched;
82 * false otherwise.
83 */
84 bool view(const QString &attachmentName, const KCalendarCore::Incidence::Ptr &incidence);
85
86 /**
87 Launches a viewer on the specified attachment.
88
89 @param attachmentName is the name of the attachment
90 @param uid is a QString containing a UID of the incidence containing the attachment.
91
92 This function is async and will return immediately. Listen to signal viewFinished()
93 if you're interested on the success of this operation.
94
95 */
96 void view(const QString &attachmentName, const QString &uid);
97
98 /**
99 Launches a viewer on the specified attachment.
100
101 @param attachmentName is the name of the attachment
102 @param message is a pointer to a valid ScheduleMessage object containing the attachment.
103
104 @return true if the attachment could be found and the viewer program successfully launched;
105 false otherwise.
106 */
107 bool view(const QString &attachmentName, const KCalendarCore::ScheduleMessage::Ptr &message);
108
109 /**
110 Saves the specified attachment to a file of the user's choice.
111
112 @param attachment is a pointer to a valid Attachment object.
113
114 @return true if the save operation was successful; false otherwise.
115 */
116 bool saveAs(const KCalendarCore::Attachment &attachment);
117
118 /**
119 Saves the specified attachment to a file of the user's choice.
120
121 @param attachmentName is the name of the attachment
122 @param incidence is a pointer to a valid Incidence object containing the attachment.
123
124 @return true if the attachment could be found and the save operation was successful;
125 false otherwise.
126 */
127 bool saveAs(const QString &attachmentName, const KCalendarCore::Incidence::Ptr &incidence);
128
129 /**
130 Saves the specified attachment to a file of the user's choice.
131
132 @param attachmentName is the name of the attachment
133 @param uid is a QString containing a UID of the incidence containing the attachment.
134
135 This function is async, it will return immediately. Listen to signal saveAsFinished()
136 if you're interested on the success of this operation.
137 */
138 void saveAs(const QString &attachmentName, const QString &uid);
139
140 /**
141 Saves the specified attachment to a file of the user's choice.
142
143 @param attachmentName is the name of the attachment
144 @param message is a pointer to a valid ScheduleMessage object containing the attachment.
145
146 @return true if the attachment could be found and the save operation was successful;
147 false otherwise.
148 */
149 bool saveAs(const QString &attachmentName, const KCalendarCore::ScheduleMessage::Ptr &message);
150
152 void viewFinished(const QString &uid, const QString &attachmentName, bool success);
153 void saveAsFinished(const QString &uid, const QString &attachmentName, bool success);
154
155private:
156 void slotFinishView(KJob *job);
157 void slotFinishSaveAs(KJob *job);
158 //@cond PRIVATE
159 std::unique_ptr<AttachmentHandlerPrivate> const d;
160 //@endcond
161}; // class AttachmentHandler
162} // namespace CalendarSupport
Provides methods to handle incidence attachments.
bool saveAs(const KCalendarCore::Attachment &attachment)
Saves the specified attachment to a file of the user's choice.
KCalendarCore::Attachment find(const QString &attachmentName, const KCalendarCore::Incidence::Ptr &incidence)
Finds the attachment in the user's calendar, by attachmentName and incidence.
AttachmentHandler(QWidget *parent)
Constructs an AttachmentHandler.
bool view(const KCalendarCore::Attachment &attachment)
Launches a viewer on the specified attachment.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.