summaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.h
blob: 8895f5b2c9718db88d00c6083b49e673ab5da2a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-License-Identifier: GPL-2.0
#ifndef FILTERMODELS_H
#define FILTERMODELS_H

#include "divetripmodel.h"

#include <QSortFilterProxyModel>
#include <memory>

// This proxy model sits on top of either a DiveTripList or DiveTripTree model
// and does filtering and/or sorting.
class MultiFilterSortModel : public QSortFilterProxyModel {
	Q_OBJECT
public:
	static MultiFilterSortModel *instance();
	bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
	bool lessThan(const QModelIndex &, const QModelIndex &) const override;

	void resetModel(DiveTripModelBase::Layout layout);
signals:
	void selectionChanged(const QVector<QModelIndex> &indices);
	void currentDiveChanged(QModelIndex index);
private slots:
	void selectionChangedSlot(const QVector<QModelIndex> &indices);
	void currentDiveChangedSlot(QModelIndex index);
private:
	MultiFilterSortModel(QObject *parent = 0);
	std::unique_ptr<DiveTripModelBase> model;
};

#endif