mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Replace the static filterwidget with a list of filterconstraints. The first attempt of using a table widget failed, because Qt's table delegates are dysfunctional. It's not that they are bad, they just don't work at all. Therefore, this code "simulates" a table in that on addition / deletion of constraints it keeps track of the rows of all constraints so that each constraint-widget can be associated with a row of the constraint model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#ifndef FILTERWIDGET_2_H
|
|
#define FILTERWIDGET_2_H
|
|
|
|
#include <QHideEvent>
|
|
#include <QShowEvent>
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
#include "ui_filterwidget2.h"
|
|
#include "core/divefilter.h"
|
|
#include "qt-models/filterconstraintmodel.h"
|
|
|
|
class FilterConstraintWidget;
|
|
|
|
class FilterWidget2 : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit FilterWidget2(QWidget *parent = 0);
|
|
~FilterWidget2();
|
|
QString shownText();
|
|
|
|
protected:
|
|
void hideEvent(QHideEvent *event) override;
|
|
void showEvent(QShowEvent *event) override;
|
|
|
|
private slots:
|
|
void clearFilter();
|
|
void closeFilter();
|
|
void updateFilter();
|
|
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();
|
|
|
|
private:
|
|
bool ignoreSignal;
|
|
Ui::FilterWidget2 ui;
|
|
FilterConstraintModel constraintModel;
|
|
bool validFilter;
|
|
void addConstraint(filter_constraint_type type);
|
|
std::vector<std::unique_ptr<FilterConstraintWidget>> constraintWidgets;
|
|
};
|
|
|
|
#endif
|