summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-21 11:29:21 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-21 11:29:21 -0700
commit19586081ed57c28aed9a649f08db4d415e72dca6 (patch)
tree02ac1d95cbeff9383ae7ff0736e098b2ce34b2f1
parente7b84233af14723814f1340010bb86c6801f1e06 (diff)
downloadsubsurface-19586081ed57c28aed9a649f08db4d415e72dca6.tar.gz
Correctly use the weightsystem_none / cylinder_none helpers
Plus a couple of minor formatting changes Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.h3
-rw-r--r--equipment.c2
-rw-r--r--qt-ui/models.cpp25
3 files changed, 14 insertions, 16 deletions
diff --git a/dive.h b/dive.h
index 7c65c39fe..06c28e0f3 100644
--- a/dive.h
+++ b/dive.h
@@ -157,6 +157,7 @@ typedef struct {
extern bool cylinder_nodata(cylinder_t *cyl);
extern bool cylinder_none(void *_data);
+extern bool weightsystem_none(void *_data);
extern bool no_weightsystems(weightsystem_t *ws);
extern bool weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2);
@@ -377,7 +378,7 @@ struct dive {
pressure_t surface_pressure;
duration_t duration;
int salinity; // kg per 10000 l
- int dive_tags;
+ int dive_tags;
struct divecomputer dc;
};
diff --git a/equipment.c b/equipment.c
index 189cc617f..5f858f41d 100644
--- a/equipment.c
+++ b/equipment.c
@@ -513,7 +513,7 @@ static gboolean description_equal(const char *desc1, const char *desc2)
(desc1 && desc2 && strcmp(desc1, desc2) == 0));
}
-static gboolean weightsystem_none(void *_data)
+gboolean weightsystem_none(void *_data)
{
weightsystem_t *ws = _data;
return !ws->weight.grams && !ws->description;
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 04f7256e6..e1ac597c0 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -136,10 +136,10 @@ void CylindersModel::setDive(dive* d)
if (current)
clear();
- int amount = 0;
+ int amount = MAX_CYLINDERS;
for(int i = 0; i < MAX_CYLINDERS; i++){
- cylinder_t& cylinder = d->cylinder[i];
- if (!cylinder.type.description){
+ cylinder_t *cylinder = &d->cylinder[i];
+ if (cylinder_none(cylinder)) {
amount = i;
break;
}
@@ -217,9 +217,8 @@ QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int r
void WeightModel::add(weightsystem_t* weight)
{
- if (rows >= MAX_WEIGHTSYSTEMS) {
+ if (rows >= MAX_WEIGHTSYSTEMS)
return;
- }
int row = rows;
@@ -243,10 +242,10 @@ void WeightModel::setDive(dive* d)
if (current)
clear();
- int amount = 0;
- for(int i = 0; i < MAX_WEIGHTSYSTEMS; i++){
- weightsystem_t& weightsystem = d->weightsystem[i];
- if (!weightsystem.description){
+ int amount = MAX_WEIGHTSYSTEMS;
+ for(int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
+ weightsystem_t *weightsystem = &d->weightsystem[i];
+ if (weightsystem_none(weightsystem)) {
amount = i;
break;
}
@@ -528,13 +527,11 @@ QVariant DiveItem::data(int column, int role) const
break;
}
- if(role == STAR_ROLE){
+ if (role == STAR_ROLE)
retVal = dive->rating;
- }
- if(role == DIVE_ROLE){
+ if (role == DIVE_ROLE)
retVal = QVariant::fromValue<void*>(dive);
- }
return retVal;
}
@@ -663,7 +660,7 @@ Qt::ItemFlags DiveTripModel::flags(const QModelIndex& index) const
}
QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation,
- int role) const
+ int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return rootItem->data(section, role);