Libkdav2

davurl.cpp
1/*
2 Copyright (c) 2010 Tobias Koenig <tokoe@kde.org>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
18
19#include "davurl.h"
20
21#include "enums.h"
22#include <QDebug>
23
24using namespace KDAV2;
25
27 : mProtocol(KDAV2::CalDav)
28{
29}
30
31DavUrl::DavUrl(const QUrl &url, Protocol protocol)
32 : mUrl(url), mProtocol(protocol)
33{
34}
35
36void DavUrl::setUrl(const QUrl &url)
37{
38 mUrl = url;
39}
40
42{
43 return mUrl;
44}
45
46void DavUrl::setProtocol(Protocol protocol)
47{
48 mProtocol = protocol;
49}
50
51Protocol DavUrl::protocol() const
52{
53 return mProtocol;
54}
55
57{
58 auto url = mUrl;
60 return url.toDisplayString();
61}
62
63QDataStream &KDAV2::operator<<(QDataStream &stream, const DavUrl &url)
64{
65 stream << QString::number(url.protocol());
66 stream << url.url();
67
68 return stream;
69}
70
71QDataStream &KDAV2::operator>>(QDataStream &stream, DavUrl &davUrl)
72{
73 QUrl url;
74 QString p;
75
76 stream >> p;
77 stream >> url;
78
79 davUrl = DavUrl(url, (Protocol) p.toInt());
80
81 return stream;
82}
83
84QDebug &KDAV2::operator<<(QDebug &debug, const DavUrl &url)
85{
86 debug << url.toDisplayString();
87 return debug;
88}
A helper class to combine url and protocol of a DAV url.
Definition davurl.h:36
void setProtocol(Protocol protocol)
Sets the DAV protocol dialect that is used to retrieve the DAV object.
Definition davurl.cpp:46
QUrl url() const
Returns the url that identifies the DAV object.
Definition davurl.cpp:41
Protocol protocol() const
Returns the DAV protocol dialect that is used to retrieve the DAV object.
Definition davurl.cpp:51
void setUrl(const QUrl &url)
Sets the url that identifies the DAV object.
Definition davurl.cpp:36
QString toDisplayString() const
Returns the url in a userfriendly way without login informations.
Definition davurl.cpp:56
DavUrl()
Creates an empty DAV url.
Definition davurl.cpp:26
QString number(double n, char format, int precision)
int toInt(bool *ok, int base) const const
void setUserInfo(const QString &userInfo, ParsingMode mode)
QString toDisplayString(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.