Skip to content
Permalink
Browse files
restore naming of generated attribute widgets
  • Loading branch information
jef-n committed Jul 24, 2014
1 parent af7f036 commit 693c2e72ddb2709944ebff665db0e69ffc0b949b
Showing with 30 additions and 23 deletions.
  1. +30 −23 src/gui/qgsattributeform.cpp
@@ -301,7 +301,7 @@ void QgsAttributeForm::init()
{
delete w;
}
delete this->layout();
delete layout();

// Get a layout
setLayout( new QGridLayout( this ) );
@@ -366,6 +366,7 @@ void QgsAttributeForm::init()
formWidget->setLayout( gridLayout );

// put the form into a scroll area to nicely handle cases with lots of attributes

QScrollArea* scrollArea = new QScrollArea( this );
scrollArea->setWidget( formWidget );
scrollArea->setWidgetResizable( true );
@@ -383,29 +384,32 @@ void QgsAttributeForm::init()

const QString widgetType = mLayer->editorWidgetV2( idx );

if ( widgetType != "Hidden" )
{
const QgsEditorWidgetConfig widgetConfig = mLayer->editorWidgetV2Config( idx );
bool labelOnTop = mLayer->labelOnTop( idx );
if ( widgetType == "Hidden" )
continue;

// This will also create the widget
QWidget *l = new QLabel( fieldName );
QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( widgetType, mLayer, idx, widgetConfig, 0, this, mContext );
QWidget *w = eww ? eww->widget() : new QLabel( QString( "<p style=\"color: red; font-style: italic;\">Failed to create widget with type '%1'</p>" ).arg( widgetType ) );
const QgsEditorWidgetConfig widgetConfig = mLayer->editorWidgetV2Config( idx );
bool labelOnTop = mLayer->labelOnTop( idx );

if ( eww )
addWidgetWrapper( eww );
// This will also create the widget
QWidget *l = new QLabel( fieldName );
QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( widgetType, mLayer, idx, widgetConfig, 0, this, mContext );
QWidget *w = eww ? eww->widget() : new QLabel( QString( "<p style=\"color: red; font-style: italic;\">Failed to create widget with type '%1'</p>" ).arg( widgetType ) );

if ( labelOnTop )
{
gridLayout->addWidget( l, row++, 0, 1, 2 );
gridLayout->addWidget( w, row++, 0, 1, 2 );
}
else
{
gridLayout->addWidget( l, row, 0 );
gridLayout->addWidget( w, row++, 1 );
}
if ( w )
w->setObjectName( field.name() );

if ( eww )
addWidgetWrapper( eww );

if ( labelOnTop )
{
gridLayout->addWidget( l, row++, 0, 1, 2 );
gridLayout->addWidget( w, row++, 0, 1, 2 );
}
else
{
gridLayout->addWidget( l, row, 0 );
gridLayout->addWidget( w, row++, 1 );
}
}

@@ -524,10 +528,13 @@ QWidget* QgsAttributeForm::createWidgetFromDef( const QgsAttributeEditorElement
QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( widgetType, mLayer, fldIdx, widgetConfig, 0, this, mContext );
newWidget = eww->widget();
addWidgetWrapper( eww );

newWidget->setObjectName( mLayer->pendingFields()[ fldIdx ].name() );
}

labelOnTop = mLayer->labelOnTop( fieldDef->idx() );
labelText = mLayer->attributeDisplayName( fieldDef->idx() );

break;
}

@@ -628,8 +635,8 @@ void QgsAttributeForm::addWidgetWrapper( QgsEditorWidgetWrapper* eww )
{
if ( meww->field() == eww->field() )
{
connect( meww, SIGNAL(valueChanged(QVariant)), eww, SLOT(setValue(QVariant)) );
connect( eww, SIGNAL(valueChanged(QVariant)), meww, SLOT(setValue(QVariant)) );
connect( meww, SIGNAL( valueChanged( QVariant ) ), eww, SLOT( setValue( QVariant ) ) );
connect( eww, SIGNAL( valueChanged( QVariant ) ), meww, SLOT( setValue( QVariant ) ) );
break;
}
}

0 comments on commit 693c2e7

Please sign in to comment.