Skip to content
Permalink
Browse files

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

  • Loading branch information
pblottiere committed Jul 27, 2017
1 parent bc9f822 commit 7b5b628f962184167053666632841fbd734c7acf
@@ -103,7 +103,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.
* @note added in QGIS 2.16
@@ -43,6 +43,7 @@ QgsValueRelationWidgetWrapper::QgsValueRelationWidgetWrapper( QgsVectorLayer* vl
, mListWidget( nullptr )
, mLineEdit( nullptr )
, mLayer( nullptr )
, mUpdating( false )
{
}

@@ -248,3 +249,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 );
}
@@ -68,6 +68,8 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper
static ValueRelationCache createCache( const QgsEditorWidgetConfig& config );
void showIndeterminateState() override;

void setEnabled( bool enabled ) override;

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

bool mUpdating;

friend class QgsValueRelationWidgetFactory;
};

0 comments on commit 7b5b628

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