mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core: remove DiveObjectHelper
Since switching to the mobile-models and removing grantlee, DiveObjectHelper was demoted to a thin wrapper around string formatting functions. The last user was removed in a previous commit. It was never a good idea, given QML's strange memory-management. Let's remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1037c15b98
commit
79f95b7f7d
6 changed files with 0 additions and 213 deletions
|
@ -122,7 +122,6 @@ SOURCES += subsurface-mobile-main.cpp \
|
|||
core/settings/qPrefLog.cpp \
|
||||
core/settings/qPrefMedia.cpp \
|
||||
core/settings/qPrefUpdateManager.cpp \
|
||||
core/subsurface-qt/diveobjecthelper.cpp \
|
||||
core/subsurface-qt/divelistnotifier.cpp \
|
||||
backend-shared/exportfuncs.cpp \
|
||||
backend-shared/plannershared.cpp \
|
||||
|
@ -257,7 +256,6 @@ HEADERS += \
|
|||
core/settings/qPrefLog.h \
|
||||
core/settings/qPrefMedia.h \
|
||||
core/settings/qPrefUpdateManager.h \
|
||||
core/subsurface-qt/diveobjecthelper.h \
|
||||
core/subsurface-qt/divelistnotifier.h \
|
||||
backend-shared/exportfuncs.h \
|
||||
backend-shared/plannershared.h \
|
||||
|
|
|
@ -246,8 +246,6 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
|||
#Subsurface Qt have the Subsurface structs QObjectified for easy access via QML.
|
||||
subsurface-qt/divelistnotifier.cpp
|
||||
subsurface-qt/divelistnotifier.h
|
||||
subsurface-qt/diveobjecthelper.cpp
|
||||
subsurface-qt/diveobjecthelper.h
|
||||
|
||||
${SERIAL_FTDI}
|
||||
${PLATFORM_SRC}
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "diveobjecthelper.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QTextDocument>
|
||||
|
||||
#include "core/dive.h"
|
||||
#include "core/qthelper.h"
|
||||
#include "core/divesite.h"
|
||||
#include "core/trip.h"
|
||||
#include "core/subsurface-string.h"
|
||||
#include "core/string-format.h"
|
||||
#include "qt-models/tankinfomodel.h"
|
||||
|
||||
#if defined(DEBUG_DOH)
|
||||
#include <execinfo.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
static int callCounter = 0;
|
||||
#endif /* defined(DEBUG_DOH) */
|
||||
|
||||
QString formatDiveSalinity(const dive *d)
|
||||
{
|
||||
int salinity = get_dive_salinity(d);
|
||||
if (!salinity)
|
||||
return QString();
|
||||
return get_salinity_string(salinity);
|
||||
}
|
||||
|
||||
QString formatDiveWaterType(const dive *d)
|
||||
{
|
||||
return get_water_type_string(get_dive_salinity(d));
|
||||
}
|
||||
|
||||
// Qt's metatype system insists on generating a default constructed object, even if that makes no sense.
|
||||
DiveObjectHelper::DiveObjectHelper()
|
||||
{
|
||||
}
|
||||
|
||||
DiveObjectHelper::DiveObjectHelper(const struct dive *d) :
|
||||
number(d->number),
|
||||
id(d->id),
|
||||
rating(d->rating),
|
||||
visibility(d->visibility),
|
||||
wavesize(d->wavesize),
|
||||
current(d->current),
|
||||
surge(d->surge),
|
||||
chill(d->chill),
|
||||
timestamp(d->when),
|
||||
location(get_dive_location(d)),
|
||||
gps(formatDiveGPS(d)),
|
||||
gps_decimal(format_gps_decimal(d)),
|
||||
dive_site(QVariant::fromValue(d->dive_site)),
|
||||
duration(formatDiveDuration(d)),
|
||||
noDive(d->duration.seconds == 0 && d->dc.duration.seconds == 0),
|
||||
depth(get_depth_string(d->dc.maxdepth.mm, true, true)),
|
||||
divemaster(d->divemaster ? d->divemaster : QString()),
|
||||
buddy(d->buddy ? d->buddy : QString()),
|
||||
airTemp(get_temperature_string(d->airtemp, true)),
|
||||
waterTemp(get_temperature_string(d->watertemp, true)),
|
||||
notes(formatNotes(d)),
|
||||
tags(get_taglist_string(d->tag_list)),
|
||||
gas(formatGas(d)),
|
||||
sac(formatSac(d)),
|
||||
weightList(formatWeightList(d)),
|
||||
weights(formatWeights(d)),
|
||||
singleWeight(d->weightsystems.nr <= 1),
|
||||
suit(d->suit ? d->suit : QString()),
|
||||
cylinders(formatCylinders(d)),
|
||||
maxcns(d->maxcns),
|
||||
otu(d->otu),
|
||||
sumWeight(formatSumWeight(d)),
|
||||
getCylinder(formatGetCylinder(d)),
|
||||
startPressure(formatStartPressure(d)),
|
||||
endPressure(formatEndPressure(d)),
|
||||
firstGas(formatFirstGas(d)),
|
||||
salinity(formatDiveSalinity(d)),
|
||||
waterType(formatDiveWaterType(d))
|
||||
{
|
||||
#if defined(DEBUG_DOH)
|
||||
void *array[4];
|
||||
size_t size;
|
||||
|
||||
// get void*'s for all entries on the stack
|
||||
size = backtrace(array, 4);
|
||||
|
||||
// print out all the frames to stderr
|
||||
fprintf(stderr, "\n\nCalling DiveObjectHelper constructor for dive %d - call #%d\n", d->number, ++callCounter);
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
#endif /* defined(DEBUG_DOH) */
|
||||
}
|
||||
|
||||
QString DiveObjectHelper::date() const
|
||||
{
|
||||
QDateTime localTime = timestampToDateTime(timestamp);
|
||||
return localTime.date().toString(prefs.date_format_short);
|
||||
}
|
||||
|
||||
QString DiveObjectHelper::time() const
|
||||
{
|
||||
QDateTime localTime = timestampToDateTime(timestamp);
|
||||
return localTime.time().toString(prefs.time_format);
|
||||
}
|
||||
|
||||
QStringList DiveObjectHelper::cylinderList() const
|
||||
{
|
||||
return formatFullCylinderList();
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef DIVE_QOBJECT_H
|
||||
#define DIVE_QOBJECT_H
|
||||
|
||||
#include "core/units.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <QVariant>
|
||||
|
||||
class DiveObjectHelper {
|
||||
Q_GADGET
|
||||
Q_PROPERTY(int number MEMBER number CONSTANT)
|
||||
Q_PROPERTY(int id MEMBER id CONSTANT)
|
||||
Q_PROPERTY(int rating MEMBER rating CONSTANT)
|
||||
Q_PROPERTY(int visibility MEMBER visibility CONSTANT)
|
||||
Q_PROPERTY(int wavesize MEMBER wavesize CONSTANT)
|
||||
Q_PROPERTY(int current MEMBER current CONSTANT)
|
||||
Q_PROPERTY(int surge MEMBER surge CONSTANT)
|
||||
Q_PROPERTY(int chill MEMBER chill CONSTANT)
|
||||
Q_PROPERTY(QString date READ date CONSTANT)
|
||||
Q_PROPERTY(QString time READ time CONSTANT)
|
||||
Q_PROPERTY(int timestamp MEMBER timestamp CONSTANT)
|
||||
Q_PROPERTY(QString location MEMBER location CONSTANT)
|
||||
Q_PROPERTY(QString gps MEMBER gps CONSTANT)
|
||||
Q_PROPERTY(QString gps_decimal MEMBER gps_decimal CONSTANT)
|
||||
Q_PROPERTY(QVariant dive_site MEMBER dive_site CONSTANT)
|
||||
Q_PROPERTY(QString duration MEMBER duration CONSTANT)
|
||||
Q_PROPERTY(bool noDive MEMBER noDive CONSTANT)
|
||||
Q_PROPERTY(QString depth MEMBER depth CONSTANT)
|
||||
Q_PROPERTY(QString divemaster MEMBER divemaster CONSTANT)
|
||||
Q_PROPERTY(QString buddy MEMBER buddy CONSTANT)
|
||||
Q_PROPERTY(QString airTemp MEMBER airTemp CONSTANT)
|
||||
Q_PROPERTY(QString waterTemp MEMBER waterTemp CONSTANT)
|
||||
Q_PROPERTY(QString notes MEMBER notes CONSTANT)
|
||||
Q_PROPERTY(QString tags MEMBER tags CONSTANT)
|
||||
Q_PROPERTY(QString gas MEMBER gas CONSTANT)
|
||||
Q_PROPERTY(QString sac MEMBER sac CONSTANT)
|
||||
Q_PROPERTY(QString weightList MEMBER weightList CONSTANT)
|
||||
Q_PROPERTY(QStringList weights MEMBER weights CONSTANT)
|
||||
Q_PROPERTY(bool singleWeight MEMBER singleWeight CONSTANT)
|
||||
Q_PROPERTY(QString suit MEMBER suit CONSTANT)
|
||||
Q_PROPERTY(QStringList cylinderList READ cylinderList CONSTANT)
|
||||
Q_PROPERTY(QStringList cylinders MEMBER cylinders CONSTANT)
|
||||
Q_PROPERTY(int maxcns MEMBER maxcns CONSTANT)
|
||||
Q_PROPERTY(int otu MEMBER otu CONSTANT)
|
||||
Q_PROPERTY(QString sumWeight MEMBER sumWeight CONSTANT)
|
||||
Q_PROPERTY(QStringList getCylinder MEMBER getCylinder CONSTANT)
|
||||
Q_PROPERTY(QStringList startPressure MEMBER startPressure CONSTANT)
|
||||
Q_PROPERTY(QStringList endPressure MEMBER endPressure CONSTANT)
|
||||
Q_PROPERTY(QStringList firstGas MEMBER firstGas CONSTANT)
|
||||
public:
|
||||
DiveObjectHelper(); // This is only to be used by Qt's metatype system!
|
||||
DiveObjectHelper(const struct dive *dive);
|
||||
int number;
|
||||
int id;
|
||||
int rating;
|
||||
int visibility;
|
||||
int wavesize;
|
||||
int current;
|
||||
int surge;
|
||||
int chill;
|
||||
QString date() const;
|
||||
timestamp_t timestamp;
|
||||
QString time() const;
|
||||
QString location;
|
||||
QString gps;
|
||||
QString gps_decimal;
|
||||
QVariant dive_site;
|
||||
QString duration;
|
||||
bool noDive;
|
||||
QString depth;
|
||||
QString divemaster;
|
||||
QString buddy;
|
||||
QString airTemp;
|
||||
QString waterTemp;
|
||||
QString notes;
|
||||
QString tags;
|
||||
QString gas;
|
||||
QString sac;
|
||||
QString weightList;
|
||||
QStringList weights;
|
||||
bool singleWeight;
|
||||
QString suit;
|
||||
QStringList cylinderList() const;
|
||||
QStringList cylinders;
|
||||
int maxcns;
|
||||
int otu;
|
||||
QString sumWeight;
|
||||
QStringList getCylinder;
|
||||
QStringList startPressure;
|
||||
QStringList endPressure;
|
||||
QStringList firstGas;
|
||||
QString salinity;
|
||||
QString waterType;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -48,7 +48,6 @@
|
|||
#include "core/settings/qPrefTechnicalDetails.h"
|
||||
#include "core/settings/qPrefPartialPressureGas.h"
|
||||
#include "core/settings/qPrefUnit.h"
|
||||
#include "core/subsurface-qt/diveobjecthelper.h"
|
||||
#include "core/trip.h"
|
||||
#include "backend-shared/exportfuncs.h"
|
||||
#include "core/worldmap-save.h"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#endif
|
||||
|
||||
class QAction;
|
||||
class DiveObjectHelper;
|
||||
struct DiveSiteChange; // An obscure implementation artifact - remove in due course.
|
||||
|
||||
class QMLManager : public QObject {
|
||||
|
|
Loading…
Reference in a new issue