From 696c9ccacd24392ea63477c5ec8a25d6649aedf7 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 2 May 2013 20:32:57 -0300 Subject: Added code to Select a dive, fixed minor annoyances. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'qt-ui/mainwindow.cpp') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 9901e4186..ae2794e3c 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -23,6 +23,7 @@ #include "../divelist.h" #include "../pref.h" #include "modeldelegates.h" +#include "models.h" MainWindow::MainWindow() : ui(new Ui::MainWindow()), model(new DiveTripModel(this)), @@ -31,11 +32,22 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), ui->setupUi(this); sortModel->setSourceModel(model); ui->ListWidget->setModel(sortModel); + connect(ui->ListWidget, SIGNAL(activated(QModelIndex)), this, SLOT(diveSelected(QModelIndex))); setWindowIcon(QIcon(":subsurface-icon")); readSettings(); } +void MainWindow::diveSelected(const QModelIndex& index) +{ + struct dive *dive = (struct dive*) index.model()->data(index, TreeItemDT::DIVE_ROLE).value(); + + if (dive) + selected_dive = get_index_for_dive(dive); + + // Here should be the code to update the other widgets. +} + void MainWindow::on_actionNew_triggered() { qDebug("actionNew"); -- cgit v1.2.3-70-g09d2