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:
|
2020-03-11 11:30:51 +01:00
|
|
|
void selectionChanged(const QVector<QModelIndex> &indices);
|
2019-11-27 21:55:37 +01:00
|
|
|
void currentDiveChanged(QModelIndex index);
|
|
|
|
private slots:
|
2020-03-11 11:30:51 +01:00
|
|
|
void selectionChangedSlot(const QVector<QModelIndex> &indices);
|
2019-11-27 21:55:37 +01:00
|
|
|
void currentDiveChangedSlot(QModelIndex index);
|
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
|