aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/filterconstraintwidget.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-17 12:07:04 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-29 16:13:03 -0700
commitc0af74ba88c0101a820da945b96258932c27bab5 (patch)
treebc2546400d325414dbd9fb6256677052d50426ed /desktop-widgets/filterconstraintwidget.h
parentaf9d379a4147b01ea599c86e0ff001cace926c1c (diff)
downloadsubsurface-c0af74ba88c0101a820da945b96258932c27bab5.tar.gz
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>
Diffstat (limited to 'desktop-widgets/filterconstraintwidget.h')
-rw-r--r--desktop-widgets/filterconstraintwidget.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/desktop-widgets/filterconstraintwidget.h b/desktop-widgets/filterconstraintwidget.h
new file mode 100644
index 000000000..60e613780
--- /dev/null
+++ b/desktop-widgets/filterconstraintwidget.h
@@ -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