Changeset View
Changeset View
Standalone View
Standalone View
src/externalwriter.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 63 | { | |||
---|---|---|---|---|---|
76 | manifest.open(QIODevice::ReadOnly); | 76 | manifest.open(QIODevice::ReadOnly); | ||
77 | QJsonDocument manifestDoc = QJsonDocument::fromJson(manifest.readAll()); | 77 | QJsonDocument manifestDoc = QJsonDocument::fromJson(manifest.readAll()); | ||
78 | if (!manifestDoc.isObject()) { | 78 | if (!manifestDoc.isObject()) { | ||
79 | qCDebug(KFILEMETADATA_LOG) << "Manifest does not seem to be a valid JSON Object"; | 79 | qCDebug(KFILEMETADATA_LOG) << "Manifest does not seem to be a valid JSON Object"; | ||
80 | return; | 80 | return; | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | QJsonObject rootObject = manifestDoc.object(); | 83 | QJsonObject rootObject = manifestDoc.object(); | ||
84 | QJsonArray mimetypesArray = rootObject.value(QStringLiteral("mimetypes")).toArray(); | 84 | const QJsonArray mimetypesArray = rootObject.value(QStringLiteral("mimetypes")).toArray(); | ||
85 | QStringList mimetypes; | 85 | QStringList mimetypes; | ||
86 | Q_FOREACH(const QVariant &mimetype, mimetypesArray) { | 86 | for (const QVariant &mimetype : mimetypesArray) { | ||
87 | mimetypes << mimetype.toString(); | 87 | mimetypes << mimetype.toString(); | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | d->writeMimetypes.append(mimetypes); | 90 | d->writeMimetypes.append(mimetypes); | ||
91 | d->mainPath = pluginDir.filePath(rootObject[QStringLiteral("main")].toString()); | 91 | d->mainPath = pluginDir.filePath(rootObject[QStringLiteral("main")].toString()); | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | QStringList ExternalWriter::writeMimetypes() const | 94 | QStringList ExternalWriter::writeMimetypes() const | ||
95 | { | 95 | { | ||
96 | Q_D(const ExternalWriter); | 96 | Q_D(const ExternalWriter); | ||
97 | return d->writeMimetypes; | 97 | return d->writeMimetypes; | ||
98 | } | 98 | } | ||
99 | 99 | | |||
100 | void ExternalWriter::write(const WriteData& data) | 100 | void ExternalWriter::write(const WriteData& data) | ||
101 | { | 101 | { | ||
102 | Q_D(ExternalWriter); | 102 | Q_D(ExternalWriter); | ||
103 | QJsonDocument writeData; | 103 | QJsonDocument writeData; | ||
104 | QJsonObject rootObject; | 104 | QJsonObject rootObject; | ||
105 | QJsonObject propertiesObject; | 105 | QJsonObject propertiesObject; | ||
106 | QByteArray output; | 106 | QByteArray output; | ||
107 | QByteArray errorOutput; | 107 | QByteArray errorOutput; | ||
108 | 108 | | |||
109 | QMap<Property::Property, QVariant> properties = data.getAllProperties(); | 109 | const QMap<Property::Property, QVariant> properties = data.getAllProperties(); | ||
110 | const auto &propertiesKeys = properties.keys(); | | |||
111 | 110 | | |||
112 | Q_FOREACH(const Property::Property &property, propertiesKeys) { | 111 | QMap<Property::Property, QVariant>::const_iterator i = properties.constBegin(); | ||
bruns: dito, iteration without intermediate list. | |||||
113 | PropertyInfo propertyInfo(property); | 112 | while (i != properties.constEnd()) { | ||
114 | propertiesObject[propertyInfo.name()] = QJsonValue::fromVariant(properties[property]); | 113 | PropertyInfo propertyInfo(i.key()); | ||
114 | propertiesObject[propertyInfo.name()] = QJsonValue::fromVariant(properties[i.key()]); | ||||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | rootObject[QStringLiteral("path")] = QJsonValue(data.inputUrl()); | 117 | rootObject[QStringLiteral("path")] = QJsonValue(data.inputUrl()); | ||
118 | rootObject[QStringLiteral("mimetype")] = data.inputMimetype(); | 118 | rootObject[QStringLiteral("mimetype")] = data.inputMimetype(); | ||
119 | rootObject[QStringLiteral("properties")] = propertiesObject; | 119 | rootObject[QStringLiteral("properties")] = propertiesObject; | ||
120 | writeData.setObject(rootObject); | 120 | writeData.setObject(rootObject); | ||
121 | 121 | | |||
122 | QProcess writerProcess; | 122 | QProcess writerProcess; | ||
Show All 27 Lines |
dito, iteration without intermediate list.