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