summaryrefslogtreecommitdiffstats
path: root/qt-models/diveimportedmodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-17 16:07:39 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-24 09:51:37 -0700
commit39a4090c0a6e1d8fe12516be06ee7b31dd4bc96d (patch)
tree7587930b64bf95ec3a652cf761e6ded573931364 /qt-models/diveimportedmodel.cpp
parentfadea413cdb4644b821369b27fad6e5f019d32c2 (diff)
downloadsubsurface-39a4090c0a6e1d8fe12516be06ee7b31dd4bc96d.tar.gz
devices: add devices in Command::importTable()
Add a device_table parameters to Command::importTable() and add_imported_dives(). The content of this table will be added to the global device list (respectively removed on undo). This is currently a no-op, as the parser doesn't yet fill out the device table, but adds devices directly to the global device table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/diveimportedmodel.cpp')
-rw-r--r--qt-models/diveimportedmodel.cpp19
1 files changed, 11 insertions, 8 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 {