2020-09-26 11:40:54 +02:00
|
|
|
#ifndef FILTERWIDGET_H
|
|
|
|
#define FILTERWIDGET_H
|
2018-10-13 11:52:08 +02:00
|
|
|
|
2020-05-18 07:20:09 +02:00
|
|
|
#include <vector>
|
2018-10-13 11:52:08 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2020-09-26 11:40:54 +02:00
|
|
|
#include "ui_filterwidget.h"
|
2019-11-17 18:13:55 +01:00
|
|
|
#include "core/divefilter.h"
|
2020-05-18 07:20:09 +02:00
|
|
|
#include "qt-models/filterconstraintmodel.h"
|
2018-10-13 11:52:08 +02:00
|
|
|
|
2020-05-18 07:20:09 +02:00
|
|
|
class FilterConstraintWidget;
|
2020-05-28 07:31:51 +02:00
|
|
|
class QMenu;
|
2020-06-22 14:08:04 +02:00
|
|
|
class QHideEvent;
|
|
|
|
class QShowEvent;
|
2018-10-13 11:52:08 +02:00
|
|
|
|
2020-09-26 11:40:54 +02:00
|
|
|
class FilterWidget : public QWidget {
|
2018-10-13 11:52:08 +02:00
|
|
|
Q_OBJECT
|
2018-12-06 20:07:47 +01:00
|
|
|
|
2018-10-13 11:52:08 +02:00
|
|
|
public:
|
2020-09-26 11:40:54 +02:00
|
|
|
explicit FilterWidget(QWidget *parent = 0);
|
|
|
|
~FilterWidget();
|
2019-02-18 12:47:20 -08:00
|
|
|
|
2018-11-16 15:24:11 +01:00
|
|
|
protected:
|
|
|
|
void hideEvent(QHideEvent *event) override;
|
|
|
|
void showEvent(QShowEvent *event) override;
|
2018-10-13 11:52:08 +02:00
|
|
|
|
2019-01-20 21:01:00 +01:00
|
|
|
private slots:
|
2019-01-25 22:11:30 +01:00
|
|
|
void clearFilter();
|
2019-01-25 22:41:07 +01:00
|
|
|
void closeFilter();
|
2020-09-12 10:29:03 +02:00
|
|
|
void filterChanged();
|
2020-05-18 07:20:09 +02:00
|
|
|
void constraintAdded(const QModelIndex &parent, int first, int last);
|
|
|
|
void constraintRemoved(const QModelIndex &parent, int first, int last);
|
|
|
|
void constraintChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
|
|
|
void constraintsReset();
|
2020-05-28 07:31:51 +02:00
|
|
|
void updatePresetMenu();
|
2020-05-28 22:19:58 +02:00
|
|
|
void presetClicked(const QModelIndex &index);
|
|
|
|
void presetSelected(const QItemSelection &selected, const QItemSelection &);
|
2020-05-27 23:09:30 +02:00
|
|
|
void on_addSetButton_clicked();
|
2019-01-01 18:49:56 +01:00
|
|
|
|
2018-10-13 11:52:08 +02:00
|
|
|
private:
|
2019-01-25 22:11:30 +01:00
|
|
|
bool ignoreSignal;
|
2020-09-12 10:29:03 +02:00
|
|
|
bool presetModified;
|
2020-09-26 11:40:54 +02:00
|
|
|
Ui::FilterWidget ui;
|
2020-05-18 07:20:09 +02:00
|
|
|
FilterConstraintModel constraintModel;
|
|
|
|
void addConstraint(filter_constraint_type type);
|
|
|
|
std::vector<std::unique_ptr<FilterConstraintWidget>> constraintWidgets;
|
2020-05-27 23:09:30 +02:00
|
|
|
FilterData createFilterData() const;
|
2020-09-12 10:29:03 +02:00
|
|
|
void updateFilter();
|
2020-05-28 07:31:51 +02:00
|
|
|
void setFilterData(const FilterData &filterData);
|
|
|
|
void loadPreset(int index);
|
2020-05-28 22:19:58 +02:00
|
|
|
void selectPreset(int i);
|
|
|
|
void clearFilterData();
|
2020-05-28 07:31:51 +02:00
|
|
|
std::unique_ptr<QMenu> loadFilterPresetMenu;
|
2020-09-12 09:48:25 +02:00
|
|
|
int selectedPreset() const; // returns -1 of no preset is selected
|
|
|
|
void updatePresetLabel();
|
2018-10-13 11:52:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|