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

Remove unnecessary method

parent e1e5fd37
Pipeline #23191 passed with stage
in 11 minutes
......@@ -24,6 +24,7 @@
#include "functions.h"
#include "kalarmapp.h"
#include "resourcescalendar.h"
#include "resources/resources.h"
#include "lib/messagebox.h"
#include "kalarm_debug.h"
......@@ -94,9 +95,10 @@ void DeferAlarmDlg::slotOk()
if (!mLimitEventId.isEmpty())
{
// Get the event being deferred
const KAEvent* event = ResourcesCalendar::getEvent(mLimitEventId);
if (event)
endTime = event->deferralLimit(&limitType);
Resource resource = Resources::resource(mLimitEventId.resourceId());
const KAEvent event = resource.event(mLimitEventId.eventId());
if (event.isValid())
endTime = event.deferralLimit(&limitType);
}
else
{
......@@ -166,10 +168,11 @@ void DeferAlarmDlg::setLimit(const DateTime& limit)
*/
DateTime DeferAlarmDlg::setLimit(const KAEvent& event)
{
Q_ASSERT(event.collectionId() >= 0);
Q_ASSERT(event.resourceId() >= 0);
mLimitEventId = EventId(event);
const KAEvent* evnt = ResourcesCalendar::getEvent(mLimitEventId);
mLimitDateTime = evnt ? evnt->deferralLimit() : DateTime();
Resource resource = Resources::resource(event.resourceId());
const KAEvent evnt = resource.event(event.id());
mLimitDateTime = evnt.isValid() ? evnt.deferralLimit() : DateTime();
mTimeWidget->setMaxDateTime(mLimitDateTime);
return mLimitDateTime;
}
......
......@@ -1233,8 +1233,12 @@ QStringList checkRtcWakeConfig(bool checkEventExists)
if (params.count() == 3 && params[2].toUInt() > KADateTime::currentUtcDateTime().toTime_t())
#endif
{
if (checkEventExists && !ResourcesCalendar::getEvent(EventId(params[0].toLongLong(), params[1])))
return QStringList();
if (checkEventExists)
{
Resource resource = Resources::resource(params[0].toLongLong());
if (!resource.event(params[1]).isValid())
return QStringList();
}
return params; // config entry is valid
}
if (!params.isEmpty())
......
......@@ -980,8 +980,8 @@ void MessageWin::saveProperties(KConfigGroup& config)
void MessageWin::readProperties(const KConfigGroup& config)
{
mInvalid = config.readEntry("Invalid", false);
const QString eventId = config.readEntry("EventID");
const ResourceId collectionId = config.readEntry("CollectionID", ResourceId(-1));
const QString eventId = config.readEntry("EventID");
const ResourceId resourceId = config.readEntry("CollectionID", ResourceId(-1));
mAlarmType = static_cast<KAAlarm::Type>(config.readEntry("AlarmType", 0));
if (mAlarmType == KAAlarm::INVALID_ALARM)
{
......@@ -1029,8 +1029,8 @@ void MessageWin::readProperties(const KConfigGroup& config)
mDontShowAgain = config.readEntry("DontShowAgain", QString());
mShowEdit = false;
// Temporarily initialise mResource and mEventId - they will be set by redisplayAlarm()
mResource = Resources::resource(collectionId);
mEventId = EventId(collectionId, eventId);
mResource = Resources::resource(resourceId);
mEventId = EventId(resourceId, eventId);
qCDebug(KALARM_LOG) << "MessageWin::readProperties:" << eventId;
if (mAlarmType != KAAlarm::INVALID_ALARM)
{
......
......@@ -53,17 +53,6 @@ void ResourcesCalendar::terminate()
mInstance = nullptr;
}
/******************************************************************************
* Find and return the event with the specified ID.
* The calendar searched is determined by the calendar identifier in the ID.
*/
KAEvent* ResourcesCalendar::getEvent(const EventId& eventId)
{
if (eventId.eventId().isEmpty())
return nullptr;
return mInstance->event(eventId);
}
/******************************************************************************
* Constructor for the resources calendar.
*/
......
......@@ -62,7 +62,6 @@ public:
static void initialise();
static void terminate();
static ResourcesCalendar* instance() { return mInstance; }
static KAEvent* getEvent(const EventId&);
Q_SIGNALS:
void earliestAlarmChanged();
......
......@@ -835,13 +835,13 @@ UndoItem* UndoAdd::doRestore(bool setArchive)
{
// Retrieve the current state of the alarm
qCDebug(KALARM_LOG) << "UndoAdd::doRestore:" << mEventId;
const KAEvent* ev = ResourcesCalendar::getEvent(EventId(mResource.id(), mEventId));
if (!ev)
KAEvent event = mResource.event(mEventId);
if (!event.isValid())
{
mRestoreError = ERR_NOT_FOUND; // alarm is no longer in calendar
// Alarm is no longer in calendar, or its type is now disabled
mRestoreError = ERR_NOT_FOUND;
return nullptr;
}
KAEvent event(*ev);
// Create a redo item to recreate the alarm.
// Do it now, since 'event' gets modified by KAlarm::deleteEvent()
......@@ -995,13 +995,12 @@ UndoItem* UndoEdit::restore()
{
qCDebug(KALARM_LOG) << "UndoEdit::restore:" << mNewEventId;
// Retrieve the current state of the alarm
const KAEvent* event = ResourcesCalendar::getEvent(EventId(mResource.id(), mNewEventId));
if (!event)
KAEvent newEvent = mResource.event(mNewEventId);
if (!newEvent.isValid())
{
mRestoreError = ERR_NOT_FOUND; // alarm is no longer in calendar
return nullptr;
}
KAEvent newEvent(*event);
// Create a redo item to restore the edit
const Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
......
......@@ -179,7 +179,7 @@ void WakeFromSuspendDlg::useWakeClicked()
#endif
if (KAlarm::setRtcWakeTime(triggerTime, this))
{
const QStringList param{QString::number(event.collectionId()), event.id(), QString::number(triggerTime)};
const QStringList param{QString::number(event.resourceId()), event.id(), QString::number(triggerTime)};
KConfigGroup config(KSharedConfig::openConfig(), "General");
config.writeEntry("RtcWake", param);
config.sync();
......
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