[PATCH] Amend divetrip model to use int units

Dirk Hohndel dirk at hohndel.org
Wed Apr 24 10:43:55 PDT 2013


On Wed, 2013-04-24 at 10:36 -0700, Dirk Hohndel wrote:
> On Wed, 2013-04-24 at 16:57 +0100, amit.k.chaudhuri at gmail.com wrote:
> > From: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
> > 
> > Amend the DiveItem class to avoid float in favour of int. Add getters
> > which return display friendly QStrings reflecting user preferences for
> > (e.g.) depth.
> > 
> > Modify DiveTripModel to support controlled alignment by column; right
> > align for depth and duration.
> > 
> > Fix problems with utf8 encoding on rating stars, degree symbols and
> > O2 subscript.
> > 
> > Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
> > ---
> > diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
> > index 40307d0..0ba0783 100644
> > --- a/qt-ui/models.cpp
> > +++ b/qt-ui/models.cpp
> > @@ -8,6 +8,8 @@
> >  #include "../dive.h"
> >  #include "../divelist.h"
> >  
> > +#include <QtDebug>
> > +
> >  extern struct tank_info tank_info[100];
> >  
> >  CylindersModel::CylindersModel(QObject* parent): QAbstractTableModel(parent)
> > @@ -292,14 +294,16 @@ void TankInfoModel::update()
> >  class DiveItem
> >  {
> >  public:
> > -	explicit DiveItem(): number(0), dateTime(QString()), duration(0.0), depth(0.0), location(QString()) {parentItem = 0;}
> > -	explicit DiveItem(int num, QString dt, float, float, QString loc, DiveItem *parent = 0);
> > +	explicit DiveItem(): number(0), dateTime(QString()), seconds(0), mm(0), location(QString()) {parentItem = 0;}
> > +	explicit DiveItem(int num, QString dt, int, int, QString loc, DiveItem *parent = 0);
> 
> Well, this is an improvement, but I wonder why we aren't using
> Subsurface's native types here. 
> 
> Or let me ask that actually as a question:
> 
> Would it be better to pass in duration_t, depth_t, etc? If "no", why?

So here is the reason why I would like this better. You changed the
arguments from "duration" and "depth" (which tells you WHAT it is) to
"seconds" and "mm" (which tells you the unit, but no longer what is
measured in this unit).

I'd much prefer to know what is passed in and then have the data
structure itself tell me that it's in seconds and mm (as the Subsurface
data structures do)

/D




More information about the subsurface mailing list