summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/diveimportedmodel.cpp19
-rw-r--r--qt-models/diveimportedmodel.h7
2 files changed, 15 insertions, 11 deletions
diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp
index 3413e03a5..0541d32d3 100644
--- a/qt-models/diveimportedmodel.cpp
+++ b/qt-models/diveimportedmodel.cpp
@@ -143,22 +143,24 @@ void DiveImportedModel::startDownload()
thread.start();
}
-std::pair<struct dive_table, struct dive_site_table> DiveImportedModel::consumeTables()
+std::tuple<struct dive_table, struct dive_site_table, struct device_table> DiveImportedModel::consumeTables()
{
beginResetModel();
// Move tables to result
struct dive_table dives = empty_dive_table;
struct dive_site_table sites = empty_dive_site_table;
+ struct device_table devices;
move_dive_table(&diveTable, &dives);
move_dive_site_table(&sitesTable, &sites);
+ devices = std::move(deviceTable);
// Reset indices
checkStates.clear();
endResetModel();
- return std::make_pair(dives, sites);
+ return std::make_tuple(dives, sites, devices);
}
int DiveImportedModel::numDives() const
@@ -191,17 +193,18 @@ void DiveImportedModel::recordDives(int flags)
deleteDeselected();
// TODO: use structured bindings once we go C++17
- std::pair<struct dive_table, struct dive_site_table> tables = consumeTables();
- if (tables.first.nr > 0) {
+ std::tuple<struct dive_table, struct dive_site_table, struct device_table> tables = consumeTables();
+ if (std::get<0>(tables).nr > 0) {
auto data = thread.data();
- Command::importDives(&tables.first, nullptr, &tables.second, nullptr, flags, data->devName());
+ Command::importDives(&std::get<0>(tables), nullptr, &std::get<1>(tables),
+ &std::get<2>(tables), nullptr, flags, data->devName());
} else {
- clear_dive_site_table(&tables.second);
+ clear_dive_site_table(&std::get<1>(tables));
}
// The dives and dive sites have been consumed, but the arrays of the tables
// still exist. Free them.
- free(tables.first.dives);
- free(tables.second.dive_sites);
+ free(std::get<0>(tables).dives);
+ free(std::get<1>(tables).dive_sites);
}
QHash<int, QByteArray> DiveImportedModel::roleNames() const {
diff --git a/qt-models/diveimportedmodel.h b/qt-models/diveimportedmodel.h
index 920bd57c6..f43057d26 100644
--- a/qt-models/diveimportedmodel.h
+++ b/qt-models/diveimportedmodel.h
@@ -1,11 +1,11 @@
#ifndef DIVEIMPORTEDMODEL_H
#define DIVEIMPORTEDMODEL_H
-#include <QAbstractTableModel>
-#include <vector>
+#include "core/device.h"
#include "core/divesite.h"
#include "core/divelist.h"
#include "core/downloadfromdcthread.h"
+#include <QAbstractTableModel>
class DiveImportedModel : public QAbstractTableModel
{
@@ -23,7 +23,7 @@ public:
Q_INVOKABLE void clearTable();
QHash<int, QByteArray> roleNames() const;
void deleteDeselected();
- std::pair<struct dive_table, struct dive_site_table> consumeTables(); // Returns dives and sites and resets model.
+ std::tuple<struct dive_table, struct dive_site_table, struct device_table> consumeTables(); // Returns downloaded tables and resets model.
int numDives() const;
Q_INVOKABLE void recordDives(int flags = IMPORT_PREFER_IMPORTED | IMPORT_IS_DOWNLOADED);
@@ -48,6 +48,7 @@ private:
std::vector<char> checkStates; // char instead of bool to avoid silly pessimization of std::vector.
struct dive_table diveTable;
struct dive_site_table sitesTable;
+ struct device_table deviceTable;
};
#endif