6#include <QtCore/QJsonArray>
13 _loadMavCmdInfoJson(jsonFilename, baseCommandList);
16void MissionCommandList::_loadMavCmdInfoJson(
const QString& jsonFilename,
bool baseCommandList)
18 if (jsonFilename.isEmpty()) {
22 qCDebug(MissionCommandListLog) <<
"Loading" << jsonFilename;
28 QStringList{
"label",
"enumStrings",
"friendlyName",
"description",
"category"},
29 QStringList{
"rawName",
"comment"});
35 QJsonValue jsonValue = jsonObject.value(_mavCmdInfoJsonKey);
36 if (!jsonValue.isArray()) {
37 qWarning() << jsonFilename <<
"mavCmdInfo not array";
42 QJsonArray jsonArray = jsonValue.toArray();
43 for(QJsonValue info: jsonArray) {
44 if (!info.isObject()) {
45 qWarning() << jsonFilename <<
"mavCmdArray should contain objects";
51 QString uiInfoErrorString;
52 if (!uiInfo->
loadJsonInfo(info.toObject(), baseCommandList, uiInfoErrorString)) {
53 uiInfo->deleteLater();
54 qWarning() << jsonFilename << uiInfoErrorString;
59 QString newCategory = uiInfo->
category();
60 if (!newCategory.isEmpty() && !_categories.contains(newCategory)) {
61 _categories.append(newCategory);
64 _infoMap[uiInfo->
command()] = uiInfo;
68 for (MAV_CMD
id: _infoMap.keys()) {
75 if (!_infoMap.contains(command)) {
79 return _infoMap[command];
#define QGC_LOGGING_CATEGORY(name, categoryStr)
Maintains a list of MissionCommandUIInfo objects loaded from a json file.
MissionCommandUIInfo * getUIInfo(MAV_CMD command) const
Returns the ui info for specified command, NULL if command not found.
static constexpr const char * qgcFileType
UI Information associated with a mission command (MAV_CMD)
bool loadJsonInfo(const QJsonObject &jsonObject, bool requireFullObject, QString &errorString)
MAV_CMD command(void) const
QString category(void) const
QJsonObject openInternalQGCJsonFile(const QString &jsonFilename, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString, const QStringList &defaultTranslateKeys, const QStringList &defaultArrayIDKeys)