mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Cleanup: remove combine_trips() function
In f427226b3b
a combine_trips_create()
function was introduced that combined trips without deleting the old
trips. This was necessary for making combine-trips function undo-able.
The old combine_trips() function is not used anymore. Therefore remove
it. Rename the combine_trips_create() function to combine_trips() as
no differentiation is needed anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2706fa7b8e
commit
0a3d757aab
3 changed files with 4 additions and 24 deletions
|
@ -1336,34 +1336,15 @@ void filter_dive(struct dive *d, bool shown)
|
|||
}
|
||||
|
||||
|
||||
/* This only gets called with non-NULL trips.
|
||||
* It does not combine notes or location, just picks the first one
|
||||
* (or the second one if the first one is empty */
|
||||
void combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b)
|
||||
{
|
||||
if (empty_string(trip_a->location) && trip_b->location) {
|
||||
free(trip_a->location);
|
||||
trip_a->location = strdup(trip_b->location);
|
||||
}
|
||||
if (empty_string(trip_a->notes) && trip_b->notes) {
|
||||
free(trip_a->notes);
|
||||
trip_a->notes = strdup(trip_b->notes);
|
||||
}
|
||||
/* this also removes the dives from trip_b and eventually
|
||||
* calls delete_trip(trip_b) when the last dive has been moved */
|
||||
while (trip_b->dives.nr > 0)
|
||||
add_dive_to_trip(trip_b->dives.dives[0], trip_a);
|
||||
}
|
||||
|
||||
/* Out of two strings, copy the string that is not empty (if any). */
|
||||
static char *copy_non_empty_string(const char *a, const char *b)
|
||||
{
|
||||
return copy_string(empty_string(b) ? a : b);
|
||||
}
|
||||
|
||||
/* Combine trips new. This combines two trips, generating a
|
||||
/* This combines the information of two trips, generating a
|
||||
* new trip. To support undo, we have to preserve the old trips. */
|
||||
dive_trip_t *combine_trips_create(struct dive_trip *trip_a, struct dive_trip *trip_b)
|
||||
dive_trip_t *combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b)
|
||||
{
|
||||
dive_trip_t *trip;
|
||||
|
||||
|
|
|
@ -44,8 +44,7 @@ extern void deselect_dive(struct dive *dive);
|
|||
extern void select_dives_in_trip(struct dive_trip *trip);
|
||||
extern void deselect_dives_in_trip(struct dive_trip *trip);
|
||||
extern void filter_dive(struct dive *d, bool shown);
|
||||
extern void combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b);
|
||||
extern dive_trip_t *combine_trips_create(struct dive_trip *trip_a, struct dive_trip *trip_b);
|
||||
extern dive_trip_t *combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b);
|
||||
extern struct dive *first_selected_dive();
|
||||
extern struct dive *last_selected_dive();
|
||||
extern bool is_trip_before_after(const struct dive *dive, bool before);
|
||||
|
|
|
@ -743,7 +743,7 @@ MergeTrips::MergeTrips(dive_trip *trip1, dive_trip *trip2)
|
|||
{
|
||||
if (trip1 == trip2)
|
||||
return;
|
||||
dive_trip *newTrip = combine_trips_create(trip1, trip2);
|
||||
dive_trip *newTrip = combine_trips(trip1, trip2);
|
||||
divesToMove.tripsToAdd.emplace_back(newTrip);
|
||||
for (int i = 0; i < trip1->dives.nr; ++i)
|
||||
divesToMove.divesToMove.push_back( { trip1->dives.dives[i], newTrip } );
|
||||
|
|
Loading…
Add table
Reference in a new issue