Commit e47267e2 authored by Don Gagne's avatar Don Gagne

Change to MVC model

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