diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-05-11 19:32:17 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:30 +0200 |
commit | 6d34411f54f8db9fdec2d4a3acc82eedb65f6b36 (patch) | |
tree | 33f0a9a6e12db1bce74663a481e3c9ce6755b137 | |
parent | 68ef451be5a0b8724381187f5aa123d87b82e222 (diff) | |
download | MultiMC-6d34411f54f8db9fdec2d4a3acc82eedb65f6b36.tar MultiMC-6d34411f54f8db9fdec2d4a3acc82eedb65f6b36.tar.gz MultiMC-6d34411f54f8db9fdec2d4a3acc82eedb65f6b36.tar.lz MultiMC-6d34411f54f8db9fdec2d4a3acc82eedb65f6b36.tar.xz MultiMC-6d34411f54f8db9fdec2d4a3acc82eedb65f6b36.zip |
Fix last instance remaining selected when deleted
-rw-r--r-- | gui/MainWindow.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 679938f3..be1b9fd8 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -870,17 +870,14 @@ void MainWindow::updateInstanceToolIcon(QString new_icon) void MainWindow::setSelectedInstanceById(const QString &id) { - QModelIndex selectionIndex = proxymodel->index(0, 0); - if (!id.isNull()) + if (id.isNull()) + return; + const QModelIndex index = MMC->instances()->getInstanceIndexById(id); + if (index.isValid()) { - const QModelIndex index = MMC->instances()->getInstanceIndexById(id); - if (index.isValid()) - { - selectionIndex = proxymodel->mapFromSource(index); - } + QModelIndex selectionIndex = proxymodel->mapFromSource(index); + view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect); } - view->selectionModel()->setCurrentIndex(selectionIndex, - QItemSelectionModel::ClearAndSelect); } void MainWindow::on_actionChangeInstGroup_triggered() @@ -1347,14 +1344,14 @@ void MainWindow::openWebPage(QUrl url) void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous) { - if(!current.isValid()) - { - selectionBad(); - MMC->settings()->set("SelectedInstance", QString()); - return; - } - QString id = current.data(InstanceList::InstanceIDRole).toString(); - m_selectedInstance = MMC->instances()->getInstanceById(id); + if(!current.isValid()) + { + MMC->settings()->set("SelectedInstance", QString()); + selectionBad(); + return; + } + QString id = current.data(InstanceList::InstanceIDRole).toString(); + m_selectedInstance = MMC->instances()->getInstanceById(id); if ( m_selectedInstance ) { ui->instanceToolBar->setEnabled(m_selectedInstance->canLaunch()); @@ -1370,9 +1367,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & } else { - selectionBad(); - MMC->settings()->set("SelectedInstance", QString()); - return; + MMC->settings()->set("SelectedInstance", QString()); + selectionBad(); + return; } } |