summaryrefslogtreecommitdiffstats
path: root/examples/knx/feature/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/knx/feature/mainwindow.cpp')
-rw-r--r--examples/knx/feature/mainwindow.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/knx/feature/mainwindow.cpp b/examples/knx/feature/mainwindow.cpp
index 7e44327..8f32b06 100644
--- a/examples/knx/feature/mainwindow.cpp
+++ b/examples/knx/feature/mainwindow.cpp
@@ -170,13 +170,16 @@ void MainWindow::on_actionImport_triggered()
on_devices_currentIndexChanged(ui->devices->currentIndex());
}
-void MainWindow::on_devices_currentIndexChanged(int /* index */)
+void MainWindow::on_devices_currentIndexChanged(int index)
{
delete m_device;
+ m_device = nullptr;
ui->secureConfigs->clear();
- const auto model = qobject_cast<QStandardItemModel*>(ui->devices->model());
- m_device = static_cast<DeviceItem *> (model->item(ui->devices->currentIndex()))->clone();
+ if (index >= 0) {
+ const auto model = qobject_cast<QStandardItemModel*>(ui->devices->model());
+ m_device = static_cast<DeviceItem *> (model->item(ui->devices->currentIndex()))->clone();
+ }
if (m_device) {
const auto deviceInfo = m_device->info();
@@ -190,6 +193,8 @@ void MainWindow::on_devices_currentIndexChanged(int /* index */)
.arg(config.userId())
.arg(ia.isValid() ? ia.toString() : tr("No specific address")), i);
}
+ } else {
+ m_device = new DeviceItem({});
}
ui->secureConfigs->setEnabled(bool(ui->secureConfigs->count())
@@ -280,6 +285,7 @@ void MainWindow::setupInterfaces()
if (i < 0)
return;
m_discoveryAgent.stop();
+ ui->devices->clear();
m_discoveryAgent.setLocalAddress(QHostAddress(ui->interfaces->currentData()
.toStringList().first()));
m_discoveryAgent.start();