Changeset View
Changeset View
Standalone View
Standalone View
src/calendar/event.cpp
| Show All 19 Lines | |||||
| 20 | * License along with this library. If not, see <https://www.gnu.org/licenses/>. | 20 | * License along with this library. If not, see <https://www.gnu.org/licenses/>. | ||
| 21 | */ | 21 | */ | ||
| 22 | 22 | | |||
| 23 | #include "event.h" | 23 | #include "event.h" | ||
| 24 | #include "../debug.h" | 24 | #include "../debug.h" | ||
| 25 | 25 | | |||
| 26 | using namespace KGAPI2; | 26 | using namespace KGAPI2; | ||
| 27 | 27 | | |||
| 28 | namespace { | ||||
| 29 | static constexpr const char *EventIdProperty = "EventId"; | ||||
| 30 | } | ||||
| 31 | | ||||
| 28 | class Q_DECL_HIDDEN Event::Private | 32 | class Q_DECL_HIDDEN Event::Private | ||
| 29 | { | 33 | { | ||
| 30 | public: | 34 | public: | ||
| 31 | explicit Private(); | | |||
| 32 | Private(const Private &other); | | |||
| 33 | | ||||
| 34 | QString id; | 35 | QString id; | ||
| 35 | bool deleted; | 36 | bool deleted = false; | ||
| 36 | bool useDefaultReminders; | 37 | bool useDefaultReminders = false; | ||
| 37 | }; | 38 | }; | ||
| 38 | 39 | | |||
| 39 | Event::Private::Private(): | | |||
| 40 | deleted(false), | | |||
| 41 | useDefaultReminders(false) | | |||
| 42 | { | | |||
| 43 | } | | |||
| 44 | | ||||
| 45 | Event::Private::Private(const Private &other): | | |||
| 46 | id(other.id), | | |||
| 47 | deleted(other.deleted), | | |||
| 48 | useDefaultReminders(other.useDefaultReminders) | | |||
| 49 | { | | |||
| 50 | } | | |||
| 51 | | ||||
| 52 | Event::Event(): | 40 | Event::Event(): | ||
| 53 | Object(), | 41 | Object(), | ||
| 54 | KCalendarCore::Event(), | 42 | KCalendarCore::Event(), | ||
| 55 | d(new Private) | 43 | d(new Private) | ||
| 56 | { | 44 | { | ||
| 57 | } | 45 | } | ||
| 58 | 46 | | |||
| 59 | Event::Event(const Event &other): | 47 | Event::Event(const Event &other): | ||
| 60 | Object(other), | 48 | Object(other), | ||
| 61 | KCalendarCore::Event(other), | 49 | KCalendarCore::Event(other), | ||
| 62 | d(new Private(*(other.d))) | 50 | d(new Private(*(other.d))) | ||
| 63 | { | 51 | { | ||
| 64 | } | 52 | } | ||
| 65 | 53 | | |||
| 66 | Event::Event(const KCalendarCore::Event &other): | 54 | Event::Event(const KCalendarCore::Event &other): | ||
| 67 | Object(), | 55 | Object(), | ||
| 68 | KCalendarCore::Event(other), | 56 | KCalendarCore::Event(other), | ||
| 69 | d(new Private) | 57 | d(new Private) | ||
| 70 | { | 58 | { | ||
| 71 | } | 59 | } | ||
| 72 | 60 | | |||
| 73 | Event::~Event() | 61 | Event::~Event()= default; | ||
| 74 | { | | |||
| 75 | delete d; | | |||
| 76 | } | | |||
| 77 | 62 | | |||
| 78 | bool Event::operator==(const Event &other) const | 63 | bool Event::operator==(const Event &other) const | ||
| 79 | { | 64 | { | ||
| 80 | if (!Object::operator==(other)) { | 65 | if (!Object::operator==(other)) { | ||
| 81 | return false; | 66 | return false; | ||
| 82 | } | 67 | } | ||
| 83 | if (!KCalendarCore::Event::operator==(other)) { | 68 | if (!KCalendarCore::Event::operator==(other)) { | ||
| 84 | return false; | 69 | return false; | ||
| Show All 28 Lines | |||||
| 113 | 98 | | |||
| 114 | void Event::setUseDefaultReminders(bool useDefault) | 99 | void Event::setUseDefaultReminders(bool useDefault) | ||
| 115 | { | 100 | { | ||
| 116 | d->useDefaultReminders = useDefault; | 101 | d->useDefaultReminders = useDefault; | ||
| 117 | } | 102 | } | ||
| 118 | 103 | | |||
| 119 | QString Event::id() const | 104 | QString Event::id() const | ||
| 120 | { | 105 | { | ||
| 121 | QString val = customProperty("LIBKGAPI", "EventId"); | 106 | const QString val = customProperty("LIBKGAPI", EventIdProperty); | ||
| 122 | if (val.isEmpty()) { | 107 | if (val.isEmpty()) { | ||
| 123 | // Backwards compatibility: prior to introducing "id", UID was used for | 108 | // Backwards compatibility: prior to introducing "id", UID was used for | ||
| 124 | // remote identification: use it | 109 | // remote identification: use it | ||
| 125 | return KCalendarCore::Incidence::uid(); | 110 | return KCalendarCore::Incidence::uid(); | ||
| 126 | } | 111 | } | ||
| 127 | return val; | 112 | return val; | ||
| 128 | } | 113 | } | ||
| 129 | 114 | | |||
| 130 | void Event::setId(const QString &id) | 115 | void Event::setId(const QString &id) | ||
| 131 | { | 116 | { | ||
| 132 | setCustomProperty("LIBKGAPI", "EventId", id); | 117 | setCustomProperty("LIBKGAPI", EventIdProperty, id); | ||
| 133 | } | 118 | } | ||