Incidenceeditor

incidencedialogfactory.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org>
3 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "incidencedialogfactory.h"
9#include "incidencedefaults.h"
10#include "incidencedialog.h"
11
12#include <Akonadi/IncidenceChanger>
13#include <Akonadi/Item>
14#include <KCalendarCore/Event>
15#include <KCalendarCore/Todo>
16
17using namespace IncidenceEditorNG;
18using namespace KCalendarCore;
19
20IncidenceDialog *IncidenceDialogFactory::create(bool needsSaving,
22 Akonadi::IncidenceChanger *changer,
23 QWidget *parent,
24 Qt::WindowFlags flags)
25{
26 switch (type) {
27 case KCalendarCore::IncidenceBase::TypeEvent: // Fall through
30 auto dialog = new IncidenceDialog(changer, parent, flags);
31
32 // needs to be save to akonadi?, apply button should be turned on if so.
33 dialog->setInitiallyDirty(needsSaving /* mInitiallyDirty */);
34
35 return dialog;
36 }
37 default:
38 return nullptr;
39 }
40}
41
42IncidenceDialog *IncidenceDialogFactory::createTodoEditor(const QString &summary,
43 const QString &description,
44 const QStringList &attachments,
45 const QStringList &attendees,
46 const QStringList &attachmentMimetypes,
47 const QStringList &attachmentLabels,
48 bool inlineAttachment,
49 const Akonadi::Collection &defaultCollection,
50 bool cleanupAttachmentTempFiles,
51 QWidget *parent,
52 Qt::WindowFlags flags)
53{
55
56 // if attach or attendee list is empty, these methods don't do anything, so
57 // it's safe to call them in every case
58 defaults.setAttachments(attachments, attachmentMimetypes, attachmentLabels, inlineAttachment);
59 defaults.setAttendees(attendees);
60
61 Todo::Ptr todo(new Todo);
62 defaults.setDefaults(todo);
63
64 todo->setSummary(summary);
65 todo->setDescription(description);
66
67 Akonadi::Item item;
68 item.setPayload(todo);
69
70 IncidenceDialog *dialog = create(true, /* no need for, we're not editing an existing to-do */
72 nullptr,
73 parent,
74 flags);
75 dialog->selectCollection(defaultCollection);
76 dialog->load(item);
77 dialog->setInitiallyDirty(true);
78 return dialog;
79}
80
81IncidenceDialog *IncidenceDialogFactory::createEventEditor(const QString &summary,
82 const QString &description,
83 const QStringList &attachments,
84 const QStringList &attendees,
85 const QStringList &attachmentMimetypes,
86 const QStringList &attachmentLabels,
87 bool inlineAttachment,
88 const Akonadi::Collection &defaultCollection,
89 bool cleanupAttachmentTempFiles,
90 QWidget *parent,
91 Qt::WindowFlags flags)
92{
94
95 // if attach or attendee list is empty, these methods don't do anything, so
96 // it's safe to call them in every case
97 defaults.setAttachments(attachments, attachmentMimetypes, attachmentLabels, inlineAttachment);
98 defaults.setAttendees(attendees);
99
101 defaults.setDefaults(event);
102
103 event->setSummary(summary);
104 event->setDescription(description);
105
106 Akonadi::Item item;
107 item.setPayload(event);
108
109 IncidenceDialog *dialog = create(false, // not needed for saving, as we're not editing an existing incidence
111 nullptr,
112 parent,
113 flags);
114
115 dialog->selectCollection(defaultCollection);
116 dialog->load(item);
117 dialog->setInitiallyDirty(true);
118
119 return dialog;
120}
void setPayload(const T &p)
The IncidenceDefaults class.
static IncidenceDefaults minimalIncidenceDefaults(bool cleanupAttachmentTempFiles=false)
Returns minimal incidence defaults: e-mails and groupware domain.
The IncidenceDialog class.
virtual void load(const Akonadi::Item &item, const QDate &activeDate=QDate())
Loads the.
virtual void selectCollection(const Akonadi::Collection &collection)
Sets the Collection combobox to.
void setInitiallyDirty(bool initiallyDirty)
By default, if you load an incidence into the editor ( load(item) ), then press [OK] without changing...
AKONADI_CALENDAR_EXPORT KCalendarCore::Todo::Ptr todo(const Akonadi::Item &item)
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
QAction * create(StandardAction id, const Receiver *recvr, Func slot, QObject *parent, std::optional< Qt::ConnectionType > connectionType=std::nullopt)
KGuiItem defaults()
typedef WindowFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.