Commit 9933b084 authored by Don Gagne's avatar Don Gagne

Merge pull request #1225 from DonLakeFlyer/SetupViewMVC

Change SetupView to MVC model
parents a21bd1d9 e47267e2
......@@ -59,20 +59,7 @@ SetupView::SetupView(QWidget* parent) :
_ui->buttonHolder->setAutoPilot(NULL);
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtons.qml"));
QObject* rootObject = (QObject*)_ui->buttonHolder->rootObject();
Q_ASSERT(rootObject);
fSucceeded = connect(rootObject, SIGNAL(setupButtonClicked(QVariant)), this, SLOT(_setupButtonClicked(QVariant)));
Q_ASSERT(fSucceeded);
fSucceeded = connect(rootObject, SIGNAL(firmwareButtonClicked()), this, SLOT(_firmwareButtonClicked()));
Q_ASSERT(fSucceeded);
fSucceeded = connect(rootObject, SIGNAL(parametersButtonClicked()), this, SLOT(_parametersButtonClicked()));
Q_ASSERT(fSucceeded);
fSucceeded = connect(rootObject, SIGNAL(summaryButtonClicked()), this, SLOT(_summaryButtonClicked()));
Q_ASSERT(fSucceeded);
_ui->buttonHolder->rootContext()->setContextProperty("controller", this);
_setActiveUAS(UASManager::instance()->getActiveUAS());
}
......@@ -91,7 +78,7 @@ void SetupView::_setActiveUAS(UASInterface* uas)
_autoPilotPlugin = NULL;
_ui->buttonHolder->setAutoPilot(NULL);
_firmwareButtonClicked();
firmwareButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("firmwareButton");
Q_ASSERT(button);
button->setProperty("checked", true);
......@@ -111,7 +98,7 @@ void SetupView::_setActiveUAS(UASInterface* uas)
void SetupView::_pluginReady(void)
{
_ui->buttonHolder->setAutoPilot(_autoPilotPlugin);
_summaryButtonClicked();
summaryButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("summaryButton");
Q_ASSERT(button);
button->setProperty("checked", true);
......@@ -126,7 +113,7 @@ void SetupView::_changeSetupWidget(QWidget* newWidget)
_ui->setupWidgetLayout->addWidget(newWidget);
}
void SetupView::_firmwareButtonClicked(void)
void SetupView::firmwareButtonClicked(void)
{
if (_uasCurrent && _uasCurrent->isArmed()) {
QGCMessageBox::warning("Setup", "Firmware Update cannot be performed while vehicle is armed.");
......@@ -146,13 +133,13 @@ void SetupView::_firmwareButtonClicked(void)
_changeSetupWidget(setup);
}
void SetupView::_parametersButtonClicked(void)
void SetupView::parametersButtonClicked(void)
{
ParameterEditor* setup = new ParameterEditor(_uasCurrent, QStringList(), this);
_changeSetupWidget(setup);
}
void SetupView::_summaryButtonClicked(void)
void SetupView::summaryButtonClicked(void)
{
Q_ASSERT(_autoPilotPlugin);
......@@ -165,7 +152,7 @@ void SetupView::_summaryButtonClicked(void)
_changeSetupWidget(summary);
}
void SetupView::_setupButtonClicked(const QVariant& component)
void SetupView::setupButtonClicked(const QVariant& component)
{
if (_uasCurrent->isArmed()) {
QGCMessageBox::warning("Setup", "Setup cannot be performed while vehicle is armed.");
......
......@@ -47,13 +47,14 @@ public:
explicit SetupView(QWidget* parent = 0);
~SetupView();
Q_INVOKABLE void firmwareButtonClicked(void);
Q_INVOKABLE void parametersButtonClicked(void);
Q_INVOKABLE void summaryButtonClicked(void);
Q_INVOKABLE void setupButtonClicked(const QVariant& component);
private slots:
void _setActiveUAS(UASInterface* uas);
void _pluginReady(void);
void _firmwareButtonClicked(void);
void _parametersButtonClicked(void);
void _summaryButtonClicked(void);
void _setupButtonClicked(const QVariant& component);
private:
void _changeSetupWidget(QWidget* newWidget);
......
......@@ -13,11 +13,6 @@ Rectangle {
QGCPalette { id: palette; colorGroup: QGCPalette.Active }
color: palette.window
signal firmwareButtonClicked;
signal summaryButtonClicked;
signal parametersButtonClicked;
signal setupButtonClicked(variant component);
ExclusiveGroup { id: setupButtonGroup }
Component {
......@@ -34,7 +29,7 @@ Rectangle {
text: "FIRMWARE"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: topLevel.firmwareButtonClicked()
onClicked: controller.firmwareButtonClicked()
}
}
}
......@@ -53,7 +48,7 @@ Rectangle {
text: "SUMMARY"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: topLevel.summaryButtonClicked()
onClicked: controller.summaryButtonClicked()
}
SetupButton {
......@@ -62,7 +57,7 @@ Rectangle {
text: "FIRMWARE"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: topLevel.firmwareButtonClicked()
onClicked: controller.firmwareButtonClicked()
}
Repeater {
......@@ -73,7 +68,7 @@ Rectangle {
text: modelData.name.toUpperCase()
setupComplete: modelData.setupComplete
exclusiveGroup: setupButtonGroup
onClicked: topLevel.setupButtonClicked(modelData)
onClicked: controller.setupButtonClicked(modelData)
}
}
......@@ -82,7 +77,7 @@ Rectangle {
text: "PARAMETERS"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: topLevel.parametersButtonClicked()
onClicked: controller.parametersButtonClicked()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment