@@ -34,17 +34,39 @@ class QToolButton;
3434class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
3535{
3636 Q_OBJECT
37+ Q_ENUMS ( ClearMode )
38+ Q_PROPERTY ( ClearMode clearMode READ clearMode WRITE setClearMode )
3739 Q_PROPERTY ( QString nullValue READ nullValue WRITE setNullValue )
40+ Q_PROPERTY ( QString defaultValue READ defaultValue WRITE setDefaultValue )
3841 Q_PROPERTY ( QString value READ value WRITE setValue NOTIFY valueChanged )
3942
4043 public:
4144
45+ // ! Behaviour when clearing value of widget
46+ enum ClearMode
47+ {
48+ ClearToNull = 0 , // !< Reset value to null
49+ ClearToDefault, // !< Reset value to default value (see defaultValue() )
50+ };
51+
4252 /* * Constructor for QgsFilterLineEdit.
4353 * @param parent parent widget
4454 * @param nullValue string for representing null values
4555 */
4656 QgsFilterLineEdit ( QWidget* parent = nullptr , const QString& nullValue = QString::null );
4757
58+ /* * Returns the clear mode for the widget. The clear mode defines the behaviour of the
59+ * widget when its value is cleared. This defaults to ClearToNull.
60+ * @see setClearMode()
61+ */
62+ ClearMode clearMode () const { return mClearMode ; }
63+
64+ /* * Sets the clear mode for the widget. The clear mode defines the behaviour of the
65+ * widget when its value is cleared. This defaults to ClearToNull.
66+ * @see clearMode()
67+ */
68+ void setClearMode ( ClearMode mode ) { mClearMode = mode; }
69+
4870 /* * Sets the string representation for null values in the widget. This does not
4971 * affect the values returned for null values by value(), rather it only affects
5072 * the text that is shown to users when the widget's value is null.
@@ -59,6 +81,23 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
5981 */
6082 QString nullValue () const { return mNullValue ; }
6183
84+ /* * Sets the default value for the widget. The default value is a value
85+ * which the widget will be reset to if it is cleared and the clearMode()
86+ * is equal to ClearToDefault.
87+ * @param defaultValue default value
88+ * @see defaultValue()
89+ * @see clearMode()
90+ */
91+ void setDefaultValue ( const QString& defaultValue ) { mDefaultValue = defaultValue; }
92+
93+ /* * Returns the default value for the widget. The default value is a value
94+ * which the widget will be reset to if it is cleared and the clearMode()
95+ * is equal to ClearToDefault.
96+ * @see setDefaultValue()
97+ * @see clearMode()
98+ */
99+ QString defaultValue () const { return mDefaultValue ; }
100+
62101 /* *
63102 * Sets the current text for the widget with support for handling null values.
64103 *
@@ -118,7 +157,11 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
118157 void onTextChanged ( const QString &text );
119158
120159 private:
160+
161+ ClearMode mClearMode ;
162+
121163 QString mNullValue ;
164+ QString mDefaultValue ;
122165 QString mStyleSheet ;
123166 bool mFocusInEvent ;
124167 bool mClearHover ;
0 commit comments