SVN_SILENT made messages (after extraction)
[kdepim.git] / kalarm / eventid.h
blob4fecee0bc0eb5755de7b0e2dadbad25e13ba778e
1 /*
2 * eventid.h - KAlarm unique event identifier for Akonadi
3 * Program: kalarm
4 * Copyright © 2012,2014 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef EVENTID_H
22 #define EVENTID_H
24 #include <kalarmcal/kaevent.h>
25 #include <QPair>
26 #include "kalarm_debug.h"
28 using namespace KAlarmCal;
30 /**
31 * Unique event identifier for Akonadi.
32 * This consists of the event UID within the individual calendar,
33 * plus the collection ID.
35 * Note that the collection ID of the display calendar is -1, since
36 * it is not an Akonadi calendar.
38 struct EventId : public QPair<Akonadi::Collection::Id, QString>
40 EventId() {}
41 EventId(Akonadi::Collection::Id c, const QString& e)
42 : QPair<Akonadi::Collection::Id, QString>(c, e) {}
43 explicit EventId(const KAEvent& event)
44 : QPair<Akonadi::Collection::Id, QString>(event.collectionId(), event.id()) {}
45 /** Set by event ID and optional resource ID, in the format "[rid:]eid". */
46 explicit EventId(const QString& resourceEventId);
47 void clear() { first = -1; second.clear(); }
48 /** Return whether the instance contains any data. */
49 bool isEmpty() const { return second.isEmpty(); }
51 Akonadi::Collection::Id collectionId() const { return first; }
52 QString eventId() const { return second; }
53 void setCollectionId(Akonadi::Collection::Id id) { first = id; }
56 // Declare as a movable type (note that QString is movable).
57 Q_DECLARE_TYPEINFO(EventId, Q_MOVABLE_TYPE);
59 inline QDebug operator<<(QDebug s, const EventId& id)
61 s.nospace() << "\"" << id.collectionId() << "::" << id.eventId().toLatin1().constData() << "\"";
62 return s.space();
65 #endif // EVENTID_H
67 // vim: et sw=4: