From b84dfddd1b24e82dccb5a20d9c30570d26846e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 16 Mar 2013 03:01:51 +0100 Subject: [PATCH] Use the actual selection for instance launch. --- gui/mainwindow.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e691c8c4..676ec45e 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -198,10 +198,18 @@ void MainWindow::on_instanceView_customContextMenuRequested ( const QPoint &pos void MainWindow::on_actionLaunchInstance_triggered() { - QModelIndex index = view->currentIndex(); - if(index.isValid()) + QAbstractItemView * iv = view; + auto smodel = iv->selectionModel(); + QModelIndex mindex; + if(smodel->hasSelection()) { - Instance * inst = (Instance *) index.data(InstanceModel::InstancePointerRole).value(); + auto rows = smodel->selectedRows(); + mindex = rows.at(0); + } + + if(mindex.isValid()) + { + Instance * inst = (Instance *) mindex.data(InstanceModel::InstancePointerRole).value(); doLogin(inst->id()); } }