summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorChristian Klinger2016-08-03 10:33:38 +0200
committerChristian Klinger2016-08-03 10:33:38 +0200
commit2448ecd6b87c24fe1203b80a014432ae816a9e9f (patch)
tree32b0e992175e59d711232bf8efe1f2dd6659ee1c /src/dialog.cpp
parentParse XML reply for help text (just like news) (diff)
downloadvmchooser2-2448ecd6b87c24fe1203b80a014432ae816a9e9f.tar.gz
vmchooser2-2448ecd6b87c24fe1203b80a014432ae816a9e9f.tar.xz
vmchooser2-2448ecd6b87c24fe1203b80a014432ae816a9e9f.zip
added --start-uuid parameter.
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index aefb6f9..87eae8e 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -250,6 +250,46 @@ bool Dialog::selectSession(const QString& name) {
return false;
}
+bool Dialog::selectSessionByUuid(const QString& name) {
+ QModelIndex root(ui->treeView->rootIndex());
+
+ for (int tab = 0; tab <= TAB_COUNT; ++tab) {
+ for (int i = 0; i < model_[tab]->rowCount(root); ++i) {
+ QModelIndex section(model_[tab]->index(i, 0, root));
+ if (!section.isValid()) {
+ break;
+ }
+ for (int j = 0; j < model_[tab]->rowCount(section); ++j) {
+ QModelIndex index(model_[tab]->index(j, 0, section));
+ SessionTreeItem* item = static_cast<SessionTreeItem*>(index.internalPointer());
+ const Session* s(item->session());
+ if (s == NULL) {
+ continue;
+ }
+ /* TODO: implement this here */
+ /* check if it is a vsession, then access the uuid and compare with name*/
+ if (s->type() == Session::VSESSION) {
+ /* cast to vsession */
+ const VSession* v = static_cast<const VSession*>(s);
+ if (v->uuid() == name) {
+ // change the tab
+ onTabButtonChanged(tab);
+ // set selection
+ ui->treeView->selectionModel()->clearSelection();
+ ui->treeView->selectionModel()->clear();
+ ui->treeView->selectionModel()->select(index, QItemSelectionModel::Select);
+ ui->treeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select);
+ ui->treeView->scrollTo(index);
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
void Dialog::selectPreviousSession() {
if (userInteracted_) {
qDebug() << "Not selecting previous session as user interacted or session was already selected";
@@ -315,7 +355,7 @@ void Dialog::setTheme() {
void Dialog::onCenterTimer() {
if (!autoStartEntry_.isEmpty()) {
- if (this->selectSession(autoStartEntry_)) {
+ if (this->selectSessionByUuid(autoStartEntry_) || this->selectSession(autoStartEntry_)) {
this->on_treeView_doubleClicked(ui->treeView->selectionModel()->currentIndex());
} else {
QMessageBox::critical(this, "Autostart", QString::fromUtf8("Konnte %1 nicht starten.").arg(autoStartEntry_));