summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-19 17:08:34 +0100
committerNils Schwabe2014-03-19 17:08:34 +0100
commit56a5cdd69ed50e809cdef1e368a41fd3c852db91 (patch)
treecba1a1746deab0c14e4ff39c498c36c2bbd1f023 /src/dialog.cpp
parent- removed function to load icons locally (diff)
downloadvmchooser2-56a5cdd69ed50e809cdef1e368a41fd3c852db91.tar.gz
vmchooser2-56a5cdd69ed50e809cdef1e368a41fd3c852db91.tar.xz
vmchooser2-56a5cdd69ed50e809cdef1e368a41fd3c852db91.zip
- changed dialog desgin
- added details view
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index b48ff1b..b156231 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -28,6 +28,11 @@ Dialog::Dialog(QWidget *parent)
centerTimer_ = new QTimer(this);
connect(centerTimer_, SIGNAL(timeout()), this, SLOT(onCenterTimer()));
centerTimer_->start(1000);
+
+ ui->treeView->setModel(model_);
+
+ QObject::connect(ui->treeView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex&, const QModelIndex&)),
+ this, SLOT(treeView_selectionChanged(const QModelIndex&, const QModelIndex&)));
}
Dialog::~Dialog() {
@@ -80,19 +85,16 @@ void Dialog::on_treeView_activated(QModelIndex index) {
void Dialog::addItems(const QList<Session*>& entries, const QString& section) {
this->model_->addItems(entries, section);
- ui->treeView->setModel(model_);
ui->treeView->expandAll();
}
void Dialog::addLabelItem(const QString& label, const QString& section) {
this->model_->addLabelItem(label, section);
- ui->treeView->setModel(model_);
ui->treeView->expandAll();
}
void Dialog::removeItem(const QString& name, const QString& section) {
this->model_->removeItem(name, section);
- ui->treeView->setModel(model_);
ui->treeView->expandAll();
}
@@ -317,3 +319,33 @@ void Dialog::addSessionsAfterDownload(QNetworkReply* reply) {
}
}
+void Dialog::treeView_selectionChanged(const QModelIndex& current, const QModelIndex&) {
+ SessionTreeItem* item =
+ static_cast<SessionTreeItem*>(current.internalPointer());
+
+ const Session* s(item->session());
+ if (!s) {
+ // no valid session has been selected, do nothing
+ return;
+ }
+
+ if (s->type() == Session::VSESSION) {
+ const VSession* vs = (VSession*) s;
+ ui->label_name->setText(vs->getAttribute("short_description", "param"));
+ ui->label_name->setToolTip(vs->getAttribute("short_description", "param"));
+
+ ui->label_creator->setText(vs->getAttribute("creator", "param"));
+ ui->label_creator->setToolTip(vs->getAttribute("creator", "param"));
+
+ ui->label_os->setText(vs->getAttribute("os", "param"));
+ ui->label_os->setToolTip(vs->getAttribute("os", "param"));
+
+ ui->textBrowser->setText(vs->getAttribute("long_description", "param"));
+
+ } else {
+ ui->label_name->setText(s->shortDescription());
+ ui->label_creator->setText("");
+ ui->label_os->setText(QCoreApplication::instance()->translate("Dialog", "Native"));
+ ui->textBrowser->setPlainText(QCoreApplication::instance()->translate("Dialog", "Running on this machine."));
+ }
+}