From 2448ecd6b87c24fe1203b80a014432ae816a9e9f Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Wed, 3 Aug 2016 10:33:38 +0200 Subject: added --start-uuid parameter. --- src/dialog.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/dialog.cpp') 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(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(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_)); -- cgit v1.2.3-55-g7522