KFileMetaData

writedata.cpp
1 /*
2  * This file is part of the KFileMetaData project
3  * Copyright (C) 2016 Varun Joshi <[email protected]>
4  * Copyright (C) 2016 Vishesh Handa <[email protected]>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) version 3, or any
10  * later version accepted by the membership of KDE e.V. (or its
11  * successor approved by the membership of KDE e.V.), which shall
12  * act as a proxy defined in Section 6 of version 3 of the license.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23 
24 #include "writedata.h"
25 
26 #include <QMimeDatabase>
27 
28 using namespace KFileMetaData;
29 
30 class Q_DECL_HIDDEN WriteData::WriteDataPrivate
31 {
32 public:
33  QString url;
36 };
37 
38 WriteData::WriteData(const QString& url, const QString& mimetype)
39  : d_ptr(new WriteDataPrivate)
40 {
41  Q_D(WriteData);
42 
43  d->url = url;
44  d->mimetype = mimetype;
45  if (mimetype.isEmpty()) {
46  d->mimetype = QMimeDatabase().mimeTypeForFile(url).name();
47  }
48 }
49 
50 WriteData::WriteData(const WriteData& rhs)
51  : d_ptr(new WriteDataPrivate(*rhs.d_ptr))
52 {
53 }
54 
55 WriteData& WriteData::operator=(const WriteData& rhs)
56 {
57  *d_ptr = *rhs.d_ptr;
58  return *this;
59 }
60 
61 bool WriteData::operator==(const WriteData& rhs) const
62 {
63  Q_D(const WriteData);
64  return d->properties == rhs.d_ptr->properties;
65 }
66 
67 void WriteData::add(Property::Property property, const QVariant& value)
68 {
69  Q_D(WriteData);
70  d->properties.insertMulti(property, value);
71 }
72 
73 WriteData::~WriteData()
74 {
75  delete d_ptr;
76 }
77 
78 QString WriteData::inputUrl() const
79 {
80  Q_D(const WriteData);
81  return d->url;
82 }
83 
84 QString WriteData::inputMimetype() const
85 {
86  Q_D(const WriteData);
87  return d->mimetype;
88 }
89 
90 PropertyMap WriteData::getAllProperties() const
91 {
92  Q_D(const WriteData);
93  return d->properties;
94 }
95 
QMimeType mimeTypeForFile(const QString &fileName, QMimeDatabase::MatchMode mode) const const
KGuiItem properties()
bool isEmpty() const const
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
Property
The Property enum contains all files property types that KFileMetaData manipulates.
Definition: properties.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon May 25 2020 23:11:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.