Libkdav2

davurl.cpp
1 /*
2  Copyright (c) 2010 Tobias Koenig <[email protected]>
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 
24 using namespace KDAV2;
25 
27  : mProtocol(KDAV2::CalDav)
28 {
29 }
30 
31 DavUrl::DavUrl(const QUrl &url, Protocol protocol)
32  : mUrl(url), mProtocol(protocol)
33 {
34 }
35 
36 void DavUrl::setUrl(const QUrl &url)
37 {
38  mUrl = url;
39 }
40 
42 {
43  return mUrl;
44 }
45 
47 {
48  mProtocol = protocol;
49 }
50 
51 Protocol DavUrl::protocol() const
52 {
53  return mProtocol;
54 }
55 
57 {
58  auto url = mUrl;
60  return url.toDisplayString();
61 }
62 
63 QDataStream &KDAV2::operator<<(QDataStream &stream, const DavUrl &url)
64 {
65  stream << QString::number(url.protocol());
66  stream << url.url();
67 
68  return stream;
69 }
70 
71 QDataStream &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 
84 QDebug &KDAV2::operator<<(QDebug &debug, const DavUrl &url)
85 {
86  debug << url.toDisplayString();
87  return debug;
88 }
QUrl url() const
Returns the url that identifies the DAV object.
Definition: davurl.cpp:41
QString toDisplayString(QUrl::FormattingOptions options) const const
void setUrl(const QUrl &url)
Sets the url that identifies the DAV object.
Definition: davurl.cpp:36
A helper class to combine url and protocol of a DAV url.
Definition: davurl.h:35
QString toDisplayString() const
Returns the url in a userfriendly way without login informations.
Definition: davurl.cpp:56
QString number(int n, int base)
Protocol protocol() const
Returns the DAV protocol dialect that is used to retrieve the DAV object.
Definition: davurl.cpp:51
DavUrl()
Creates an empty DAV url.
Definition: davurl.cpp:26
void setUserInfo(const QString &userInfo, QUrl::ParsingMode mode)
void setProtocol(Protocol protocol)
Sets the DAV protocol dialect that is used to retrieve the DAV object.
Definition: davurl.cpp:46
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jan 27 2022 23:10:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.