Commit b20ac002 authored by David Jarvie's avatar David Jarvie
Browse files

Add event name property

parent 7cdee8df
Pipeline #38803 passed with stage
in 10 minutes and 46 seconds
......@@ -2,7 +2,7 @@
This file is part of kalarmcal library, which provides access to KAlarm
calendar data.
SPDX-FileCopyrightText: 2018, 2019 David Jarvie <djarvie@kde.org>
SPDX-FileCopyrightText: 2018-2020 David Jarvie <djarvie@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -37,6 +37,7 @@ const QString SC = QStringLiteral(";");
void KAEventTest::constructors()
{
const KADateTime dt(QDate(2010,5,13), QTime(3, 45, 0), QTimeZone("Europe/London"));
const QString name(QStringLiteral("name"));
const QString text(QStringLiteral("message"));
const QColor fgColour(130, 110, 240);
const QColor bgColour(20, 70, 140);
......@@ -44,9 +45,10 @@ void KAEventTest::constructors()
const KAEvent::Flags flags(KAEvent::CONFIRM_ACK | KAEvent::AUTO_CLOSE);
{
// Display alarm
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QCOMPARE(event.message(), text);
QCOMPARE(event.displayMessage(), text);
QVERIFY(event.fileName().isEmpty());
......@@ -64,9 +66,10 @@ void KAEventTest::constructors()
}
{
// Display file alarm
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::FILE, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::FILE, 3, flags);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QVERIFY(event.message().isEmpty());
QVERIFY(event.displayMessage().isEmpty());
QCOMPARE(event.fileName(), text);
......@@ -84,9 +87,10 @@ void KAEventTest::constructors()
}
{
// Command alarm
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::COMMAND, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::COMMAND, 3, flags);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QVERIFY(event.message().isEmpty());
QVERIFY(event.displayMessage().isEmpty());
QVERIFY(event.fileName().isEmpty());
......@@ -101,9 +105,10 @@ void KAEventTest::constructors()
}
{
// Email alarm
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::EMAIL, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::EMAIL, 3, flags);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QCOMPARE(event.message(), text);
QVERIFY(event.displayMessage().isEmpty());
QVERIFY(event.fileName().isEmpty());
......@@ -118,9 +123,10 @@ void KAEventTest::constructors()
}
{
// Audio alarm
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::AUDIO, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::AUDIO, 3, flags);
QCOMPARE(event.startDateTime(), DateTime(dt));
QVERIFY(event.cleanText().isEmpty());
QCOMPARE(event.name(), name);
QVERIFY(event.message().isEmpty());
QVERIFY(event.displayMessage().isEmpty());
QVERIFY(event.fileName().isEmpty());
......@@ -143,7 +149,8 @@ void KAEventTest::constructors()
Event::Ptr kcalevent(new Event);
kcalevent->setCreated(createdDt);
kcalevent->setDtStart(dt.qDateTime());
kcalevent->setSummary(text);
kcalevent->setSummary(name);
kcalevent->setDescription(text);
kcalevent->setUid(uid);
kcalevent->setRevision(12);
kcalevent->setReadOnly(false);
......@@ -154,6 +161,7 @@ void KAEventTest::constructors()
QCOMPARE(event.createdDateTime().qDateTime(), createdDt);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QCOMPARE(event.message(), text);
QCOMPARE(event.displayMessage(), text);
QVERIFY(event.fileName().isEmpty());
......@@ -171,7 +179,8 @@ void KAEventTest::constructors()
Event::Ptr kcalevent(new Event);
kcalevent->setCreated(createdDt);
kcalevent->setDtStart(dt.qDateTime());
kcalevent->setSummary(text);
kcalevent->setSummary(name);
kcalevent->setDescription(text);
kcalevent->setUid(uid);
kcalevent->setRevision(12);
kcalevent->setReadOnly(false);
......@@ -183,6 +192,7 @@ void KAEventTest::constructors()
QCOMPARE(event.createdDateTime().qDateTime(), createdDt);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QVERIFY(event.message().isEmpty());
QVERIFY(event.displayMessage().isEmpty());
QCOMPARE(event.fileName(), text);
......@@ -202,7 +212,8 @@ void KAEventTest::constructors()
Event::Ptr kcalevent(new Event);
kcalevent->setCreated(createdDt);
kcalevent->setDtStart(dt.qDateTime());
kcalevent->setSummary(text);
kcalevent->setSummary(name);
kcalevent->setDescription(text);
kcalevent->setUid(uid);
kcalevent->setRevision(12);
kcalevent->setReadOnly(false);
......@@ -213,6 +224,7 @@ void KAEventTest::constructors()
QCOMPARE(event.createdDateTime().qDateTime(), createdDt);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), cmdline);
QCOMPARE(event.name(), name);
QVERIFY(event.message().isEmpty());
QVERIFY(event.displayMessage().isEmpty());
QVERIFY(event.fileName().isEmpty());
......@@ -234,7 +246,8 @@ void KAEventTest::constructors()
Event::Ptr kcalevent(new Event);
kcalevent->setCreated(createdDt);
kcalevent->setDtStart(dt.qDateTime());
kcalevent->setSummary(text);
kcalevent->setSummary(name);
kcalevent->setDescription(text);
kcalevent->setUid(uid);
kcalevent->setRevision(12);
kcalevent->setReadOnly(false);
......@@ -245,6 +258,7 @@ void KAEventTest::constructors()
QCOMPARE(event.createdDateTime().qDateTime(), createdDt);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QCOMPARE(event.message(), text);
QVERIFY(event.displayMessage().isEmpty());
QVERIFY(event.fileName().isEmpty());
......@@ -265,6 +279,7 @@ void KAEventTest::constructors()
Event::Ptr kcalevent(new Event);
kcalevent->setCreated(createdDt);
kcalevent->setDtStart(dt.qDateTime());
kcalevent->setSummary(name);
kcalevent->setUid(uid);
kcalevent->setRevision(12);
kcalevent->setReadOnly(true);
......@@ -275,6 +290,7 @@ void KAEventTest::constructors()
QCOMPARE(event.createdDateTime().qDateTime(), createdDt);
QCOMPARE(event.startDateTime(), DateTime(dt));
QCOMPARE(event.cleanText(), text);
QCOMPARE(event.name(), name);
QVERIFY(event.message().isEmpty());
QVERIFY(event.displayMessage().isEmpty());
QVERIFY(event.fileName().isEmpty());
......@@ -292,13 +308,14 @@ void KAEventTest::constructors()
void KAEventTest::flags()
{
const KADateTime dt(QDate(2010,5,13), QTime(3, 45, 0), QTimeZone("Europe/London"));
const QString name(QStringLiteral("name"));
const QString text(QStringLiteral("message"));
const QColor fgColour(130, 110, 240);
const QColor bgColour(20, 70, 140);
const QFont font(QStringLiteral("Helvetica"), 10, QFont::Bold, true);
{
const KAEvent::Flags flags(KAEvent::BEEP | KAEvent::DEFAULT_FONT);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QCOMPARE(event.flags(), flags);
QVERIFY(!event.startDateTime().isDateOnly());
QVERIFY(!event.repeatAtLogin());
......@@ -320,7 +337,7 @@ void KAEventTest::flags()
}
{
const KAEvent::Flags flags(KAEvent::REPEAT_AT_LOGIN | KAEvent::DISABLED);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(event.repeatAtLogin());
......@@ -343,7 +360,7 @@ void KAEventTest::flags()
{
const KADateTime dtDateOnly(QDate(2010,5,13), QTimeZone("Europe/London"));
const KAEvent::Flags flags(KAEvent::REPEAT_AT_LOGIN | KAEvent::DISABLED);
KAEvent event(dtDateOnly, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
KAEvent event(dtDateOnly, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QVERIFY(event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags | KAEvent::ANY_TIME);
QVERIFY(event.repeatAtLogin());
......@@ -365,7 +382,7 @@ void KAEventTest::flags()
}
{
const KAEvent::Flags flags(KAEvent::REPEAT_AT_LOGIN | KAEvent::DISABLED);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags | KAEvent::ANY_TIME);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags | KAEvent::ANY_TIME);
QVERIFY(event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags | KAEvent::ANY_TIME);
QVERIFY(event.repeatAtLogin());
......@@ -387,7 +404,7 @@ void KAEventTest::flags()
}
{
const KAEvent::Flags flags(KAEvent::CONFIRM_ACK | KAEvent::SPEAK | KAEvent::EXCL_HOLIDAYS);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(!event.repeatAtLogin());
......@@ -410,7 +427,7 @@ void KAEventTest::flags()
{
KAEvent::setHolidays(KHolidays::HolidayRegion());
const KAEvent::Flags flags(KAEvent::AUTO_CLOSE | KAEvent::EXCL_HOLIDAYS | KAEvent::REPEAT_SOUND);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(!event.repeatAtLogin());
......@@ -432,7 +449,7 @@ void KAEventTest::flags()
}
{
const KAEvent::Flags flags(KAEvent::COPY_KORGANIZER | KAEvent::WORK_TIME_ONLY);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(!event.repeatAtLogin());
......@@ -454,7 +471,7 @@ void KAEventTest::flags()
}
{
const KAEvent::Flags flags(KAEvent::SCRIPT | KAEvent::EXEC_IN_XTERM);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::COMMAND, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::COMMAND, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(!event.repeatAtLogin());
......@@ -476,7 +493,7 @@ void KAEventTest::flags()
}
{
const KAEvent::Flags flags(KAEvent::DISPLAY_COMMAND | KAEvent::REMINDER_ONCE);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::COMMAND, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::COMMAND, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(!event.repeatAtLogin());
......@@ -498,7 +515,7 @@ void KAEventTest::flags()
}
{
const KAEvent::Flags flags(KAEvent::EMAIL_BCC);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::EMAIL, 3, flags);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::EMAIL, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(!event.repeatAtLogin());
......@@ -1204,6 +1221,7 @@ void KAEventTest::toKCalEvent()
// Check KCalendarCore::Event custom properties.
const KADateTime dt(QDate(2010,5,13), QTime(3, 45, 0), QTimeZone("Europe/London"));
const KADateTime createdDt(QDate(2009,4,13), QTime(11,14,0), QTimeZone("UTC"));
const QString name(QStringLiteral("name"));
const QString text = QStringLiteral("message");
const QColor fgColour(0x82, 0x6e, 0xf0);
const QColor bgColour(0x14, 0x46, 0x8c);
......@@ -1212,7 +1230,7 @@ void KAEventTest::toKCalEvent()
{
// Event category, UID, revision, start time using time zone, created time
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, KAEvent::CONFIRM_ACK);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, KAEvent::CONFIRM_ACK);
event.setEventId(uid);
event.incrementRevision();
event.incrementRevision();
......@@ -1230,6 +1248,7 @@ void KAEventTest::toKCalEvent()
QCOMPARE(flags.at(1), QStringLiteral("3"));
QCOMPARE(kcalevent->dtStart(), dt.qDateTime());
QCOMPARE(kcalevent->created(), createdDt.qDateTime());
QCOMPARE(kcalevent->summary(), name);
const Alarm::List kcalalarms = kcalevent->alarms();
QCOMPARE(kcalalarms.size(), 1);
Alarm::Ptr kcalalarm(kcalalarms[0]);
......@@ -1240,7 +1259,7 @@ void KAEventTest::toKCalEvent()
{
// Start time using LocalZone
const KADateTime dt(QDate(2010,5,13), QTime(3, 45, 0), KADateTime::LocalZone);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, KAEvent::CONFIRM_ACK);
KAEvent event(dt, name, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, KAEvent::CONFIRM_ACK);
event.setEventId(uid);
event.incrementRevision();
event.setCategory(CalEvent::ACTIVE);
......
......@@ -129,7 +129,7 @@ void SerializerPluginKAlarm::compare(AbstractDifferencesReporter *reporter, cons
if (eventL.category() != eventR.category()) {
reportDifference(reporter, KAEventFormatter::AlarmCategory);
}
if (eventL.templateName() != eventR.templateName()) {
if (eventL.name() != eventR.name()) {
reportDifference(reporter, KAEventFormatter::TemplateName);
}
if (eventL.createdDateTime() != eventR.createdDateTime()) {
......
......@@ -39,6 +39,8 @@ QString KAEventFormatter::label(Parameter param)
return i18nc("@label", "Alarm type");
case AlarmCategory:
return i18nc("@label", "Alarm status");
case Name:
return i18nc("@label", "Alarm name");
case TemplateName:
return i18nc("@label", "Template name");
case CreatedTime:
......@@ -160,6 +162,7 @@ bool KAEventFormatter::isApplicable(Parameter param) const
case Id:
case AlarmType:
case AlarmCategory:
case Name:
case CreatedTime:
case StartTime:
case Recurs:
......@@ -272,8 +275,9 @@ QString KAEventFormatter::value(Parameter param) const
break;
}
break;
case Name:
case TemplateName:
return mEvent.templateName();
return mEvent.name();
case CreatedTime:
return mEvent.createdDateTime().toUtc().toString(QStringLiteral("%Y-%m-%d %H:%M:%SZ"));
case StartTime:
......
......@@ -23,6 +23,7 @@ public:
Id,
AlarmType,
AlarmCategory,
Name,
TemplateName,
CreatedTime,
StartTime,
......
......@@ -137,8 +137,9 @@ public:
typedef QMap<AlarmType, AlarmData> AlarmMap;
KAEventPrivate();
KAEventPrivate(const KADateTime &, const QString &message, const QColor &bg, const QColor &fg,
const QFont &f, KAEvent::SubAction, int lateCancel, KAEvent::Flags flags,
KAEventPrivate(const KADateTime &, const QString &name, const QString &message,
const QColor &bg, const QColor &fg, const QFont &f,
KAEvent::SubAction, int lateCancel, KAEvent::Flags flags,
bool changesPending = false);
explicit KAEventPrivate(const KCalendarCore::Event::Ptr &);
KAEventPrivate(const KAEventPrivate &);
......@@ -237,11 +238,11 @@ public:
mutable KAEvent::CmdErrType mCommandError{KAEvent::CMD_NO_ERROR}; // command execution error last time the alarm triggered
QString mEventID; // UID: KCalendarCore::Event unique ID
QString mTemplateName; // alarm template's name, or null if normal event
QMap<QByteArray, QString> mCustomProperties; // KCalendarCore::Event's non-KAlarm custom properties
Akonadi::Item::Id mItemId{-1}; // Akonadi::Item ID for this event
mutable ResourceId mResourceId{-1}; // ID of resource containing the event, or for a displaying event,
// saved resource ID (not the resource the event is in)
QString mName; // name of the alarm
QString mText; // message text, file URL, command, email body [or audio file for KAAlarm]
QString mAudioFile; // ATTACH: audio file to play
QString mPreAction; // command to execute before alarm is displayed
......@@ -485,16 +486,26 @@ KAEventPrivate::KAEventPrivate()
/******************************************************************************
* Initialise the instance with the specified parameters.
*/
KAEvent::KAEvent(const KADateTime &dt, const QString &message, const QColor &bg, const QColor &fg, const QFont &f,
KAEvent::KAEvent(const KADateTime &dt, const QString &name, const QString &message,
const QColor &bg, const QColor &fg, const QFont &f,
SubAction action, int lateCancel, Flags flags, bool changesPending)
: d(new KAEventPrivate(dt, message, bg, fg, f, action, lateCancel, flags, changesPending))
: d(new KAEventPrivate(dt, name, message, bg, fg, f, action, lateCancel, flags, changesPending))
{
}
KAEventPrivate::KAEventPrivate(const KADateTime &dateTime, const QString &text, const QColor &bg, const QColor &fg,
const QFont &font, KAEvent::SubAction action, int lateCancel, KAEvent::Flags flags,
KAEvent::KAEvent(const KADateTime &dt, const QString &message,
const QColor &bg, const QColor &fg, const QFont &f,
SubAction action, int lateCancel, Flags flags, bool changesPending)
: d(new KAEventPrivate(dt, QString(), message, bg, fg, f, action, lateCancel, flags, changesPending))
{
}
KAEventPrivate::KAEventPrivate(const KADateTime &dateTime, const QString &name, const QString &text,
const QColor &bg, const QColor &fg, const QFont &font,
KAEvent::SubAction action, int lateCancel, KAEvent::Flags flags,
bool changesPending)
: mAlarmCount(1)
: mName(name)
, mAlarmCount(1)
, mBgColour(bg)
, mFgColour(fg)
, mFont(font)
......@@ -565,6 +576,7 @@ KAEventPrivate::KAEventPrivate(const KCalendarCore::Event::Ptr &event)
// Extract status from the event
mEventID = event->uid();
mRevision = event->revision();
mName = event->summary();
mBgColour = QColor(255, 255, 255); // missing/invalid colour - return white background
mFgColour = QColor(0, 0, 0); // and black foreground
mReadOnly = event->isReadOnly();
......@@ -730,9 +742,6 @@ KAEventPrivate::KAEventPrivate(const KCalendarCore::Event::Ptr &event)
if (dateOnly && !mRepetition.isDaily()) {
mRepetition.set(Duration(mRepetition.intervalDays(), Duration::Days));
}
if (mCategory == CalEvent::TEMPLATE) {
mTemplateName = event->summary();
}
if (event->customStatus() == DISABLED_STATUS) {
mEnabled = false;
}
......@@ -996,10 +1005,10 @@ void KAEventPrivate::copy(const KAEventPrivate &event)
mMainWorkTrigger = event.mMainWorkTrigger;
mCommandError = event.mCommandError;
mEventID = event.mEventID;
mTemplateName = event.mTemplateName;
mCustomProperties = event.mCustomProperties;
mItemId = event.mItemId;
mResourceId = event.mResourceId;
mName = event.mName;
mText = event.mText;
mAudioFile = event.mAudioFile;
mPreAction = event.mPreAction;
......@@ -1085,7 +1094,7 @@ void KAEvent::set(const KCalendarCore::Event::Ptr &e)
void KAEvent::set(const KADateTime &dt, const QString &message, const QColor &bg, const QColor &fg,
const QFont &f, SubAction act, int lateCancel, Flags flags, bool changesPending)
{
*this = KAEvent(dt, message, bg, fg, f, act, lateCancel, flags, changesPending);
*this = KAEvent(dt, QString(), message, bg, fg, f, act, lateCancel, flags, changesPending);
}
/******************************************************************************
......@@ -1122,6 +1131,7 @@ bool KAEventPrivate::updateKCalEvent(const Event::Ptr &ev, KAEvent::UidAction ui
ev->setTransparency(Event::Transparent);
// Set up event-specific data
ev->setSummary(mName);
// Set up custom properties.
if (setCustomProperties) {
......@@ -1185,7 +1195,7 @@ bool KAEventPrivate::updateKCalEvent(const Event::Ptr &ev, KAEvent::UidAction ui
}
(flags += DEFER_FLAG) += param;
}
if (!mTemplateName.isEmpty() && mTemplateAfterTime >= 0) {
if (mCategory == CalEvent::TEMPLATE && mTemplateAfterTime >= 0) {
(flags += TEMPL_AFTER_TIME_FLAG) += QString::number(mTemplateAfterTime);
}
if (mAkonadiItemId >= 0) {
......@@ -1326,9 +1336,7 @@ bool KAEventPrivate::updateKCalEvent(const Event::Ptr &ev, KAEvent::UidAction ui
ancillaryType = 2;
}
}
if (!mTemplateName.isEmpty()) {
ev->setSummary(mTemplateName);
} else if (mDisplaying) {
if (mDisplaying && mCategory != CalEvent::TEMPLATE) {
QStringList list(DISPLAYING_TYPE);
if (mDisplayingFlags & KAEvent::REPEAT_AT_LOGIN) {
list += AT_LOGIN_TYPE;
......@@ -1828,6 +1836,11 @@ Akonadi::Item::Id KAEvent::akonadiItemId() const
return d->mAkonadiItemId;
}
QString KAEvent::name() const
{
return d->mName;
}
QString KAEvent::cleanText() const
{
return d->mText;
......@@ -2068,19 +2081,19 @@ bool KAEvent::speak() const
void KAEvent::setTemplate(const QString &name, int afterTime)
{
d->setCategory(CalEvent::TEMPLATE);
d->mTemplateName = name;
d->mName = name;
d->mTemplateAfterTime = afterTime;
d->mTriggerChanged = true; // templates and archived don't have trigger times
}
bool KAEvent::isTemplate() const
{
return !d->mTemplateName.isEmpty();
return d->mCategory == CalEvent::TEMPLATE;
}
QString KAEvent::templateName() const
{
return d->mTemplateName;
return d->mName;
}
bool KAEvent::usingDefaultTime() const
......@@ -3638,6 +3651,7 @@ bool KAEventPrivate::compare(const KAEventPrivate& other, KAEvent::Comparison co
if (mCategory != other.mCategory
|| mActionSubType != other.mActionSubType
|| mDisplaying != other.mDisplaying
|| mName != other.mName
|| mText != other.mText
|| mStartDateTime != other.mStartDateTime
|| mLateCancel != other.mLateCancel
......@@ -3699,8 +3713,7 @@ bool KAEventPrivate::compare(const KAEventPrivate& other, KAEvent::Comparison co
}
break;
case CalEvent::TEMPLATE:
if (mTemplateName != other.mTemplateName
|| mTemplateAfterTime != other.mTemplateAfterTime) {
if (mTemplateAfterTime != other.mTemplateAfterTime) {
return false;
}
break;
......@@ -3853,8 +3866,8 @@ void KAEventPrivate::dumpDebug() const
qCDebug(KALARMCAL_LOG) << "-- mAllWorkTrigger:" << mAllWorkTrigger.toString();
qCDebug(KALARMCAL_LOG) << "-- mMainWorkTrigger:" << mMainWorkTrigger.toString();
qCDebug(KALARMCAL_LOG) << "-- mCategory:" << mCategory;
if (!mTemplateName.isEmpty()) {
qCDebug(KALARMCAL_LOG) << "-- mTemplateName:" << mTemplateName;
qCDebug(KALARMCAL_LOG) << "-- mName:" << mName;
if (mCategory == CalEvent::TEMPLATE) {
qCDebug(KALARMCAL_LOG) << "-- mTemplateAfterTime:" << mTemplateAfterTime;
}
qCDebug(KALARMCAL_LOG) << "-- mText:" << mText;
......
......@@ -309,6 +309,7 @@ public:
/** Construct an event and initialise with the specified parameters.
* @param dt start date/time. If @p dt is date-only, or if #ANY_TIME flag
* is specified, the event will be date-only.
* @param name name of the alarm.
* @param text alarm message (@p action = #MESSAGE);
* file to display (@p action = #FILE);
* command to execute (@p action = #COMMAND);
......@@ -326,7 +327,32 @@ public:
* to the instance; call endChanges() when changes
* are complete.
*/
KAEvent(const KADateTime &dt, const QString &text, const QColor &bg, const QColor &fg,
KAEvent(const KADateTime &dt, const QString &name, const QString &text,
const QColor &bg, const QColor &fg, const QFont &font,
SubAction action, int lateCancel, Flags flags, bool changesPending = false);
/** Construct an event and initialise with the specified parameters.
* @param dt start date/time. If @p dt is date-only, or if #ANY_TIME flag
* is specified, the event will be date-only.
* @param text alarm message (@p action = #MESSAGE);
* file to display (@p action = #FILE);
* command to execute (@p action = #COMMAND);
* email body (@p action = #EMAIL);
* audio file (@p action = #AUDIO).
* @param bg background color (for display alarms, ignored otherwise).
* @param fg foreground color (for display alarms, ignored otherwise).
* @param font font (for display alarms, ignored otherwise). Ignored if
* #DEFAULT_FONT flag is specified.
* @param action alarm action type.
* @param lateCancel late-cancellation period (minutes), else 0.
* @param flags OR of #Flag enum values.
* @param changesPending true to inhibit automatic calculations and data
* updates until further changes have been applied
* to the instance; call endChanges() when changes
* are complete.
* @deprecated Use the other constructor.
*/
KALARMCAL_DEPRECATED KAEvent(const KADateTime &dt, const QString &text, const QColor &bg, const QColor &fg,
const QFont &font, SubAction action, int lateCancel, Flags flags, bool changesPending = false);
/** Construct an event and initialise it from a KCalendarCore::Event.
......@@ -578,6 +604,9 @@ public:
*/
Akonadi::Item::Id akonadiItemId() const;
/** Return the alarm's name. */
QString name() const;
/** Return the alarm's text. Its significance depends on the type of alarm;
* alternatively, use message(), displayMessage(), fileName() or command(),
* which incorporate checks on alarm type.
......@@ -767,8 +796,9 @@ public:
/** Return the alarm template's name.
* @return template name, or empty if not a template
* @see setTemplate()
* @deprecated Use name() instead.
*/
QString templateName() const;
KALARMCAL_DEPRECATED QString templateName() const;
/** Return whether the alarm template does not specify a time.
* @return @c true if no time is specified, i.e. the normal default alarm time will
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment