Add various enhancements to profile export and dive data copy

... as suggested by Lubomir.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2019-02-03 15:47:52 +01:00 committed by Dirk Hohndel
parent f72853a597
commit 95326274be
5 changed files with 55 additions and 37 deletions

View file

@ -94,6 +94,8 @@ void DiveLogExportDialog::showExplanation()
ui->description->setText(tr("Write depths of images to file."));
} else if (ui->exportTeX->isChecked()) {
ui->description->setText(tr("Write dive as TeX macros to file."));
} else if (ui->exportProfile->isChecked()) {
ui->description->setText(tr("Write the profile image as PNG file."));
}
}
@ -168,7 +170,7 @@ void DiveLogExportDialog::on_buttonBox_accepted()
if (!filename.isNull() && !filename.isEmpty())
export_TeX(qPrintable(filename), ui->exportSelected->isChecked());
} else if (ui->exportProfile->isChecked()) {
filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir);
filename = QFileDialog::getSaveFileName(this, tr("Save profile image"), lastDir);
if (!filename.isNull() && !filename.isEmpty())
exportProfile(qPrintable(filename), ui->exportSelected->isChecked());
}
@ -231,18 +233,20 @@ void DiveLogExportDialog::export_depths(const char *filename, const bool selecte
free_buffer(&buf);
}
void DiveLogExportDialog::exportProfile(const QString filename, const bool selected_only)
void DiveLogExportDialog::exportProfile(QString filename, const bool selected_only)
{
struct dive *dive;
int i;
int count = 0;
if (!filename.endsWith(".png", Qt::CaseInsensitive))
filename = filename.append(".png");
QFileInfo fi(filename);
for_each_dive (i, dive) {
if (selected_only && !dive->selected)
continue;
if (count)
saveProfile(dive, fi.completeBaseName().append(QString("-%1.").arg(count)).append(fi.suffix()));
saveProfile(dive, fi.path() + QDir::separator() + fi.completeBaseName().append(QString("-%1.").arg(count)) + fi.suffix());
else
saveProfile(dive, filename);
++count;