KFileMetaData

writedata.cpp
1 /*
2  This file is part of the KFileMetaData project
3  SPDX-FileCopyrightText: 2016 Varun Joshi <[email protected]>
4  SPDX-FileCopyrightText: 2016 Vishesh Handa <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 
9 #include "writedata.h"
10 
11 #include <QMimeDatabase>
12 
13 using namespace KFileMetaData;
14 
15 class Q_DECL_HIDDEN WriteData::WriteDataPrivate
16 {
17 public:
18  QString url;
22 };
23 
24 WriteData::WriteData(const QString& url, const QString& mimetype)
25  : d_ptr(new WriteDataPrivate)
26 {
27  Q_D(WriteData);
28 
29  d->url = url;
30  d->mimetype = mimetype;
31  if (mimetype.isEmpty()) {
32  d->mimetype = QMimeDatabase().mimeTypeForFile(url).name();
33  }
34 }
35 
36 WriteData::WriteData(const WriteData& rhs)
37  : d_ptr(new WriteDataPrivate(*rhs.d_ptr))
38 {
39 }
40 
41 WriteData& WriteData::operator=(const WriteData& rhs)
42 {
43  *d_ptr = *rhs.d_ptr;
44  return *this;
45 }
46 
47 bool WriteData::operator==(const WriteData& rhs) const
48 {
49  Q_D(const WriteData);
50  return d->properties == rhs.d_ptr->properties;
51 }
52 
53 void WriteData::add(Property::Property property, const QVariant& value)
54 {
55  Q_D(WriteData);
56  d->properties.insertMulti(property, value);
57 }
58 
59 void WriteData::addImageData(const QMap<EmbeddedImageData::ImageType, QByteArray>& images)
60 {
61  Q_D(WriteData);
62  d->images = images;
63 }
64 
65 QMap<EmbeddedImageData::ImageType, QByteArray> WriteData::imageData() const
66 {
67  Q_D(const WriteData);
68  return d->images;
69 }
70 
71 WriteData::~WriteData()
72 {
73  delete d_ptr;
74 }
75 
76 QString WriteData::inputUrl() const
77 {
78  Q_D(const WriteData);
79  return d->url;
80 }
81 
82 QString WriteData::inputMimetype() const
83 {
84  Q_D(const WriteData);
85  return d->mimetype;
86 }
87 
88 PropertyMap WriteData::getAllProperties() const
89 {
90  Q_D(const WriteData);
91  return d->properties;
92 }
93 
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:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Nov 21 2020 22:54:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.