mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Core: Rename functions to more generic names
Rename - dive_get_insertion_index() -> dive_table_get_insertion_index() - unregister_dive_from_table() -> remove_from_dive_table() - get_idx_in_table() -> get_idx_in_dive_table() - sort_table() -> sort_dive_table() This will make it more straight-forward to generate these functions from macros. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2802d42969
commit
d1971a64f9
9 changed files with 22 additions and 22 deletions
|
@ -610,7 +610,7 @@ int datatrak_import(struct memblock *mem, struct dive_table *table)
|
|||
}
|
||||
out:
|
||||
taglist_cleanup(&g_tag_list);
|
||||
sort_table(table);
|
||||
sort_dive_table(table);
|
||||
return rc;
|
||||
bail:
|
||||
return 1;
|
||||
|
|
|
@ -542,7 +542,7 @@ extern int legacy_format_o2pressures(const struct dive *dive, const struct divec
|
|||
extern bool dive_less_than(const struct dive *a, const struct dive *b);
|
||||
extern bool trip_less_than(const struct dive_trip *a, const struct dive_trip *b);
|
||||
extern bool dive_or_trip_less_than(struct dive_or_trip a, struct dive_or_trip b);
|
||||
extern void sort_table(struct dive_table *table);
|
||||
extern void sort_dive_table(struct dive_table *table);
|
||||
extern struct dive *fixup_dive(struct dive *dive);
|
||||
extern void fixup_dc_duration(struct divecomputer *dc);
|
||||
extern int dive_getUniqID();
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
* bool dive_less_than(const struct dive *a, const struct dive *b)
|
||||
* bool trip_less_than(const struct dive_trip *a, const struct dive_trip *b)
|
||||
* bool dive_or_trip_less_than(struct dive_or_trip a, struct dive_or_trip b)
|
||||
* void sort_table(struct dive_table *table)
|
||||
* void sort_dive_table(struct dive_table *table)
|
||||
* bool is_trip_before_after(const struct dive *dive, bool before)
|
||||
* void delete_dive_from_table(struct dive_table *table, int idx)
|
||||
* int find_next_visible_dive(timestamp_t when);
|
||||
|
@ -498,7 +498,7 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive)
|
|||
}
|
||||
}
|
||||
|
||||
static int get_idx_in_table(const struct dive_table *table, const struct dive *dive)
|
||||
static int get_idx_in_dive_table(const struct dive_table *table, const struct dive *dive)
|
||||
{
|
||||
for (int i = 0; i < table->nr; ++i) {
|
||||
if (table->dives[i] == dive)
|
||||
|
@ -885,7 +885,7 @@ static void add_to_dive_table(struct dive_table *table, int idx, struct dive *di
|
|||
}
|
||||
}
|
||||
|
||||
static void unregister_dive_from_table(struct dive_table *table, int idx)
|
||||
static void remove_from_dive_table(struct dive_table *table, int idx)
|
||||
{
|
||||
int i;
|
||||
for (i = idx; i < table->nr - 1; i++)
|
||||
|
@ -905,9 +905,9 @@ struct dive_trip *unregister_dive_from_trip(struct dive *dive)
|
|||
if (!trip)
|
||||
return NULL;
|
||||
|
||||
idx = get_idx_in_table(&trip->dives, dive);
|
||||
idx = get_idx_in_dive_table(&trip->dives, dive);
|
||||
if (idx >= 0)
|
||||
unregister_dive_from_table(&trip->dives, idx);
|
||||
remove_from_dive_table(&trip->dives, idx);
|
||||
dive->divetrip = NULL;
|
||||
return trip;
|
||||
}
|
||||
|
@ -928,7 +928,7 @@ void add_dive_to_trip(struct dive *dive, dive_trip_t *trip)
|
|||
return;
|
||||
if (dive->divetrip)
|
||||
fprintf(stderr, "Warning: adding dive to trip that has trip set\n");
|
||||
idx = dive_get_insertion_index(&trip->dives, dive);
|
||||
idx = dive_table_get_insertion_index(&trip->dives, dive);
|
||||
add_to_dive_table(&trip->dives, idx, dive);
|
||||
dive->divetrip = trip;
|
||||
}
|
||||
|
@ -1086,7 +1086,7 @@ static void autogroup_dives(struct dive_table *table)
|
|||
void delete_dive_from_table(struct dive_table *table, int idx)
|
||||
{
|
||||
free_dive(table->dives[idx]);
|
||||
unregister_dive_from_table(table, idx);
|
||||
remove_from_dive_table(table, idx);
|
||||
}
|
||||
|
||||
/* This removes a dive from the global dive table but doesn't free the
|
||||
|
@ -1098,7 +1098,7 @@ struct dive *unregister_dive(int idx)
|
|||
struct dive *dive = get_dive(idx);
|
||||
if (!dive)
|
||||
return NULL; /* this should never happen */
|
||||
unregister_dive_from_table(&dive_table, idx);
|
||||
remove_from_dive_table(&dive_table, idx);
|
||||
if (dive->selected)
|
||||
amount_selected--;
|
||||
dive->selected = false;
|
||||
|
@ -1136,7 +1136,7 @@ struct dive **grow_dive_table(struct dive_table *table)
|
|||
|
||||
/* get the index where we want to insert the dive so that everything stays
|
||||
* ordered according to dive_less_than() */
|
||||
int dive_get_insertion_index(struct dive_table *table, struct dive *dive)
|
||||
int dive_table_get_insertion_index(struct dive_table *table, struct dive *dive)
|
||||
{
|
||||
/* we might want to use binary search here */
|
||||
for (int i = 0; i < table->nr; i++) {
|
||||
|
@ -1352,7 +1352,7 @@ void process_loaded_dives()
|
|||
for_each_dive(i, dive)
|
||||
set_dc_nickname(dive);
|
||||
|
||||
sort_table(&dive_table);
|
||||
sort_dive_table(&dive_table);
|
||||
|
||||
/* Autogroup dives if desired by user. */
|
||||
autogroup_dives(&dive_table);
|
||||
|
@ -1448,7 +1448,7 @@ void process_imported_dives(struct dive_table *import_table, bool prefer_importe
|
|||
set_dc_nickname(import_table->dives[i]);
|
||||
|
||||
/* Sort the table of dives to be imported and combine mergable dives */
|
||||
sort_table(import_table);
|
||||
sort_dive_table(import_table);
|
||||
merge_imported_dives(import_table);
|
||||
|
||||
/* Merge newly imported dives into the dive table.
|
||||
|
@ -1703,7 +1703,7 @@ static int sortfn(const void *_a, const void *_b)
|
|||
return comp_dives(a, b);
|
||||
}
|
||||
|
||||
void sort_table(struct dive_table *table)
|
||||
void sort_dive_table(struct dive_table *table)
|
||||
{
|
||||
qsort(table->dives, table->nr, sizeof(struct dive *), sortfn);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ extern void process_imported_dives(struct dive_table *import_table, bool prefer_
|
|||
extern char *get_dive_gas_string(const struct dive *dive);
|
||||
|
||||
extern struct dive **grow_dive_table(struct dive_table *table);
|
||||
extern int dive_get_insertion_index(struct dive_table *table, struct dive *dive);
|
||||
extern int dive_table_get_insertion_index(struct dive_table *table, struct dive *dive);
|
||||
extern void add_single_dive(int idx, struct dive *dive);
|
||||
extern void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2low_p);
|
||||
extern int get_divenr(const struct dive *dive);
|
||||
|
|
|
@ -188,7 +188,7 @@ void ostctools_import(const char *file, struct dive_table *divetable)
|
|||
}
|
||||
record_dive_to_table(ostcdive, divetable);
|
||||
mark_divelist_changed(true);
|
||||
sort_table(divetable);
|
||||
sort_dive_table(divetable);
|
||||
|
||||
close_out:
|
||||
fclose(archive);
|
||||
|
|
|
@ -511,7 +511,7 @@ AddDive::AddDive(dive *d, bool autogroup, bool newNumber)
|
|||
allocTrip.reset(trip);
|
||||
}
|
||||
|
||||
int idx = dive_get_insertion_index(&dive_table, divePtr.get());
|
||||
int idx = dive_table_get_insertion_index(&dive_table, divePtr.get());
|
||||
if (newNumber)
|
||||
divePtr->number = get_dive_nr_at_idx(idx);
|
||||
|
||||
|
@ -603,7 +603,7 @@ void ShiftTime::redoit()
|
|||
d->when += timeChanged;
|
||||
|
||||
// Changing times may have unsorted the dive table
|
||||
sort_table(&dive_table);
|
||||
sort_dive_table(&dive_table);
|
||||
|
||||
// We send one time changed signal per trip (see comments in DiveListNotifier.h).
|
||||
// Therefore, collect all dives in an array and sort by trip.
|
||||
|
@ -615,7 +615,7 @@ void ShiftTime::redoit()
|
|||
// Send signals and sort tables.
|
||||
processByTrip(dives, [&](dive_trip *trip, const QVector<dive *> &divesInTrip) {
|
||||
if (trip)
|
||||
sort_table(&trip->dives); // Keep the trip-table in order
|
||||
sort_dive_table(&trip->dives); // Keep the trip-table in order
|
||||
emit diveListNotifier.divesTimeChanged(trip, timeChanged, divesInTrip);
|
||||
});
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ static bool merge_locations_into_dives(void)
|
|||
int i, j, tracer=0, changed=0;
|
||||
struct dive *gpsfix, *nextgpsfix, *dive;
|
||||
|
||||
sort_table(&gps_location_table);
|
||||
sort_dive_table(&gps_location_table);
|
||||
|
||||
for_each_dive (i, dive) {
|
||||
if (!dive_has_gps_location(dive)) {
|
||||
|
|
|
@ -1130,7 +1130,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
|
|||
if (needResort) {
|
||||
// we know that the only thing that might happen in a resort is that
|
||||
// this one dive moves to a different spot in the dive list
|
||||
sort_table(&dive_table);
|
||||
sort_dive_table(&dive_table);
|
||||
int newIdx = get_idx_by_uniq_id(d->id);
|
||||
if (newIdx != oldIdx) {
|
||||
DiveListModel::instance()->removeDive(modelIdx);
|
||||
|
|
|
@ -1083,5 +1083,5 @@ void smartrak_import(const char *file, struct dive_table *divetable)
|
|||
mdb->catalog = NULL;
|
||||
mdb_close(mdb_clon);
|
||||
mdb_close(mdb);
|
||||
sort_table(divetable);
|
||||
sort_dive_table(divetable);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue