mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Core: move autogroup() into divelist.c
After loading or importing, the caller usually called autogroup() to autogroup dives if so wished by the user. This has already led to bugs, when autogroup() was forgotten. Instead, call autogroup() directly in the process_loaded_dives() and process_imported_dives() functions. Not only does this prevent forgetting the call - it also means that autogrouping can be changed without changing every caller. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7923507e76
commit
f8327ed51b
6 changed files with 7 additions and 9 deletions
|
@ -25,7 +25,6 @@
|
|||
* dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive)
|
||||
* dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocated)
|
||||
* dive_trip_t *get_trip_for_new_dive(struct dive *new_dive, bool *allocated)
|
||||
* void autogroup_dives(void)
|
||||
* void combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b)
|
||||
* dive_trip_t *combine_trips_create(struct dive_trip *trip_a, struct dive_trip *trip_b)
|
||||
* struct dive *unregister_dive(int idx)
|
||||
|
@ -1042,7 +1041,7 @@ dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocat
|
|||
* Walk the dives from the oldest dive, and see if we can autogroup them.
|
||||
* But only do this when the user selected autogrouping.
|
||||
*/
|
||||
void autogroup_dives(void)
|
||||
static void autogroup_dives(void)
|
||||
{
|
||||
int from, to;
|
||||
dive_trip_t *trip;
|
||||
|
@ -1354,6 +1353,9 @@ void process_loaded_dives()
|
|||
set_dc_nickname(dive);
|
||||
|
||||
sort_table(&dive_table);
|
||||
|
||||
/* Autogroup dives if desired by user. */
|
||||
autogroup_dives();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1502,6 +1504,9 @@ void process_imported_dives(struct dive_table *import_table, bool prefer_importe
|
|||
if (!sequence_changed)
|
||||
try_to_renumber(preexisting);
|
||||
|
||||
/* Autogroup dives if desired by user. */
|
||||
autogroup_dives();
|
||||
|
||||
/* We might have deleted the old selected dive.
|
||||
* Choose the newest dive as selected (if any) */
|
||||
current_dive = dive_table.nr > 0 ? dive_table.dives[dive_table.nr - 1] : NULL;
|
||||
|
|
|
@ -35,7 +35,6 @@ extern dive_trip_t *create_trip_from_dive(struct dive *dive);
|
|||
extern dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive);
|
||||
extern dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocated);
|
||||
extern dive_trip_t *get_trip_for_new_dive(struct dive *new_dive, bool *allocated);
|
||||
extern void autogroup_dives(void);
|
||||
extern bool consecutive_selected();
|
||||
extern void select_dive(struct dive *dive);
|
||||
extern void deselect_dive(struct dive *dive);
|
||||
|
|
|
@ -1011,7 +1011,6 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
|||
}
|
||||
|
||||
process_imported_dives(&table, false, false);
|
||||
autogroup_dives();
|
||||
Command::clear();
|
||||
MainWindow::instance()->refreshDisplay();
|
||||
}
|
||||
|
|
|
@ -525,7 +525,6 @@ void DownloadFromDCWidget::on_ok_clicked()
|
|||
// first new dive) and select it again after processing all the dives
|
||||
int uniqId = table->dives[table->nr - 1]->id;
|
||||
process_imported_dives(table, preferDownloaded(), true);
|
||||
autogroup_dives();
|
||||
Command::clear();
|
||||
// after process_imported_dives does any merging or resorting needed, we need
|
||||
// to recreate the model for the dive list so we can select the newest dive
|
||||
|
|
|
@ -617,7 +617,6 @@ void MainWindow::on_actionCloudstorageopen_triggered()
|
|||
if (!parse_file(fileNamePtr.data(), &dive_table))
|
||||
setCurrentFile(fileNamePtr.data());
|
||||
process_loaded_dives();
|
||||
autogroup_dives();
|
||||
Command::clear();
|
||||
hideProgressBar();
|
||||
refreshDisplay();
|
||||
|
@ -1715,7 +1714,6 @@ void MainWindow::importFiles(const QStringList fileNames)
|
|||
parse_file(fileNamePtr.data(), &table);
|
||||
}
|
||||
process_imported_dives(&table, false, false);
|
||||
autogroup_dives();
|
||||
Command::clear();
|
||||
refreshDisplay();
|
||||
}
|
||||
|
@ -1739,7 +1737,6 @@ void MainWindow::loadFiles(const QStringList fileNames)
|
|||
hideProgressBar();
|
||||
updateRecentFiles();
|
||||
process_loaded_dives();
|
||||
autogroup_dives();
|
||||
Command::clear();
|
||||
|
||||
refreshDisplay();
|
||||
|
|
|
@ -157,7 +157,6 @@ void DiveImportedModel::recordDives()
|
|||
}
|
||||
|
||||
process_imported_dives(diveTable, true, true);
|
||||
autogroup_dives();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> DiveImportedModel::roleNames() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue