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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-05-06 20:36:37 -07:00
parent 1a8239a240
commit b75a89aa86
7 changed files with 100 additions and 9 deletions

View file

@ -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);