From 56a5cdd69ed50e809cdef1e368a41fd3c852db91 Mon Sep 17 00:00:00 2001 From: Nils Schwabe Date: Wed, 19 Mar 2014 17:08:34 +0100 Subject: - changed dialog desgin - added details view --- src/dialog.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/dialog.cpp') 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& 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(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.")); + } +} -- cgit v1.2.3-55-g7522