From 414c109d650a1014e7b84dfb66a00df420d67c97 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 20 Jan 2016 16:43:34 +0100 Subject: Remodel section handling: Use constants --- src/dialog.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/dialog.cpp') 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(index.internalPointer()); + if (item->session() == NULL && item->sectionType() == SECTION_GENERIC) { + genericExpandedOnce_ = true; + } +} + void Dialog::addItems(const QList& 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(); } -- cgit v1.2.3-55-g7522