mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: Make cylinder formatting functions const-clean
In qt-models/cylindermodel.cpp the various formatting functions can take a pointer-to-const cylinder. Thus, the data() function can likewise treat the cylinder as const - as it should. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
4355ce3924
commit
cd4f66014f
1 changed files with 8 additions and 9 deletions
|
@ -29,14 +29,13 @@ QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, in
|
||||||
return CleanerTableModel::headerData(section, orientation, role);
|
return CleanerTableModel::headerData(section, orientation, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CylindersModel *CylindersModel::instance()
|
CylindersModel *CylindersModel::instance()
|
||||||
{
|
{
|
||||||
static CylindersModel self;
|
static CylindersModel self;
|
||||||
return &self;
|
return &self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString get_cylinder_string(cylinder_t *cyl)
|
static QString get_cylinder_string(const cylinder_t *cyl)
|
||||||
{
|
{
|
||||||
QString unit;
|
QString unit;
|
||||||
int decimals;
|
int decimals;
|
||||||
|
@ -73,9 +72,9 @@ static QString gas_volume_string(int ml, const char *tail)
|
||||||
return QString("%L1 %2 %3").arg(vol, 0, 'f', decimals).arg(unit).arg(tail);
|
return QString("%L1 %2 %3").arg(vol, 0, 'f', decimals).arg(unit).arg(tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant gas_wp_tooltip(cylinder_t *cyl);
|
static QVariant gas_wp_tooltip(const cylinder_t *cyl);
|
||||||
|
|
||||||
static QVariant gas_usage_tooltip(cylinder_t *cyl)
|
static QVariant gas_usage_tooltip(const cylinder_t *cyl)
|
||||||
{
|
{
|
||||||
pressure_t startp = cyl->start.mbar ? cyl->start : cyl->sample_start;
|
pressure_t startp = cyl->start.mbar ? cyl->start : cyl->sample_start;
|
||||||
pressure_t endp = cyl->end.mbar ? cyl->end : cyl->sample_end;
|
pressure_t endp = cyl->end.mbar ? cyl->end : cyl->sample_end;
|
||||||
|
@ -94,7 +93,7 @@ static QVariant gas_usage_tooltip(cylinder_t *cyl)
|
||||||
gas_volume_string(end, ")");
|
gas_volume_string(end, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant gas_volume_tooltip(cylinder_t *cyl, pressure_t p)
|
static QVariant gas_volume_tooltip(const cylinder_t *cyl, pressure_t p)
|
||||||
{
|
{
|
||||||
int vol = gas_volume(cyl, p);
|
int vol = gas_volume(cyl, p);
|
||||||
double Z;
|
double Z;
|
||||||
|
@ -106,17 +105,17 @@ static QVariant gas_volume_tooltip(cylinder_t *cyl, pressure_t p)
|
||||||
return gas_volume_string(vol, "(Z=") + QString("%1)").arg(Z, 0, 'f', 3);
|
return gas_volume_string(vol, "(Z=") + QString("%1)").arg(Z, 0, 'f', 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant gas_wp_tooltip(cylinder_t *cyl)
|
static QVariant gas_wp_tooltip(const cylinder_t *cyl)
|
||||||
{
|
{
|
||||||
return gas_volume_tooltip(cyl, cyl->type.workingpressure);
|
return gas_volume_tooltip(cyl, cyl->type.workingpressure);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant gas_start_tooltip(cylinder_t *cyl)
|
static QVariant gas_start_tooltip(const cylinder_t *cyl)
|
||||||
{
|
{
|
||||||
return gas_volume_tooltip(cyl, cyl->start.mbar ? cyl->start : cyl->sample_start);
|
return gas_volume_tooltip(cyl, cyl->start.mbar ? cyl->start : cyl->sample_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant gas_end_tooltip(cylinder_t *cyl)
|
static QVariant gas_end_tooltip(const cylinder_t *cyl)
|
||||||
{
|
{
|
||||||
return gas_volume_tooltip(cyl, cyl->end.mbar ? cyl->end : cyl->sample_end);
|
return gas_volume_tooltip(cyl, cyl->end.mbar ? cyl->end : cyl->sample_end);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +134,7 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
||||||
if (!index.isValid() || index.row() >= MAX_CYLINDERS)
|
if (!index.isValid() || index.row() >= MAX_CYLINDERS)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
const cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::BackgroundRole: {
|
case Qt::BackgroundRole: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue