File indexing completed on 2024-04-28 07:41:18
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 /** 0009 @file 0010 This file is part of the API for handling calendar data and 0011 defines the Journal class. 0012 0013 @brief 0014 Provides a Journal in the sense of RFC2445. 0015 0016 @author Cornelius Schumacher \<schumacher@kde.org\> 0017 */ 0018 0019 #include "incidence_p.h" 0020 #include "journal.h" 0021 #include "visitor.h" 0022 0023 #include "kcalendarcore_debug.h" 0024 0025 using namespace KCalendarCore; 0026 0027 //@cond PRIVATE 0028 class KCalendarCore::JournalPrivate : public IncidencePrivate 0029 { 0030 bool validStatus(Incidence::Status) override; 0031 }; 0032 0033 bool JournalPrivate::validStatus(Incidence::Status status) 0034 { 0035 constexpr unsigned validSet 0036 = 1u << Incidence::StatusNone 0037 | 1u << Incidence::StatusDraft 0038 | 1u << Incidence::StatusFinal 0039 | 1u << Incidence::StatusCanceled; 0040 return validSet & (1u << status); 0041 } 0042 0043 //@endcond 0044 0045 Journal::Journal() 0046 : Incidence(new JournalPrivate) 0047 { 0048 } 0049 0050 Journal::Journal(const Journal &other) 0051 : Incidence(other, new JournalPrivate(*(other.d_func()))) 0052 { 0053 } 0054 0055 Journal::~Journal() = default; 0056 0057 Incidence::IncidenceType Journal::type() const 0058 { 0059 return TypeJournal; 0060 } 0061 0062 QByteArray Journal::typeStr() const 0063 { 0064 return QByteArrayLiteral("Journal"); 0065 } 0066 0067 Journal *Journal::clone() const 0068 { 0069 return new Journal(*this); 0070 } 0071 0072 IncidenceBase &Journal::assign(const IncidenceBase &other) 0073 { 0074 if (&other != this) { 0075 Incidence::assign(other); 0076 } 0077 return *this; 0078 } 0079 0080 bool Journal::equals(const IncidenceBase &journal) const 0081 { 0082 return Incidence::equals(journal); 0083 } 0084 0085 bool Journal::accept(Visitor &v, const IncidenceBase::Ptr &incidence) 0086 { 0087 return v.visit(incidence.staticCast<Journal>()); 0088 } 0089 0090 QDateTime Journal::dateTime(DateTimeRole role) const 0091 { 0092 switch (role) { 0093 case RoleEnd: 0094 case RoleEndTimeZone: 0095 return QDateTime(); 0096 case RoleDisplayStart: 0097 case RoleDisplayEnd: 0098 return dtStart(); 0099 default: 0100 return dtStart(); 0101 } 0102 } 0103 0104 void Journal::setDateTime(const QDateTime &dateTime, DateTimeRole role) 0105 { 0106 switch (role) { 0107 case RoleDnD: { 0108 setDtStart(dateTime); 0109 break; 0110 } 0111 default: 0112 qCDebug(KCALCORE_LOG) << "Unhandled role" << role; 0113 } 0114 } 0115 0116 void Journal::virtual_hook(VirtualHook id, void *data) 0117 { 0118 Q_UNUSED(id); 0119 Q_UNUSED(data); 0120 } 0121 0122 QLatin1String Journal::mimeType() const 0123 { 0124 return Journal::journalMimeType(); 0125 } 0126 0127 /* static */ 0128 QLatin1String Journal::journalMimeType() 0129 { 0130 return QLatin1String("application/x-vnd.akonadi.calendar.journal"); 0131 } 0132 0133 QLatin1String Journal::iconName(const QDateTime &) const 0134 { 0135 return QLatin1String("view-pim-journal"); 0136 } 0137 0138 void Journal::serialize(QDataStream &out) const 0139 { 0140 Incidence::serialize(out); 0141 } 0142 0143 void Journal::deserialize(QDataStream &in) 0144 { 0145 Incidence::deserialize(in); 0146 } 0147 0148 bool Journal::supportsGroupwareCommunication() const 0149 { 0150 return false; 0151 }