2017-04-27 18:25:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-28 20:51:07 +00:00
|
|
|
#ifndef DIVECOMPUTERMODEL_H
|
|
|
|
#define DIVECOMPUTERMODEL_H
|
|
|
|
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "qt-models/cleanertablemodel.h"
|
2020-09-13 17:08:41 +00:00
|
|
|
#include "core/device.h"
|
2020-10-10 10:40:27 +00:00
|
|
|
#include <QSortFilterProxyModel>
|
2015-05-28 20:51:07 +00:00
|
|
|
|
|
|
|
class DiveComputerModel : public CleanerTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
REMOVE,
|
|
|
|
MODEL,
|
|
|
|
ID,
|
|
|
|
NICKNAME
|
|
|
|
};
|
2018-06-16 12:06:35 +00:00
|
|
|
DiveComputerModel(QObject *parent = 0);
|
2018-09-29 20:13:44 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
2015-05-28 20:51:07 +00:00
|
|
|
|
2020-10-21 21:10:08 +00:00
|
|
|
private
|
2015-05-28 20:51:07 +00:00
|
|
|
slots:
|
2020-09-12 21:38:45 +00:00
|
|
|
void update();
|
2020-10-21 21:10:08 +00:00
|
|
|
void deviceAdded(int idx);
|
|
|
|
void deviceDeleted(int idx);
|
|
|
|
void deviceEdited(int idx);
|
2015-05-28 20:51:07 +00:00
|
|
|
};
|
|
|
|
|
2020-10-10 10:40:27 +00:00
|
|
|
class DiveComputerSortedModel : public QSortFilterProxyModel {
|
|
|
|
public:
|
|
|
|
using QSortFilterProxyModel::QSortFilterProxyModel;
|
2020-09-12 21:31:46 +00:00
|
|
|
void remove(const QModelIndex &index);
|
2020-10-10 10:40:27 +00:00
|
|
|
private:
|
|
|
|
bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const;
|
|
|
|
};
|
|
|
|
|
2015-05-28 20:51:07 +00:00
|
|
|
#endif
|