File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -139,5 +139,11 @@ void QgsTextEditWrapper::setEnabled( bool enabled )
139
139
mPlainTextEdit ->setReadOnly ( !enabled );
140
140
141
141
if ( mLineEdit )
142
- mLineEdit ->setReadOnly ( !enabled );
142
+ {
143
+ QgsFilterLineEdit* qgsWidget = dynamic_cast <QgsFilterLineEdit*>( mLineEdit );
144
+ if ( qgsWidget )
145
+ qgsWidget->setReadOnly ( !enabled );
146
+ else
147
+ mLineEdit ->setReadOnly ( !enabled );
148
+ }
143
149
}
Original file line number Diff line number Diff line change @@ -81,15 +81,19 @@ void QgsFilterLineEdit::clear()
81
81
void QgsFilterLineEdit::changeEvent ( QEvent *e )
82
82
{
83
83
QLineEdit::changeEvent ( e );
84
- if ( !isEnabled () || isReadOnly () )
85
- btnClear->setVisible ( false );
86
- else
87
- btnClear->setVisible ( text () != mNullValue );
84
+ btnClear->setVisible ( isEnabled () && !isReadOnly () && !isNull () );
88
85
}
89
86
87
+ void QgsFilterLineEdit::setReadOnly ( bool readOnly )
88
+ {
89
+ QLineEdit::setReadOnly ( readOnly );
90
+ btnClear->setVisible ( isEnabled () && !isReadOnly () && !isNull () );
91
+ }
92
+
93
+
90
94
void QgsFilterLineEdit::onTextChanged ( const QString &text )
91
95
{
92
- btnClear->setVisible ( ! isEnabled () && !isReadOnly () && text != mNullValue );
96
+ btnClear->setVisible ( isEnabled () && !isReadOnly () && ! isNull () );
93
97
94
98
if ( isNull () )
95
99
{
Original file line number Diff line number Diff line change @@ -58,6 +58,12 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
58
58
*/
59
59
inline bool isNull () const { return text () == mNullValue ; }
60
60
61
+ /* *
62
+ * @brief setReadOnly set the line edit to be read only and hide the clear button
63
+ * @note Since QLineEdit::setReadOnly() is not virtual, it needs to be called for QgsFilterLineEdit
64
+ */
65
+ void setReadOnly ( bool readOnly );
66
+
61
67
signals:
62
68
void cleared ();
63
69
You can’t perform that action at this time.
0 commit comments