From f542dc4030dda5dac1da1cc928f7a40a50919c4d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 23 Dec 2018 12:46:25 +0100 Subject: Import: add trip_table argument to DiveImportedModel::repopulate() In the future we want to download trips into a distinct trip-table instead of the global trip-table to allow for undo of import. Therefore add a trip_table argument to DiveImportedModel::repopulate() and a trip_table member to DiveImportedModel. To correctly set these, add a DownloadThread::trips() function, which currently simply returns the global trip table. Finally, make "struct trip_table *" a Q_METATYPE, so that the corresponding arguments can be passed from QML. Signed-off-by: Berthold Stoeger --- qt-models/diveimportedmodel.cpp | 3 ++- qt-models/diveimportedmodel.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'qt-models') diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp index ec450d53f..11d644950 100644 --- a/qt-models/diveimportedmodel.cpp +++ b/qt-models/diveimportedmodel.cpp @@ -127,11 +127,12 @@ void DiveImportedModel::clearTable() endRemoveRows(); } -void DiveImportedModel::repopulate(dive_table_t *table) +void DiveImportedModel::repopulate(dive_table_t *table, trip_table_t *trips) { beginResetModel(); diveTable = table; + tripTable = trips; firstIndex = 0; lastIndex = diveTable->nr - 1; checkStates.resize(diveTable->nr); diff --git a/qt-models/diveimportedmodel.h b/qt-models/diveimportedmodel.h index 0c5ba34cd..ede40431b 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 roleNames() const; - Q_INVOKABLE void repopulate(dive_table_t *table); + Q_INVOKABLE void repopulate(dive_table_t *table, trip_table_t *trips); Q_INVOKABLE void recordDives(); public slots: @@ -34,6 +34,7 @@ private: int lastIndex; std::vector checkStates; // char instead of bool to avoid silly pessimization of std::vector. struct dive_table *diveTable; + struct trip_table *tripTable; }; #endif -- cgit v1.2.3-70-g09d2