Section.h 2.6 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 10 11 12 13 14 15 16 17
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once

#include "MissionItem.h"
#include "Vehicle.h"
#include "QmlObjectListModel.h"

Q_DECLARE_LOGGING_CATEGORY(SectionLog)

18 19
class PlanMasterController;

20 21 22 23 24 25
// A Section encapsulates a set of mission commands which can be associated with another simple mission item.
class Section : public QObject
{
    Q_OBJECT

public:
26 27 28
    Section(PlanMasterController* masterController, QObject* parent = nullptr)
        : QObject           (parent)
        , _masterController (masterController)
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
    {

    }

    Q_PROPERTY(bool     available           READ available          WRITE setAvailable  NOTIFY availableChanged)
    Q_PROPERTY(bool     settingsSpecified   READ settingsSpecified                      NOTIFY settingsSpecifiedChanged)
    Q_PROPERTY(bool     dirty               READ dirty              WRITE setDirty      NOTIFY availableChanged)

    virtual bool available          (void) const = 0;
    virtual bool settingsSpecified  (void) const = 0;
    virtual bool dirty              (void) const = 0;

    virtual void setAvailable       (bool available) = 0;
    virtual void setDirty           (bool dirty) = 0;

    /// Scans the loaded items for the section items
    ///     @param visualItems Item list
46
    ///     @param scanIndex Index to start scanning from
47
    /// @return true: section found, items added, scanIndex updated
48
    virtual bool scanForSection(QmlObjectListModel* visualItems, int scanIndex) = 0;
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

    /// Appends the mission items associated with this section
    ///     @param items List to append to
    ///     @param missionItemParent QObject parent for created MissionItems
    ///     @param nextSequenceNumber[in,out] Sequence number for first item, updated as items are added
    virtual void appendSectionItems(QList<MissionItem*>& items, QObject* missionItemParent, int& nextSequenceNumber) = 0;

    /// Returns the number of mission items represented by this section.
    ///     Signals: itemCountChanged
    virtual int itemCount(void) const = 0;

signals:
    void availableChanged           (bool available);
    void settingsSpecifiedChanged   (bool settingsSpecified);
    void dirtyChanged               (bool dirty);
    void itemCountChanged           (int itemCount);

protected:
67
    PlanMasterController* _masterController = nullptr;
68
};