From 26396dcf05762b6077ebc017e7fe0ca685c769aa Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Fri, 15 Apr 2016 11:40:48 +0200 Subject: Changed the AirflowDirection to be Flags instead of a enum Also renamed the values to make it possible to use all commonly used combinations of AirflowDirections Change-Id: If0447be66a618925deb0d249c3171f1b16ed2984 Reviewed-by: Robert Griebl --- examples/vehiclefunctions/climate_qml/main.qml | 51 +++++++--------- .../vehiclefunctions/climate_widget/mainwindow.cpp | 69 +++++++++------------- .../vehiclefunctions/climate_widget/mainwindow.h | 6 +- .../vehiclefunctions/climate_widget/mainwindow.ui | 21 +++---- 4 files changed, 60 insertions(+), 87 deletions(-) (limited to 'examples') diff --git a/examples/vehiclefunctions/climate_qml/main.qml b/examples/vehiclefunctions/climate_qml/main.qml index 2ac10f0..7776b01 100644 --- a/examples/vehiclefunctions/climate_qml/main.qml +++ b/examples/vehiclefunctions/climate_qml/main.qml @@ -81,48 +81,39 @@ ApplicationWindow { ColumnLayout { anchors.fill: parent - ExclusiveGroup { id: group } - RadioButton { - text: "Floor Panel" - exclusiveGroup: group - checked: climateControl.airflowDirection.value === ClimateControl.FloorPanel - enabled: climateControl.airflowDirection.availableValues.indexOf(ClimateControl.FloorPanel) !== -1 + CheckBox { + text: "Windshield" + checked: climateControl.airflowDirections.value & ClimateControl.Windshield + enabled: climateControl.airflowDirections.availableValues.indexOf(ClimateControl.Windshield) !== -1 onClicked: { if (checked) - climateControl.airflowDirection.value = ClimateControl.FloorPanel + climateControl.airflowDirections.value |= ClimateControl.Windshield + else + climateControl.airflowDirections.value &= ~ClimateControl.Windshield } } - RadioButton { - text: "Floor Duct" - exclusiveGroup: group - checked: climateControl.airflowDirection.value === ClimateControl.FloorDuct - enabled: climateControl.airflowDirection.availableValues.indexOf(ClimateControl.FloorDuct) !== -1 + CheckBox { + text: "Dashboard" + checked: climateControl.airflowDirections.value & ClimateControl.Dashboard + enabled: climateControl.airflowDirections.availableValues.indexOf(ClimateControl.Dashboard) !== -1 onClicked: { if (checked) - climateControl.airflowDirection.value = ClimateControl.FloorDuct + climateControl.airflowDirections.value |= ClimateControl.Dashboard + else + climateControl.airflowDirections.value &= ~ClimateControl.Dashboard } } - RadioButton { - text: "Bi Level" - exclusiveGroup: group - checked: climateControl.airflowDirection.value === ClimateControl.BiLevel - enabled: climateControl.airflowDirection.availableValues.indexOf(ClimateControl.BiLevel) !== -1 + CheckBox { + text: "Floor" + checked: climateControl.airflowDirections.value & ClimateControl.Floor + enabled: climateControl.airflowDirections.availableValues.indexOf(ClimateControl.Floor) !== -1 onClicked: { if (checked) - climateControl.airflowDirection.value = ClimateControl.BiLevel - } - } - - RadioButton { - text: "Defrost Floor" - exclusiveGroup: group - checked: climateControl.airflowDirection.value === ClimateControl.DefrostFloor - enabled: climateControl.airflowDirection.availableValues.indexOf(ClimateControl.DefrostFloor) !== -1 - onClicked: { - if (checked) - climateControl.airflowDirection.value = ClimateControl.DefrostFloor + climateControl.airflowDirections.value |= ClimateControl.Floor + else + climateControl.airflowDirections.value &= ~ClimateControl.Floor } } } diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.cpp b/examples/vehiclefunctions/climate_widget/mainwindow.cpp index af43331..66ac611 100644 --- a/examples/vehiclefunctions/climate_widget/mainwindow.cpp +++ b/examples/vehiclefunctions/climate_widget/mainwindow.cpp @@ -60,15 +60,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - m_radioButtonGroup(new QButtonGroup(this)), + m_buttonGroup(new QButtonGroup(this)), m_climateControl(0) { ui->setupUi(this); - m_radioButtonGroup->addButton(ui->rb_BiLevel); - m_radioButtonGroup->addButton(ui->rb_DefrostFloor); - m_radioButtonGroup->addButton(ui->rb_FloorDuct); - m_radioButtonGroup->addButton(ui->rb_FloorPanel); + m_buttonGroup->setExclusive(false); + m_buttonGroup->addButton(ui->cb_windshield); + m_buttonGroup->addButton(ui->cb_dashboard); + m_buttonGroup->addButton(ui->cb_floor); //![1] m_climateControl = new QtIVIClimateControl(QString(), this); @@ -80,13 +80,14 @@ MainWindow::MainWindow(QWidget *parent) : //![2] //Air Flow Direction - setupFlowDirectionRadioButtons(m_climateControl->airflowDirection()); - setupFlowDirectionAttribute(m_climateControl->airflowDirectionAttribute()); - connect(m_radioButtonGroup, static_cast(&QButtonGroup::buttonToggled), + setupFlowDirectionRadioButtons(m_climateControl->airflowDirections()); + setupFlowDirectionAttribute(m_climateControl->airflowDirectionsAttribute()); + connect(m_buttonGroup, static_cast(&QButtonGroup::buttonToggled), this, &MainWindow::onFlowDirectionButtonToggled); - connect(m_climateControl, &QtIVIClimateControl::airflowDirectionChanged, + + connect(m_climateControl, &QtIVIClimateControl::airflowDirectionsChanged, this, &MainWindow::setupFlowDirectionRadioButtons); - connect(m_climateControl, &QtIVIClimateControl::airflowDirectionAttributeChanged, + connect(m_climateControl, &QtIVIClimateControl::airflowDirectionsAttributeChanged, this, &MainWindow::setupFlowDirectionAttribute); //Air Condition @@ -142,46 +143,34 @@ void MainWindow::onAirConditioningAttributeChanged(const QtIVIPropertyAttribute< } //![3] -void MainWindow::setupFlowDirectionRadioButtons(QtIVIClimateControl::AirflowDirection direction) +void MainWindow::setupFlowDirectionRadioButtons(QtIVIClimateControl::AirflowDirections direction) { - QAbstractButton* button = ui->rb_BiLevel; - - if (direction == QtIVIClimateControl::BiLevel) - button = ui->rb_BiLevel; - else if (direction == QtIVIClimateControl::DefrostFloor) - button = ui->rb_DefrostFloor; - else if (direction == QtIVIClimateControl::FloorDuct) - button = ui->rb_FloorDuct; - else if (direction == QtIVIClimateControl::FloorPanel) - button = ui->rb_FloorPanel; - - button->setChecked(true); + ui->cb_windshield->setChecked(direction.testFlag(QtIVIClimateControl::Windshield)); + ui->cb_dashboard->setChecked(direction.testFlag(QtIVIClimateControl::Dashboard)); + ui->cb_floor->setChecked(direction.testFlag(QtIVIClimateControl::Floor)); } -void MainWindow::setupFlowDirectionAttribute(const QtIVIPropertyAttribute & attribute) +void MainWindow::setupFlowDirectionAttribute(const QtIVIPropertyAttribute & attribute) { - ui->rb_BiLevel->setEnabled(attribute.availableValues().contains(QtIVIClimateControl::BiLevel)); - ui->rb_DefrostFloor->setEnabled(attribute.availableValues().contains(QtIVIClimateControl::DefrostFloor)); - ui->rb_FloorDuct->setEnabled(attribute.availableValues().contains(QtIVIClimateControl::FloorDuct)); - ui->rb_FloorPanel->setEnabled(attribute.availableValues().contains(QtIVIClimateControl::FloorPanel)); + ui->cb_windshield->setEnabled(attribute.availableValues().contains(QtIVIClimateControl::Windshield)); + ui->cb_dashboard->setEnabled(attribute.availableValues().contains(QtIVIClimateControl::Dashboard)); + ui->cb_floor->setEnabled(attribute.availableValues().contains(QtIVIClimateControl::Floor)); } void MainWindow::onFlowDirectionButtonToggled(QAbstractButton *button, bool checked) { - if (!checked) - return; + Q_UNUSED(button) + Q_UNUSED(checked) - QtIVIClimateControl::AirflowDirection direction = QtIVIClimateControl::BiLevel; + QtIVIClimateControl::AirflowDirections direction; - if (button == ui->rb_BiLevel) - direction = QtIVIClimateControl::BiLevel; - else if (button == ui->rb_DefrostFloor) - direction = QtIVIClimateControl::DefrostFloor; - else if (button == ui->rb_FloorDuct) - direction = QtIVIClimateControl::FloorDuct; - else if (button == ui->rb_FloorPanel) - direction = QtIVIClimateControl::FloorPanel; + if (ui->cb_windshield->isChecked()) + direction |= QtIVIClimateControl::Windshield; + if (ui->cb_dashboard->isChecked()) + direction |= QtIVIClimateControl::Dashboard; + if (ui->cb_floor->isChecked()) + direction |= QtIVIClimateControl::Floor; - m_climateControl->setAirflowDirection(direction); + m_climateControl->setAirflowDirections(direction); } //![3] diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.h b/examples/vehiclefunctions/climate_widget/mainwindow.h index af17946..65d936a 100644 --- a/examples/vehiclefunctions/climate_widget/mainwindow.h +++ b/examples/vehiclefunctions/climate_widget/mainwindow.h @@ -77,13 +77,13 @@ private slots: void onAirRecirculationAttributeChanged(const QtIVIPropertyAttribute &attribute); void onHeaterAttributeChanged(const QtIVIPropertyAttribute &attribute); void onAirConditioningAttributeChanged(const QtIVIPropertyAttribute &attribute); - void setupFlowDirectionRadioButtons(QtIVIClimateControl::AirflowDirection direction); - void setupFlowDirectionAttribute(const QtIVIPropertyAttribute &attribute); + void setupFlowDirectionRadioButtons(QtIVIClimateControl::AirflowDirections direction); + void setupFlowDirectionAttribute(const QtIVIPropertyAttribute &attribute); void onFlowDirectionButtonToggled(QAbstractButton * button, bool checked); private: Ui::MainWindow *ui; - QButtonGroup *m_radioButtonGroup; + QButtonGroup *m_buttonGroup; QtIVIClimateControl* m_climateControl; }; diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.ui b/examples/vehiclefunctions/climate_widget/mainwindow.ui index 88e7331..7f53ae2 100644 --- a/examples/vehiclefunctions/climate_widget/mainwindow.ui +++ b/examples/vehiclefunctions/climate_widget/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 384 - 236 + 238 @@ -22,30 +22,23 @@ - + - Floor Panel + Windshield - + - Floor Duct + Dashboard - + - Bi &Level - - - - - - - Defrost Floor + Floor -- cgit v1.2.1