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