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

kabc

  • sources
  • kde-4.14
  • kdepimlibs
  • kabc
calendarurl.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2015 Laurent Montel <montel@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "calendarurl.h"
22 
23 #include <QMap>
24 #include <QUrl>
25 #include <qstringlist.h>
26 
27 using namespace KABC;
28 
29 class CalendarUrl::Private : public QSharedData
30 {
31 public:
32  Private()
33  {
34  }
35 
36  Private( const Private &other )
37  : QSharedData( other )
38  {
39  parameters = other.parameters;
40  type = other.type;
41  url = other.url;
42  }
43  static QString typeToString(CalendarUrl::CalendarType type);
44  QMap<QString, QStringList> parameters;
45  QUrl url;
46  CalendarUrl::CalendarType type;
47 
48 };
49 
50 QString CalendarUrl::Private::typeToString(CalendarUrl::CalendarType type)
51 {
52  QString ret;
53  switch(type) {
54  case Unknown:
55  ret = QLatin1String("Unknown");
56  break;
57  case FBUrl:
58  ret = QLatin1String("FreeBusy");
59  break;
60  case CALUri:
61  ret = QLatin1String("CalUri");
62  break;
63  case CALADRUri:
64  ret = QLatin1String("Caladruri");
65  break;
66  }
67  return ret;
68 }
69 
70 
71 CalendarUrl::CalendarUrl()
72  : d(new Private)
73 {
74  d->type = Unknown;
75 }
76 
77 CalendarUrl::CalendarUrl(CalendarUrl::CalendarType type)
78  : d(new Private)
79 {
80  d->type = type;
81 }
82 
83 CalendarUrl::CalendarUrl( const CalendarUrl &other )
84  : d( other.d )
85 {
86 }
87 
88 CalendarUrl::~CalendarUrl()
89 {
90 
91 }
92 
93 QMap<QString, QStringList> CalendarUrl::parameters() const
94 {
95  return d->parameters;
96 }
97 
98 bool CalendarUrl::operator==(const CalendarUrl &other) const
99 {
100  return (d->parameters == other.parameters()) && (d->type == other.type()) && (d->url == other.url());
101 }
102 
103 bool CalendarUrl::operator!=(const CalendarUrl &other) const
104 {
105  return !( other == *this );
106 }
107 
108 CalendarUrl &CalendarUrl::operator=(const CalendarUrl &other)
109 {
110  if ( this != &other ) {
111  d = other.d;
112  }
113 
114  return *this;
115 }
116 
117 
118 QString CalendarUrl::toString() const
119 {
120  QString str;
121  str += QString::fromLatin1( "CalendarUrl {\n" );
122  str += QString::fromLatin1( " url: %1\n" ).arg( d->url.toString() );
123  str += QString::fromLatin1( " type: %1\n" ).arg( CalendarUrl::Private::typeToString(d->type) );
124  if (!d->parameters.isEmpty()) {
125  QMapIterator<QString, QStringList> i(d->parameters);
126  QString param;
127  while (i.hasNext()) {
128  i.next();
129  param += QString::fromLatin1("%1 %2").arg(i.key()).arg(i.value().join(QLatin1String(",")));
130  }
131  str += QString::fromLatin1( " parameters: %1\n" ).arg( param );
132  }
133  str += QString::fromLatin1( "}\n" );
134  return str;
135 }
136 
137 void CalendarUrl::setParameters(const QMap<QString, QStringList> &params)
138 {
139  d->parameters = params;
140 }
141 
142 bool CalendarUrl::isValid() const
143 {
144  return (d->type != Unknown) && (d->url.isValid());
145 }
146 
147 void CalendarUrl::setType(CalendarUrl::CalendarType type)
148 {
149  d->type = type;
150 }
151 
152 CalendarUrl::CalendarType CalendarUrl::type() const
153 {
154  return d->type;
155 }
156 
157 void CalendarUrl::setUrl(const QUrl &url)
158 {
159  d->url = url;
160 }
161 
162 QUrl CalendarUrl::url() const
163 {
164  return d->url;
165 }
166 
167 QDataStream &KABC::operator<<(QDataStream &s, const CalendarUrl &calUrl)
168 {
169  return s << calUrl.d->parameters << (uint)calUrl.d->type << calUrl.d->url;
170 }
171 
172 QDataStream &KABC::operator>>(QDataStream &s, CalendarUrl &calUrl)
173 {
174  uint type;
175  s >> calUrl.d->parameters >> type >> calUrl.d->url;
176  calUrl.d->type = static_cast<CalendarUrl::CalendarType>(type);
177  return s;
178 }
179 
KABC::Plugin::type
virtual QString type() const
Returns the plugin's type.
Definition: plugin.cpp:48
QDataStream
QMap< QString, QStringList >
KABC::operator<<
QDataStream & operator<<(QDataStream &stream, const Address &address)
Serializes the address object into the stream.
Definition: address.cpp:680
QSharedData
QMapIterator
QString
QUrl
KABC::operator>>
QDataStream & operator>>(QDataStream &stream, Address &address)
Initializes the address object from the stream.
Definition: address.cpp:688
QLatin1String
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

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

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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