6#include <QtCore/QJsonArray>
11 _loadMavCmdInfoJson(jsonFilename, baseCommandList);
14void MissionCommandList::_loadMavCmdInfoJson(
const QString& jsonFilename,
bool baseCommandList)
16 if (jsonFilename.isEmpty()) {
20 qCDebug(MissionCommandsLog) <<
"Loading" << jsonFilename;
30 QJsonValue jsonValue = jsonObject.value(_mavCmdInfoJsonKey);
31 if (!jsonValue.isArray()) {
32 qWarning() << jsonFilename <<
"mavCmdInfo not array";
37 QJsonArray jsonArray = jsonValue.toArray();
38 for(QJsonValue info: jsonArray) {
39 if (!info.isObject()) {
40 qWarning() << jsonFilename <<
"mavCmdArray should contain objects";
46 QString uiInfoErrorString;
47 if (!uiInfo->
loadJsonInfo(info.toObject(), baseCommandList, uiInfoErrorString)) {
48 uiInfo->deleteLater();
49 qWarning() << jsonFilename << uiInfoErrorString;
54 QString newCategory = uiInfo->
category();
55 if (!newCategory.isEmpty() && !_categories.contains(newCategory)) {
56 _categories.append(newCategory);
59 _infoMap[uiInfo->command()] = uiInfo;
63 for (MAV_CMD
id: _infoMap.keys()) {
70 if (!_infoMap.contains(command)) {
74 return _infoMap[command];
MissionCommandUIInfo * getUIInfo(MAV_CMD command) const
Returns the ui info for specified command, NULL if command not found.
static constexpr const char * qgcFileType
MissionCommandList(const QString &jsonFilename, bool baseCommandList, QObject *parent=nullptr)
bool loadJsonInfo(const QJsonObject &jsonObject, bool requireFullObject, QString &errorString)
QString category(void) const
QJsonObject openInternalQGCJsonFile(const QString &jsonFilename, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString)
returned error string if validation fails