MissionCommandList.h 1.75 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * 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 23
#ifndef MissionCommandList_H
#define MissionCommandList_H

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

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

24
class MissionCommandUIInfo;
25

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

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

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

42
    const QList<MAV_CMD>& commandIds(void) const { return _ids; }
43 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 54 55
};

#endif