2017-04-18 15:32:10 +00:00
|
|
|
#ifndef DIVEIMPORTEDMODEL_H
|
|
|
|
#define DIVEIMPORTEDMODEL_H
|
|
|
|
|
2019-11-16 21:24:06 +00:00
|
|
|
#include "core/divelist.h"
|
2022-11-12 07:40:04 +00:00
|
|
|
#include "core/divelog.h"
|
2019-09-25 18:49:13 +00:00
|
|
|
#include "core/downloadfromdcthread.h"
|
2020-10-17 14:07:39 +00:00
|
|
|
#include <QAbstractTableModel>
|
2017-04-18 15:32:10 +00:00
|
|
|
|
|
|
|
class DiveImportedModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-06-04 12:40:25 +00:00
|
|
|
enum roleTypes { DateTime = Qt::UserRole + 1, Duration, Depth, Selected};
|
2017-05-26 15:53:25 +00:00
|
|
|
|
|
|
|
DiveImportedModel(QObject *parent = 0);
|
2017-04-18 15:32:10 +00:00
|
|
|
int columnCount(const QModelIndex& index = QModelIndex()) const;
|
|
|
|
int rowCount(const QModelIndex& index = QModelIndex()) const;
|
|
|
|
QVariant data(const QModelIndex& index, int role) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
2020-03-11 10:30:51 +00:00
|
|
|
void setImportedDivesIndices(int first, int last);
|
2017-04-18 15:32:10 +00:00
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
2017-06-16 08:22:44 +00:00
|
|
|
Q_INVOKABLE void clearTable();
|
2017-05-26 15:53:25 +00:00
|
|
|
QHash<int, QByteArray> roleNames() const;
|
2019-09-22 16:50:10 +00:00
|
|
|
void deleteDeselected();
|
2022-11-12 07:40:04 +00:00
|
|
|
struct divelog consumeTables(); // Returns downloaded tables and resets model.
|
2019-09-22 19:48:46 +00:00
|
|
|
|
2019-09-22 19:00:15 +00:00
|
|
|
int numDives() const;
|
2024-06-19 20:45:25 +00:00
|
|
|
Q_INVOKABLE void recordDives(int flags = import_flags::prefer_imported | import_flags::is_downloaded);
|
2019-09-25 18:49:13 +00:00
|
|
|
Q_INVOKABLE void startDownload();
|
2020-11-23 16:17:17 +00:00
|
|
|
Q_INVOKABLE void waitForDownload();
|
2019-09-25 18:49:13 +00:00
|
|
|
|
|
|
|
DownloadThread thread;
|
2017-04-18 15:32:10 +00:00
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void changeSelected(QModelIndex clickedIndex);
|
2017-05-29 18:36:00 +00:00
|
|
|
void selectRow(int row);
|
2017-04-18 15:32:10 +00:00
|
|
|
void selectAll();
|
|
|
|
void selectNone();
|
|
|
|
|
2019-09-25 18:49:13 +00:00
|
|
|
private
|
|
|
|
slots:
|
|
|
|
void downloadThreadFinished();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void downloadFinished();
|
|
|
|
|
2017-04-18 15:32:10 +00:00
|
|
|
private:
|
2018-12-09 18:10:55 +00:00
|
|
|
std::vector<char> checkStates; // char instead of bool to avoid silly pessimization of std::vector.
|
2022-11-12 07:40:04 +00:00
|
|
|
struct divelog log;
|
2017-04-18 15:32:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|