diff options
author | Simon Rettberg | 2016-01-20 16:43:34 +0100 |
---|---|---|
committer | Simon Rettberg | 2016-01-20 16:43:34 +0100 |
commit | 414c109d650a1014e7b84dfb66a00df420d67c97 (patch) | |
tree | ede0c5404aa408cd2bbb626312ed46383c7b13b6 /src/dialog.cpp | |
parent | Re-introduce tree structure: Allow server-defined sections (diff) | |
download | vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.tar.gz vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.tar.xz vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.zip |
Remodel section handling: Use constants
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r-- | src/dialog.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp index 1d497d2..e430be5 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -29,6 +29,7 @@ Dialog::Dialog(int defaultTab, QWidget *parent) defaultTab_ = defaultTab; qDebug() << "Default tab: " << defaultTab; userInteracted_ = false; + genericExpandedOnce_ = false; ui->setupUi(this); @@ -150,6 +151,14 @@ 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) { + genericExpandedOnce_ = true; + } +} + void Dialog::addItems(const QList<Session*>& entries, int tab) { if (tab < 0 || tab > 2) { return; @@ -429,7 +438,7 @@ void Dialog::onTabButtonChanged(int tab) { // give focus to treeView if (!ui->filterEdit->hasFocus()) { - ui->treeView->setFocus(); + ui->filterEdit->setFocus(); } // Update pressed status of buttons @@ -474,7 +483,7 @@ void Dialog::on_filterEdit_textChanged() { } } -void Dialog::setListModel(QAbstractItemModel *model) { +void Dialog::setListModel(SessionTreeModel *model) { QAbstractItemModel *old = NULL; if (ui->treeView->model() == model_[0] || ui->treeView->model() == model_[1] || ui->treeView->model() == model_[2]) { } else { @@ -482,6 +491,12 @@ void Dialog::setListModel(QAbstractItemModel *model) { } ui->treeView->setModel(model); ui->treeView->expandAll(); + if (!genericExpandedOnce_ && g_forLocationHandling == LOCATION_EXCLUSIVE && model->rowCount() > 1) { + QModelIndex index = model->getSection(SECTION_GENERIC); + if (index.isValid()) { + ui->treeView->collapse(index); + } + } if (old != NULL) { old->deleteLater(); } |