Changeset View
Changeset View
Standalone View
Standalone View
src/kcalmodel.cpp
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "kcalmodel.h" | 20 | #include "kcalmodel.h" | ||
21 | 21 | | |||
22 | #include <Collection> | 22 | #include <Collection> | ||
23 | #include <Item> | 23 | #include <Item> | ||
24 | #include <ItemFetchScope> | 24 | #include <ItemFetchScope> | ||
25 | 25 | | |||
26 | #include <KCalCore/FreeBusy> | 26 | #include <KCalendarCore/FreeBusy> | ||
27 | #include <KCalCore/Event> | 27 | #include <KCalendarCore/Event> | ||
28 | #include <KCalCore/Journal> | 28 | #include <KCalendarCore/Journal> | ||
29 | #include <KCalCore/Todo> | 29 | #include <KCalendarCore/Todo> | ||
30 | 30 | | |||
31 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
32 | 32 | | |||
33 | #include <QIcon> | 33 | #include <QIcon> | ||
34 | using namespace CalendarSupport; | 34 | using namespace CalendarSupport; | ||
35 | 35 | | |||
36 | class Q_DECL_HIDDEN KCalModel::Private | 36 | class Q_DECL_HIDDEN KCalModel::Private | ||
37 | { | 37 | { | ||
38 | public: | 38 | public: | ||
39 | Private(KCalModel *model) | 39 | Private(KCalModel *model) | ||
40 | : q(model) | 40 | : q(model) | ||
41 | { | 41 | { | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | static QStringList allMimeTypes() | 44 | static QStringList allMimeTypes() | ||
45 | { | 45 | { | ||
46 | QStringList types; | 46 | QStringList types; | ||
47 | types << KCalCore::Event::eventMimeType() | 47 | types << KCalendarCore::Event::eventMimeType() | ||
48 | << KCalCore::Todo::todoMimeType() | 48 | << KCalendarCore::Todo::todoMimeType() | ||
49 | << KCalCore::Journal::journalMimeType() | 49 | << KCalendarCore::Journal::journalMimeType() | ||
50 | << KCalCore::FreeBusy::freeBusyMimeType(); | 50 | << KCalendarCore::FreeBusy::freeBusyMimeType(); | ||
51 | return types; | 51 | return types; | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | bool collectionMatchesMimeTypes() const | 54 | bool collectionMatchesMimeTypes() const | ||
55 | { | 55 | { | ||
56 | const QStringList lst = allMimeTypes(); | 56 | const QStringList lst = allMimeTypes(); | ||
57 | for (const QString &type : lst) { | 57 | for (const QString &type : lst) { | ||
58 | if (q->collection().contentMimeTypes().contains(type)) { | 58 | if (q->collection().contentMimeTypes().contains(type)) { | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 128 | return i18nc("@info", | |||
130 | "The current collection holds mimetypes: %1", | 130 | "The current collection holds mimetypes: %1", | ||
131 | collection().contentMimeTypes().join(QLatin1Char(','))); | 131 | collection().contentMimeTypes().join(QLatin1Char(','))); | ||
132 | } | 132 | } | ||
133 | return QVariant(); | 133 | return QVariant(); | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | const Akonadi::Item item = itemForIndex(index); | 136 | const Akonadi::Item item = itemForIndex(index); | ||
137 | 137 | | |||
138 | if (!item.hasPayload<KCalCore::Incidence::Ptr>()) { | 138 | if (!item.hasPayload<KCalendarCore::Incidence::Ptr>()) { | ||
139 | return QVariant(); | 139 | return QVariant(); | ||
140 | } | 140 | } | ||
141 | 141 | | |||
142 | const KCalCore::Incidence::Ptr incidence = item.payload<KCalCore::Incidence::Ptr>(); | 142 | const KCalendarCore::Incidence::Ptr incidence = item.payload<KCalendarCore::Incidence::Ptr>(); | ||
143 | 143 | | |||
144 | // Icon for the model entry | 144 | // Icon for the model entry | ||
145 | switch (role) { | 145 | switch (role) { | ||
146 | case Qt::DecorationRole: | 146 | case Qt::DecorationRole: | ||
147 | if (index.column() == 0) { | 147 | if (index.column() == 0) { | ||
148 | if (incidence->type() == KCalCore::Incidence::TypeTodo) { | 148 | if (incidence->type() == KCalendarCore::Incidence::TypeTodo) { | ||
149 | return QIcon::fromTheme(QStringLiteral("view-pim-tasks")); | 149 | return QIcon::fromTheme(QStringLiteral("view-pim-tasks")); | ||
150 | } else if (incidence->type() == KCalCore::Incidence::TypeJournal) { | 150 | } else if (incidence->type() == KCalendarCore::Incidence::TypeJournal) { | ||
151 | return QIcon::fromTheme(QStringLiteral("view-pim-journal")); | 151 | return QIcon::fromTheme(QStringLiteral("view-pim-journal")); | ||
152 | } else if (incidence->type() == KCalCore::Incidence::TypeEvent) { | 152 | } else if (incidence->type() == KCalendarCore::Incidence::TypeEvent) { | ||
153 | return QIcon::fromTheme(QStringLiteral("view-calendar")); | 153 | return QIcon::fromTheme(QStringLiteral("view-calendar")); | ||
154 | } else { | 154 | } else { | ||
155 | return QIcon::fromTheme(QStringLiteral("network-wired")); | 155 | return QIcon::fromTheme(QStringLiteral("network-wired")); | ||
156 | } | 156 | } | ||
157 | } | 157 | } | ||
158 | break; | 158 | break; | ||
159 | case Qt::DisplayRole: | 159 | case Qt::DisplayRole: | ||
160 | switch (index.column()) { | 160 | switch (index.column()) { | ||
161 | case Summary: | 161 | case Summary: | ||
162 | return incidence->summary(); | 162 | return incidence->summary(); | ||
163 | case DateTimeStart: | 163 | case DateTimeStart: | ||
164 | return incidence->dtStart().toString(); | 164 | return incidence->dtStart().toString(); | ||
165 | case DateTimeEnd: | 165 | case DateTimeEnd: | ||
166 | return incidence->dateTime(KCalCore::Incidence::RoleEnd).toString(); | 166 | return incidence->dateTime(KCalendarCore::Incidence::RoleEnd).toString(); | ||
167 | case Type: | 167 | case Type: | ||
168 | return incidence->type(); | 168 | return incidence->type(); | ||
169 | default: | 169 | default: | ||
170 | break; | 170 | break; | ||
171 | } | 171 | } | ||
172 | break; | 172 | break; | ||
173 | default: | 173 | default: | ||
174 | return QVariant(); | 174 | return QVariant(); | ||
Show All 29 Lines |