Skip to content
Permalink
Browse files

line edit: do not display clear icon when read only

  • Loading branch information
3nids committed Sep 24, 2014
1 parent e194423 commit ce486da41ea29f54406934d366c1bf00a205278d
Showing with 22 additions and 6 deletions.
  1. +7 −1 src/gui/editorwidgets/qgstexteditwrapper.cpp
  2. +9 −5 src/gui/qgsfilterlineedit.cpp
  3. +6 −0 src/gui/qgsfilterlineedit.h
@@ -139,5 +139,11 @@ void QgsTextEditWrapper::setEnabled( bool enabled )
mPlainTextEdit->setReadOnly( !enabled );

if ( mLineEdit )
mLineEdit->setReadOnly( !enabled );
{
QgsFilterLineEdit* qgsWidget = dynamic_cast<QgsFilterLineEdit*>( mLineEdit );
if ( qgsWidget )
qgsWidget->setReadOnly( !enabled );
else
mLineEdit->setReadOnly( !enabled );
}
}
@@ -81,15 +81,19 @@ void QgsFilterLineEdit::clear()
void QgsFilterLineEdit::changeEvent( QEvent *e )
{
QLineEdit::changeEvent( e );
if ( !isEnabled() || isReadOnly() )
btnClear->setVisible( false );
else
btnClear->setVisible( text() != mNullValue );
btnClear->setVisible( isEnabled() && !isReadOnly() && !isNull() );
}

void QgsFilterLineEdit::setReadOnly( bool readOnly )
{
QLineEdit::setReadOnly( readOnly );
btnClear->setVisible( isEnabled() && !isReadOnly() && !isNull() );
}


void QgsFilterLineEdit::onTextChanged( const QString &text )
{
btnClear->setVisible( !isEnabled() && !isReadOnly() && text != mNullValue );
btnClear->setVisible( isEnabled() && !isReadOnly() && !isNull() );

if ( isNull() )
{
@@ -58,6 +58,12 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
*/
inline bool isNull() const { return text() == mNullValue; }

/**
* @brief setReadOnly set the line edit to be read only and hide the clear button
* @note Since QLineEdit::setReadOnly() is not virtual, it needs to be called for QgsFilterLineEdit
*/
void setReadOnly( bool readOnly );

signals:
void cleared();

0 comments on commit ce486da

Please sign in to comment.
You can’t perform that action at this time.