From b75a89aa868d39be29d2bb220a6e0c50d5a2b0ac Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 6 May 2013 20:36:37 -0700 Subject: Start populating the maintab Dive Info widget Establish some useful helpers and use them when updating the values. One of the helpers (from statistics.c) puzzlingly doesn't link - so that's ifdefed out. Also had to re-arrange the settings reading code (it came too late) and to extract the expanding code of the top dive from the settings reading code (as it had no business being there to begin with). Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'qt-ui/mainwindow.cpp') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index e8fe80460..56ae64b0c 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -32,14 +32,17 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), sortModel(new QSortFilterProxyModel()) { ui->setupUi(this); + readSettings(); sortModel->setSourceModel(model); ui->ListWidget->setModel(sortModel); setWindowIcon(QIcon(":subsurface-icon")); - connect(ui->ListWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(dive_selection_changed(QItemSelection,QItemSelection))); - - readSettings(); + QModelIndex firstDiveOrTrip = sortModel->index(0,0); + if (sortModel->index(0,0, firstDiveOrTrip).isValid()) + ui->ListWidget->setCurrentIndex(sortModel->index(0,0, firstDiveOrTrip)); + else + ui->ListWidget->setCurrentIndex(firstDiveOrTrip); } void MainWindow::on_actionNew_triggered() @@ -343,11 +346,6 @@ void MainWindow::readSettings() } ui->ListWidget->collapseAll(); ui->ListWidget->expand(sortModel->index(0,0)); - QModelIndex firstDiveOrTrip = sortModel->index(0,0); - if (sortModel->index(0,0, firstDiveOrTrip).isValid()) - ui->ListWidget->setCurrentIndex(sortModel->index(0,0, firstDiveOrTrip)); - else - ui->ListWidget->setCurrentIndex(firstDiveOrTrip); settings.endGroup(); settings.beginGroup("Units"); GET_UNIT(v, "feet", length, units::METERS, units::FEET); -- cgit v1.2.3-70-g09d2