initial commit to split repos
This commit is contained in:
42
mvc/data/mapdata.cpp
Normal file
42
mvc/data/mapdata.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "mapdata.h"
|
||||
|
||||
MapData::MapData(QObject *parent) : QObject{parent} {}
|
||||
|
||||
QList<std::unique_ptr<Waypoint>> MapData::waypoints() const {
|
||||
return m_waypoints;
|
||||
}
|
||||
|
||||
void MapData::setWaypoints(
|
||||
const QList<std::unique_ptr<Waypoint>> &newWaypoints) {
|
||||
if (m_waypoints == newWaypoints)
|
||||
return;
|
||||
m_waypoints = newWaypoints;
|
||||
emit waypointsChanged();
|
||||
}
|
||||
|
||||
int MapData::zoomLevel() const { return m_zoomLevel; }
|
||||
|
||||
void MapData::setZoomLevel(int newZoomLevel) {
|
||||
if (m_zoomLevel == newZoomLevel)
|
||||
return;
|
||||
m_zoomLevel = newZoomLevel;
|
||||
emit zoomLevelChanged();
|
||||
}
|
||||
|
||||
int MapData::gpsUpdateInterval() const { return m_gpsUpdateInterval; }
|
||||
|
||||
void MapData::setGpsUpdateInterval(int newGpsUpdateInterval) {
|
||||
if (m_gpsUpdateInterval == newGpsUpdateInterval)
|
||||
return;
|
||||
m_gpsUpdateInterval = newGpsUpdateInterval;
|
||||
emit gpsUpdateIntervalChanged();
|
||||
}
|
||||
|
||||
int MapData::defaultZoomLevel() const { return m_defaultZoomLevel; }
|
||||
|
||||
void MapData::setDefaultZoomLevel(int newDefaultZoomLevel) {
|
||||
if (m_defaultZoomLevel == newDefaultZoomLevel)
|
||||
return;
|
||||
m_defaultZoomLevel = newDefaultZoomLevel;
|
||||
emit defaultZoomLevelChanged();
|
||||
}
|
||||
46
mvc/data/mapdata.h
Normal file
46
mvc/data/mapdata.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef MAPDATA_H
|
||||
#define MAPDATA_H
|
||||
|
||||
#include "waypoint.h"
|
||||
#include <QObject>
|
||||
|
||||
class MapData : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MapData(QObject *parent = nullptr);
|
||||
|
||||
Q_PROPERTY(QList<std::unique_ptr<Waypoint>> waypoints READ waypoints WRITE
|
||||
setWaypoints NOTIFY waypointsChanged FINAL)
|
||||
Q_PROPERTY(int zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY
|
||||
zoomLevelChanged FINAL)
|
||||
Q_PROPERTY(int gpsUpdateInterval READ gpsUpdateInterval WRITE
|
||||
setGpsUpdateInterval NOTIFY gpsUpdateIntervalChanged FINAL)
|
||||
Q_PROPERTY(int defaultZoomLevel READ defaultZoomLevel NOTIFY
|
||||
defaultZoomLevelChanged FINAL)
|
||||
|
||||
QList<std::unique_ptr<Waypoint>> waypoints() const;
|
||||
void setWaypoints(const QList<std::unique_ptr<Waypoint>> &newWaypoints);
|
||||
|
||||
int zoomLevel() const;
|
||||
void setZoomLevel(int newZoomLevel);
|
||||
|
||||
int gpsUpdateInterval() const;
|
||||
void setGpsUpdateInterval(int newGpsUpdateInterval);
|
||||
|
||||
int defaultZoomLevel() const;
|
||||
void setDefaultZoomLevel(int newDefaultZoomLevel);
|
||||
|
||||
signals:
|
||||
void waypointsChanged();
|
||||
void zoomLevelChanged();
|
||||
void gpsUpdateIntervalChanged();
|
||||
void defaultZoomLevelChanged();
|
||||
|
||||
private:
|
||||
QList<std::unique_ptr<Waypoint>> m_waypoints;
|
||||
int m_zoomLevel;
|
||||
int m_gpsUpdateInterval;
|
||||
int m_defaultZoomLevel;
|
||||
};
|
||||
|
||||
#endif // MAPDATA_H
|
||||
16
mvc/data/waypoint.cpp
Normal file
16
mvc/data/waypoint.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "waypoint.h"
|
||||
|
||||
Waypoint::Waypoint(QObject *parent) : QObject{parent} {}
|
||||
|
||||
Waypoint::Waypoint(const double latitude, const double longitude)
|
||||
: m_latitude(latitude), m_longitude(longitude), m_altitude(0) {}
|
||||
|
||||
Waypoint::Waypoint(const double latitude, const double longitude,
|
||||
WeatherData &data)
|
||||
: m_latitude(latitude), m_longitude(longitude), m_altitude(0),
|
||||
m_data(data) {}
|
||||
|
||||
Waypoint::Waypoint(const double latitude, const double longitude,
|
||||
const double altitude, WeatherData &data)
|
||||
: m_latitude(latitude), m_longitude(longitude), m_altitude(altitude),
|
||||
m_data(data) {}
|
||||
23
mvc/data/waypoint.h
Normal file
23
mvc/data/waypoint.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef WAYPOINT_H
|
||||
#define WAYPOINT_H
|
||||
|
||||
#include "weatherdata.h"
|
||||
#include <QObject>
|
||||
|
||||
class Waypoint : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Waypoint(QObject *parent = nullptr);
|
||||
Waypoint(const double latitude, const double longitude);
|
||||
Waypoint(const double latitude, const double longitude, WeatherData &data);
|
||||
Waypoint(const double latitude, const double longitude, const double altitude,
|
||||
WeatherData &data);
|
||||
|
||||
private:
|
||||
double m_latitude;
|
||||
double m_longitude;
|
||||
double m_altitude;
|
||||
WeatherData m_data;
|
||||
};
|
||||
|
||||
#endif // WAYPOINT_H
|
||||
331
mvc/data/weatherdata.cpp
Normal file
331
mvc/data/weatherdata.cpp
Normal file
@@ -0,0 +1,331 @@
|
||||
#include "weatherdata.h"
|
||||
|
||||
WeatherData::WeatherData(QObject *parent) : QObject{parent} {}
|
||||
|
||||
WeatherData::WeatherData(long tijd, const QString &tijd_nl, int offset,
|
||||
float temp, int wind_ms, int wind_bf, int wind_knp,
|
||||
int wind_kmh, int wind_r, const QString &wind_ltr,
|
||||
int visibility, int neersl, float luchtd_bar,
|
||||
float luchtdmmhg, float luchtdinHg, int hw, int mw,
|
||||
int lw, int tw, int rv, int gr, int gr_w,
|
||||
const QString &cape, int snd, int snv, int cond,
|
||||
int iconCode, const QString &sameenv,
|
||||
const QString &icoon)
|
||||
: m_tijd(tijd), m_tijd_nl(tijd_nl), m_offset(offset), m_temp(temp),
|
||||
m_wind_ms(wind_ms), m_wind_bf(wind_bf), m_wind_knp(wind_knp),
|
||||
m_wind_kmh(wind_kmh), m_wind_r(wind_r), m_wind_ltr(wind_ltr),
|
||||
m_visibility(visibility), m_neersl(neersl), m_luchtd_bar(luchtd_bar),
|
||||
m_luchtdmmhg(luchtdmmhg), m_luchtdinHg(luchtdinHg), m_hw(hw), m_mw(mw),
|
||||
m_lw(lw), m_tw(tw), m_rv(rv), m_gr(gr), m_gr_w(gr_w), m_cape(cape),
|
||||
m_snd(snd), m_snv(snv), m_cond(cond), m_iconCode(iconCode),
|
||||
m_sameenv(sameenv), m_icoon(icoon) {}
|
||||
|
||||
WeatherData::WeatherData(const WeatherData &other)
|
||||
: m_tijd(other.m_tijd), m_tijd_nl(other.m_tijd_nl),
|
||||
m_offset(other.m_offset), m_temp(other.m_temp),
|
||||
m_wind_ms(other.m_wind_ms), m_wind_bf(other.m_wind_bf),
|
||||
m_wind_knp(other.m_wind_knp), m_wind_kmh(other.m_wind_kmh),
|
||||
m_wind_r(other.m_wind_r), m_wind_ltr(other.m_wind_ltr),
|
||||
m_visibility(other.m_visibility), m_neersl(other.m_neersl),
|
||||
m_luchtd_bar(other.m_luchtd_bar), m_luchtdmmhg(other.m_luchtdmmhg),
|
||||
m_luchtdinHg(other.m_luchtdinHg), m_hw(other.m_hw), m_mw(other.m_mw),
|
||||
m_lw(other.m_lw), m_tw(other.m_tw), m_rv(other.m_rv), m_gr(other.m_gr),
|
||||
m_gr_w(other.m_gr_w), m_cape(other.m_cape), m_snd(other.m_snd),
|
||||
m_snv(other.m_snv), m_cond(other.m_cond), m_iconCode(other.m_iconCode),
|
||||
m_sameenv(other.m_sameenv), m_icoon(other.m_icoon) {}
|
||||
|
||||
WeatherData WeatherData::operator=(const WeatherData &other) {
|
||||
m_tijd = (other.m_tijd);
|
||||
m_tijd_nl = (other.m_tijd_nl);
|
||||
m_offset = (other.m_offset);
|
||||
m_temp = (other.m_temp);
|
||||
m_wind_ms = (other.m_wind_ms);
|
||||
m_wind_bf = (other.m_wind_bf);
|
||||
m_wind_knp = (other.m_wind_knp);
|
||||
m_wind_kmh = (other.m_wind_kmh);
|
||||
m_wind_r = (other.m_wind_r);
|
||||
m_wind_ltr = (other.m_wind_ltr);
|
||||
m_visibility = (other.m_visibility);
|
||||
m_neersl = (other.m_neersl);
|
||||
m_luchtd_bar = (other.m_luchtd_bar);
|
||||
m_luchtdmmhg = (other.m_luchtdmmhg);
|
||||
m_luchtdinHg = (other.m_luchtdinHg);
|
||||
m_hw = (other.m_hw);
|
||||
m_mw = (other.m_mw);
|
||||
m_lw = (other.m_lw);
|
||||
m_tw = (other.m_tw);
|
||||
m_rv = (other.m_rv);
|
||||
m_gr = (other.m_gr);
|
||||
m_gr_w = (other.m_gr_w);
|
||||
m_cape = (other.m_cape);
|
||||
m_snd = (other.m_snd);
|
||||
m_snv = (other.m_snv);
|
||||
m_cond = (other.m_cond);
|
||||
m_iconCode = (other.m_iconCode);
|
||||
m_sameenv = (other.m_sameenv);
|
||||
m_icoon = (other.m_icoon);
|
||||
return *this;
|
||||
}
|
||||
|
||||
long WeatherData::tijd() const { return m_tijd; }
|
||||
|
||||
void WeatherData::setTijd(long newTijd) {
|
||||
if (m_tijd == newTijd)
|
||||
return;
|
||||
m_tijd = newTijd;
|
||||
emit tijdChanged();
|
||||
}
|
||||
|
||||
QString WeatherData::tijd_nl() const { return m_tijd_nl; }
|
||||
|
||||
void WeatherData::setTijd_nl(const QString &newTijd_nl) {
|
||||
if (m_tijd_nl == newTijd_nl)
|
||||
return;
|
||||
m_tijd_nl = newTijd_nl;
|
||||
emit tijd_nlChanged();
|
||||
}
|
||||
|
||||
int WeatherData::offset() const { return m_offset; }
|
||||
|
||||
void WeatherData::setOffset(int newOffset) {
|
||||
if (m_offset == newOffset)
|
||||
return;
|
||||
m_offset = newOffset;
|
||||
emit offsetChanged();
|
||||
}
|
||||
|
||||
float WeatherData::temp() const { return m_temp; }
|
||||
|
||||
void WeatherData::setTemp(float newTemp) {
|
||||
if (qFuzzyCompare(m_temp, newTemp))
|
||||
return;
|
||||
m_temp = newTemp;
|
||||
emit tempChanged();
|
||||
}
|
||||
|
||||
int WeatherData::wind_ms() const { return m_wind_ms; }
|
||||
|
||||
void WeatherData::setWind_ms(int newWind_ms) {
|
||||
if (m_wind_ms == newWind_ms)
|
||||
return;
|
||||
m_wind_ms = newWind_ms;
|
||||
emit wind_msChanged();
|
||||
}
|
||||
|
||||
int WeatherData::wind_bf() const { return m_wind_bf; }
|
||||
|
||||
void WeatherData::setWind_bf(int newWind_bf) {
|
||||
if (m_wind_bf == newWind_bf)
|
||||
return;
|
||||
m_wind_bf = newWind_bf;
|
||||
emit wind_bfChanged();
|
||||
}
|
||||
|
||||
int WeatherData::wind_knp() const { return m_wind_knp; }
|
||||
|
||||
void WeatherData::setWind_knp(int newWind_knp) {
|
||||
if (m_wind_knp == newWind_knp)
|
||||
return;
|
||||
m_wind_knp = newWind_knp;
|
||||
emit wind_knpChanged();
|
||||
}
|
||||
|
||||
int WeatherData::wind_kmh() const { return m_wind_kmh; }
|
||||
|
||||
void WeatherData::setWind_kmh(int newWind_kmh) {
|
||||
if (m_wind_kmh == newWind_kmh)
|
||||
return;
|
||||
m_wind_kmh = newWind_kmh;
|
||||
emit wind_kmhChanged();
|
||||
}
|
||||
|
||||
int WeatherData::wind_r() const { return m_wind_r; }
|
||||
|
||||
void WeatherData::setWind_r(int newWind_r) {
|
||||
if (m_wind_r == newWind_r)
|
||||
return;
|
||||
m_wind_r = newWind_r;
|
||||
emit wind_rChanged();
|
||||
}
|
||||
|
||||
QString WeatherData::wind_ltr() const { return m_wind_ltr; }
|
||||
|
||||
void WeatherData::setWind_ltr(const QString &newWind_ltr) {
|
||||
if (m_wind_ltr == newWind_ltr)
|
||||
return;
|
||||
m_wind_ltr = newWind_ltr;
|
||||
emit wind_ltrChanged();
|
||||
}
|
||||
|
||||
int WeatherData::visibility() const { return m_visibility; }
|
||||
|
||||
void WeatherData::setVisibility(int newVisibility) {
|
||||
if (m_visibility == newVisibility)
|
||||
return;
|
||||
m_visibility = newVisibility;
|
||||
emit visibilityChanged();
|
||||
}
|
||||
|
||||
int WeatherData::neersl() const { return m_neersl; }
|
||||
|
||||
void WeatherData::setNeersl(int newNeersl) {
|
||||
if (m_neersl == newNeersl)
|
||||
return;
|
||||
m_neersl = newNeersl;
|
||||
emit neerslChanged();
|
||||
}
|
||||
|
||||
float WeatherData::luchtd_bar() const { return m_luchtd_bar; }
|
||||
|
||||
void WeatherData::setLuchtd_bar(float newLuchtd_bar) {
|
||||
if (qFuzzyCompare(m_luchtd_bar, newLuchtd_bar))
|
||||
return;
|
||||
m_luchtd_bar = newLuchtd_bar;
|
||||
emit luchtd_barChanged();
|
||||
}
|
||||
|
||||
float WeatherData::luchtdmmhg() const { return m_luchtdmmhg; }
|
||||
|
||||
void WeatherData::setLuchtdmmhg(float newLuchtdmmhg) {
|
||||
if (qFuzzyCompare(m_luchtdmmhg, newLuchtdmmhg))
|
||||
return;
|
||||
m_luchtdmmhg = newLuchtdmmhg;
|
||||
emit luchtdmmhgChanged();
|
||||
}
|
||||
|
||||
float WeatherData::luchtdinHg() const { return m_luchtdinHg; }
|
||||
|
||||
void WeatherData::setLuchtdinHg(float newLuchtdinHg) {
|
||||
if (qFuzzyCompare(m_luchtdinHg, newLuchtdinHg))
|
||||
return;
|
||||
m_luchtdinHg = newLuchtdinHg;
|
||||
emit luchtdinHgChanged();
|
||||
}
|
||||
|
||||
int WeatherData::hw() const { return m_hw; }
|
||||
|
||||
void WeatherData::setHw(int newHw) {
|
||||
if (m_hw == newHw)
|
||||
return;
|
||||
m_hw = newHw;
|
||||
emit hwChanged();
|
||||
}
|
||||
|
||||
int WeatherData::mw() const { return m_mw; }
|
||||
|
||||
void WeatherData::setMw(int newMw) {
|
||||
if (m_mw == newMw)
|
||||
return;
|
||||
m_mw = newMw;
|
||||
emit mwChanged();
|
||||
}
|
||||
|
||||
int WeatherData::lw() const { return m_lw; }
|
||||
|
||||
void WeatherData::setLw(int newLw) {
|
||||
if (m_lw == newLw)
|
||||
return;
|
||||
m_lw = newLw;
|
||||
emit lwChanged();
|
||||
}
|
||||
|
||||
int WeatherData::tw() const { return m_tw; }
|
||||
|
||||
void WeatherData::setTw(int newTw) {
|
||||
if (m_tw == newTw)
|
||||
return;
|
||||
m_tw = newTw;
|
||||
emit twChanged();
|
||||
}
|
||||
|
||||
int WeatherData::rv() const { return m_rv; }
|
||||
|
||||
void WeatherData::setRv(int newRv) {
|
||||
if (m_rv == newRv)
|
||||
return;
|
||||
m_rv = newRv;
|
||||
emit rvChanged();
|
||||
}
|
||||
|
||||
int WeatherData::gr() const { return m_gr; }
|
||||
|
||||
void WeatherData::setGr(int newGr) {
|
||||
if (m_gr == newGr)
|
||||
return;
|
||||
m_gr = newGr;
|
||||
emit grChanged();
|
||||
}
|
||||
|
||||
int WeatherData::gr_w() const { return m_gr_w; }
|
||||
|
||||
void WeatherData::setGr_w(int newGr_w) {
|
||||
if (m_gr_w == newGr_w)
|
||||
return;
|
||||
m_gr_w = newGr_w;
|
||||
emit gr_wChanged();
|
||||
}
|
||||
|
||||
QString WeatherData::cape() const { return m_cape; }
|
||||
|
||||
void WeatherData::setCape(const QString &newCape) {
|
||||
if (m_cape == newCape)
|
||||
return;
|
||||
m_cape = newCape;
|
||||
emit capeChanged();
|
||||
}
|
||||
|
||||
int WeatherData::snd() const { return m_snd; }
|
||||
|
||||
void WeatherData::setSnd(int newSnd) {
|
||||
if (m_snd == newSnd)
|
||||
return;
|
||||
m_snd = newSnd;
|
||||
emit sndChanged();
|
||||
}
|
||||
|
||||
int WeatherData::snv() const { return m_snv; }
|
||||
|
||||
void WeatherData::setSnv(int newSnv) {
|
||||
if (m_snv == newSnv)
|
||||
return;
|
||||
m_snv = newSnv;
|
||||
emit snvChanged();
|
||||
}
|
||||
|
||||
int WeatherData::cond() const { return m_cond; }
|
||||
|
||||
void WeatherData::setCond(int newCond) {
|
||||
if (m_cond == newCond)
|
||||
return;
|
||||
m_cond = newCond;
|
||||
emit condChanged();
|
||||
}
|
||||
|
||||
int WeatherData::iconCode() const { return m_iconCode; }
|
||||
|
||||
void WeatherData::setIconCode(int newIconCode) {
|
||||
if (m_iconCode == newIconCode)
|
||||
return;
|
||||
m_iconCode = newIconCode;
|
||||
emit iconCodeChanged();
|
||||
}
|
||||
|
||||
QString WeatherData::sameenv() const { return m_sameenv; }
|
||||
|
||||
void WeatherData::setSameenv(const QString &newSameenv) {
|
||||
if (m_sameenv == newSameenv)
|
||||
return;
|
||||
m_sameenv = newSameenv;
|
||||
emit sameenvChanged();
|
||||
}
|
||||
|
||||
QString WeatherData::icoon() const { return m_icoon; }
|
||||
|
||||
void WeatherData::setIcoon(const QString &newIcoon) {
|
||||
if (m_icoon == newIcoon)
|
||||
return;
|
||||
m_icoon = newIcoon;
|
||||
emit icoonChanged();
|
||||
}
|
||||
|
||||
void WeatherData::print() {}
|
||||
306
mvc/data/weatherdata.h
Normal file
306
mvc/data/weatherdata.h
Normal file
@@ -0,0 +1,306 @@
|
||||
#ifndef WEATHERDATA_H
|
||||
#define WEATHERDATA_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class WeatherData : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ICON_NAME {
|
||||
regen,
|
||||
bewolkt,
|
||||
halfbewolkt,
|
||||
lichtbewolkt,
|
||||
nachtbewolkt,
|
||||
wolkennacht,
|
||||
zonnig,
|
||||
helderenacht
|
||||
};
|
||||
Q_ENUM(ICON_NAME)
|
||||
|
||||
enum WEATHER_COND {
|
||||
Regen,
|
||||
Bewolkt,
|
||||
Halfbewolkt,
|
||||
Lichtbewolkt,
|
||||
Zonnig,
|
||||
Helder
|
||||
};
|
||||
Q_ENUM(WEATHER_COND)
|
||||
|
||||
enum WIND_DIR {
|
||||
Noord,
|
||||
NNO,
|
||||
NO,
|
||||
ONO,
|
||||
Oost,
|
||||
OZO,
|
||||
ZO,
|
||||
ZZO,
|
||||
Zuid,
|
||||
ZZW,
|
||||
ZW,
|
||||
WZW,
|
||||
West,
|
||||
WNW,
|
||||
NW,
|
||||
NNW
|
||||
};
|
||||
Q_ENUM(WIND_DIR)
|
||||
|
||||
explicit WeatherData(QObject *parent = nullptr);
|
||||
|
||||
WeatherData(long tijd, const QString &tijd_nl, int offset, float temp,
|
||||
int wind_ms, int wind_bf, int wind_knp, int wind_kmh, int wind_r,
|
||||
const QString &wind_ltr, int visibility, int neersl,
|
||||
float luchtd_bar, float luchtdmmhg, float luchtdinHg, int hw,
|
||||
int mw, int lw, int tw, int rv, int gr, int gr_w,
|
||||
const QString &cape, int snd, int snv, int cond, int iconCode,
|
||||
const QString &sameenv, const QString &icoon);
|
||||
|
||||
WeatherData(const WeatherData &other);
|
||||
WeatherData operator=(WeatherData const &other);
|
||||
|
||||
Q_PROPERTY(long tijd READ tijd WRITE setTijd NOTIFY tijdChanged
|
||||
FINAL) // DateTime in Timestamp
|
||||
Q_PROPERTY(QString tijd_nl READ tijd_nl WRITE setTijd_nl NOTIFY tijd_nlChanged
|
||||
FINAL) // DateTime is Human readable format
|
||||
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged
|
||||
FINAL) // Offset is the last reference hour point of the
|
||||
// model's predicted weather data
|
||||
Q_PROPERTY(float temp READ temp WRITE setTemp NOTIFY tempChanged
|
||||
FINAL) // temp in Celsius
|
||||
Q_PROPERTY(int wind_ms READ wind_ms WRITE setWind_ms NOTIFY wind_msChanged
|
||||
FINAL) // Wind avg speed in m/s
|
||||
Q_PROPERTY(int wind_bf READ wind_bf WRITE setWind_bf NOTIFY wind_bfChanged
|
||||
FINAL) // Wind avg speed in Beaufort
|
||||
Q_PROPERTY(int wind_knp READ wind_knp WRITE setWind_knp NOTIFY wind_knpChanged
|
||||
FINAL) // Wind avg speed in knots
|
||||
Q_PROPERTY(int wind_kmh READ wind_kmh WRITE setWind_kmh NOTIFY wind_kmhChanged
|
||||
FINAL) // Wind avg speed in k/h
|
||||
Q_PROPERTY(int wind_r READ wind_r WRITE setWind_r NOTIFY wind_rChanged
|
||||
FINAL) // Wind direction in degrees
|
||||
Q_PROPERTY(
|
||||
QString wind_ltr READ wind_ltr WRITE setWind_ltr NOTIFY wind_ltrChanged
|
||||
FINAL) // Wind directions in Letters like N,S,E,W
|
||||
Q_PROPERTY(int visibility READ visibility WRITE setVisibility NOTIFY
|
||||
visibilityChanged FINAL) // Visibility in meters
|
||||
Q_PROPERTY(int neersl READ neersl WRITE setNeersl NOTIFY neerslChanged
|
||||
FINAL) // Precipitation in nml
|
||||
Q_PROPERTY(float luchtd_bar READ luchtd_bar WRITE setLuchtd_bar NOTIFY
|
||||
luchtd_barChanged FINAL) // Air pressure in mbar
|
||||
Q_PROPERTY(float luchtdmmhg READ luchtdmmhg WRITE setLuchtdmmhg NOTIFY
|
||||
luchtdmmhgChanged FINAL) // Air pressure in mmHg
|
||||
Q_PROPERTY(float luchtdinHg READ luchtdinHg WRITE setLuchtdinHg NOTIFY
|
||||
luchtdinHgChanged FINAL) // Air pressure in inHg
|
||||
Q_PROPERTY(int hw READ hw WRITE setHw NOTIFY hwChanged
|
||||
FINAL) //% of Higher Cloud desnsity
|
||||
Q_PROPERTY(int mw READ mw WRITE setMw NOTIFY mwChanged
|
||||
FINAL) // % of medium cloud density
|
||||
Q_PROPERTY(int lw READ lw WRITE setLw NOTIFY lwChanged
|
||||
FINAL) // % of low cloud density
|
||||
Q_PROPERTY(int tw READ tw WRITE setTw NOTIFY twChanged
|
||||
FINAL) // % avg of all cloud density
|
||||
Q_PROPERTY(
|
||||
int rv READ rv WRITE setRv NOTIFY rvChanged FINAL) // Reletive Humidity
|
||||
Q_PROPERTY(int gr READ gr WRITE setGr NOTIFY grChanged
|
||||
FINAL) // Expected Sun radiation J/cm2
|
||||
Q_PROPERTY(int gr_w READ gr_w WRITE setGr_w NOTIFY gr_wChanged
|
||||
FINAL) // Expected Sun radiation watts/m2
|
||||
Q_PROPERTY(QString cape READ cape WRITE setCape NOTIFY capeChanged
|
||||
FINAL) // Not gonna use it
|
||||
Q_PROPERTY(int snd READ snd WRITE setSnd NOTIFY sndChanged
|
||||
FINAL) // Available snow deck in mm
|
||||
Q_PROPERTY(int snv READ snv WRITE setSnv NOTIFY snvChanged
|
||||
FINAL) // Actual snowfall in mm
|
||||
Q_PROPERTY(int cond READ cond WRITE setCond NOTIFY condChanged
|
||||
FINAL) // Cond is condition code is weather type like sunny,
|
||||
// rainy, etc
|
||||
Q_PROPERTY(int iconCode READ iconCode WRITE setIconCode NOTIFY iconCodeChanged
|
||||
FINAL) // Icon code of the weather
|
||||
Q_PROPERTY(QString sameenv READ sameenv WRITE setSameenv NOTIFY sameenvChanged
|
||||
FINAL) // Name of the current weather type
|
||||
Q_PROPERTY(QString icoon READ icoon WRITE setIcoon NOTIFY icoonChanged
|
||||
FINAL) // Icon name of the current weather
|
||||
|
||||
long tijd() const;
|
||||
void setTijd(long newTijd);
|
||||
|
||||
QString tijd_nl() const;
|
||||
void setTijd_nl(const QString &newTijd_nl);
|
||||
|
||||
int offset() const;
|
||||
void setOffset(int newOffset);
|
||||
|
||||
float temp() const;
|
||||
void setTemp(float newTemp);
|
||||
|
||||
int wind_ms() const;
|
||||
void setWind_ms(int newWind_ms);
|
||||
|
||||
int wind_bf() const;
|
||||
void setWind_bf(int newWind_bf);
|
||||
|
||||
int wind_knp() const;
|
||||
void setWind_knp(int newWind_knp);
|
||||
|
||||
int wind_kmh() const;
|
||||
void setWind_kmh(int newWind_kmh);
|
||||
|
||||
int wind_r() const;
|
||||
void setWind_r(int newWind_r);
|
||||
|
||||
QString wind_ltr() const;
|
||||
void setWind_ltr(const QString &newWind_ltr);
|
||||
|
||||
int visibility() const;
|
||||
void setVisibility(int newVisibility);
|
||||
|
||||
int neersl() const;
|
||||
void setNeersl(int newNeersl);
|
||||
|
||||
float luchtd_bar() const;
|
||||
void setLuchtd_bar(float newLuchtd_bar);
|
||||
|
||||
float luchtdmmhg() const;
|
||||
void setLuchtdmmhg(float newLuchtdmmhg);
|
||||
|
||||
float luchtdinHg() const;
|
||||
void setLuchtdinHg(float newLuchtdinHg);
|
||||
|
||||
int hw() const;
|
||||
void setHw(int newHw);
|
||||
|
||||
int mw() const;
|
||||
void setMw(int newMw);
|
||||
|
||||
int lw() const;
|
||||
void setLw(int newLw);
|
||||
|
||||
int tw() const;
|
||||
void setTw(int newTw);
|
||||
|
||||
int rv() const;
|
||||
void setRv(int newRv);
|
||||
|
||||
int gr() const;
|
||||
void setGr(int newGr);
|
||||
|
||||
int gr_w() const;
|
||||
void setGr_w(int newGr_w);
|
||||
|
||||
QString cape() const;
|
||||
void setCape(const QString &newCape);
|
||||
|
||||
int snd() const;
|
||||
void setSnd(int newSnd);
|
||||
|
||||
int snv() const;
|
||||
void setSnv(int newSnv);
|
||||
|
||||
int cond() const;
|
||||
void setCond(int newCond);
|
||||
|
||||
int iconCode() const;
|
||||
void setIconCode(int newIconCode);
|
||||
|
||||
QString sameenv() const;
|
||||
void setSameenv(const QString &newSameenv);
|
||||
|
||||
QString icoon() const;
|
||||
void setIcoon(const QString &newIcoon);
|
||||
|
||||
void print();
|
||||
|
||||
signals:
|
||||
void tijdChanged();
|
||||
void tijd_nlChanged();
|
||||
|
||||
void offsetChanged();
|
||||
|
||||
void tempChanged();
|
||||
|
||||
void wind_msChanged();
|
||||
|
||||
void wind_bfChanged();
|
||||
|
||||
void wind_knpChanged();
|
||||
|
||||
void wind_kmhChanged();
|
||||
|
||||
void wind_rChanged();
|
||||
|
||||
void wind_ltrChanged();
|
||||
|
||||
void visibilityChanged();
|
||||
|
||||
void neerslChanged();
|
||||
|
||||
void luchtd_barChanged();
|
||||
|
||||
void luchtdmmhgChanged();
|
||||
|
||||
void luchtdinHgChanged();
|
||||
|
||||
void hwChanged();
|
||||
|
||||
void mwChanged();
|
||||
|
||||
void lwChanged();
|
||||
|
||||
void twChanged();
|
||||
|
||||
void rvChanged();
|
||||
|
||||
void grChanged();
|
||||
|
||||
void gr_wChanged();
|
||||
|
||||
void capeChanged();
|
||||
|
||||
void sndChanged();
|
||||
|
||||
void snvChanged();
|
||||
|
||||
void condChanged();
|
||||
|
||||
void iconCodeChanged();
|
||||
|
||||
void sameenvChanged();
|
||||
|
||||
void icoonChanged();
|
||||
|
||||
private:
|
||||
long m_tijd;
|
||||
QString m_tijd_nl;
|
||||
int m_offset;
|
||||
float m_temp;
|
||||
int m_wind_ms;
|
||||
int m_wind_bf;
|
||||
int m_wind_knp;
|
||||
int m_wind_kmh;
|
||||
int m_wind_r;
|
||||
QString m_wind_ltr;
|
||||
int m_visibility;
|
||||
int m_neersl;
|
||||
float m_luchtd_bar;
|
||||
float m_luchtdmmhg;
|
||||
float m_luchtdinHg;
|
||||
int m_hw;
|
||||
int m_mw;
|
||||
int m_lw;
|
||||
int m_tw;
|
||||
int m_rv;
|
||||
int m_gr;
|
||||
int m_gr_w;
|
||||
QString m_cape;
|
||||
int m_snd;
|
||||
int m_snv;
|
||||
int m_cond;
|
||||
int m_iconCode;
|
||||
QString m_sameenv;
|
||||
QString m_icoon;
|
||||
};
|
||||
|
||||
#endif // WEATHERDATA_H
|
||||
84
mvc/data/weatherdetailsdata.cpp
Normal file
84
mvc/data/weatherdetailsdata.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "weatherdetailsdata.h"
|
||||
#include <QJsonArray>
|
||||
#include <qjsonobject.h>
|
||||
|
||||
WeatherDetailsData::WeatherDetailsData(QObject *parent) : QObject{parent} {}
|
||||
|
||||
WeatherDetailsData::WeatherDetailsData(std::shared_ptr<WeatherController> &ctrl)
|
||||
: m_localWeatherCtrl(ctrl) {}
|
||||
|
||||
QString WeatherDetailsData::weatherStatus() const { return m_weatherStatus; }
|
||||
|
||||
void WeatherDetailsData::setWeatherStatus(QString newWeatherStatus) {
|
||||
if (m_weatherStatus == newWeatherStatus)
|
||||
return;
|
||||
m_weatherStatus = newWeatherStatus;
|
||||
emit weatherStatusChanged();
|
||||
}
|
||||
|
||||
double WeatherDetailsData::temperature() const { return m_temperature; }
|
||||
|
||||
void WeatherDetailsData::setTemperature(double newTemperature) {
|
||||
if (qFuzzyCompare(m_temperature, newTemperature))
|
||||
return;
|
||||
m_temperature = newTemperature;
|
||||
emit temperatureChanged();
|
||||
}
|
||||
|
||||
double WeatherDetailsData::humidity() const { return m_humidity; }
|
||||
|
||||
void WeatherDetailsData::setHumidity(double newHumidity) {
|
||||
if (qFuzzyCompare(m_humidity, newHumidity))
|
||||
return;
|
||||
m_humidity = newHumidity;
|
||||
emit humidityChanged();
|
||||
}
|
||||
|
||||
double WeatherDetailsData::windSpeed() const { return m_windSpeed; }
|
||||
|
||||
void WeatherDetailsData::setWindSpeed(double newWindSpeed) {
|
||||
if (qFuzzyCompare(m_windSpeed, newWindSpeed))
|
||||
return;
|
||||
m_windSpeed = newWindSpeed;
|
||||
emit windSpeedChanged();
|
||||
}
|
||||
|
||||
double WeatherDetailsData::precipitation() const { return m_precipitation; }
|
||||
|
||||
void WeatherDetailsData::setPrecipitation(double newPrecipitation) {
|
||||
if (qFuzzyCompare(m_precipitation, newPrecipitation))
|
||||
return;
|
||||
m_precipitation = newPrecipitation;
|
||||
emit precipitationChanged();
|
||||
}
|
||||
|
||||
void WeatherDetailsData::populate(double temperature, double humidity,
|
||||
double windSpeed, double precipitation,
|
||||
QString weatherStatus) {
|
||||
setTemperature(temperature);
|
||||
setHumidity(humidity);
|
||||
setWindSpeed(windSpeed);
|
||||
setPrecipitation(precipitation);
|
||||
setWeatherStatus(weatherStatus);
|
||||
}
|
||||
|
||||
void WeatherDetailsData::populate(QGeoCoordinate coord) {
|
||||
QJsonObject obj = m_localWeatherCtrl->fetchCurrentWeatherData(coord);
|
||||
QJsonArray liveweerArray = obj["liveweer"].toArray();
|
||||
QJsonObject firstEntry = liveweerArray.at(0).toObject();
|
||||
QString temp = verifyForDash(firstEntry["temp"].toString());
|
||||
QString humidity = verifyForDash(firstEntry["lv"].toString());
|
||||
QString windSpeed = verifyForDash(firstEntry["windkmh"].toString());
|
||||
QString precipitation = verifyForDash(firstEntry["neerslagints"].toString());
|
||||
QString weatherStatus = verifyForDash(firstEntry["image"].toString());
|
||||
populate(temp.toDouble(), humidity.toDouble(), windSpeed.toDouble(),
|
||||
precipitation.toDouble(), weatherStatus);
|
||||
}
|
||||
|
||||
QString WeatherDetailsData::getImgSrc(QString status) {
|
||||
return QString("qrc:/images/live_icons/%1.png").arg(status);
|
||||
}
|
||||
|
||||
QString WeatherDetailsData::verifyForDash(QString data) {
|
||||
return data == "-" ? "0" : data;
|
||||
}
|
||||
81
mvc/data/weatherdetailsdata.h
Normal file
81
mvc/data/weatherdetailsdata.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#ifndef WEATHERDETAILSDATA_H
|
||||
#define WEATHERDETAILSDATA_H
|
||||
|
||||
#include <QObject>
|
||||
#include "../controller/weathercontroller.h"
|
||||
#include "enums/weatherstatus.h"
|
||||
#include <QObject>
|
||||
|
||||
class WeatherDetailsData : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum LIVE_ICON_NAME {
|
||||
zonnig,
|
||||
bliksem,
|
||||
regen,
|
||||
buien,
|
||||
hagel,
|
||||
mist,
|
||||
sneeuw,
|
||||
bewolkt,
|
||||
halfbewolkt,
|
||||
zwaarbewolkt,
|
||||
lichtbewolkt,
|
||||
nachtmist,
|
||||
helderenacht,
|
||||
wolkennacht
|
||||
};
|
||||
Q_ENUM(LIVE_ICON_NAME)
|
||||
|
||||
explicit WeatherDetailsData(QObject *parent = nullptr);
|
||||
WeatherDetailsData(std::shared_ptr<WeatherController> &ctrl);
|
||||
|
||||
Q_PROPERTY(double temperature READ temperature WRITE setTemperature NOTIFY
|
||||
temperatureChanged FINAL)
|
||||
Q_PROPERTY(double humidity READ humidity WRITE setHumidity NOTIFY
|
||||
humidityChanged FINAL)
|
||||
Q_PROPERTY(double windSpeed READ windSpeed WRITE setWindSpeed NOTIFY
|
||||
windSpeedChanged FINAL)
|
||||
Q_PROPERTY(double precipitation READ precipitation WRITE setPrecipitation
|
||||
NOTIFY precipitationChanged FINAL)
|
||||
Q_PROPERTY(QString weatherStatus READ weatherStatus WRITE setWeatherStatus
|
||||
NOTIFY weatherStatusChanged FINAL)
|
||||
|
||||
QString weatherStatus() const;
|
||||
void setWeatherStatus(QString newWeatherStatus);
|
||||
|
||||
double temperature() const;
|
||||
void setTemperature(double newTemperature);
|
||||
|
||||
double humidity() const;
|
||||
void setHumidity(double newHumidity);
|
||||
|
||||
double windSpeed() const;
|
||||
void setWindSpeed(double newWindSpeed);
|
||||
|
||||
double precipitation() const;
|
||||
void setPrecipitation(double newPrecipitation);
|
||||
|
||||
void populate(double temperature, double humidity, double windSpeed,
|
||||
double precipitation, QString weatherStatus);
|
||||
Q_INVOKABLE void populate(QGeoCoordinate coord);
|
||||
Q_INVOKABLE QString getImgSrc(QString status);
|
||||
|
||||
signals:
|
||||
void weatherStatusChanged();
|
||||
void temperatureChanged();
|
||||
void humidityChanged();
|
||||
void windSpeedChanged();
|
||||
void precipitationChanged();
|
||||
|
||||
private:
|
||||
QString m_weatherStatus = "regen";
|
||||
double m_temperature = 0.0;
|
||||
double m_humidity = 0.0;
|
||||
double m_windSpeed = 0.0;
|
||||
double m_precipitation = 0.0;
|
||||
std::shared_ptr<WeatherController> m_localWeatherCtrl;
|
||||
QString verifyForDash(QString data);
|
||||
};
|
||||
|
||||
#endif // WEATHERDETAILSDATA_H
|
||||
Reference in New Issue
Block a user