Skip to content

Commit

Permalink
Merge branch 'jb46283' into 'master'
Browse files Browse the repository at this point in the history
[alarms] Allow creation of alarms independently of a model. JB#46283

See merge request mer-core/nemo-qml-plugin-alarms!7
  • Loading branch information
adenexter committed Jul 18, 2019
2 parents 5db30e4 + 59af42f commit ed48c1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/alarmobject.cpp
Expand Up @@ -39,14 +39,14 @@

AlarmObject::AlarmObject(QObject *parent)
: QObject(parent), m_hour(0), m_minute(0), m_enabled(false),
m_createdDate(QDateTime::currentDateTime()), m_countdown(false), m_triggerTime(0),
m_createdDate(QDateTime::currentDateTime()), m_countdown(false), m_reminder(false), m_triggerTime(0),
m_elapsed(0), m_cookie(0), m_timeoutSnoozeCounter(0), m_maximalTimeoutSnoozeCount(0)
{
}

AlarmObject::AlarmObject(const QMap<QString,QString> &data, QObject *parent)
: QObject(parent), m_hour(0), m_minute(0), m_enabled(false),
m_createdDate(QDateTime::currentDateTime()), m_countdown(false), m_triggerTime(0),
m_createdDate(QDateTime::currentDateTime()), m_countdown(false), m_reminder(false), m_triggerTime(0),
m_elapsed(0), m_cookie(0)
{
for (QMap<QString,QString>::ConstIterator it = data.begin(); it != data.end(); it++) {
Expand Down Expand Up @@ -90,6 +90,10 @@ AlarmObject::AlarmObject(const QMap<QString,QString> &data, QObject *parent)
m_maximalTimeoutSnoozeCount = it.value().toInt();
} else if (it.key() == "notebook") {
m_notebookUid = it.value();
} else if (it.key() == QLatin1String("phoneNumber")) {
m_phoneNumber = it.value();
} else if (it.key() == QLatin1String("type") && it.value() == QLatin1String("reminder")) {
m_reminder = true;
}
}

Expand Down Expand Up @@ -173,7 +177,9 @@ void AlarmObject::setCountdown(bool countdown)

int AlarmObject::type() const
{
if (m_startDate.isValid() && m_endDate.isValid())
if (m_reminder)
return Reminder;
else if (m_startDate.isValid() && m_endDate.isValid())
return Calendar;
else if (m_countdown)
return Countdown;
Expand Down
14 changes: 13 additions & 1 deletion src/alarmobject.h
Expand Up @@ -48,7 +48,7 @@ class AlarmObject : public QObject
AlarmObject(QObject *parent = 0);
AlarmObject(const QMap<QString,QString> &data, QObject *parent = 0);

enum Type { Calendar, Clock, Countdown };
enum Type { Calendar, Clock, Countdown, Reminder };
Q_ENUMS(Type)

/*!
Expand Down Expand Up @@ -256,6 +256,16 @@ class AlarmObject : public QObject
Q_PROPERTY(QString calendarEventRecurrenceId READ calendarEventRecurrenceId CONSTANT)
QString calendarEventRecurrenceId() const;

/*!
* \qmlproperty string Alarm::calendarEventRecurrenceId
*
* Recurrence identifier of a calendar event. Only valid for calendar alarms.
*
* \sa type
*/
Q_PROPERTY(QString phoneNumber READ phoneNumber CONSTANT)
QString phoneNumber() const { return m_phoneNumber; }

/*!
* \qmlproperty string Alarm::autoSnoozeCounter
*
Expand Down Expand Up @@ -369,12 +379,14 @@ private slots:
bool m_enabled;
QDateTime m_createdDate;
bool m_countdown;
bool m_reminder;
uint m_triggerTime;
uint m_elapsed;
QDateTime m_startDate, m_endDate;
QString m_uid;
QString m_recurrenceId;
QString m_notebookUid;
QString m_phoneNumber;

// Timed
unsigned m_cookie;
Expand Down

0 comments on commit ed48c1f

Please sign in to comment.