8#include <QJsonDocument>
14#include <unordered_map>
21 for (
const auto &
item : jsonArray) {
43 std::wcerr <<
"Trying to read translation catalogs from \""
58 if (!document.isArray()) {
71 catalogs.emplace_back(std::move(catalog));
92 if (!document.isObject()) {
116 bool verbose,
QString *errorString)
121 std::wcerr <<
"Warning: Translations will not be available due to the following error."
122 << std::endl << *errorString << std::endl;
123 errorString->
clear();
125 std::unordered_map<QString, QString> moduleToCatalogMap;
126 std::unordered_map<QString, QString> repositoryToCatalogMap;
128 for (
const QString &module : catalog.modules) {
129 moduleToCatalogMap.insert(std::make_pair(module, catalog.name));
131 for (
const QString &repository : catalog.repositories) {
132 repositoryToCatalogMap.insert(std::make_pair(repository, catalog.name));
138 while (dit.hasNext()) {
145 module.
id = modules.size();
147 *errorString =
"Internal Error: too many modules for ModuleBitset to hold."_L1;
152 auto it = moduleToCatalogMap.
find(module.
name);
153 if (
it != moduleToCatalogMap.
end())
158 if (
it != repositoryToCatalogMap.
end())
163 modules.emplace_back(std::move(module));
171 return modules.at(
id);
176 auto moduleHasPluginType = [&pluginType] (
const QtModule &module) {
177 return module.pluginTypes.contains(pluginType);
180 auto it = std::find_if(modules.begin(), modules.end(), moduleHasPluginType);
181 if (
it != modules.end())
The QDirIterator class provides an iterator for directory entrylists.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QString fileName() const override
Returns the name set by setFileName() or to the QFile constructors.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
iterator find(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool populate(const QString &modulesDir, const QString &translationsDir, bool verbose, QString *errorString)
const QtModule & moduleById(size_t id) const
size_t moduleIdForPluginType(const QString &pluginType) const
QSet< QString >::iterator it
static QString dump(const QByteArray &)
#define qUtf8Printable(string)
QLatin1StringView QLatin1String
static QtModule moduleFromJsonFile(const QString &filePath, QString *errorString)
std::vector< TranslationCatalog > TranslationCatalogs
static TranslationCatalogs readTranslationsCatalogs(const QString &translationsDir, bool verbose, QString *errorString)
static QStringList toStringList(const QJsonArray &jsonArray)
static void dump(const QtModule &module)
\inmodule QtCore\reentrant
QString errorString() const
\variable QJsonParseError::error
static constexpr size_t InvalidId
QString translationCatalog