KDAV

davitem.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Grégory Oestreicher <greg@kamago.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "davitem.h"
8
9#include "davurl.h"
10
11using namespace KDAV;
12
13class DavItemPrivate : public QSharedData
14{
15public:
16 DavUrl mUrl;
17 QString mContentType;
18 QByteArray mData;
19 QString mEtag;
20};
21
23 : d(new DavItemPrivate)
24{
25}
26
27DavItem::DavItem(const DavUrl &url, const QString &contentType, const QByteArray &data, const QString &etag)
28 : d(new DavItemPrivate)
29{
30 d->mUrl = url;
31 d->mContentType = contentType;
32 d->mData = data;
33 d->mEtag = etag;
34}
35
36DavItem::DavItem(const DavItem &other) = default;
37DavItem::DavItem(DavItem &&) = default;
38DavItem &DavItem::operator=(const DavItem &other) = default;
39DavItem &DavItem::operator=(DavItem &&) = default;
40DavItem::~DavItem() = default;
41
42void DavItem::setUrl(const DavUrl &url)
43{
44 d->mUrl = url;
45}
46
48{
49 return d->mUrl;
50}
51
52void DavItem::setContentType(const QString &contentType)
53{
54 d->mContentType = contentType;
55}
56
58{
59 return d->mContentType;
60}
61
63{
64 d->mData = data;
65}
66
68{
69 return d->mData;
70}
71
72void DavItem::setEtag(const QString &etag)
73{
74 d->mEtag = etag;
75}
76
78{
79 return d->mEtag;
80}
81
82QDataStream &KDAV::operator<<(QDataStream &stream, const DavItem &item)
83{
84 stream << item.url();
85 stream << item.contentType();
86 stream << item.data();
87 stream << item.etag();
88
89 return stream;
90}
91
92QDataStream &KDAV::operator>>(QDataStream &stream, DavItem &item)
93{
94 QString contentType;
95 QString etag;
96 DavUrl url;
97 QByteArray data;
98
99 stream >> url;
100 stream >> contentType;
101 stream >> data;
102 stream >> etag;
103
104 item = DavItem(url, contentType, data, etag);
105
106 return stream;
107}
A helper class to store information about DAV resources.
Definition davitem.h:39
QString contentType() const
Returns the content type of the item.
Definition davitem.cpp:57
DavUrl url() const
Returns the URL that identifies the item.
Definition davitem.cpp:47
void setEtag(const QString &etag)
Sets the etag of the item.
Definition davitem.cpp:72
QByteArray data() const
Returns the raw content data of the item.
Definition davitem.cpp:67
DavItem()
Creates an empty DAV item.
Definition davitem.cpp:22
void setUrl(const DavUrl &url)
Sets the url that identifies the item.
Definition davitem.cpp:42
void setData(const QByteArray &data)
Sets the raw content data of the item.
Definition davitem.cpp:62
QString etag() const
Returns the ETag of the item.
Definition davitem.cpp:77
void setContentType(const QString &type)
Sets the content type of the item.
Definition davitem.cpp:52
A helper class to combine URL and protocol of a DAV URL.
Definition davurl.h:27
The KDAV namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:05:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.