Fix the current index when removing a configured host

This commit is contained in:
Michael Zanetti 2021-07-06 18:09:59 +02:00
parent 0abd282821
commit aad5cc26d8
2 changed files with 6 additions and 1 deletions

View File

@ -120,6 +120,11 @@ void ConfiguredHostsModel::removeHost(int index)
if (m_list.isEmpty()) {
createHost();
}
if (m_currentIndex >= m_list.count()) {
m_currentIndex = m_list.count() - 1;
emit currentIndexChanged();
}
}
int ConfiguredHostsModel::indexOf(ConfiguredHost *host) const

View File

@ -8,7 +8,7 @@ Drawer {
id: root
property ConfiguredHostsModel configuredHosts: null
readonly property Engine currentEngine: configuredHosts.get(configuredHosts.currentIndex).engine
readonly property Engine currentEngine: configuredHosts.count > 0 ? configuredHosts.get(configuredHosts.currentIndex).engine : null
signal openThingSettings();
signal openMagicSettings();