mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Cleanup: Remove global QFuture from exportFuncs
When exporting dives we show a message. The message is closed when the export is finished. This is coordinated by a QFuture. Instead of keeping a global QFuture in the export-code, pass it around as a local variable. This is supported according to Qt's documentation: "QFuture is a lightweight reference counted class that can be passed by value." and the source code indicates the same. Not only does this remove a global, it also makes the code more flexible: Now we could show one notification per export, for example. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2cea115ddb
commit
5b302235f4
3 changed files with 7 additions and 7 deletions
|
@ -311,8 +311,8 @@ std::vector<const dive_site *> exportFuncs::getDiveSitesToExport(bool selectedOn
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exportFuncs::exportUsingStyleSheet(QString filename, bool doExport, int units,
|
QFuture<int> exportFuncs::exportUsingStyleSheet(QString filename, bool doExport, int units,
|
||||||
QString stylesheet, bool anonymize)
|
QString stylesheet, bool anonymize)
|
||||||
{
|
{
|
||||||
future = QtConcurrent::run(export_dives_xslt, filename.toUtf8(), doExport, units, stylesheet.toUtf8(), anonymize);
|
return QtConcurrent::run(export_dives_xslt, filename.toUtf8(), doExport, units, stylesheet.toUtf8(), anonymize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,8 @@ public:
|
||||||
void export_TeX(const char *filename, const bool selected_only, bool plain);
|
void export_TeX(const char *filename, const bool selected_only, bool plain);
|
||||||
void export_depths(const char *filename, const bool selected_only);
|
void export_depths(const char *filename, const bool selected_only);
|
||||||
std::vector<const dive_site *> getDiveSitesToExport(bool selectedOnly);
|
std::vector<const dive_site *> getDiveSitesToExport(bool selectedOnly);
|
||||||
void exportUsingStyleSheet(QString filename, bool doExport, int units,
|
QFuture<int> exportUsingStyleSheet(QString filename, bool doExport, int units,
|
||||||
QString stylesheet, bool anonymize);
|
QString stylesheet, bool anonymize);
|
||||||
QFuture<int> future;
|
|
||||||
|
|
||||||
// prepareDivesForUploadDiveLog
|
// prepareDivesForUploadDiveLog
|
||||||
// prepareDivesForUploadDiveShare
|
// prepareDivesForUploadDiveShare
|
||||||
|
|
|
@ -214,9 +214,10 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
||||||
qPrefDisplay::set_lastDir(fileInfo.dir().path());
|
qPrefDisplay::set_lastDir(fileInfo.dir().path());
|
||||||
// the non XSLT exports are called directly above, the XSLT based ons are called here
|
// the non XSLT exports are called directly above, the XSLT based ons are called here
|
||||||
if (!stylesheet.isEmpty()) {
|
if (!stylesheet.isEmpty()) {
|
||||||
exportFuncs::instance()->exportUsingStyleSheet(filename, ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8(), ui->anonymize->isChecked());
|
QFuture<void> future = exportFuncs::instance()->exportUsingStyleSheet(filename, ui->exportSelected->isChecked(),
|
||||||
MainWindow::instance()->getNotificationWidget()->showNotification(tr("Please wait, exporting..."), KMessageWidget::Information);
|
ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8(), ui->anonymize->isChecked());
|
||||||
MainWindow::instance()->getNotificationWidget()->setFuture(exportFuncs::instance()->future);
|
MainWindow::instance()->getNotificationWidget()->showNotification(tr("Please wait, exporting..."), KMessageWidget::Information);
|
||||||
|
MainWindow::instance()->getNotificationWidget()->setFuture(future);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue