Move Dive class from qthelper.h/cpp to it's own file

and rename it to DiveObjectHelper, since it should be an QObject
based class to make it easier on the QML, grantlee and widgets
side to display the dive's internal data.

each Q_PROPERTY defined in the DiveObjectHelper.h file
can be acessed directly via it's name.

So, if you are on a model that  returns a dive, acess it's name
by dive.name

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2016-01-07 16:01:24 -02:00 committed by Dirk Hohndel
parent c022f5c4f7
commit 25aa80846b
10 changed files with 403 additions and 564 deletions

View file

@ -69,7 +69,6 @@ QString TemplateLayout::generate()
m_templateLoader->setTemplateDirs(QStringList() << getPrintingTemplatePathUser());
m_engine->addTemplateLoader(m_templateLoader);
Grantlee::registerMetaType<Dive>();
Grantlee::registerMetaType<template_options>();
Grantlee::registerMetaType<print_options>();
@ -81,7 +80,7 @@ QString TemplateLayout::generate()
//TODO check for exporting selected dives only
if (!dive->selected && PrintOptions->print_selected)
continue;
Dive d(dive);
DiveObjectHelper *d = new DiveObjectHelper(dive);
diveList.append(QVariant::fromValue(d));
progress++;
emit progressUpdated(progress * 100.0 / totalWork);

View file

@ -7,6 +7,7 @@
#include "statistics.h"
#include "qthelper.h"
#include "helpers.h"
#include "subsurface-core/subsurface-qt/DiveObjectHelper.h"
int getTotalWork(print_options *printOptions);
void find_all_templates();
@ -44,7 +45,6 @@ public:
~YearInfo();
};
Q_DECLARE_METATYPE(Dive)
Q_DECLARE_METATYPE(template_options)
Q_DECLARE_METATYPE(print_options)
Q_DECLARE_METATYPE(YearInfo)
@ -59,7 +59,7 @@ Q_DECLARE_METATYPE(YearInfo)
#define _RETURN_DIVE_PROPERTY_IDX(prop, idx) \
if (property == _CONC_STR(prop, idx)) return object.prop(idx)
GRANTLEE_BEGIN_LOOKUP(Dive)
GRANTLEE_BEGIN_LOOKUP(DiveObjectHelper)
_RETURN_DIVE_PROPERTY(number);
else _RETURN_DIVE_PROPERTY(id);
else _RETURN_DIVE_PROPERTY(date);