summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/divelist.c11
-rw-r--r--core/downloadfromdcthread.cpp23
-rw-r--r--core/downloadfromdcthread.h4
-rw-r--r--core/libdivecomputer.c7
-rw-r--r--core/libdivecomputer.h2
-rw-r--r--core/uemis-downloader.c15
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp6
-rw-r--r--mobile-widgets/qml/DownloadFromDiveComputer.qml2
-rw-r--r--mobile-widgets/qmlmanager.cpp10
-rw-r--r--mobile-widgets/qmlmanager.h4
-rw-r--r--qt-models/diveimportedmodel.cpp5
-rw-r--r--qt-models/diveimportedmodel.h3
12 files changed, 18 insertions, 74 deletions
diff --git a/core/divelist.c b/core/divelist.c
index fc4e58877..bab581eec 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -1661,8 +1661,10 @@ bool try_to_merge_trip(struct dive_trip *trip_import, struct dive_table *import_
* 3) Trips to be added
* The dives to be added are owning (i.e. the caller is responsible
* for freeing them).
- * The dives and trips in import_table and import_trip table are
+ * The dives and trips in "import_table" and "import_trip_table" are
* consumed. On return, both tables have size 0.
+ * "import_trip_table" may be NULL if all dives are not associated
+ * with a trip.
* The output parameters should be empty - if not, their content
* will be cleared!
*
@@ -1690,6 +1692,13 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table *
bool sequence_changed = false;
bool new_dive_has_number = false;
+ /* If the caller didn't pass an import_trip_table because all
+ * dives are tripless, provide a local table. This may be
+ * necessary if the trips are autogrouped */
+ struct trip_table local_trip_table = { 0 };
+ if (!import_trip_table)
+ import_trip_table = &local_trip_table;
+
/* Make sure that output parameters don't contain garbage */
clear_table(dives_to_add);
clear_table(dives_to_remove);
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index 0774c5e8b..97e04c48b 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -60,7 +60,6 @@ static void updateRememberedDCs()
DownloadThread::DownloadThread() : downloadTable({ 0 }),
- tripTable({ 0 }),
m_data(DCDeviceData::instance())
{
}
@@ -70,7 +69,6 @@ void DownloadThread::run()
auto internalData = m_data->internalData();
internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
internalData->download_table = &downloadTable;
- internalData->trip_table = &tripTable;
internalData->btname = strdup(m_data->devBluetoothName().toUtf8());
if (!internalData->descriptor) {
qDebug() << "No download possible when DC type is unknown";
@@ -83,10 +81,6 @@ void DownloadThread::run()
#endif
qDebug() << "Starting download from " << (internalData->bluetooth_mode ? "BT" : internalData->devname);
clear_table(&downloadTable);
- if (tripTable.nr > 0) {
- qWarning() << "DownloadThread::run(): Trip table not empty after reset";
- tripTable.nr = 0;
- }
Q_ASSERT(internalData->download_table != nullptr);
const char *errorText;
@@ -265,7 +259,6 @@ DCDeviceData::DCDeviceData()
memset(&data, 0, sizeof(data));
data.trip = nullptr;
data.download_table = nullptr;
- data.trip_table = nullptr;
data.diveid = 0;
data.deviceid = 0;
#if defined(BT_SUPPORT)
@@ -274,7 +267,6 @@ DCDeviceData::DCDeviceData()
data.bluetooth_mode = false;
#endif
data.force_download = false;
- data.create_new_trip = false;
data.libdc_dump = false;
#if defined(SUBSURFACE_MOBILE)
data.libdc_log = true;
@@ -314,11 +306,6 @@ struct dive_table *DownloadThread::table()
return &downloadTable;
}
-struct trip_table *DownloadThread::trips()
-{
- return &tripTable;
-}
-
QString DCDeviceData::vendor() const
{
return data.vendor;
@@ -354,11 +341,6 @@ bool DCDeviceData::forceDownload() const
return data.force_download;
}
-bool DCDeviceData::createNewTrip() const
-{
- return data.create_new_trip;
-}
-
int DCDeviceData::deviceId() const
{
return data.deviceid;
@@ -415,11 +397,6 @@ void DCDeviceData::setForceDownload(bool force)
data.force_download = force;
}
-void DCDeviceData::setCreateNewTrip(bool create)
-{
- data.create_new_trip = create;
-}
-
void DCDeviceData::setDeviceId(int deviceId)
{
data.deviceid = deviceId;
diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h
index 506a75ac0..da8bec994 100644
--- a/core/downloadfromdcthread.h
+++ b/core/downloadfromdcthread.h
@@ -26,7 +26,6 @@ public:
QString devBluetoothName() const;
QString descriptor() const;
bool forceDownload() const;
- bool createNewTrip() const;
bool saveLog() const;
int deviceId() const;
int diveId() const;
@@ -48,7 +47,6 @@ public:
void setDevBluetoothName(const QString& devBluetoothName);
void setBluetoothMode(bool mode);
void setForceDownload(bool force);
- void setCreateNewTrip(bool create);
void setSaveDump(bool dumpMode);
void setSaveLog(bool saveLog);
private:
@@ -61,7 +59,6 @@ private:
class DownloadThread : public QThread {
Q_OBJECT
Q_PROPERTY(dive_table_t *table READ table CONSTANT)
- Q_PROPERTY(trip_table_t *trips READ trips CONSTANT)
public:
DownloadThread();
@@ -69,7 +66,6 @@ public:
DCDeviceData *data();
struct dive_table *table();
- struct trip_table *trips();
QString error;
private:
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index 15dd1132a..b3dd8f5e4 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -824,13 +824,6 @@ static int dive_cb(const unsigned char *data, unsigned int size,
dive->dc.sample[0].temperature.mkelvin = 0;
}
- if (devdata->create_new_trip) {
- if (!devdata->trip)
- devdata->trip = create_and_hookup_trip_from_dive(dive, devdata->trip_table);
- else
- add_dive_to_trip(dive, devdata->trip);
- }
-
record_dive_to_table(dive, devdata->download_table);
mark_divelist_changed(true);
return true;
diff --git a/core/libdivecomputer.h b/core/libdivecomputer.h
index 2732adfb5..8f6d222db 100644
--- a/core/libdivecomputer.h
+++ b/core/libdivecomputer.h
@@ -41,13 +41,11 @@ typedef struct dc_user_device_t
struct dive_trip *trip;
int preexisting;
bool force_download;
- bool create_new_trip;
bool libdc_log;
bool libdc_dump;
bool bluetooth_mode;
FILE *libdc_logfile;
struct dive_table *download_table;
- struct trip_table *trip_table;
} device_data_t;
const char *errmsg (dc_status_t rc);
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index 5dd6567b6..35dc817b0 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -211,17 +211,6 @@ static struct dive *get_dive_by_uemis_diveid(device_data_t *devdata, uint32_t ob
return NULL;
}
-static void record_uemis_dive(device_data_t *devdata, struct dive *dive)
-{
- if (devdata->create_new_trip) {
- if (!devdata->trip)
- devdata->trip = create_and_hookup_trip_from_dive(dive, &trip_table);
- else
- add_dive_to_trip(dive, devdata->trip);
- }
- record_dive_to_table(dive, devdata->download_table);
-}
-
/* send text to the importer progress bar */
static void uemis_info(const char *fmt, ...)
{
@@ -1024,14 +1013,14 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
* be a short read because of some error */
if (done && ++bp < endptr && *bp != '{' && strstr(bp, "{{")) {
done = false;
- record_uemis_dive(devdata, dive);
+ record_dive_to_table(dive, devdata->download_table);
mark_divelist_changed(true);
dive = uemis_start_dive(deviceid);
}
}
if (is_log) {
if (dive->dc.diveid) {
- record_uemis_dive(devdata, dive);
+ record_dive_to_table(dive, devdata->download_table);
mark_divelist_changed(true);
} else { /* partial dive */
free(dive);
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index a3bc6287c..3376d5c39 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -384,7 +384,6 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
}
data->setForceDownload(ui.forceDownload->isChecked());
- data->setCreateNewTrip(ui.createNewTrip->isChecked());
data->setSaveLog(ui.logToFile->isChecked());
data->setSaveDump(ui.dumpToFile->isChecked());
@@ -486,7 +485,7 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
}
ui.downloadCancelRetryButton->setText(tr("Retry download"));
ui.downloadCancelRetryButton->setEnabled(true);
- diveImportedModel->repopulate(thread.table(), thread.trips());
+ diveImportedModel->repopulate(thread.table());
}
void DownloadFromDCWidget::on_cancel_clicked()
@@ -504,7 +503,6 @@ void DownloadFromDCWidget::on_ok_clicked()
if (currentState != DONE && currentState != ERROR)
return;
struct dive_table *table = thread.table();
- struct trip_table *trips = thread.trips();
// delete non-selected dives
int total = table->nr;
@@ -518,7 +516,7 @@ void DownloadFromDCWidget::on_ok_clicked()
if (table->nr > 0) {
auto data = thread.data();
- Command::importDives(table, trips, preferDownloaded(), true, false, ui.createNewTrip->isChecked(), data->devName());
+ Command::importDives(table, nullptr, preferDownloaded(), true, false, ui.createNewTrip->isChecked(), data->devName());
}
if (ostcFirmwareCheck && currentState == DONE)
diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml
index 332a978dd..a1403b07d 100644
--- a/mobile-widgets/qml/DownloadFromDiveComputer.qml
+++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml
@@ -28,7 +28,7 @@ Kirigami.Page {
id: downloadThread
onFinished : {
- importModel.repopulate(table, trips)
+ importModel.repopulate(table)
progressBar.visible = false
if (dcImportModel.rowCount() > 0) {
console.log(dcImportModel.rowCount() + " dive downloaded")
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 5e858f9cf..cc5072a63 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1803,11 +1803,6 @@ bool QMLManager::DC_bluetoothMode() const
return DCDeviceData::instance()->bluetoothMode();
}
-bool QMLManager::DC_createNewTrip() const
-{
- return DCDeviceData::instance()->createNewTrip();
-}
-
bool QMLManager::DC_saveDump() const
{
return DCDeviceData::instance()->saveDump();
@@ -1853,11 +1848,6 @@ void QMLManager::DC_setForceDownload(bool force)
DCDeviceData::instance()->setForceDownload(force);
}
-void QMLManager::DC_setCreateNewTrip(bool create)
-{
- DCDeviceData::instance()->setCreateNewTrip(create);
-}
-
void QMLManager::DC_setSaveDump(bool dumpMode)
{
DCDeviceData::instance()->setSaveDump(dumpMode);
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 2812ae08f..5636af379 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -45,7 +45,6 @@ class QMLManager : public QObject {
Q_PROPERTY(QString descriptor READ DC_descriptor)
Q_PROPERTY(bool DC_forceDownload READ DC_forceDownload WRITE DC_setForceDownload)
Q_PROPERTY(bool DC_bluetoothMode READ DC_bluetoothMode WRITE DC_setBluetoothMode)
- Q_PROPERTY(bool DC_createNewTrip READ DC_createNewTrip WRITE DC_setCreateNewTrip)
Q_PROPERTY(bool DC_saveDump READ DC_saveDump WRITE DC_setSaveDump)
Q_PROPERTY(int DC_deviceId READ DC_deviceId WRITE DC_setDeviceId)
Q_PROPERTY(QString pluggedInDeviceName MEMBER m_pluggedInDeviceName NOTIFY pluggedInDeviceNameChanged)
@@ -75,9 +74,6 @@ public:
bool DC_bluetoothMode() const;
void DC_setBluetoothMode(bool mode);
- bool DC_createNewTrip() const;
- void DC_setCreateNewTrip(bool create);
-
bool DC_saveDump() const;
void DC_setSaveDump(bool dumpMode);
diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp
index ff93e1792..59fe9b12b 100644
--- a/qt-models/diveimportedmodel.cpp
+++ b/qt-models/diveimportedmodel.cpp
@@ -127,12 +127,11 @@ void DiveImportedModel::clearTable()
endRemoveRows();
}
-void DiveImportedModel::repopulate(dive_table_t *table, trip_table_t *trips)
+void DiveImportedModel::repopulate(dive_table_t *table)
{
beginResetModel();
diveTable = table;
- tripTable = trips;
firstIndex = 0;
lastIndex = diveTable->nr - 1;
checkStates.resize(diveTable->nr);
@@ -159,7 +158,7 @@ void DiveImportedModel::recordDives()
}
// TODO: Might want to let the user select "add_to_new_trip"
- add_imported_dives(diveTable, tripTable, true, true, false, false);
+ add_imported_dives(diveTable, nullptr, true, true, false, false);
}
QHash<int, QByteArray> DiveImportedModel::roleNames() const {
diff --git a/qt-models/diveimportedmodel.h b/qt-models/diveimportedmodel.h
index ede40431b..0c5ba34cd 100644
--- a/qt-models/diveimportedmodel.h
+++ b/qt-models/diveimportedmodel.h
@@ -20,7 +20,7 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const;
Q_INVOKABLE void clearTable();
QHash<int, QByteArray> roleNames() const;
- Q_INVOKABLE void repopulate(dive_table_t *table, trip_table_t *trips);
+ Q_INVOKABLE void repopulate(dive_table_t *table);
Q_INVOKABLE void recordDives();
public
slots:
@@ -34,7 +34,6 @@ private:
int lastIndex;
std::vector<char> checkStates; // char instead of bool to avoid silly pessimization of std::vector.
struct dive_table *diveTable;
- struct trip_table *tripTable;
};
#endif