• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.14
  • kdepim
  • mailcommon
  • collectionpage
collectiontypeutil.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 
19 */
20 
21 #include "collectiontypeutil.h"
22 #include <KLocalizedString>
23 
24 using namespace MailCommon;
25 CollectionTypeUtil::CollectionTypeUtil()
26 {
27 
28 }
29 
30 CollectionTypeUtil::~CollectionTypeUtil()
31 {
32 
33 }
34 
35 QByteArray CollectionTypeUtil::kolabFolderType()
36 {
37  return "/shared/vendor/kolab/folder-type";
38 }
39 
40 QByteArray CollectionTypeUtil::kolabIncidencesFor()
41 {
42  return "/shared/vendor/kolab/incidences-for";
43 }
44 
45 QByteArray CollectionTypeUtil::kolabSharedSeen()
46 {
47  return "/shared/vendor/cmu/cyrus-imapd/sharedseen";
48 }
49 
50 
51 QString CollectionTypeUtil::folderContentDescription( CollectionTypeUtil::FolderContentsType type )
52 {
53  switch ( type ) {
54  case CollectionTypeUtil::ContentsTypeMail:
55  return ( i18nc( "type of folder content", "Mail" ) );
56  case CollectionTypeUtil::ContentsTypeCalendar:
57  return ( i18nc( "type of folder content", "Calendar" ) );
58  case CollectionTypeUtil::ContentsTypeContact:
59  return ( i18nc( "type of folder content", "Contacts" ) );
60  case CollectionTypeUtil::ContentsTypeNote:
61  return ( i18nc( "type of folder content", "Notes" ) );
62  case CollectionTypeUtil::ContentsTypeTask:
63  return ( i18nc( "type of folder content", "Tasks" ) );
64  case CollectionTypeUtil::ContentsTypeJournal:
65  return ( i18nc( "type of folder content", "Journal" ) );
66  case CollectionTypeUtil::ContentsTypeConfiguration:
67  return ( i18nc( "type of folder content", "Configuration" ) );
68  case CollectionTypeUtil::ContentsTypeFreebusy:
69  return ( i18nc( "type of folder content", "Freebusy" ) );
70  case CollectionTypeUtil::ContentsTypeFile:
71  return ( i18nc( "type of folder content", "Files" ) );
72  default:
73  return ( i18nc( "type of folder content", "Unknown" ) );
74  }
75 }
76 
77 
78 QString CollectionTypeUtil::incidencesForToString( CollectionTypeUtil::IncidencesFor type )
79 {
80  switch ( type ) {
81  case CollectionTypeUtil::IncForNobody:
82  return QLatin1String("nobody");
83  case CollectionTypeUtil::IncForAdmins:
84  return QLatin1String("admins");
85  case CollectionTypeUtil::IncForReaders:
86  return QLatin1String("readers");
87  }
88 
89  return QString(); // can't happen
90 }
91 
92 CollectionTypeUtil::IncidencesFor CollectionTypeUtil::incidencesForFromString( const QString &string )
93 {
94  if ( string == QLatin1String("nobody") ) {
95  return CollectionTypeUtil::IncForNobody;
96  }
97  else if ( string == QLatin1String("admins") ) {
98  return CollectionTypeUtil::IncForAdmins;
99  }
100  else if ( string == QLatin1String("readers") ) {
101  return CollectionTypeUtil::IncForReaders;
102  }
103 
104  return CollectionTypeUtil::IncForAdmins; // by default
105 }
106 
107 CollectionTypeUtil::FolderContentsType CollectionTypeUtil::typeFromKolabName(const QByteArray &name)
108 {
109  if ( name == "task" || name == "task.default" ) {
110  return CollectionTypeUtil::ContentsTypeTask;
111  }
112  if ( name == "event" || name == "event.default" ) {
113  return CollectionTypeUtil::ContentsTypeCalendar;
114  }
115  if ( name == "contact" || name == "contact.default" ) {
116  return CollectionTypeUtil::ContentsTypeContact;
117  }
118  if ( name == "note" || name == "note.default" ) {
119  return CollectionTypeUtil::ContentsTypeNote;
120  }
121  if ( name == "journal" || name == "journal.default" ) {
122  return CollectionTypeUtil::ContentsTypeJournal;
123  }
124  if ( name == "configuration" || name == "configuration.default" ) {
125  return CollectionTypeUtil::ContentsTypeConfiguration;
126  }
127  if ( name == "freebusy" || name == "freebusy.default" ) {
128  return CollectionTypeUtil::ContentsTypeFreebusy;
129  }
130  if ( name == "file" || name == "file.default" ) {
131  return CollectionTypeUtil::ContentsTypeFile;
132  }
133 
134  return CollectionTypeUtil::ContentsTypeMail;
135 }
136 
137 QByteArray CollectionTypeUtil::kolabNameFromType( CollectionTypeUtil::FolderContentsType type )
138 {
139  switch ( type ) {
140  case CollectionTypeUtil::ContentsTypeCalendar:
141  return "event";
142  case CollectionTypeUtil::ContentsTypeContact:
143  return "contact";
144  case CollectionTypeUtil::ContentsTypeNote:
145  return "note";
146  case CollectionTypeUtil::ContentsTypeTask:
147  return "task";
148  case CollectionTypeUtil::ContentsTypeJournal:
149  return "journal";
150  case CollectionTypeUtil::ContentsTypeConfiguration:
151  return "configuration";
152  case CollectionTypeUtil::ContentsTypeFreebusy:
153  return "freebusy";
154  case CollectionTypeUtil::ContentsTypeFile:
155  return "file";
156  default:
157  return QByteArray();
158  }
159 }
160 
161 CollectionTypeUtil::FolderContentsType CollectionTypeUtil::contentsTypeFromString( const QString &type )
162 {
163  if ( type == i18nc( "type of folder content", "Mail" ) ) {
164  return CollectionTypeUtil::ContentsTypeMail;
165  }
166  if ( type == i18nc( "type of folder content", "Calendar" ) ) {
167  return CollectionTypeUtil::ContentsTypeCalendar;
168  }
169  if ( type == i18nc( "type of folder content", "Contacts" ) ) {
170  return CollectionTypeUtil::ContentsTypeContact;
171  }
172  if ( type == i18nc( "type of folder content", "Notes" ) ) {
173  return CollectionTypeUtil::ContentsTypeNote;
174  }
175  if ( type == i18nc( "type of folder content", "Tasks" ) ) {
176  return CollectionTypeUtil::ContentsTypeTask;
177  }
178  if ( type == i18nc( "type of folder content", "Journal" ) ) {
179  return CollectionTypeUtil::ContentsTypeJournal;
180  }
181  if ( type == i18nc( "type of folder content", "Configuration" ) ) {
182  return CollectionTypeUtil::ContentsTypeConfiguration;
183  }
184  if ( type == i18nc( "type of folder content", "Freebusy" ) ) {
185  return CollectionTypeUtil::ContentsTypeFreebusy;
186  }
187  if ( type == i18nc( "type of folder content", "Files" ) ) {
188  return CollectionTypeUtil::ContentsTypeFile;
189  }
190 
191  return CollectionTypeUtil::ContentsTypeMail; //safety return value
192 }
193 
194 QString CollectionTypeUtil::typeNameFromKolabType( const QByteArray &type )
195 {
196  if ( type == "task" || type == "task.default" ) {
197  return i18nc( "type of folder content", "Tasks" );
198  }
199  if ( type == "event" || type == "event.default" ) {
200  return i18nc( "type of folder content", "Calendar" );
201  }
202  if ( type == "contact" || type == "contact.default" ) {
203  return i18nc( "type of folder content", "Contacts" );
204  }
205  if ( type == "note" || type == "note.default" ) {
206  return i18nc( "type of folder content", "Notes" );
207  }
208  if ( type == "journal" || type == "journal.default" ) {
209  return i18nc( "type of folder content", "Journal" );
210  }
211  if ( type == "configuration" || type == "configuration.default" ) {
212  return i18nc( "type of folder content", "Configuration" );
213  }
214  if ( type == "freebusy" || type == "freebusy.default" ) {
215  return i18nc( "type of folder content", "Freebusy" );
216  }
217  if ( type == "file" || type == "file.default" ) {
218  return i18nc( "type of folder content", "Files" );
219  }
220 
221  return i18nc( "type of folder content", "Mail" );
222 }
223 
224 QString CollectionTypeUtil::iconNameFromContentsType(CollectionTypeUtil::FolderContentsType type)
225 {
226  QString iconName;
227  switch (type) {
228  case CollectionTypeUtil::ContentsTypeCalendar:
229  iconName = QString::fromLatin1( "view-calendar" );
230  break;
231  case CollectionTypeUtil::ContentsTypeContact:
232  iconName= QString::fromLatin1( "view-pim-contacts" );
233  break;
234  case CollectionTypeUtil::ContentsTypeNote:
235  iconName = QString::fromLatin1( "view-pim-notes" );
236  break;
237  case CollectionTypeUtil::ContentsTypeTask:
238  iconName = QString::fromLatin1( "view-pim-tasks" );
239  break;
240  case CollectionTypeUtil::ContentsTypeJournal:
241  iconName = QString::fromLatin1( "view-pim-journal" );
242  break;
243  case CollectionTypeUtil::ContentsTypeConfiguration:
244  iconName = QString::fromLatin1( "configure" );
245  break;
246  case CollectionTypeUtil::ContentsTypeFreebusy:
247  iconName = QString::fromLatin1( "view-calendar-agenda" );
248  break;
249  case CollectionTypeUtil::ContentsTypeFile:
250  iconName = QString::fromLatin1( "document-open" );
251  break;
252  case CollectionTypeUtil::ContentsTypeMail:
253  default:
254  break;
255  }
256 
257  return iconName;
258 }
259 
MailCommon::CollectionTypeUtil::IncForReaders
Definition: collectiontypeutil.h:56
MailCommon::CollectionTypeUtil::kolabFolderType
static QByteArray kolabFolderType()
Definition: collectiontypeutil.cpp:35
MailCommon::CollectionTypeUtil::incidencesForToString
QString incidencesForToString(CollectionTypeUtil::IncidencesFor type)
Definition: collectiontypeutil.cpp:78
QByteArray
MailCommon::CollectionTypeUtil::typeFromKolabName
CollectionTypeUtil::FolderContentsType typeFromKolabName(const QByteArray &name)
Definition: collectiontypeutil.cpp:107
MailCommon::CollectionTypeUtil::typeNameFromKolabType
QString typeNameFromKolabType(const QByteArray &type)
Definition: collectiontypeutil.cpp:194
MailCommon::CollectionTypeUtil::ContentsTypeJournal
Definition: collectiontypeutil.h:46
MailCommon::CollectionTypeUtil::ContentsTypeNote
Definition: collectiontypeutil.h:44
MailCommon::CollectionTypeUtil::~CollectionTypeUtil
~CollectionTypeUtil()
Definition: collectiontypeutil.cpp:30
collectiontypeutil.h
MailCommon::CollectionTypeUtil::ContentsTypeContact
Definition: collectiontypeutil.h:43
MailCommon::CollectionTypeUtil::kolabIncidencesFor
static QByteArray kolabIncidencesFor()
Definition: collectiontypeutil.cpp:40
MailCommon::CollectionTypeUtil::CollectionTypeUtil
CollectionTypeUtil()
Definition: collectiontypeutil.cpp:25
MailCommon::CollectionTypeUtil::IncForAdmins
Definition: collectiontypeutil.h:55
MailCommon::CollectionTypeUtil::ContentsTypeFreebusy
Definition: collectiontypeutil.h:48
MailCommon::CollectionTypeUtil::kolabNameFromType
QByteArray kolabNameFromType(CollectionTypeUtil::FolderContentsType type)
Definition: collectiontypeutil.cpp:137
MailCommon::CollectionTypeUtil::incidencesForFromString
CollectionTypeUtil::IncidencesFor incidencesForFromString(const QString &string)
Definition: collectiontypeutil.cpp:92
QString
MailCommon::CollectionTypeUtil::ContentsTypeFile
Definition: collectiontypeutil.h:49
MailCommon::CollectionTypeUtil::kolabSharedSeen
static QByteArray kolabSharedSeen()
Definition: collectiontypeutil.cpp:45
MailCommon::CollectionTypeUtil::ContentsTypeTask
Definition: collectiontypeutil.h:45
QLatin1String
MailCommon::CollectionTypeUtil::ContentsTypeConfiguration
Definition: collectiontypeutil.h:47
QString::fromLatin1
QString fromLatin1(const char *str, int size)
MailCommon::CollectionTypeUtil::folderContentDescription
QString folderContentDescription(CollectionTypeUtil::FolderContentsType type)
Definition: collectiontypeutil.cpp:51
MailCommon::CollectionTypeUtil::iconNameFromContentsType
QString iconNameFromContentsType(CollectionTypeUtil::FolderContentsType type)
Definition: collectiontypeutil.cpp:224
MailCommon::CollectionTypeUtil::FolderContentsType
FolderContentsType
Definition: collectiontypeutil.h:40
MailCommon::CollectionTypeUtil::ContentsTypeCalendar
Definition: collectiontypeutil.h:42
MailCommon::CollectionTypeUtil::IncidencesFor
IncidencesFor
Definition: collectiontypeutil.h:53
MailCommon::CollectionTypeUtil::IncForNobody
Definition: collectiontypeutil.h:54
MailCommon::CollectionTypeUtil::contentsTypeFromString
CollectionTypeUtil::FolderContentsType contentsTypeFromString(const QString &type)
Definition: collectiontypeutil.cpp:161
MailCommon::CollectionTypeUtil::ContentsTypeMail
Definition: collectiontypeutil.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal