Incidenceeditor

editorconfig.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Sebastian Sauer <sebsauer@kdab.net>
3
4 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
5*/
6
7#include "editorconfig.h"
8#include "korganizereditorconfig.h"
9
10#include <QCoreApplication>
11
12using namespace IncidenceEditorNG;
13
14class IncidenceEditorNG::EditorConfigPrivate
15{
16public:
17 static EditorConfig *config;
18 static void cleanup_config()
19 {
20 delete config;
21 config = nullptr;
22 }
23
25};
26
27EditorConfig *EditorConfigPrivate::config = nullptr;
28
29EditorConfig::EditorConfig()
30 : d(new EditorConfigPrivate)
31{
32}
33
34EditorConfig::~EditorConfig() = default;
35
36EditorConfig *EditorConfig::instance()
37{
38 if (!EditorConfigPrivate::config) {
39 // No one called setEditorConfig(), so we default to a KorganizerEditorConfig.
40 EditorConfig::setEditorConfig(new IncidenceEditorNG::KOrganizerEditorConfig);
41 }
42
43 return EditorConfigPrivate::config;
44}
45
46void EditorConfig::setEditorConfig(EditorConfig *config)
47{
48 delete EditorConfigPrivate::config;
49 EditorConfigPrivate::config = config;
50 qAddPostRoutine(EditorConfigPrivate::cleanup_config);
51}
52
54{
55 if (EditorConfigPrivate::config != this) {
56 return EditorConfigPrivate::config->fullName();
57 }
58 return {};
59}
60
62{
63 if (EditorConfigPrivate::config != this) {
64 return EditorConfigPrivate::config->email();
65 }
66 return {};
67}
68
69bool EditorConfig::thatIsMe(const QString &mail) const
70{
71 if (EditorConfigPrivate::config != this) {
72 return EditorConfigPrivate::config->thatIsMe(mail);
73 }
74 return false;
75}
76
78{
79 if (EditorConfigPrivate::config != this) {
80 return EditorConfigPrivate::config->allEmails();
81 }
82
83 QStringList mails;
84 const QString m = email();
85 if (!m.isEmpty()) {
86 mails << m;
87 }
88 return mails;
89}
90
92{
93 if (EditorConfigPrivate::config != this) {
94 return EditorConfigPrivate::config->allOrganizers();
95 }
96 return {};
97}
98
100{
101 if (EditorConfigPrivate::config != this) {
102 return EditorConfigPrivate::config->showTimeZoneSelectorInIncidenceEditor();
103 }
104 return true;
105}
106
107QStringList &EditorConfig::templates(KCalendarCore::IncidenceBase::IncidenceType type)
108{
109 return d->mTemplates[type];
110}
Configuration details.
virtual QList< Organizer > allOrganizers() const
Returns all email addresses together with the full username for the user.
virtual bool thatIsMe(const QString &email) const
Return true if the given email belongs to the user.
virtual QStringList allEmails() const
Returns all email addresses for the user.
virtual QString email() const
Return the own mail address.
virtual bool showTimeZoneSelectorInIncidenceEditor() const
Show timezone selectors in the event and todo editor dialog.
virtual QString fullName() const
Return the own full name.
bool isEmpty() const const
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.