diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dialog.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
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<SessionTreeItem*>(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<SessionTreeItem*>(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<SessionTreeItem*>(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(); |