dive download: pass current filename to dialog

Instead of accessing a global variable, pass the filename
from the MainWindow to the dialog. This is supposed to cut
down on the global variable mess.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-16 10:02:54 +01:00 committed by bstoeger
parent 981352646c
commit 64419f2b19
5 changed files with 18 additions and 18 deletions

View file

@ -26,7 +26,8 @@ static bool is_vendor_searchable(QString vendor)
return vendor == "Uemis" || vendor == "Garmin";
}
DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent) : QDialog(parent, QFlag(0)),
DownloadFromDCWidget::DownloadFromDCWidget(const QString &filename, QWidget *parent) : QDialog(parent, QFlag(0)),
filename(filename),
downloading(false),
previousLast(0),
timer(new QTimer(this)),
@ -461,11 +462,10 @@ void DownloadFromDCWidget::checkLogFile(int state)
void DownloadFromDCWidget::pickLogFile()
{
QString filename = existing_filename ?: prefs.default_filename;
QFileInfo fi(filename);
filename = fi.absolutePath().append(QDir::separator()).append("subsurface.log");
QString logfilename = fi.absolutePath().append(QDir::separator()).append("subsurface.log");
QString logFile = QFileDialog::getSaveFileName(this, tr("Choose file for dive computer download logfile"),
filename, tr("Log files") + " (*.log)");
logfilename, tr("Log files") + " (*.log)");
if (!logFile.isEmpty()) {
free(logfile_name);
logfile_name = copy_qstring(logFile);
@ -487,11 +487,10 @@ void DownloadFromDCWidget::checkDumpFile(int state)
void DownloadFromDCWidget::pickDumpFile()
{
QString filename = existing_filename ?: prefs.default_filename;
QFileInfo fi(filename);
filename = fi.absolutePath().append(QDir::separator()).append("subsurface.bin");
QString dumpfilename = fi.absolutePath().append(QDir::separator()).append("subsurface.bin");
QString dumpFile = QFileDialog::getSaveFileName(this, tr("Choose file for dive computer binary dump file"),
filename, tr("Dump files") + " (*.bin)");
dumpfilename, tr("Dump files") + " (*.bin)");
if (!dumpFile.isEmpty()) {
free(dumpfile_name);
dumpfile_name = copy_qstring(dumpFile);
@ -547,7 +546,7 @@ void DownloadFromDCWidget::on_ok_clicked()
diveImportedModel->recordDives(flags);
if (ostcFirmwareCheck && currentState == DONE)
ostcFirmwareCheck->checkLatest(this, diveImportedModel->thread.data()->internalData());
ostcFirmwareCheck->checkLatest(this, diveImportedModel->thread.data()->internalData(), filename);
accept();
}