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>
This commit is contained in:
Berthold Stoeger 2020-10-17 16:07:39 +02:00 committed by Dirk Hohndel
parent fadea413cd
commit 39a4090c0a
17 changed files with 113 additions and 40 deletions

View file

@ -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