mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Only offer to merge dives if they are consecutive in the divelist
You cannot merge dives if there is another, unselected dive "between" them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2d40172d78
commit
446ab45858
3 changed files with 26 additions and 1 deletions
24
divelist.c
24
divelist.c
|
@ -916,6 +916,30 @@ void add_single_dive(int idx, struct dive *dive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool consecutive_selected()
|
||||||
|
{
|
||||||
|
struct dive *d;
|
||||||
|
int i;
|
||||||
|
bool consecutive = TRUE;
|
||||||
|
bool firstfound = FALSE;
|
||||||
|
bool lastfound = FALSE;
|
||||||
|
|
||||||
|
if (amount_selected == 0 || amount_selected == 1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
for_each_dive(i, d) {
|
||||||
|
if (d->selected) {
|
||||||
|
if (!firstfound)
|
||||||
|
firstfound = TRUE;
|
||||||
|
else if (lastfound)
|
||||||
|
consecutive = FALSE;
|
||||||
|
} else if (firstfound) {
|
||||||
|
lastfound = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return consecutive;
|
||||||
|
}
|
||||||
|
|
||||||
struct dive *merge_two_dives(struct dive *a, struct dive *b)
|
struct dive *merge_two_dives(struct dive *a, struct dive *b)
|
||||||
{
|
{
|
||||||
struct dive *res;
|
struct dive *res;
|
||||||
|
|
|
@ -44,6 +44,7 @@ extern void remove_dive_from_trip(struct dive *dive);
|
||||||
extern dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive);
|
extern dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive);
|
||||||
extern void autogroup_dives(void);
|
extern void autogroup_dives(void);
|
||||||
extern struct dive *merge_two_dives(struct dive *a, struct dive *b);
|
extern struct dive *merge_two_dives(struct dive *a, struct dive *b);
|
||||||
|
extern bool consecutive_selected();
|
||||||
extern void select_dive(int idx);
|
extern void select_dive(int idx);
|
||||||
extern void deselect_dive(int idx);
|
extern void deselect_dive(int idx);
|
||||||
|
|
||||||
|
|
|
@ -400,7 +400,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
}
|
}
|
||||||
if (d)
|
if (d)
|
||||||
popup.addAction(tr("delete dive"), this, SLOT(deleteDive()));
|
popup.addAction(tr("delete dive"), this, SLOT(deleteDive()));
|
||||||
if (amount_selected > 1)
|
if (amount_selected > 1 && consecutive_selected())
|
||||||
popup.addAction(tr("merge selected dives"), this, SLOT(mergeDives()));
|
popup.addAction(tr("merge selected dives"), this, SLOT(mergeDives()));
|
||||||
// "collapse all" really closes all trips,
|
// "collapse all" really closes all trips,
|
||||||
// "collapse" keeps the trip with the selected dive open
|
// "collapse" keeps the trip with the selected dive open
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue