diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-05 09:02:02 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-05 09:02:03 +0200 |
commit | e4edadd2dcb0a7a20cdcfa7d4b4b2a2415227245 (patch) | |
tree | cd2adefedba016885a44f50ceaac4eeadab7aaef /examples/knx/feature/mainwindow.cpp | |
parent | 0e4c4e4ddc707384e44e68c3a77479ba11bf61b1 (diff) | |
parent | df0ba9b97c26901f52769381df3c4cbf1fae9ca6 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I573251c84151c29558c1edbbb8c394661f577b63
Diffstat (limited to 'examples/knx/feature/mainwindow.cpp')
-rw-r--r-- | examples/knx/feature/mainwindow.cpp | 12 |
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(); |