PlanElementController.cc 1.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

#include "PlanElementController.h"
#include "QGCApplication.h"
12
#include "MultiVehicleManager.h"
13 14 15 16

PlanElementController::PlanElementController(QObject* parent)
    : QObject(parent)
    , _multiVehicleMgr(qgcApp()->toolbox()->multiVehicleManager())
17
    , _activeVehicle(_multiVehicleMgr->offlineEditingVehicle())
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
    , _editMode(false)
{

}

PlanElementController::~PlanElementController()
{

}

void PlanElementController::start(bool editMode)
{
    _editMode = editMode;
    connect(_multiVehicleMgr, &MultiVehicleManager::activeVehicleChanged, this, &PlanElementController::_activeVehicleChanged);
    _activeVehicleChanged(_multiVehicleMgr->activeVehicle());
}

void PlanElementController::_activeVehicleChanged(Vehicle* activeVehicle)
{
    if (_activeVehicle) {
38
        _activeVehicleBeingRemoved();
39
        _activeVehicle = NULL;
40 41
    }

42 43 44 45
    if (activeVehicle) {
        _activeVehicle = activeVehicle;
    } else {
        _activeVehicle = _multiVehicleMgr->offlineEditingVehicle();
46
    }
47
    _activeVehicleSet();
48 49 50 51

    // Whenever vehicle changes we need to update syncInProgress
    emit syncInProgressChanged(syncInProgress());
}