mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
a38ea971a0
Add an option for users to sync the dive computer time with the PC time every time dives are downloaded. Obviously this will only work on dive computers that have time synchronisation support in libdivecomputer, for other computers a notice is logged. The selection for this option is persisted as a preference. Signed-off-by: Michael Keller <github@ike.ch>
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include "qt-models/diveimportedmodel.h"
|
|
|
|
void cliDownloader(const char *vendor, const char *product, const char *device)
|
|
{
|
|
DiveImportedModel diveImportedModel;
|
|
DiveImportedModel::connect(&diveImportedModel, &DiveImportedModel::downloadFinished, [] {
|
|
// do something useful at the end of the download
|
|
printf("Finished\n");
|
|
});
|
|
|
|
auto data = diveImportedModel.thread.data();
|
|
data->setVendor(vendor);
|
|
data->setProduct(product);
|
|
data->setBluetoothMode(false);
|
|
if (data->vendor() == "Uemis") {
|
|
QString devname(device);
|
|
int colon = devname.indexOf(QStringLiteral(":\\ (UEMISSDA)"));
|
|
if (colon >= 0) {
|
|
devname.truncate(colon + 2);
|
|
fprintf(stderr, "shortened devname to \"%s\"", qPrintable(devname));
|
|
}
|
|
data->setDevName(devname);
|
|
} else {
|
|
data->setDevName(device);
|
|
}
|
|
|
|
// some assumptions - should all be configurable
|
|
data->setForceDownload(false);
|
|
data->setSaveLog(true);
|
|
data->setSaveDump(false);
|
|
data->setSyncTime(false);
|
|
|
|
diveImportedModel.startDownload();
|
|
diveImportedModel.waitForDownload();
|
|
diveImportedModel.recordDives();
|
|
}
|