qt-models: add getters to diveplanner model

diveplannermodel already contains set_<asc/desc> function that convert from
screen value to real value; this adds get functions that convert real value to
screen value, so now all conversions are done in one place.

Use prefix Display to identify this is values prepared for the UI (both desktop
and QML).

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
jan Iversen 2020-01-19 18:19:14 +01:00 committed by Dirk Hohndel
parent 917e3ff0a2
commit 851ab68aa2
2 changed files with 27 additions and 0 deletions

View file

@ -520,30 +520,50 @@ void DivePlannerPointsModel::setAscrate75(int rate)
qPrefDivePlanner::set_ascrate75(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
int DivePlannerPointsModel::ascrate75Display()
{
return lrint((float)prefs.ascrate75 / UNIT_FACTOR);
}
void DivePlannerPointsModel::setAscrate50(int rate)
{
qPrefDivePlanner::set_ascrate50(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
int DivePlannerPointsModel::ascrate50Display()
{
return lrint((float)prefs.ascrate50 / UNIT_FACTOR);
}
void DivePlannerPointsModel::setAscratestops(int rate)
{
qPrefDivePlanner::set_ascratestops(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
int DivePlannerPointsModel::ascratestopsDisplay()
{
return lrint((float)prefs.ascratestops / UNIT_FACTOR);
}
void DivePlannerPointsModel::setAscratelast6m(int rate)
{
qPrefDivePlanner::set_ascratelast6m(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
int DivePlannerPointsModel::ascratelast6mDisplay()
{
return lrint((float)prefs.ascratelast6m / UNIT_FACTOR);
}
void DivePlannerPointsModel::setDescrate(int rate)
{
qPrefDivePlanner::set_descrate(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
int DivePlannerPointsModel::descrateDisplay()
{
return lrint((float)prefs.descrate / UNIT_FACTOR);
}
void DivePlannerPointsModel::setVerbatim(bool value)
{

View file

@ -47,6 +47,13 @@ public:
bool tankInUse(int cylinderid);
void setupCylinders();
bool updateMaxDepth();
int ascrate75Display();
int ascrate50Display();
int ascratestopsDisplay();
int ascratelast6mDisplay();
int descrateDisplay();
/**
* @return the row number.
*/