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

kabc

  • 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
27using namespace KABC;
28
29class CalendarUrl::Private : public QSharedData
30{
31public:
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
50QString 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
71CalendarUrl::CalendarUrl()
72 : d(new Private)
73{
74 d->type = Unknown;
75}
76
77CalendarUrl::CalendarUrl(CalendarUrl::CalendarType type)
78 : d(new Private)
79{
80 d->type = type;
81}
82
83CalendarUrl::CalendarUrl( const CalendarUrl &other )
84 : d( other.d )
85{
86}
87
88CalendarUrl::~CalendarUrl()
89{
90
91}
92
93QMap<QString, QStringList> CalendarUrl::parameters() const
94{
95 return d->parameters;
96}
97
98bool CalendarUrl::operator==(const CalendarUrl &other) const
99{
100 return (d->parameters == other.parameters()) && (d->type == other.type()) && (d->url == other.url());
101}
102
103bool CalendarUrl::operator!=(const CalendarUrl &other) const
104{
105 return !( other == *this );
106}
107
108CalendarUrl &CalendarUrl::operator=(const CalendarUrl &other)
109{
110 if ( this != &other ) {
111 d = other.d;
112 }
113
114 return *this;
115}
116
117
118QString 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
137void CalendarUrl::setParameters(const QMap<QString, QStringList> &params)
138{
139 d->parameters = params;
140}
141
142bool CalendarUrl::isValid() const
143{
144 return (d->type != Unknown) && (d->url.isValid());
145}
146
147void CalendarUrl::setType(CalendarUrl::CalendarType type)
148{
149 d->type = type;
150}
151
152CalendarUrl::CalendarType CalendarUrl::type() const
153{
154 return d->type;
155}
156
157void CalendarUrl::setUrl(const QUrl &url)
158{
159 d->url = url;
160}
161
162QUrl CalendarUrl::url() const
163{
164 return d->url;
165}
166
167QDataStream &KABC::operator<<(QDataStream &s, const CalendarUrl &calUrl)
168{
169 return s << calUrl.d->parameters << (uint)calUrl.d->type << calUrl.d->url;
170}
171
172QDataStream &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
Class that holds a Calendar Url (FBURL/CALADRURI/CALURI)
Definition: address.h:29
KABC::operator<<
QDataStream & operator<<(QDataStream &stream, const Address &address)
Serializes the address object into the stream.
Definition: address.cpp:680
KABC::operator>>
QDataStream & operator>>(QDataStream &stream, Address &address)
Initializes the address object from the stream.
Definition: address.cpp:688
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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
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