Changeset View
Changeset View
Standalone View
Standalone View
src/externalextractor.cpp
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 106 | { | |||
---|---|---|---|---|---|
142 | 142 | | |||
143 | QJsonDocument extractorData = QJsonDocument::fromJson(output); | 143 | QJsonDocument extractorData = QJsonDocument::fromJson(output); | ||
144 | if (!extractorData.isObject()) { | 144 | if (!extractorData.isObject()) { | ||
145 | return; | 145 | return; | ||
146 | } | 146 | } | ||
147 | QJsonObject rootObject = extractorData.object(); | 147 | QJsonObject rootObject = extractorData.object(); | ||
148 | QJsonObject propertiesObject = rootObject[QStringLiteral("properties")].toObject(); | 148 | QJsonObject propertiesObject = rootObject[QStringLiteral("properties")].toObject(); | ||
149 | 149 | | |||
150 | Q_FOREACH(const auto &key, propertiesObject.keys()) { | 150 | const auto propertiesObjectEnd = propertiesObject.constEnd(); | ||
bruns: Can you change this to iterate over the entries, without intermediate list? | |||||
151 | if (key == QStringLiteral("typeInfo")) { | 151 | auto i = propertiesObject.constBegin(); | ||
152 | TypeInfo info = TypeInfo::fromName(propertiesObject.value(key).toString()); | 152 | for (; i != propertiesObjectEnd; ++i) { | ||
153 | if (i.key() == QStringLiteral("typeInfo")) { | ||||
154 | TypeInfo info = TypeInfo::fromName(propertiesObject.value(i.key()).toString()); | ||||
153 | result->addType(info.type()); | 155 | result->addType(info.type()); | ||
154 | continue; | 156 | continue; | ||
155 | } | 157 | } | ||
156 | 158 | | |||
157 | // for plaintext extraction | 159 | // for plaintext extraction | ||
158 | if (key == QStringLiteral("text")) { | 160 | if (i.key() == QStringLiteral("text")) { | ||
159 | result->append(propertiesObject.value(key).toString(QStringLiteral(""))); | 161 | result->append(propertiesObject.value(i.key()).toString(QStringLiteral(""))); | ||
160 | continue; | 162 | continue; | ||
161 | } | 163 | } | ||
162 | 164 | | |||
163 | PropertyInfo info = PropertyInfo::fromName(key); | 165 | PropertyInfo info = PropertyInfo::fromName(i.key()); | ||
164 | if (info.name() != key) { | 166 | if (info.name() != i.key()) { | ||
165 | continue; | 167 | continue; | ||
166 | } | 168 | } | ||
167 | result->add(info.property(), propertiesObject.value(key).toVariant()); | 169 | result->add(info.property(), i.value().toVariant()); | ||
168 | } | 170 | } | ||
169 | 171 | | |||
170 | if (rootObject[QStringLiteral("status")].toString() != QStringLiteral("OK")) { | 172 | if (rootObject[QStringLiteral("status")].toString() != QStringLiteral("OK")) { | ||
171 | qCDebug(KFILEMETADATA_LOG) << rootObject[QStringLiteral("error")].toString(); | 173 | qCDebug(KFILEMETADATA_LOG) << rootObject[QStringLiteral("error")].toString(); | ||
172 | } | 174 | } | ||
173 | } | 175 | } |
Can you change this to iterate over the entries, without intermediate list?