diff options
author | Jan Darmochwal | 2010-10-05 16:48:21 +0200 |
---|---|---|
committer | Jan Darmochwal | 2010-10-05 16:48:21 +0200 |
commit | 7abea084608e1c180216ea4d2bce702717ec2369 (patch) | |
tree | b731d464921bb22f1859bc9d8c81a710d3a96ddf | |
parent | simple PVS configuration in vmchooser (diff) | |
download | vmchooser-7abea084608e1c180216ea4d2bce702717ec2369.tar.gz vmchooser-7abea084608e1c180216ea4d2bce702717ec2369.tar.xz vmchooser-7abea084608e1c180216ea4d2bce702717ec2369.zip |
highlight previous session
This patch makes vmchooser hightlight the previous session run.
Selection of the session is only based on the session name.
The topmost session with the same name as the previous session will be highlighted.
-rw-r--r-- | src/dialog.cpp | 26 | ||||
-rw-r--r-- | src/dialog.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 1 |
3 files changed, 28 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()); } diff --git a/src/dialog.h b/src/dialog.h index e4d87e9..f8794d9 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -18,6 +18,8 @@ public: Dialog(QWidget *parent = 0); ~Dialog(); void addItems(const QList<Session*>&, const QString& section); + void selectSession(const QString& name); + void selectPreviousSession(); protected: void changeEvent(QEvent *e); diff --git a/src/main.cpp b/src/main.cpp index 1fa71be..6766403 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -190,6 +190,7 @@ int main(int argc, char *argv[]) { w.addItems(xsessions, "X Sessions"); w.addItems(vsessions, "Virtual Sessions"); + w.selectPreviousSession(); w.show(); return a.exec(); } |