From 5471c7e1e6de9e7899c6f1fe037573fab37a2125 Mon Sep 17 00:00:00 2001 From: Jan Darmochwal Date: Sun, 10 Oct 2010 13:51:15 +0200 Subject: Failure message if session cannot be started --- src/dialog.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/dialog.cpp b/src/dialog.cpp index 2d6fecf..cfb3fae 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -1,4 +1,7 @@ #include "dialog.h" + +#include + #include "ui_dialog.h" #include "save_restore_session.h" #include "sessiontreeitem.h" @@ -14,7 +17,8 @@ Dialog::Dialog(QWidget *parent) if (ifaceDBus_->isValid()) { // PVS is running QStringList accessOptions; - accessOptions << trUtf8("None") << trUtf8("View Only") << trUtf8("Full"); + accessOptions <comboBoxLecturer->insertItems(0, accessOptions); ui->comboBoxOthers->insertItems(0, accessOptions); @@ -43,17 +47,17 @@ void Dialog::changeEvent(QEvent *e) { } void Dialog::on_treeView_activated(QModelIndex index) { - // TODO handle failures - // TODO get rid of this->entries, storing them in the model should be enough - // alternatively use references instead of copies? + // this method gets called when a Session has been activated SessionTreeItem* item = static_cast(index.internalPointer()); const Session* s(item->session()); if (!s) { + // no valid session has been selected, do nothing return; } + if (s->run()) { if (ifaceDBus_->isValid()) { writePVSSettings(); @@ -61,15 +65,15 @@ void Dialog::on_treeView_activated(QModelIndex index) { writeSessionName(s->shortDescription()); close(); } else { - // TODO: error instead of close - close(); + QMessageBox::warning( + this, trUtf8("vmchooser"), + trUtf8("Vmchooser failed to run the selected session!"); } } void Dialog::addItems(const QList& entries, const QString& section) { this->model_->addItems(entries, section); - // TODO: do this only once? ui->treeView->setModel(model_); ui->treeView->expandAll(); } @@ -79,7 +83,6 @@ void Dialog::on_pushButtonAbort_clicked() { } void Dialog::on_pushButtonStart_clicked() { - // TODO: check if a model is selected this->on_treeView_activated(ui->treeView->selectionModel()->currentIndex()); } @@ -147,14 +150,14 @@ void Dialog::writePVSSettings() { } void Dialog::on_comboBoxLecturer_currentIndexChanged(int index) { - // TODO: may others have more access than lecturer? + // TODO (Jan): may others have more access than lecturer? if (index < ui->comboBoxOthers->currentIndex()) { ui->comboBoxOthers->setCurrentIndex(index); } } void Dialog::on_comboBoxOthers_currentIndexChanged(int index) { - // TODO: may others have more access than lecturer? + // TODO (Jan): may others have more access than lecturer? if (index > ui->comboBoxLecturer->currentIndex()) { ui->comboBoxLecturer->setCurrentIndex(index); } -- cgit v1.2.3-55-g7522