QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ComponentInformationTranslation.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QJsonObject>
4#include <QtCore/QHash>
5#include <QtCore/QObject>
6#include <QtCore/QString>
7#include <QtCore/QLoggingCategory>
8
9Q_DECLARE_LOGGING_CATEGORY(ComponentInformationTranslationLog)
10
12
13class ComponentInformationTranslation : public QObject
14{
15 Q_OBJECT
16#ifdef QGC_UNITTEST_BUILD
17 friend class ComponentInformationTranslationTest; // Unit test
18#endif
19
20public:
21 ComponentInformationTranslation(QObject* parent, QGCCachedFileDownload* cachedFileDownload);
22
29 bool downloadAndTranslate(const QString& summaryJsonFile, const QString& toTranslateJsonFile, int maxCacheAgeSec, const QString& componentName);
30
31 QString translateJsonUsingTS(const QString& toTranslateJsonFile, const QString& tsFile);
32
33signals:
34 void downloadComplete(QString translatedJsonTempFile, QString errorMsg);
35
36private slots:
37 void onDownloadCompleted(bool success, const QString &localFile, QString errorMsg, bool fromCache);
38private:
39 QString getUrlFromSummaryJson(const QString& summaryJsonFile, const QString& locale, const QString& componentName);
40
41 static QJsonObject translate(const QJsonObject& translationObj, const QHash<QString, QString>& translations, QJsonObject doc);
42
43 static QJsonObject translateItems(const QString& prefix, const QJsonObject& defs, const QJsonObject& translationObj,
44 const QHash<QString, QString>& translations, QJsonObject jsonData);
45 static QJsonValue translateTranslationItems(const QString& prefix, const QJsonObject& defs, const QJsonObject& translationObj,
46 const QHash<QString, QString>& translations, QJsonValue jsonData);
47 static QString getRefName(const QString& ref);
48
49 QGCCachedFileDownload* _cachedFileDownload = nullptr;
50 QString _toTranslateJsonFile;
51};
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
void downloadComplete(QString translatedJsonTempFile, QString errorMsg)
bool downloadAndTranslate(const QString &summaryJsonFile, const QString &toTranslateJsonFile, int maxCacheAgeSec, const QString &componentName)
QString translateJsonUsingTS(const QString &toTranslateJsonFile, const QString &tsFile)