mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
8581e213ed
The trip selection code was an awkward layering violation. Whereas dive selections due to dive undo-commands trickled down via DiveTripModel-->MultiFilterSortModel-->DiveListView, for trip editing, the DiveListView directly intercepted the TripEdited signal. Instead, mimic the dive-selection code. This is a bit longer but more consistent and logical. The undo/redo of trip changes is now also a "programmatical" change of the selection. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
31 lines
1 KiB
C++
31 lines
1 KiB
C++
// 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, QModelIndex currentDive);
|
|
void tripSelected(QModelIndex trip, QModelIndex currentDive);
|
|
private slots:
|
|
void selectionChangedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive);
|
|
void tripSelectedSlot(QModelIndex trip, QModelIndex currentDive);
|
|
private:
|
|
MultiFilterSortModel(QObject *parent = 0);
|
|
std::unique_ptr<DiveTripModelBase> model;
|
|
};
|
|
|
|
#endif
|