8#include "collectiontypeutil.h"
11#include <KLocalizedString>
14CollectionTypeUtil::CollectionTypeUtil() =
default;
16CollectionTypeUtil::~CollectionTypeUtil() =
default;
18QByteArray CollectionTypeUtil::kolabFolderType()
20 return "/shared/vendor/kolab/folder-type";
23QByteArray CollectionTypeUtil::kolabIncidencesFor()
25 return "/shared/vendor/kolab/incidences-for";
28QByteArray CollectionTypeUtil::kolabSharedSeen()
30 return "/shared/vendor/cmu/cyrus-imapd/sharedseen";
33QString CollectionTypeUtil::folderContentDescription(CollectionTypeUtil::FolderContentsType type)
36 case CollectionTypeUtil::ContentsTypeMail:
37 return i18nc(
"type of folder content",
"Mail");
38 case CollectionTypeUtil::ContentsTypeCalendar:
39 return i18nc(
"type of folder content",
"Calendar");
40 case CollectionTypeUtil::ContentsTypeContact:
41 return i18nc(
"type of folder content",
"Contacts");
42 case CollectionTypeUtil::ContentsTypeNote:
43 return i18nc(
"type of folder content",
"Notes");
44 case CollectionTypeUtil::ContentsTypeTask:
45 return i18nc(
"type of folder content",
"Tasks");
46 case CollectionTypeUtil::ContentsTypeJournal:
47 return i18nc(
"type of folder content",
"Journal");
48 case CollectionTypeUtil::ContentsTypeConfiguration:
49 return i18nc(
"type of folder content",
"Configuration");
50 case CollectionTypeUtil::ContentsTypeFreebusy:
51 return i18nc(
"type of folder content",
"Freebusy");
52 case CollectionTypeUtil::ContentsTypeFile:
53 return i18nc(
"type of folder content",
"Files");
55 return i18nc(
"type of folder content",
"Unknown");
59QString CollectionTypeUtil::incidencesForToString(CollectionTypeUtil::IncidencesFor type)
62 case CollectionTypeUtil::IncForNobody:
63 return QStringLiteral(
"nobody");
64 case CollectionTypeUtil::IncForAdmins:
65 return QStringLiteral(
"admins");
66 case CollectionTypeUtil::IncForReaders:
67 return QStringLiteral(
"readers");
73CollectionTypeUtil::IncidencesFor CollectionTypeUtil::incidencesForFromString(
const QString &
string)
75 if (
string ==
"nobody"_L1) {
76 return CollectionTypeUtil::IncForNobody;
77 }
else if (
string ==
"admins"_L1) {
78 return CollectionTypeUtil::IncForAdmins;
79 }
else if (
string ==
"readers"_L1) {
80 return CollectionTypeUtil::IncForReaders;
83 return CollectionTypeUtil::IncForAdmins;
86CollectionTypeUtil::FolderContentsType CollectionTypeUtil::typeFromKolabName(
const QByteArray &name)
88 if (name ==
"task" || name ==
"task.default") {
89 return CollectionTypeUtil::ContentsTypeTask;
91 if (name ==
"event" || name ==
"event.default") {
92 return CollectionTypeUtil::ContentsTypeCalendar;
94 if (name ==
"contact" || name ==
"contact.default") {
95 return CollectionTypeUtil::ContentsTypeContact;
97 if (name ==
"note" || name ==
"note.default") {
98 return CollectionTypeUtil::ContentsTypeNote;
100 if (name ==
"journal" || name ==
"journal.default") {
101 return CollectionTypeUtil::ContentsTypeJournal;
103 if (name ==
"configuration" || name ==
"configuration.default") {
104 return CollectionTypeUtil::ContentsTypeConfiguration;
106 if (name ==
"freebusy" || name ==
"freebusy.default") {
107 return CollectionTypeUtil::ContentsTypeFreebusy;
109 if (name ==
"file" || name ==
"file.default") {
110 return CollectionTypeUtil::ContentsTypeFile;
113 return CollectionTypeUtil::ContentsTypeMail;
116QByteArray CollectionTypeUtil::kolabNameFromType(CollectionTypeUtil::FolderContentsType type)
119 case CollectionTypeUtil::ContentsTypeCalendar:
121 case CollectionTypeUtil::ContentsTypeContact:
123 case CollectionTypeUtil::ContentsTypeNote:
125 case CollectionTypeUtil::ContentsTypeTask:
127 case CollectionTypeUtil::ContentsTypeJournal:
129 case CollectionTypeUtil::ContentsTypeConfiguration:
130 return "configuration";
131 case CollectionTypeUtil::ContentsTypeFreebusy:
133 case CollectionTypeUtil::ContentsTypeFile:
140CollectionTypeUtil::FolderContentsType CollectionTypeUtil::contentsTypeFromString(
const QString &type)
142 if (type ==
i18nc(
"type of folder content",
"Mail")) {
143 return CollectionTypeUtil::ContentsTypeMail;
145 if (type ==
i18nc(
"type of folder content",
"Calendar")) {
146 return CollectionTypeUtil::ContentsTypeCalendar;
148 if (type ==
i18nc(
"type of folder content",
"Contacts")) {
149 return CollectionTypeUtil::ContentsTypeContact;
151 if (type ==
i18nc(
"type of folder content",
"Notes")) {
152 return CollectionTypeUtil::ContentsTypeNote;
154 if (type ==
i18nc(
"type of folder content",
"Tasks")) {
155 return CollectionTypeUtil::ContentsTypeTask;
157 if (type ==
i18nc(
"type of folder content",
"Journal")) {
158 return CollectionTypeUtil::ContentsTypeJournal;
160 if (type ==
i18nc(
"type of folder content",
"Configuration")) {
161 return CollectionTypeUtil::ContentsTypeConfiguration;
163 if (type ==
i18nc(
"type of folder content",
"Freebusy")) {
164 return CollectionTypeUtil::ContentsTypeFreebusy;
166 if (type ==
i18nc(
"type of folder content",
"Files")) {
167 return CollectionTypeUtil::ContentsTypeFile;
170 return CollectionTypeUtil::ContentsTypeMail;
175 if (type ==
"task" || type ==
"task.default") {
176 return i18nc(
"type of folder content",
"Tasks");
178 if (type ==
"event" || type ==
"event.default") {
179 return i18nc(
"type of folder content",
"Calendar");
181 if (type ==
"contact" || type ==
"contact.default") {
182 return i18nc(
"type of folder content",
"Contacts");
184 if (type ==
"note" || type ==
"note.default") {
185 return i18nc(
"type of folder content",
"Notes");
187 if (type ==
"journal" || type ==
"journal.default") {
188 return i18nc(
"type of folder content",
"Journal");
190 if (type ==
"configuration" || type ==
"configuration.default") {
191 return i18nc(
"type of folder content",
"Configuration");
193 if (type ==
"freebusy" || type ==
"freebusy.default") {
194 return i18nc(
"type of folder content",
"Freebusy");
196 if (type ==
"file" || type ==
"file.default") {
197 return i18nc(
"type of folder content",
"Files");
200 return i18nc(
"type of folder content",
"Mail");
203QString CollectionTypeUtil::iconNameFromContentsType(CollectionTypeUtil::FolderContentsType type)
207 case CollectionTypeUtil::ContentsTypeCalendar:
208 iconName = QStringLiteral(
"view-calendar");
210 case CollectionTypeUtil::ContentsTypeContact:
211 iconName = QStringLiteral(
"view-pim-contacts");
213 case CollectionTypeUtil::ContentsTypeNote:
214 iconName = QStringLiteral(
"view-pim-notes");
216 case CollectionTypeUtil::ContentsTypeTask:
217 iconName = QStringLiteral(
"view-pim-tasks");
219 case CollectionTypeUtil::ContentsTypeJournal:
220 iconName = QStringLiteral(
"view-pim-journal");
222 case CollectionTypeUtil::ContentsTypeConfiguration:
223 iconName = QStringLiteral(
"configure");
225 case CollectionTypeUtil::ContentsTypeFreebusy:
226 iconName = QStringLiteral(
"view-calendar-agenda");
228 case CollectionTypeUtil::ContentsTypeFile:
229 iconName = QStringLiteral(
"document-open");
231 case CollectionTypeUtil::ContentsTypeMail:
QString i18nc(const char *context, const char *text, const TYPE &arg...)