summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2019-06-05 16:17:16 +0200
committerSimon Rettberg2019-06-05 16:17:16 +0200
commit615ca2f927e8a4c4b5b0591495e7c9417231cab3 (patch)
tree1962e3603a24baa0d4c2cc06c65ab32542243975 /src/dialog.cpp
parentUse Qt5 style signal/slot connections (diff)
downloadvmchooser2-615ca2f927e8a4c4b5b0591495e7c9417231cab3.tar.gz
vmchooser2-615ca2f927e8a4c4b5b0591495e7c9417231cab3.tar.xz
vmchooser2-615ca2f927e8a4c4b5b0591495e7c9417231cab3.zip
Don't group by type in "recent" tab
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp17
1 files changed, 11 insertions, 6 deletions
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<Session*>& 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<Session*> matches;
@@ -233,8 +235,6 @@ void Dialog::addItems(const QList<Session*>& 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) {