KCalendarCore

journal.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2001 Cornelius Schumacher <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 /**
9  @file
10  This file is part of the API for handling calendar data and
11  defines the Journal class.
12 
13  @brief
14  Provides a Journal in the sense of RFC2445.
15 
16  @author Cornelius Schumacher <[email protected]>
17 */
18 
19 #include "incidence_p.h"
20 #include "journal.h"
21 #include "visitor.h"
22 
23 #include "kcalendarcore_debug.h"
24 
25 using namespace KCalendarCore;
26 
27 //@cond PRIVATE
28 class KCalendarCore::JournalPrivate : public IncidencePrivate
29 {
30  bool validStatus(Incidence::Status) override;
31 };
32 
33 bool JournalPrivate::validStatus(Incidence::Status status)
34 {
35  constexpr unsigned validSet
36  = 1u << Incidence::StatusNone
40  return validSet & (1u << status);
41 }
42 
43 //@endcond
44 
46  : Incidence(new JournalPrivate)
47 {
48 }
49 
51  : Incidence(other, new JournalPrivate(*(other.d_func())))
52 {
53 }
54 
55 Journal::~Journal() = default;
56 
58 {
59  return TypeJournal;
60 }
61 
63 {
64  return QByteArrayLiteral("Journal");
65 }
66 
68 {
69  return new Journal(*this);
70 }
71 
73 {
74  if (&other != this) {
75  Incidence::assign(other);
76  }
77  return *this;
78 }
79 
80 bool Journal::equals(const IncidenceBase &journal) const
81 {
82  return Incidence::equals(journal);
83 }
84 
85 bool Journal::accept(Visitor &v, const IncidenceBase::Ptr &incidence)
86 {
87  return v.visit(incidence.staticCast<Journal>());
88 }
89 
91 {
92  switch (role) {
93  case RoleEnd:
94  case RoleEndTimeZone:
95  return QDateTime();
96  case RoleDisplayStart:
97  case RoleDisplayEnd:
98  return dtStart();
99  default:
100  return dtStart();
101  }
102 }
103 
104 void Journal::setDateTime(const QDateTime &dateTime, DateTimeRole role)
105 {
106  switch (role) {
107  case RoleDnD: {
109  break;
110  }
111  default:
112  qCDebug(KCALCORE_LOG) << "Unhandled role" << role;
113  }
114 }
115 
116 void Journal::virtual_hook(VirtualHook id, void *data)
117 {
118  Q_UNUSED(id);
119  Q_UNUSED(data);
120 }
121 
123 {
124  return Journal::journalMimeType();
125 }
126 
127 /* static */
129 {
130  return QLatin1String("application/x-vnd.akonadi.calendar.journal");
131 }
132 
134 {
135  return QLatin1String("view-pim-journal");
136 }
137 
138 void Journal::serialize(QDataStream &out) const
139 {
141 }
142 
143 void Journal::deserialize(QDataStream &in)
144 {
146 }
147 
149 {
150  return false;
151 }
Status
The different types of overall incidence status or confirmation.
Definition: incidence.h:84
IncidenceBase & assign(const IncidenceBase &other) override
Definition: journal.cpp:72
void serialize(QDataStream &out) const override
Sub-type specific serialization.
Definition: incidence.cpp:1207
IncidenceType type() const override
Definition: journal.cpp:57
@ RoleDisplayEnd
Role used for display purposes, represents the end boundary if an incidence supports dtEnd.
virtual bool visit(const Event::Ptr &event)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition: visitor.cpp:25
QDateTime dateTime(DateTimeRole role) const override
Definition: journal.cpp:90
@ StatusNone
No status.
Definition: incidence.h:85
DateTimeRole
The different types of incidence date/times roles.
Namespace for all KCalendarCore types.
Definition: alarm.h:36
@ StatusFinal
journal is final
Definition: incidence.h:93
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition: incidence.h:59
void virtual_hook(VirtualHook id, void *data) override
Definition: journal.cpp:116
Provides a Journal in the sense of RFC2445.
Definition: journal.h:32
Journal * clone() const override
Returns an exact copy of this journal.
Definition: journal.cpp:67
QLatin1String iconName(const QDateTime &recurrenceId={}) const override
Definition: journal.cpp:133
An abstract class that provides a common base for all calendar incidence classes.
Definition: incidencebase.h:98
QLatin1String mimeType() const override
Definition: journal.cpp:122
bool equals(const IncidenceBase &journal) const override
Compare this with journal for equality.
Definition: journal.cpp:80
Journal()
Constructs an empty journal.
Definition: journal.cpp:45
bool equals(const IncidenceBase &incidence) const override
Compares this with Incidence incidence for equality.
Definition: incidence.cpp:198
void deserialize(QDataStream &in) override
Sub-type specific deserialization.
Definition: incidence.cpp:1235
Q_SCRIPTABLE CaptureState status()
@ RoleDisplayStart
Role for display purposes, represents the start boundary of an incidence.
bool supportsGroupwareCommunication() const override
Definition: journal.cpp:148
This class provides the interface for a visitor of calendar components.
Definition: visitor.h:30
@ RoleEnd
Role for determining an incidence's dtEnd, will return an invalid QDateTime if the incidence does not...
void setDtStart(const QDateTime &dt) override
Sets the incidence starting date/time.
Definition: incidence.cpp:376
@ StatusCanceled
event or to-do canceled; journal removed
Definition: incidence.h:90
static QLatin1String journalMimeType()
Returns the Akonadi specific sub MIME type of a KCalendarCore::Journal.
Definition: journal.cpp:128
IncidenceType
The different types of incidences, per RFC2445.
~Journal() override
Destroys a journal.
@ RoleEndTimeZone
Role for determining an incidence's ending timezone.
QByteArray typeStr() const override
Definition: journal.cpp:62
IncidenceBase & assign(const IncidenceBase &other) override
Provides polymorfic assignment.
Definition: incidence.cpp:184
@ TypeJournal
Type is a journal.
@ RoleDnD
Role for determining new start and end dates after a DnD.
void setDateTime(const QDateTime &dateTime, DateTimeRole role) override
Definition: journal.cpp:104
QSharedPointer< X > staticCast() const const
@ StatusDraft
journal is draft
Definition: incidence.h:92
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 04:01:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.