1 | /* |
---|---|
2 | This file is part of the KFileMetaData project |
3 | SPDX-FileCopyrightText: 2016 Varun Joshi <varunj.1011@gmail.com> |
4 | SPDX-FileCopyrightText: 2016 Vishesh Handa <me@vhanda.in> |
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 KFileMetaData::WriteDataPrivate |
16 | { |
17 | public: |
18 | QString url; |
19 | QString mimetype; |
20 | PropertyMultiMap properties; |
21 | QMap<EmbeddedImageData::ImageType, QByteArray> images; |
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(fileName: 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.insert(key: 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() = default; |
72 | |
73 | QString WriteData::inputUrl() const |
74 | { |
75 | Q_D(const WriteData); |
76 | return d->url; |
77 | } |
78 | |
79 | QString WriteData::inputMimetype() const |
80 | { |
81 | Q_D(const WriteData); |
82 | return d->mimetype; |
83 | } |
84 | |
85 | PropertyMultiMap WriteData::properties() const |
86 | { |
87 | Q_D(const WriteData); |
88 | return d->properties; |
89 | } |
90 |