KDAV

davurl.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "davurl.h"
8
9
10using namespace KDAV;
11
12namespace KDAV
13{
14class DavUrlPrivate : public QSharedData
15{
16public:
17 Protocol mProtocol = KDAV::CalDav;
18 QUrl mUrl;
19};
20}
21
23 : d(new DavUrlPrivate)
24{
25}
26
27DavUrl::DavUrl(const QUrl &url, Protocol protocol)
28 : d(new DavUrlPrivate)
29{
30 d->mUrl = url;
31 d->mProtocol = protocol;
32}
33
34DavUrl::DavUrl(const DavUrl &) = default;
35DavUrl::DavUrl(DavUrl &&) = default;
36DavUrl::~DavUrl() = default;
37DavUrl &DavUrl::operator=(const DavUrl &) = default;
38DavUrl &DavUrl::operator=(DavUrl &&) = default;
39
40void DavUrl::setUrl(const QUrl &url)
41{
42 d->mUrl = url;
43}
44
46{
47 return d->mUrl;
48}
49
51{
52 d->mProtocol = protocol;
53}
54
56{
57 return d->mProtocol;
58}
59
61{
62 auto url = d->mUrl;
64 return url.toDisplayString();
65}
66
67QDataStream &KDAV::operator<<(QDataStream &stream, const DavUrl &url)
68{
69 stream << QString::number(url.protocol());
70 stream << url.url();
71
72 return stream;
73}
74
75QDataStream &KDAV::operator>>(QDataStream &stream, DavUrl &davUrl)
76{
77 QUrl url;
78 QString p;
79
80 stream >> p;
81 stream >> url;
82
83 davUrl = DavUrl(url, static_cast<Protocol>(p.toInt()));
84
85 return stream;
86}
A helper class to combine URL and protocol of a DAV URL.
Definition davurl.h:27
void setProtocol(Protocol protocol)
Sets the DAV protocol dialect that is used to retrieve the DAV object.
Definition davurl.cpp:50
QUrl url() const
Returns the URL that identifies the DAV object.
Definition davurl.cpp:45
Protocol protocol() const
Returns the DAV protocol dialect that is used to retrieve the DAV object.
Definition davurl.cpp:55
void setUrl(const QUrl &url)
Sets the url that identifies the DAV object.
Definition davurl.cpp:40
QString toDisplayString() const
Returns the URL in a user-friendly way without login information.
Definition davurl.cpp:60
DavUrl()
Creates an empty DAV URL.
Definition davurl.cpp:22
The KDAV namespace.
Protocol
Describes the DAV protocol dialect.
Definition enums.h:20
@ CalDav
The CalDav protocol as defined in https://devguide.calconnect.org/CalDAV.
Definition enums.h:21
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 Tue Mar 26 2024 11:16:34 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.