MissionCommandList.h 1.71 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

10
#pragma once
11 12 13 14 15 16 17 18 19 20 21

#include "QGCToolbox.h"
#include "QGCMAVLink.h"
#include "QGCLoggingCategory.h"
#include "QmlObjectListModel.h"

#include <QObject>
#include <QString>
#include <QJsonObject>
#include <QJsonValue>

22
class MissionCommandUIInfo;
23

24
/// Maintains a list of MissionCommandUIInfo objects loaded from a json file.
25 26 27 28 29
class MissionCommandList : public QObject
{
    Q_OBJECT
    
public:
30 31
    /// @param jsonFilename Json file which contains commands
    /// @param baseCommandList true: bottomost level of mission command hierarchy (partial not allowed), false: mid-level of command hierarchy
32
    MissionCommandList(const QString& jsonFilename, bool baseCommandList, QObject* parent = nullptr);
33

34 35
    /// Returns list of categories in this list
    QStringList& categories(void) { return _categories; }
36

37 38
    /// Returns the ui info for specified command, NULL if command not found
    MissionCommandUIInfo* getUIInfo(MAV_CMD command) const;
39

40
    const QList<MAV_CMD>& commandIds(void) const { return _ids; }
41
    
42 43
    static const char* qgcFileType;

44
private:
45
    void _loadMavCmdInfoJson(const QString& jsonFilename, bool baseCommandList);
46

47 48 49
    QMap<MAV_CMD, MissionCommandUIInfo*>    _infoMap;
    QList<MAV_CMD>                          _ids;
    QStringList                             _categories;
50

51 52
    static const char* _versionJsonKey;
    static const char* _mavCmdInfoJsonKey;
53
};