mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Import: Make DownloadThread a subobject of DiveImportedModel
Currently, desktop and mobile are accessing the DownloadThread and the DiveImportedModel concurrently. This makes a big data flow mess. To achieve a more hierarchical data flow, start by making the DownloadThread a subobject of DiveImportedModel. Start the download by calling a function in DiveImportedModel. Route the finished signal through DiveImportedModel. Thus, the model can reload itself with the new data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6e343c734a
commit
ad7ffa0af0
5 changed files with 45 additions and 33 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <QAbstractTableModel>
|
||||
#include <vector>
|
||||
#include "core/divesite.h"
|
||||
#include "core/downloadfromdcthread.h"
|
||||
|
||||
class DiveImportedModel : public QAbstractTableModel
|
||||
{
|
||||
|
|
@ -20,8 +21,10 @@ 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, dive_site_table_t *sites);
|
||||
Q_INVOKABLE void recordDives();
|
||||
Q_INVOKABLE void startDownload();
|
||||
|
||||
DownloadThread thread;
|
||||
public
|
||||
slots:
|
||||
void changeSelected(QModelIndex clickedIndex);
|
||||
|
|
@ -29,7 +32,15 @@ slots:
|
|||
void selectAll();
|
||||
void selectNone();
|
||||
|
||||
private
|
||||
slots:
|
||||
void downloadThreadFinished();
|
||||
|
||||
signals:
|
||||
void downloadFinished();
|
||||
|
||||
private:
|
||||
void repopulate(dive_table_t *table, dive_site_table_t *sites);
|
||||
int firstIndex;
|
||||
int lastIndex;
|
||||
std::vector<char> checkStates; // char instead of bool to avoid silly pessimization of std::vector.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue