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

Use ResourceId where applicable

parent d641749d
......@@ -44,14 +44,13 @@
#include <QStandardPaths>
#include <QFileDialog>
using namespace Akonadi;
using namespace KCalendarCore;
using namespace KAlarmCal;
static KACalendar::Compat fix(const KCalendarCore::FileStorage::Ptr&);
static const QString displayCalendarName = QStringLiteral("displaying.ics");
static const Collection::Id DISPLAY_COL_ID = -1; // resource ID used for displaying calendar
static const ResourceId DISPLAY_COL_ID = -1; // resource ID used for displaying calendar
AlarmCalendar* AlarmCalendar::mResourcesCalendar = nullptr;
AlarmCalendar* AlarmCalendar::mDisplayCalendar = nullptr;
......@@ -405,7 +404,7 @@ void AlarmCalendar::updateDisplayKAEvents()
if (mCalType == RESOURCES)
return;
qCDebug(KALARM_LOG) << "AlarmCalendar::updateDisplayKAEvents";
const Collection::Id key = DISPLAY_COL_ID;
const ResourceId key = DISPLAY_COL_ID;
KAEvent::List& events = mResourceMap[key];
for (KAEvent* event : events)
{
......@@ -444,7 +443,7 @@ void AlarmCalendar::updateDisplayKAEvents()
* Called after the calendar is deleted or alarm types have been disabled, or
* the AlarmCalendar is closed.
*/
void AlarmCalendar::removeKAEvents(Collection::Id key, bool closing, CalEvent::Types types)
void AlarmCalendar::removeKAEvents(ResourceId key, bool closing, CalEvent::Types types)
{
bool removed = false;
ResourceMap::Iterator rit = mResourceMap.find(key);
......@@ -917,7 +916,7 @@ bool AlarmCalendar::addEvent(KAEvent& evnt, QWidget* promptParent, bool useEvent
}
}
Collection::Id key = resource.id();
ResourceId key = resource.id();
Event::Ptr kcalEvent((mCalType == RESOURCES) ? (Event*)nullptr : new Event);
KAEvent* event = new KAEvent(evnt);
QString id = event->id();
......@@ -1008,7 +1007,7 @@ bool AlarmCalendar::addEvent(KAEvent& evnt, QWidget* promptParent, bool useEvent
*/
void AlarmCalendar::addNewEvent(const Resource& resource, KAEvent* event, bool replace)
{
const Collection::Id key = resource.id();
const ResourceId key = resource.id();
event->setCollectionId(key);
if (!replace)
{
......@@ -1197,7 +1196,7 @@ CalEvent::Type AlarmCalendar::deleteEventInternal(const QString& eventID, const
Event::Ptr kcalEvent;
if (mCalendarStorage)
kcalEvent = mCalendarStorage->calendar()->event(id);
const Collection::Id key = resource.id();
const ResourceId key = resource.id();
KAEventMap::Iterator it = mEventMap.find(EventId(key, id));
if (it != mEventMap.end())
{
......@@ -1309,7 +1308,7 @@ KAEvent::List AlarmCalendar::events(const QString& uniqueId) const
{
for (ResourceMap::ConstIterator rit = mResourceMap.constBegin(); rit != mResourceMap.constEnd(); ++rit)
{
const Collection::Id id = rit.key();
const ResourceId id = rit.key();
KAEventMap::ConstIterator it = mEventMap.constFind(EventId(id, uniqueId));
if (it != mEventMap.constEnd())
list += it.value();
......@@ -1329,7 +1328,7 @@ KAEvent::List AlarmCalendar::events(const Resource& resource, CalEvent::Types ty
return list;
if (resource.isValid())
{
const Collection::Id key = resource.id();
const ResourceId key = resource.id();
ResourceMap::ConstIterator rit = mResourceMap.constFind(key);
if (rit == mResourceMap.constEnd())
return list;
......@@ -1465,7 +1464,7 @@ void AlarmCalendar::findEarliestAlarm(const Resource& resource)
findEarliestAlarm(resource.id());
}
void AlarmCalendar::findEarliestAlarm(Akonadi::Collection::Id key)
void AlarmCalendar::findEarliestAlarm(ResourceId key)
{
EarliestMap::Iterator eit = mEarliestAlarm.find(key);
if (eit != mEarliestAlarm.end())
......
......@@ -2342,7 +2342,7 @@ void KAlarmApp::commandMessage(ShellProcess* proc, QWidget* parent)
* If this is the first time through, open the calendar file, and start
* processing the execution queue.
*/
bool KAlarmApp::initCheck(bool calendarOnly, bool waitForCollection, Akonadi::Collection::Id collectionId)
bool KAlarmApp::initCheck(bool calendarOnly, bool waitForCollection, ResourceId resourceId)
{
static bool firstTime = true;
if (firstTime)
......@@ -2376,7 +2376,7 @@ bool KAlarmApp::initCheck(bool calendarOnly, bool waitForCollection, Akonadi::Co
if (waitForCollection)
{
// Wait for one or all calendar resources to be populated
if (!waitUntilPopulated(collectionId, AKONADI_TIMEOUT))
if (!waitUntilPopulated(resourceId, AKONADI_TIMEOUT))
return false;
}
return true;
......
......@@ -170,7 +170,7 @@ class KAlarmApp : public QApplication
KAlarmApp(int& argc, char** argv);
bool initialise();
int activateInstance(const QStringList& args, const QString& workingDirectory, QString* outputText);
bool initCheck(bool calendarOnly = false, bool waitForCollection = false, Akonadi::Collection::Id = -1);
bool initCheck(bool calendarOnly = false, bool waitForCollection = false, ResourceId = -1);
bool waitUntilPopulated(ResourceId, int timeout);
bool quitIf(int exitCode, bool force = false);
bool checkSystemTray();
......
......@@ -1170,10 +1170,10 @@ bool MessageWin::reinstateFromDisplaying(const Event::Ptr& kcalEvent, KAEvent& e
{
if (!kcalEvent)
return false;
Akonadi::Collection::Id collectionId;
event.reinstateFromDisplaying(kcalEvent, collectionId, showEdit, showDefer);
event.setCollectionId(collectionId);
resource = Resources::resource(collectionId);
ResourceId resourceId;
event.reinstateFromDisplaying(kcalEvent, resourceId, showEdit, showDefer);
event.setCollectionId(resourceId);
resource = Resources::resource(resourceId);
qCDebug(KALARM_LOG) << "MessageWin::reinstateFromDisplaying:" << EventId(event) << ": success";
return true;
}
......
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