Fix last instance remaining selected when deleted
This commit is contained in:
parent
68ef451be5
commit
6d34411f54
@ -870,17 +870,14 @@ void MainWindow::updateInstanceToolIcon(QString new_icon)
|
|||||||
|
|
||||||
void MainWindow::setSelectedInstanceById(const QString &id)
|
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);
|
QModelIndex selectionIndex = proxymodel->mapFromSource(index);
|
||||||
if (index.isValid())
|
view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect);
|
||||||
{
|
|
||||||
selectionIndex = proxymodel->mapFromSource(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
view->selectionModel()->setCurrentIndex(selectionIndex,
|
|
||||||
QItemSelectionModel::ClearAndSelect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionChangeInstGroup_triggered()
|
void MainWindow::on_actionChangeInstGroup_triggered()
|
||||||
@ -1347,14 +1344,14 @@ void MainWindow::openWebPage(QUrl url)
|
|||||||
|
|
||||||
void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||||
{
|
{
|
||||||
if(!current.isValid())
|
if(!current.isValid())
|
||||||
{
|
{
|
||||||
selectionBad();
|
MMC->settings()->set("SelectedInstance", QString());
|
||||||
MMC->settings()->set("SelectedInstance", QString());
|
selectionBad();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString id = current.data(InstanceList::InstanceIDRole).toString();
|
QString id = current.data(InstanceList::InstanceIDRole).toString();
|
||||||
m_selectedInstance = MMC->instances()->getInstanceById(id);
|
m_selectedInstance = MMC->instances()->getInstanceById(id);
|
||||||
if ( m_selectedInstance )
|
if ( m_selectedInstance )
|
||||||
{
|
{
|
||||||
ui->instanceToolBar->setEnabled(m_selectedInstance->canLaunch());
|
ui->instanceToolBar->setEnabled(m_selectedInstance->canLaunch());
|
||||||
@ -1370,9 +1367,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selectionBad();
|
MMC->settings()->set("SelectedInstance", QString());
|
||||||
MMC->settings()->set("SelectedInstance", QString());
|
selectionBad();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user