From 9fe4ddf06e0d46b9bd9bf2565299e8bef9b4a989 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 21 Jan 2016 13:12:22 +0100 Subject: Collapse templates aswell in location exclusive mode --- src/dialog.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/dialog.cpp') diff --git a/src/dialog.cpp b/src/dialog.cpp index e430be5..39f0d6c 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -154,7 +154,7 @@ void Dialog::on_treeView_doubleClicked(const QModelIndex& index) void Dialog::on_treeView_expanded(const QModelIndex& index) { SessionTreeItem* item = static_cast(index.internalPointer()); - if (item->session() == NULL && item->sectionType() == SECTION_GENERIC) { + if (item->session() == NULL && item->sectionType() != SECTION_FOR_LOCATION) { genericExpandedOnce_ = true; } } @@ -209,24 +209,27 @@ bool Dialog::selectSession(const QString& name) { for (int tab = 0; tab <= TAB_COUNT; ++tab) { for (int i = 0; i < model_[tab]->rowCount(root); ++i) { - QModelIndex index = model_[tab]->index(i, 0, root); - if (!index.isValid()) { + QModelIndex section(model_[tab]->index(i, 0, root)); + if (!section.isValid()) { break; } - SessionTreeItem* item = static_cast(index.internalPointer()); - const Session* s(item->session()); - if (!s) { - continue; - } - if (s->shortDescription() == 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); - return true; + 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; + } + if (s->shortDescription() == 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); + return true; + } } } } @@ -496,6 +499,10 @@ void Dialog::setListModel(SessionTreeModel *model) { if (index.isValid()) { ui->treeView->collapse(index); } + index = model->getSection(SECTION_TEMPLATES); + if (index.isValid()) { + ui->treeView->collapse(index); + } } if (old != NULL) { old->deleteLater(); -- cgit v1.2.3-55-g7522