[PATCH 2/2] Use get_dive to populate divelistview with dives

Dirk Hohndel dirk at hohndel.org
Thu Apr 18 12:43:21 PDT 2013


I did some minor cleanup, switched you to using for_each_dive and pushed
your commits.

This is nice progress. I don't think we want to print the depth to 100um
precision (especially since it is stored in mm - which makes me think
that there's something odd going on somewhere... I'll have to check and
fix that).

But as I said, this is moving us in the right direction.

Thanks

/D

amit.k.chaudhuri at gmail.com writes:

> From: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
>
> 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..
>
> Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
> ---
>  qt-ui/mainwindow.cpp |   27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
> index e81d9de..fb5def8 100644
> --- a/qt-ui/mainwindow.cpp
> +++ b/qt-ui/mainwindow.cpp
> @@ -10,6 +10,7 @@
>  #include <QFileDialog>
>  #include <QMessageBox>
>  #include <QtDebug>
> +#include <QDateTime>
>  
>  #include "divelistview.h"
>  #include "divetripmodel.h"
> @@ -31,28 +32,30 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow())
>  	if (model){
>  		ui->ListWidget->setModel(model);
>  	}
> -	/* add in dives here.
> -	 * we need to root to parent all top level dives
> +	/* we need root to parent all top level dives
>  	 * 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
> +	 *
>  	 */
>  	DiveItem *dive = 0;
>  	DiveItem *root = model->itemForIndex(QModelIndex());
>  	if (root){
> -		dive = new DiveItem(1,QString("01/03/13"),14.2, 29.0,QString("Wraysbury"),root);
> -
>  		Q_UNUSED(dive)
>  
> -		qDebug("dive_table checks - number of dives is %d", dive_table.nr);
> -		qDebug("# allocated dives = %d, pre-existing = %d",
> -		       dive_table.allocated, dive_table.preexisting);
> +		struct dive *d;
> +		qDebug("address of dive_table %p", &dive_table);
> +		int count = dive_table.nr;
> +		for( int i = 0 ; i < count; ++i){
> +			d = get_dive(i);
> +			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()
> -- 
> 1.7.10.4
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

-- 
Dirk Hohndel
Intel Open Source Technology Center


More information about the subsurface mailing list