Skip to content

Commit

Permalink
Merge pull request #51561 from elpaso/attributeform-dd-widget-maxsize
Browse files Browse the repository at this point in the history
Make form combo box widgets shrinkable
  • Loading branch information
elpaso committed Jan 24, 2023
2 parents 99b49d0 + d97baeb commit e2fe280
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsclassificationwidgetwrapper.cpp
Expand Up @@ -36,7 +36,10 @@ void QgsClassificationWidgetWrapper::showIndeterminateState()

QWidget *QgsClassificationWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsClassificationWidgetWrapper::initWidget( QWidget *editor )
Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsenumerationwidgetwrapper.cpp
Expand Up @@ -45,7 +45,10 @@ void QgsEnumerationWidgetWrapper::showIndeterminateState()

QWidget *QgsEnumerationWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsEnumerationWidgetWrapper::initWidget( QWidget *editor )
Expand Down
7 changes: 6 additions & 1 deletion src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.cpp
Expand Up @@ -51,7 +51,12 @@ QWidget *QgsUniqueValuesWidgetWrapper::createWidget( QWidget *parent )
if ( config( QStringLiteral( "Editable" ) ).toBool() )
return new QgsFilterLineEdit( parent );
else
return new QComboBox( parent );
{
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}
}

void QgsUniqueValuesWidgetWrapper::initWidget( QWidget *editor )
Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.cpp
Expand Up @@ -32,7 +32,10 @@ QgsValueMapSearchWidgetWrapper::QgsValueMapSearchWidgetWrapper( QgsVectorLayer *

QWidget *QgsValueMapSearchWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
auto combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsValueMapSearchWidgetWrapper::comboBoxIndexChanged( int idx )
Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsvaluemapwidgetwrapper.cpp
Expand Up @@ -52,7 +52,10 @@ void QgsValueMapWidgetWrapper::showIndeterminateState()

QWidget *QgsValueMapWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsValueMapWidgetWrapper::initWidget( QWidget *editor )
Expand Down
3 changes: 2 additions & 1 deletion src/gui/editorwidgets/qgsvaluemapwidgetwrapper.h
Expand Up @@ -23,7 +23,6 @@

SIP_NO_FILE


/**
* \ingroup gui
* \brief Wraps a value map widget.
Expand Down Expand Up @@ -71,4 +70,6 @@ class GUI_EXPORT QgsValueMapWidgetWrapper : public QgsEditorWidgetWrapper

};



#endif // QGSVALUEMAPWIDGETWRAPPER_H
Expand Up @@ -202,7 +202,10 @@ QWidget *QgsValueRelationSearchWidgetWrapper::createWidget( QWidget *parent )
}
else
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -291,7 +291,10 @@ QWidget *QgsValueRelationWidgetWrapper::createWidget( QWidget *parent )
}
else
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsfeaturelistcombobox.cpp
Expand Up @@ -29,6 +29,8 @@ QgsFeatureListComboBox::QgsFeatureListComboBox( QWidget *parent )
, mModel( new QgsFeatureFilterModel( this ) )
, mCompleter( new QCompleter( mModel ) )
{
setMinimumContentsLength( 1 );
setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
mCompleter->setCaseSensitivity( Qt::CaseInsensitive );
mCompleter->setFilterMode( Qt::MatchContains );
setEditable( true );
Expand Down

0 comments on commit e2fe280

Please sign in to comment.