Skip to content
Permalink
Browse files

Fixes value relation widget to always keep scrollbar activated. Fixes #…

  • Loading branch information
pblottiere committed Jul 21, 2017
1 parent 0cba29c commit 7e4f1f8c95da96f4deb212a8935e3ae3d2200992
@@ -122,7 +122,7 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper
*
* \param enabled Enable or Disable?
*/
void setEnabled( bool enabled ) override;
virtual void setEnabled( bool enabled ) override;

/** Sets the widget to display in an indeterminate "mixed value" state.
* \since QGIS 2.16
@@ -33,6 +33,7 @@ QgsValueRelationWidgetWrapper::QgsValueRelationWidgetWrapper( QgsVectorLayer *vl
, mListWidget( nullptr )
, mLineEdit( nullptr )
, mLayer( nullptr )
, mUpdating( false )
{
}

@@ -198,3 +199,26 @@ void QgsValueRelationWidgetWrapper::showIndeterminateState()
whileBlocking( mLineEdit )->clear();
}
}

void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
{
if ( mUpdating )
return;

if ( mListWidget )
{
mUpdating = true;
for ( int i = 0; i < mListWidget->count(); ++i )
{
QListWidgetItem *item = mListWidget->item( i );

if ( enabled )
item->setFlags( item->flags() | Qt::ItemIsEnabled );
else
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
}
mUpdating = false;
}
else
QgsEditorWidgetWrapper::setEnabled( enabled );
}
@@ -59,6 +59,8 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper

void showIndeterminateState() override;

void setEnabled( bool enabled ) override;

protected:
QWidget *createWidget( QWidget *parent ) override;
void initWidget( QWidget *editor ) override;
@@ -75,6 +77,8 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper
QgsValueRelationFieldFormatter::ValueRelationCache mCache;
QgsVectorLayer *mLayer = nullptr;

bool mUpdating;

friend class QgsValueRelationWidgetFactory;
};

0 comments on commit 7e4f1f8

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