MissionCommandList.h 1.72 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 11 12 13 14 15 16 17 18 19 20 21 22
#ifndef MissionCommandList_H
#define MissionCommandList_H

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

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

23
class MissionCommandUIInfo;
24

25
/// Maintains a list of MissionCommandUIInfo objects loaded from a json file.
26 27 28 29 30
class MissionCommandList : public QObject
{
    Q_OBJECT
    
public:
31 32
    /// @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
33
    MissionCommandList(const QString& jsonFilename, bool baseCommandList, QObject* parent = nullptr);
34

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

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

41
    const QList<MAV_CMD>& commandIds(void) const { return _ids; }
42 43
    
private:
44
    void _loadMavCmdInfoJson(const QString& jsonFilename, bool baseCommandList);
45

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

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

#endif