File indexing completed on 2025-01-26 04:54:49
0001 /* 0002 * This file is part of LibKGAPI library 0003 * 0004 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "event.h" 0010 #include "debug.h" 0011 0012 using namespace KGAPI2; 0013 0014 namespace 0015 { 0016 static constexpr const char *EventIdProperty = "EventId"; 0017 static constexpr const char *EventHangoutLinkProperty = "EventHangoutLink"; 0018 } 0019 0020 class Q_DECL_HIDDEN Event::Private 0021 { 0022 public: 0023 QString id; 0024 bool deleted = false; 0025 bool useDefaultReminders = false; 0026 }; 0027 0028 Event::Event() 0029 : Object() 0030 , KCalendarCore::Event() 0031 , d(new Private) 0032 { 0033 } 0034 0035 Event::Event(const Event &other) 0036 : Object(other) 0037 , KCalendarCore::Event(other) 0038 , d(new Private(*(other.d))) 0039 { 0040 } 0041 0042 Event::Event(const KCalendarCore::Event &other) 0043 : Object() 0044 , KCalendarCore::Event(other) 0045 , d(new Private) 0046 { 0047 } 0048 0049 Event::~Event() = default; 0050 0051 bool Event::operator==(const Event &other) const 0052 { 0053 if (!Object::operator==(other)) { 0054 return false; 0055 } 0056 if (!KCalendarCore::Event::operator==(other)) { 0057 return false; 0058 } 0059 if (d->deleted != other.d->deleted) { 0060 qCDebug(KGAPIDebug) << "Deleted does not match"; 0061 return false; 0062 } 0063 if (d->useDefaultReminders != other.d->useDefaultReminders) { 0064 qCDebug(KGAPIDebug) << "UseDefaultReminders does not match"; 0065 return false; 0066 } 0067 0068 return true; 0069 } 0070 0071 bool Event::deleted() const 0072 { 0073 return d->deleted; 0074 } 0075 0076 bool Event::useDefaultReminders() const 0077 { 0078 return d->useDefaultReminders; 0079 } 0080 0081 void Event::setDeleted(bool deleted) 0082 { 0083 d->deleted = deleted; 0084 } 0085 0086 void Event::setUseDefaultReminders(bool useDefault) 0087 { 0088 d->useDefaultReminders = useDefault; 0089 } 0090 0091 QString Event::id() const 0092 { 0093 const QString val = customProperty("LIBKGAPI", EventIdProperty); 0094 if (val.isEmpty()) { 0095 // Backwards compatibility: prior to introducing "id", UID was used for 0096 // remote identification: use it 0097 return KCalendarCore::Incidence::uid(); 0098 } 0099 return val; 0100 } 0101 0102 void Event::setId(const QString &id) 0103 { 0104 setCustomProperty("LIBKGAPI", EventIdProperty, id); 0105 } 0106 0107 QString Event::hangoutLink() const 0108 { 0109 return customProperty("LIBKGAPI", EventHangoutLinkProperty); 0110 } 0111 0112 void Event::setHangoutLink(const QString &hangoutLink) 0113 { 0114 setCustomProperty("LIBKGAPI", EventHangoutLinkProperty, hangoutLink); 0115 }