2017-04-27 18:25:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-28 21:33:51 +00:00
|
|
|
#ifndef DIVETRIPMODEL_H
|
|
|
|
#define DIVETRIPMODEL_H
|
|
|
|
|
|
|
|
#include "treemodel.h"
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "core/dive.h"
|
2016-11-19 12:23:54 +00:00
|
|
|
#include <string>
|
2015-05-28 21:33:51 +00:00
|
|
|
|
|
|
|
struct DiveItem : public TreeItem {
|
2015-10-20 12:36:53 +00:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(TripItem)
|
|
|
|
public:
|
2015-05-28 21:33:51 +00:00
|
|
|
enum Column {
|
|
|
|
NR,
|
|
|
|
DATE,
|
|
|
|
RATING,
|
|
|
|
DEPTH,
|
|
|
|
DURATION,
|
|
|
|
TEMPERATURE,
|
|
|
|
TOTALWEIGHT,
|
|
|
|
SUIT,
|
|
|
|
CYLINDER,
|
|
|
|
GAS,
|
|
|
|
SAC,
|
|
|
|
OTU,
|
|
|
|
MAXCNS,
|
2018-04-04 06:18:29 +00:00
|
|
|
TAGS,
|
2016-11-19 12:23:54 +00:00
|
|
|
PHOTOS,
|
2017-10-02 15:52:07 +00:00
|
|
|
COUNTRY,
|
2015-05-28 21:33:51 +00:00
|
|
|
LOCATION,
|
|
|
|
COLUMNS
|
|
|
|
};
|
|
|
|
|
2018-07-31 05:41:19 +00:00
|
|
|
QVariant data(int column, int role) const override;
|
2015-05-28 21:33:51 +00:00
|
|
|
int diveId;
|
2018-07-31 05:41:19 +00:00
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
2015-05-28 21:33:51 +00:00
|
|
|
QString displayDate() const;
|
|
|
|
QString displayDuration() const;
|
|
|
|
QString displayDepth() const;
|
|
|
|
QString displayDepthWithUnit() const;
|
|
|
|
QString displayTemperature() const;
|
2017-10-09 06:46:18 +00:00
|
|
|
QString displayTemperatureWithUnit() const;
|
2015-05-28 21:33:51 +00:00
|
|
|
QString displayWeight() const;
|
2017-10-09 06:46:18 +00:00
|
|
|
QString displayWeightWithUnit() const;
|
2015-05-28 21:33:51 +00:00
|
|
|
QString displaySac() const;
|
2017-10-09 06:46:18 +00:00
|
|
|
QString displaySacWithUnit() const;
|
2018-04-04 06:18:29 +00:00
|
|
|
QString displayTags() const;
|
2016-11-19 12:23:54 +00:00
|
|
|
int countPhotos(dive *dive) const;
|
2015-05-28 21:33:51 +00:00
|
|
|
int weight() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TripItem : public TreeItem {
|
2015-10-20 12:36:53 +00:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(TripItem)
|
|
|
|
public:
|
2018-07-31 05:41:19 +00:00
|
|
|
QVariant data(int column, int role) const override;
|
2015-05-28 21:33:51 +00:00
|
|
|
dive_trip_t *trip;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DiveTripModel : public TreeModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum Column {
|
|
|
|
NR,
|
|
|
|
DATE,
|
|
|
|
RATING,
|
|
|
|
DEPTH,
|
|
|
|
DURATION,
|
|
|
|
TEMPERATURE,
|
|
|
|
TOTALWEIGHT,
|
|
|
|
SUIT,
|
|
|
|
CYLINDER,
|
|
|
|
GAS,
|
|
|
|
SAC,
|
|
|
|
OTU,
|
|
|
|
MAXCNS,
|
2018-04-04 06:18:29 +00:00
|
|
|
TAGS,
|
2016-11-19 12:23:54 +00:00
|
|
|
PHOTOS,
|
2017-10-02 15:52:07 +00:00
|
|
|
COUNTRY,
|
2015-05-28 21:33:51 +00:00
|
|
|
LOCATION,
|
|
|
|
COLUMNS
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ExtraRoles {
|
|
|
|
STAR_ROLE = Qt::UserRole + 1,
|
|
|
|
DIVE_ROLE,
|
|
|
|
TRIP_ROLE,
|
|
|
|
SORT_ROLE,
|
|
|
|
DIVE_IDX
|
|
|
|
};
|
|
|
|
enum Layout {
|
|
|
|
TREE,
|
|
|
|
LIST,
|
|
|
|
CURRENT
|
|
|
|
};
|
|
|
|
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
2018-07-31 05:41:19 +00:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
2015-05-28 21:33:51 +00:00
|
|
|
DiveTripModel(QObject *parent = 0);
|
|
|
|
Layout layout() const;
|
|
|
|
void setLayout(Layout layout);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setupModelData();
|
|
|
|
QMap<dive_trip_t *, TripItem *> trips;
|
|
|
|
Layout currentLayout;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|