MauiKit File Browsing

WebDAVItem.cpp
1#include <QDateTime>
2#include <QDebug>
3#include <QIODevice>
4#include <QString>
5#include <QTextStream>
6
7#include "../WebDAVClient.hpp"
8#include "../utils/WebDAVReply.hpp"
9#include "WebDAVItem.hpp"
10
11WebDAVItem::WebDAVItem(WebDAVClient *webdavClient, QString href, QString creationDate, QString lastModified, QString displayName, QString contentType, QString contentLength, bool isCollection)
12{
13 this->webdavClient = webdavClient;
14 this->href = href;
15 this->creationDate = QDateTime::fromString(creationDate, Qt::DateFormat::ISODate);
16 this->lastModified = lastModified;
17 this->displayName = displayName;
18 this->contentType = contentType;
19 this->contentLength = contentLength.toInt();
20 this->flagIsCollection = isCollection;
21}
22
23bool WebDAVItem::isCollection()
24{
25 return this->flagIsCollection;
26}
27
28bool WebDAVItem::isFile()
29{
30 return !this->flagIsCollection;
31}
32
33WebDAVReply *WebDAVItem::download()
34{
35 return this->webdavClient->downloadFrom(this->href);
36}
37
38WebDAVReply *WebDAVItem::upload(QString filename, QIODevice *file)
39{
40 return this->webdavClient->uploadTo(this->href, filename, file);
41}
42
43WebDAVReply *WebDAVItem::createDir(QString dirName)
44{
45 return this->webdavClient->createDir(this->href, dirName);
46}
47
48WebDAVReply *WebDAVItem::copy(QString destination)
49{
50 return this->webdavClient->copy(this->href, destination);
51}
52
53WebDAVReply *WebDAVItem::move(QString destination, bool overwrite)
54{
55 return this->webdavClient->move(this->href, destination, overwrite);
56}
57
58WebDAVReply *WebDAVItem::remove()
59{
60 return this->webdavClient->remove(this->href);
61}
62
63WebDAVReply *WebDAVItem::listDir()
64{
65 return this->webdavClient->listDir(this->href);
66}
67
68QString WebDAVItem::toString()
69{
70 QString s;
71 QTextStream out(&s);
72
73 out << "HREF : " << this->href << "," << Qt::endl
74 << "CREATION_DATE : " << this->creationDate.toString() << "," << Qt::endl
75 << "LAST_MODIFIED : " << this->lastModified << "," << Qt::endl
76 << "DISPLAY_NAME : " << this->displayName << "," << Qt::endl
77 << "CONTENT_TYPE : " << this->contentType << "," << Qt::endl
78 << "CONTENT_LENGTH : " << this->contentLength << "," << Qt::endl
79 << "IS_COLLECTION : " << this->flagIsCollection;
80
81 return s;
82}
83
84QString WebDAVItem::getHref()
85{
86 return this->href;
87}
88
89QDateTime WebDAVItem::getCreationDate()
90{
91 return this->creationDate;
92}
93
94QString WebDAVItem::getLastModified()
95{
96 return this->lastModified;
97}
98
99QString WebDAVItem::getDisplayName()
100{
101 return this->displayName;
102}
103
104QString WebDAVItem::getContentType()
105{
106 return this->contentType;
107}
108
109int WebDAVItem::getContentLength()
110{
111 return this->contentLength;
112}
Wraps the available actions for a remote item.
AKONADI_CALENDAR_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &collection)
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
int toInt(bool *ok, int base) const const
QTextStream & endl(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.