Commit 2065178e authored by Volker Krause's avatar Volker Krause
Browse files

Add a method to store multi-extractor files

This is needed by KItinerary Workbench, to remove its limitation of not
being able to modify such files so far.
parent bc6feff8
...@@ -341,3 +341,28 @@ void ExtractorRepository::setAdditionalSearchPaths(const QStringList& searchPath ...@@ -341,3 +341,28 @@ void ExtractorRepository::setAdditionalSearchPaths(const QStringList& searchPath
{ {
d->m_extraSearchPaths = searchPaths; d->m_extraSearchPaths = searchPaths;
} }
QJsonValue ExtractorRepository::extractorToJson(const Extractor &extractor) const
{
QJsonArray a;
bool added = false;
for (const auto &e : d->m_extractors) {
if (e.fileName() != extractor.fileName()) {
continue;
}
if (extractor.name() == e.name()) {
a.push_back(extractor.toJson());
added = true;
} else {
a.push_back(e.toJson());
}
}
if (!added) {
a.push_back(extractor.toJson());
}
if (a.size() == 1) {
return a.at(0);
}
return a;
}
...@@ -39,6 +39,7 @@ class Pass; ...@@ -39,6 +39,7 @@ class Pass;
} }
class QJsonArray; class QJsonArray;
class QJsonValue;
class QString; class QString;
class QStringList; class QStringList;
...@@ -89,6 +90,13 @@ public: ...@@ -89,6 +90,13 @@ public:
/** Sets additional search paths to look for extractors. */ /** Sets additional search paths to look for extractors. */
void setAdditionalSearchPaths(const QStringList &searchPaths); void setAdditionalSearchPaths(const QStringList &searchPaths);
///@cond internal
/** JSON serialization of @p extractor, including all other Extractor definitions in the same file, if any.
* Only for tooling, do not use otherwise.
*/
QJsonValue extractorToJson(const Extractor &extractor) const;
///@endcond
private: private:
ExtractorRepositoryPrivate* d; ExtractorRepositoryPrivate* d;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment