summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2016-01-07 16:01:24 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-08 08:04:44 -0800
commit25aa80846b84c0b3cd3e0b0256a046e1e92fb1db (patch)
treec9934f39f2e039e5877af7ee0d3b0d96c5a1debf /desktop-widgets
parentc022f5c4f71f3e7670ed458d714d96fd6e88c55b (diff)
downloadsubsurface-25aa80846b84c0b3cd3e0b0256a046e1e92fb1db.tar.gz
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>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/templatelayout.cpp3
-rw-r--r--desktop-widgets/templatelayout.h4
2 files changed, 3 insertions, 4 deletions
diff --git a/desktop-widgets/templatelayout.cpp b/desktop-widgets/templatelayout.cpp
index a376459a6..59768034e 100644
--- a/desktop-widgets/templatelayout.cpp
+++ b/desktop-widgets/templatelayout.cpp
@@ -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);
diff --git a/desktop-widgets/templatelayout.h b/desktop-widgets/templatelayout.h
index 1ef9b5834..6f4478a08 100644
--- a/desktop-widgets/templatelayout.h
+++ b/desktop-widgets/templatelayout.h
@@ -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);