summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index 37b6fb6..6a931ca 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -3,7 +3,6 @@
#include "save_restore_session.h"
#include "sessiontreeitem.h"
-
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
@@ -181,5 +180,30 @@ void Dialog::on_comboBoxOthers_currentIndexChanged(int index)
if (index > ui->comboBoxLecturer->currentIndex()) {
ui->comboBoxLecturer->setCurrentIndex(index);
}
+}
+
+void Dialog::selectSession(const QString& name) {
+ QModelIndex root(ui->treeView->rootIndex());
+
+ for (int i = 0; i < model_->rowCount(root); ++i) {
+ QModelIndex section = model_->index(i, 0, root);
+ if (!section.isValid()) break;
+ for (int row = 0; row < model_->rowCount(section); ++row) {
+ QModelIndex index = model_->index(row, 0, section);
+ if (!index.isValid()) break;
+
+ SessionTreeItem* item =
+ static_cast<SessionTreeItem*>(index.internalPointer());
+ const Session* s(item->session());
+ if (!s) continue;
+ if (s->shortDescription() == name) {
+ ui->treeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select);
+ return;
+ }
+ }
+ }
+}
+void Dialog::selectPreviousSession() {
+ selectSession(readSessionName());
}