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>
8
9class ComponentInformationTranslation : public QObject
10{
11 Q_OBJECT
12#ifdef QGC_UNITTEST_BUILD
13 friend class ComponentInformationTranslationTest; // Unit test
14#endif
15
16public:
17 ComponentInformationTranslation(QObject* parent, QGCCachedFileDownload* cachedFileDownload);
18
25 bool downloadAndTranslate(const QString& summaryJsonFile, const QString& toTranslateJsonFile, int maxCacheAgeSec, const QString& componentName);
26
27 QString translateJsonUsingTS(const QString& toTranslateJsonFile, const QString& tsFile);
28
29signals:
30 void downloadComplete(QString translatedJsonTempFile, QString errorMsg);
31
32private slots:
33 void onDownloadCompleted(bool success, const QString &localFile, QString errorMsg, bool fromCache);
34private:
35 QString getUrlFromSummaryJson(const QString& summaryJsonFile, const QString& locale, const QString& componentName);
36
37 static QJsonObject translate(const QJsonObject& translationObj, const QHash<QString, QString>& translations, QJsonObject doc);
38
39 static QJsonObject translateItems(const QString& prefix, const QJsonObject& defs, const QJsonObject& translationObj,
40 const QHash<QString, QString>& translations, QJsonObject jsonData);
41 static QJsonValue translateTranslationItems(const QString& prefix, const QJsonObject& defs, const QJsonObject& translationObj,
42 const QHash<QString, QString>& translations, QJsonValue jsonData);
43 static QString getRefName(const QString& ref);
44
45 QGCCachedFileDownload* _cachedFileDownload = nullptr;
46 QString _toTranslateJsonFile;
47};
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)
Cached file download with time-based expiration.