mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Removed duplicated method.
This patch removes a duplicated method: get_divenr and get_index_for_dive. The two are exactly the same ( if my c is not broken, but I may be broken since I'm working like crazy for almost 30h nonstop. ), so please take a good look before applying this one. [Dirk Hohndel: Tomaz took the slightly broken of the two implementations, so I switched that out for the correct one] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ad0aa8cc49
commit
314cf4c628
4 changed files with 14 additions and 23 deletions
9
dive.c
9
dive.c
|
@ -2038,15 +2038,6 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_index_for_dive(struct dive *dive) {
|
|
||||||
int i;
|
|
||||||
struct dive *d;
|
|
||||||
for_each_dive(i, d)
|
|
||||||
if (d == dive)
|
|
||||||
return i;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct dive *find_dive_including(timestamp_t when)
|
struct dive *find_dive_including(timestamp_t when)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
2
dive.h
2
dive.h
|
@ -416,8 +416,6 @@ struct dive {
|
||||||
struct divecomputer dc;
|
struct divecomputer dc;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int get_index_for_dive(struct dive *dive);
|
|
||||||
|
|
||||||
static inline int dive_has_gps_location(struct dive *dive)
|
static inline int dive_has_gps_location(struct dive *dive)
|
||||||
{
|
{
|
||||||
return dive->latitude.udeg || dive->longitude.udeg;
|
return dive->latitude.udeg || dive->longitude.udeg;
|
||||||
|
|
14
divelist.c
14
divelist.c
|
@ -368,10 +368,12 @@ static void add_dive_to_deco(struct dive *dive)
|
||||||
|
|
||||||
int get_divenr(struct dive *dive)
|
int get_divenr(struct dive *dive)
|
||||||
{
|
{
|
||||||
int divenr = -1;
|
int i;
|
||||||
while (++divenr < dive_table.nr && get_dive(divenr) != dive)
|
struct dive *d;
|
||||||
;
|
for_each_dive(i, d)
|
||||||
return divenr;
|
if (d == dive)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct gasmix air = { .o2.permille = O2_IN_AIR };
|
static struct gasmix air = { .o2.permille = O2_IN_AIR };
|
||||||
|
@ -787,8 +789,8 @@ struct dive *merge_two_dives(struct dive *a, struct dive *b)
|
||||||
|
|
||||||
if (!a || !b)
|
if (!a || !b)
|
||||||
return NULL;
|
return NULL;
|
||||||
i = get_index_for_dive(a);
|
i = get_divenr(a);
|
||||||
j = get_index_for_dive(b);
|
j = get_divenr(b);
|
||||||
res = merge_dives(a, b, b->when - a->when, FALSE);
|
res = merge_dives(a, b, b->when - a->when, FALSE);
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -227,9 +227,9 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
|
||||||
|
|
||||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
||||||
QAbstractItemModel *oldModel = m->sourceModel();
|
QAbstractItemModel *oldModel = m->sourceModel();
|
||||||
if (oldModel)
|
if (oldModel){
|
||||||
oldModel->deleteLater();
|
oldModel->deleteLater();
|
||||||
|
}
|
||||||
DiveTripModel *tripModel = new DiveTripModel(this);
|
DiveTripModel *tripModel = new DiveTripModel(this);
|
||||||
tripModel->setLayout(layout);
|
tripModel->setLayout(layout);
|
||||||
|
|
||||||
|
@ -347,12 +347,12 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS
|
||||||
if (child && child->divetrip)
|
if (child && child->divetrip)
|
||||||
selectedTrips.remove(child->divetrip);
|
selectedTrips.remove(child->divetrip);
|
||||||
while (child) {
|
while (child) {
|
||||||
deselect_dive(get_index_for_dive(child));
|
deselect_dive(get_divenr(child));
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deselect_dive(get_index_for_dive(dive));
|
deselect_dive(get_divenr(dive));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_FOREACH(const QModelIndex& index, newSelected.indexes()) {
|
Q_FOREACH(const QModelIndex& index, newSelected.indexes()) {
|
||||||
|
@ -368,7 +368,7 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS
|
||||||
if (child && child->divetrip)
|
if (child && child->divetrip)
|
||||||
selectedTrips.insert(child->divetrip);
|
selectedTrips.insert(child->divetrip);
|
||||||
while (child) {
|
while (child) {
|
||||||
select_dive(get_index_for_dive(child));
|
select_dive(get_divenr(child));
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
selection.select(index.child(0,0), index.child(model->rowCount(index) -1 , 0));
|
selection.select(index.child(0,0), index.child(model->rowCount(index) -1 , 0));
|
||||||
|
@ -378,7 +378,7 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS
|
||||||
expand(index);
|
expand(index);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
select_dive(get_index_for_dive(dive));
|
select_dive(get_divenr(dive));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QTreeView::selectionChanged(selectionModel()->selection(), newDeselected);
|
QTreeView::selectionChanged(selectionModel()->selection(), newDeselected);
|
||||||
|
|
Loading…
Add table
Reference in a new issue