core: move process_import_dives() and related functions to divelog

These functions accessed the global divelog make this explicit.

I'm still not happy about the situation, because these functions
access global state, such as the selection. I think these
should be moved up the call-chain.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-19 22:45:25 +02:00 committed by bstoeger
parent b34116e2e2
commit 176f544106
14 changed files with 500 additions and 494 deletions

View file

@ -967,7 +967,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
}
QString source = fileNames.size() == 1 ? fileNames[0] : tr("multiple files");
Command::importDives(&log, IMPORT_MERGE_ALL_TRIPS, source);
Command::importDives(&log, import_flags::merge_all_trips, source);
}
TagDragDelegate::TagDragDelegate(QObject *parent) : QStyledItemDelegate(parent)

View file

@ -565,11 +565,11 @@ void DownloadFromDCWidget::on_ok_clicked()
if (currentState != DONE && currentState != ERRORED)
return;
int flags = IMPORT_IS_DOWNLOADED;
int flags = import_flags::is_downloaded;
if (preferDownloaded())
flags |= IMPORT_PREFER_IMPORTED;
flags |= import_flags::prefer_imported;
if (ui.createNewTrip->isChecked())
flags |= IMPORT_ADD_TO_NEW_TRIP;
flags |= import_flags::add_to_new_trip;
diveImportedModel->recordDives(flags);

View file

@ -419,7 +419,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
std::string encoded = encodeFileName(*filename);
if (!parse_file(encoded.c_str(), &divelog))
setCurrentFile(encoded);
process_loaded_dives();
divelog.process_loaded_dives();
hideProgressBar();
refreshDisplay();
updateAutogroup();
@ -1313,7 +1313,7 @@ void MainWindow::importFiles(const std::vector<std::string> &fileNames)
parse_file(encoded.c_str(), &log);
}
QString source = fileNames.size() == 1 ? QString::fromStdString(fileNames[0]) : tr("multiple files");
Command::importDives(&log, IMPORT_MERGE_ALL_TRIPS, source);
Command::importDives(&log, import_flags::merge_all_trips, source);
}
void MainWindow::loadFiles(const std::vector<std::string> &fileNames)
@ -1334,7 +1334,7 @@ void MainWindow::loadFiles(const std::vector<std::string> &fileNames)
}
hideProgressBar();
updateRecentFiles();
process_loaded_dives();
divelog.process_loaded_dives();
refreshDisplay();
updateAutogroup();

View file

@ -7,7 +7,7 @@
#include "desktop-widgets/mainwindow.h"
#include "commands/command.h"
#include "core/device.h"
#include "core/divelist.h" // For IMPORT_MERGE_ALL_TRIPS
#include "core/divelist.h"
#include "core/divelog.h"
#include "core/errorhelper.h"
#include "core/file.h"
@ -458,7 +458,7 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button)
/* parse file and import dives */
struct divelog log;
parse_file(QFile::encodeName(zipFile.fileName()), &log);
Command::importDives(&log, IMPORT_MERGE_ALL_TRIPS, QStringLiteral("divelogs.de"));
Command::importDives(&log, import_flags::merge_all_trips, QStringLiteral("divelogs.de"));
/* store last entered user/pass in config */
qPrefCloudStorage::set_divelogde_user(ui.userID->text());