Changeset View
Changeset View
Standalone View
Standalone View
src/calendar/reminder.cpp
| Show All 24 Lines | |||||
| 25 | #include "../debug.h" | 25 | #include "../debug.h" | ||
| 26 | 26 | | |||
| 27 | using namespace KGAPI2; | 27 | using namespace KGAPI2; | ||
| 28 | using namespace KCalendarCore; | 28 | using namespace KCalendarCore; | ||
| 29 | 29 | | |||
| 30 | class Q_DECL_HIDDEN Reminder::Private | 30 | class Q_DECL_HIDDEN Reminder::Private | ||
| 31 | { | 31 | { | ||
| 32 | public: | 32 | public: | ||
| 33 | Private(); | 33 | Alarm::Type type = Alarm::Invalid; | ||
| 34 | Private(const Private &other); | | |||
| 35 | ~Private() {} | | |||
| 36 | | ||||
| 37 | Alarm::Type type; | | |||
| 38 | Duration offset; | 34 | Duration offset; | ||
| 39 | }; | 35 | }; | ||
| 40 | 36 | | |||
| 41 | Reminder::Private::Private(): | | |||
| 42 | type(Alarm::Invalid) | | |||
| 43 | { | | |||
| 44 | } | | |||
| 45 | | ||||
| 46 | Reminder::Private::Private(const Private &other): | | |||
| 47 | type(other.type), | | |||
| 48 | offset(other.offset) | | |||
| 49 | { | | |||
| 50 | } | | |||
| 51 | | ||||
| 52 | Reminder::Reminder(): | 37 | Reminder::Reminder(): | ||
| 53 | d(new Private) | 38 | d(new Private) | ||
| 54 | { | 39 | { | ||
| 55 | } | 40 | } | ||
| 56 | 41 | | |||
| 57 | Reminder::Reminder (const Alarm::Type &type, const Duration& startOffset): | 42 | Reminder::Reminder(const Alarm::Type &type, const Duration& startOffset): | ||
| 58 | d(new Private) | 43 | d(new Private) | ||
| 59 | { | 44 | { | ||
| 60 | d->type = type; | 45 | d->type = type; | ||
| 61 | d->offset = startOffset; | 46 | d->offset = startOffset; | ||
| 62 | } | 47 | } | ||
| 63 | 48 | | |||
| 64 | Reminder::Reminder (const Reminder& other): | 49 | Reminder::Reminder(const Reminder& other): | ||
| 65 | d(new Private(*(other.d))) | 50 | d(new Private(*(other.d))) | ||
| 66 | { | 51 | { | ||
| 67 | } | 52 | } | ||
| 68 | 53 | | |||
| 69 | Reminder::~Reminder() | 54 | Reminder::~Reminder() = default; | ||
| 70 | { | | |||
| 71 | delete d; | | |||
| 72 | } | | |||
| 73 | 55 | | |||
| 74 | bool Reminder::operator==(const Reminder &other) const | 56 | bool Reminder::operator==(const Reminder &other) const | ||
| 75 | { | 57 | { | ||
| 76 | if (d->type != other.d->type) { | 58 | if (d->type != other.d->type) { | ||
| 77 | qCDebug(KGAPIDebug) << "Types don't match"; | 59 | qCDebug(KGAPIDebug) << "Types don't match"; | ||
| 78 | return false; | 60 | return false; | ||
| 79 | } | 61 | } | ||
| 80 | if (d->offset != other.d->offset) { | 62 | if (d->offset != other.d->offset) { | ||
| 81 | qCDebug(KGAPIDebug) << "Offsets don't match"; | 63 | qCDebug(KGAPIDebug) << "Offsets don't match"; | ||
| 82 | return false; | 64 | return false; | ||
| 83 | } | 65 | } | ||
| 84 | return true; | 66 | return true; | ||
| 85 | } | 67 | } | ||
| 86 | 68 | | |||
| 87 | | ||||
| 88 | void Reminder::setType (Alarm::Type type) | 69 | void Reminder::setType(Alarm::Type type) | ||
| 89 | { | 70 | { | ||
| 90 | d->type = type; | 71 | d->type = type; | ||
| 91 | } | 72 | } | ||
| 92 | 73 | | |||
| 93 | Alarm::Type Reminder::type() const | 74 | Alarm::Type Reminder::type() const | ||
| 94 | { | 75 | { | ||
| 95 | return d->type; | 76 | return d->type; | ||
| 96 | } | 77 | } | ||
| 97 | 78 | | |||
| 98 | void Reminder::setStartOffset (const Duration& startOffset) | 79 | void Reminder::setStartOffset(const Duration &startOffset) | ||
| 99 | { | 80 | { | ||
| 100 | d->offset = startOffset; | 81 | d->offset = startOffset; | ||
| 101 | } | 82 | } | ||
| 102 | 83 | | |||
| 103 | Duration Reminder::startOffset() const | 84 | Duration Reminder::startOffset() const | ||
| 104 | { | 85 | { | ||
| 105 | return d->offset; | 86 | return d->offset; | ||
| 106 | } | 87 | } | ||
| 107 | 88 | | |||
| 108 | // In LibKGAPI1 we return AlarmPtr | 89 | // In LibKGAPI1 we return AlarmPtr | ||
| 109 | Alarm* Reminder::toAlarm (Incidence* incidence) const | 90 | Alarm *Reminder::toAlarm(Incidence *incidence) const | ||
| 110 | { | 91 | { | ||
| 111 | Alarm* alarm = new Alarm(incidence); | 92 | auto alarm = new Alarm(incidence); | ||
| 112 | | ||||
| 113 | alarm->setType(d->type); | 93 | alarm->setType(d->type); | ||
| 114 | alarm->setStartOffset(d->offset); | 94 | alarm->setStartOffset(d->offset); | ||
| 115 | | ||||
| 116 | return alarm; | 95 | return alarm; | ||
| 117 | } | 96 | } | ||
| 118 | 97 | | |||