Updated the Tools menu to reflect current build.
[kdepim.git] / kalarm / eventid.h
blobc5f440d5675bad7eba701978cc794465b0f1db88
1 /*
2 * eventid.h - KAlarm unique event identifier for Akonadi
3 * Program: kalarm
4 * Copyright © 2012 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 <QDebug>
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; }
55 // Declare as a movable type (note that QString is movable).
56 Q_DECLARE_TYPEINFO(EventId, Q_MOVABLE_TYPE);
58 inline QDebug operator<<(QDebug s, const EventId& id)
60 s.nospace() << "\"" << id.collectionId() << "::" << id.eventId().toLatin1().constData() << "\"";
61 return s.space();
64 #endif // EVENTID_H
66 // vim: et sw=4: