File indexing completed on 2024-05-12 05:22:14
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 "reminder.h" 0010 #include "debug.h" 0011 0012 using namespace KGAPI2; 0013 using namespace KCalendarCore; 0014 0015 class Q_DECL_HIDDEN Reminder::Private 0016 { 0017 public: 0018 Alarm::Type type = Alarm::Invalid; 0019 Duration offset; 0020 }; 0021 0022 Reminder::Reminder() 0023 : d(new Private) 0024 { 0025 } 0026 0027 Reminder::Reminder(Alarm::Type type, const Duration &startOffset) 0028 : d(new Private) 0029 { 0030 d->type = type; 0031 d->offset = startOffset; 0032 } 0033 0034 Reminder::Reminder(const Reminder &other) 0035 : d(new Private(*(other.d))) 0036 { 0037 } 0038 0039 Reminder::~Reminder() = default; 0040 0041 bool Reminder::operator==(const Reminder &other) const 0042 { 0043 if (d->type != other.d->type) { 0044 qCDebug(KGAPIDebug) << "Types don't match"; 0045 return false; 0046 } 0047 if (d->offset != other.d->offset) { 0048 qCDebug(KGAPIDebug) << "Offsets don't match"; 0049 return false; 0050 } 0051 return true; 0052 } 0053 0054 void Reminder::setType(Alarm::Type type) 0055 { 0056 d->type = type; 0057 } 0058 0059 Alarm::Type Reminder::type() const 0060 { 0061 return d->type; 0062 } 0063 0064 void Reminder::setStartOffset(const Duration &startOffset) 0065 { 0066 d->offset = startOffset; 0067 } 0068 0069 Duration Reminder::startOffset() const 0070 { 0071 return d->offset; 0072 } 0073 0074 // In LibKGAPI1 we return AlarmPtr 0075 Alarm *Reminder::toAlarm(Incidence *incidence) const 0076 { 0077 auto alarm = new Alarm(incidence); 0078 alarm->setType(d->type); 0079 alarm->setStartOffset(d->offset); 0080 return alarm; 0081 }