summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2016-01-21 13:12:22 +0100
committerSimon Rettberg2016-01-21 13:12:22 +0100
commit9fe4ddf06e0d46b9bd9bf2565299e8bef9b4a989 (patch)
treec9750a9759b054a577e4ef98ef77af27bf73fcff /src/dialog.cpp
parentFix copy paste messup (diff)
downloadvmchooser2-9fe4ddf06e0d46b9bd9bf2565299e8bef9b4a989.tar.gz
vmchooser2-9fe4ddf06e0d46b9bd9bf2565299e8bef9b4a989.tar.xz
vmchooser2-9fe4ddf06e0d46b9bd9bf2565299e8bef9b4a989.zip
Collapse templates aswell in location exclusive mode
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp41
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();