mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
filter: add a filter constraint widget
This add a widget that represents a single filter constraint. Since filter constraints are very general, the widget has to consider a number of cases: - numerical ranges - star-widget ranges - string lists - multiple choice lists Moreover, it supports units, which must be updated when the preferences change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
af9d379a41
commit
c0af74ba88
3 changed files with 544 additions and 0 deletions
70
desktop-widgets/filterconstraintwidget.h
Normal file
70
desktop-widgets/filterconstraintwidget.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef FILTERCONSTRAINTWIDGET_H
|
||||
#define FILTERCONSTRAINTWIDGET_H
|
||||
|
||||
#include "core/filterconstraint.h"
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
|
||||
class FilterConstraintModel;
|
||||
class QComboBox;
|
||||
class QDateEdit;
|
||||
class QDoubleSpinBox;
|
||||
class QGridLayout;
|
||||
class QHBoxLayout;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QListWidget;
|
||||
class QPushButton;
|
||||
class QTimeEdit;
|
||||
class StarWidget;
|
||||
|
||||
// Technically, this is not a single widget, but numerous widgets,
|
||||
// which are added to the row of a QGridLayout
|
||||
class FilterConstraintWidget : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FilterConstraintWidget(FilterConstraintModel *model, const QModelIndex &index, QGridLayout *layout);
|
||||
~FilterConstraintWidget();
|
||||
void moveToRow(int row); // call if the row of the widget has changed.
|
||||
// this will update the index used to access the model as well as the position in the layout
|
||||
void update();
|
||||
private
|
||||
slots:
|
||||
void trash();
|
||||
void stringEdited(const QString &s);
|
||||
void multipleChoiceEdited();
|
||||
void negateEdited(int index);
|
||||
void rangeModeEdited(int index);
|
||||
void stringModeEdited(int index);
|
||||
void fromEditedInt(int i);
|
||||
void toEditedInt(int i);
|
||||
void fromEditedFloat(double f);
|
||||
void toEditedFloat(double f);
|
||||
void fromEditedTimestamp(const QDateTime &datetime);
|
||||
void toEditedTimestamp(const QDateTime &datetime);
|
||||
private:
|
||||
QGridLayout *layout;
|
||||
FilterConstraintModel *model;
|
||||
int row;
|
||||
const filter_constraint_type type; // we don't support changing the type
|
||||
void addToLayout();
|
||||
void removeFromLayout();
|
||||
|
||||
std::unique_ptr<QHBoxLayout> rangeLayout;
|
||||
std::unique_ptr<QPushButton> trashButton;
|
||||
std::unique_ptr<QLabel> typeLabel;
|
||||
std::unique_ptr<QComboBox> negate;
|
||||
std::unique_ptr<QComboBox> stringMode;
|
||||
std::unique_ptr<QComboBox> rangeMode;
|
||||
std::unique_ptr<QListWidget> multipleChoice;
|
||||
std::unique_ptr<QLineEdit> string;
|
||||
std::unique_ptr<StarWidget> starFrom, starTo;
|
||||
std::unique_ptr<QDoubleSpinBox> spinBoxFrom, spinBoxTo;
|
||||
std::unique_ptr<QDateEdit> dateFrom, dateTo;
|
||||
std::unique_ptr<QTimeEdit> timeFrom, timeTo;
|
||||
std::unique_ptr<QLabel> unitFrom, unitTo;
|
||||
std::unique_ptr<QLabel> toLabel;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue