2017-04-27 20:25:32 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-11-13 16:31:03 -02:00
|
|
|
#ifndef FILTERMODELS_H
|
|
|
|
#define FILTERMODELS_H
|
|
|
|
|
2018-12-27 10:06:11 +01:00
|
|
|
#include "divetripmodel.h"
|
2018-10-29 14:56:48 +01:00
|
|
|
|
2014-11-13 16:31:03 -02:00
|
|
|
#include <QSortFilterProxyModel>
|
2019-12-09 15:37:26 +01:00
|
|
|
#include <memory>
|
2014-11-13 16:31:03 -02:00
|
|
|
|
2019-12-09 15:37:26 +01:00
|
|
|
// This proxy model sits on top of either a DiveTripList or DiveTripTree model
|
|
|
|
// and does filtering and/or sorting.
|
2014-11-13 16:31:03 -02:00
|
|
|
class MultiFilterSortModel : public QSortFilterProxyModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static MultiFilterSortModel *instance();
|
2018-09-29 22:13:44 +02:00
|
|
|
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
2018-10-29 20:17:53 +01:00
|
|
|
bool lessThan(const QModelIndex &, const QModelIndex &) const override;
|
2019-11-17 18:13:55 +01:00
|
|
|
|
2018-12-27 10:06:11 +01:00
|
|
|
void resetModel(DiveTripModelBase::Layout layout);
|
2019-11-27 21:55:37 +01:00
|
|
|
signals:
|
2022-09-17 19:07:35 +02:00
|
|
|
void divesSelected(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC); // currentDC < 0 -> keep DC.
|
2022-08-27 17:28:34 +02:00
|
|
|
void tripSelected(QModelIndex trip, QModelIndex currentDive);
|
2019-11-27 21:55:37 +01:00
|
|
|
private slots:
|
2022-09-04 08:21:48 +02:00
|
|
|
void divesSelectedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC);
|
2022-08-27 17:28:34 +02:00
|
|
|
void tripSelectedSlot(QModelIndex trip, QModelIndex currentDive);
|
2014-11-13 16:31:03 -02:00
|
|
|
private:
|
|
|
|
MultiFilterSortModel(QObject *parent = 0);
|
2019-12-09 15:37:26 +01:00
|
|
|
std::unique_ptr<DiveTripModelBase> model;
|
2014-11-13 16:31:03 -02:00
|
|
|
};
|
|
|
|
|
2014-11-13 13:45:32 -08:00
|
|
|
#endif
|