From 615ca2f927e8a4c4b5b0591495e7c9417231cab3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 5 Jun 2019 16:17:16 +0200 Subject: Don't group by type in "recent" tab --- src/dialog.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/dialog.cpp') diff --git a/src/dialog.cpp b/src/dialog.cpp index 5e7a6b0..984b7ad 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -28,7 +28,7 @@ static bool isProcessRunning(const QString &binary); Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { model_[TAB_NATIVE] = new SessionTreeModel(parent); - model_[TAB_RECENT_COURSES] = new SessionTreeModel(parent); + model_[TAB_RECENT_COURSES] = new SessionTreeModel(parent, true); model_[TAB_ALL_VMS] = new SessionTreeModel(parent); userInteracted_ = false; genericExpandedOnce_ = false; @@ -215,10 +215,12 @@ void Dialog::on_treeView_expanded(const QModelIndex& index) { } void Dialog::addItems(const QList& entries, int tab) { - if (tab < 0 || tab > 2) { - return; - } + if (tab < 0 || tab >= TAB_COUNT) + return; // Invalid index + if (Config::isSet(Config::EXAM_MODE) && tab == TAB_NATIVE) + return; // Exam mode -- keep native sessions empty if (tab != TAB_RECENT_COURSES) { + // If tab is not the recent courses tab, check the list for any recent sessions auto prev = UserConfig::getLastSessions(); if (!prev.isEmpty()) { QList matches; @@ -233,8 +235,6 @@ void Dialog::addItems(const QList& entries, int tab) { } } } - if (Config::isSet(Config::EXAM_MODE) && tab == TAB_NATIVE) - return; this->model_[tab]->addItems(entries); tabs_[tab]->setEnabled(this->model_[tab]->rowCount() != 0); if (tab == activeTab_) { @@ -769,9 +769,14 @@ void Dialog::on_filterEdit_textChanged() { void Dialog::setListModel(SessionTreeModel *model) { QAbstractItemModel *old = nullptr; if (ui->treeView->model() == model_[TAB_NATIVE] || ui->treeView->model() == model_[TAB_RECENT_COURSES] || ui->treeView->model() == model_[TAB_ALL_VMS]) { + // A default model is currently being set; don't delete it } else { + // Remember currently set model so we can delete it after setting the new one old = ui->treeView->model(); } + // Disconnect current model + QObject::disconnect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &Dialog::treeView_selectionChanged); ui->treeView->setModel(model); ui->treeView->expandAll(); if (!genericExpandedOnce_ && g_forLocationHandling == LOCATION_EXCLUSIVE && model->rowCount() > 1) { -- cgit v1.2.3-55-g7522