mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use get_dive to populate divelistview with dives
Add dives from dive_table to the model/view using the functions provided to extract the dives. We do not yet handle trips. Formatting of date/time, depth and duration need attention. Relies on earlier patch to delay Qt ui construction. We should look at the signals we publish to link to other widgets etc.. [Dirk Hohndel: use for_each_dive -- clean up some white space] Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
073be111f4
commit
1a15462073
1 changed files with 18 additions and 16 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "divelistview.h"
|
#include "divelistview.h"
|
||||||
#include "divetripmodel.h"
|
#include "divetripmodel.h"
|
||||||
|
@ -31,28 +32,29 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow())
|
||||||
if (model) {
|
if (model) {
|
||||||
ui->ListWidget->setModel(model);
|
ui->ListWidget->setModel(model);
|
||||||
}
|
}
|
||||||
/* add in dives here.
|
/* we need root to parent all top level dives
|
||||||
* we need to root to parent all top level dives
|
|
||||||
* trips need more work as it complicates parent/child stuff.
|
* trips need more work as it complicates parent/child stuff.
|
||||||
*
|
*
|
||||||
* We show how to obtain the root and add a demo dive
|
|
||||||
*
|
|
||||||
* Todo: work through integration with current list of dives/trips
|
|
||||||
* Todo: look at alignment/format of e.g. duration in view
|
* Todo: look at alignment/format of e.g. duration in view
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
DiveItem *dive = 0;
|
DiveItem *dive = 0;
|
||||||
DiveItem *root = model->itemForIndex(QModelIndex());
|
DiveItem *root = model->itemForIndex(QModelIndex());
|
||||||
if (root) {
|
if (root) {
|
||||||
dive = new DiveItem(1,QString("01/03/13"),14.2, 29.0,QString("Wraysbury"),root);
|
int i;
|
||||||
|
|
||||||
Q_UNUSED(dive)
|
Q_UNUSED(dive)
|
||||||
|
|
||||||
qDebug("dive_table checks - number of dives is %d", dive_table.nr);
|
struct dive *d;
|
||||||
qDebug("# allocated dives = %d, pre-existing = %d",
|
qDebug("address of dive_table %p", &dive_table);
|
||||||
dive_table.allocated, dive_table.preexisting);
|
for_each_dive(i, d) {
|
||||||
|
dive = new DiveItem(d->number,
|
||||||
|
QDateTime::fromTime_t(d->when).toString(),
|
||||||
|
(float)d->maxdepth.mm/1000 ,
|
||||||
|
(float)d->duration.seconds/60,
|
||||||
|
d->location,
|
||||||
|
root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionNew_triggered()
|
void MainWindow::on_actionNew_triggered()
|
||||||
|
|
Loading…
Add table
Reference in a new issue