Skip to content

Commit

Permalink
Merge pull request #377 from matthias-kuhn/attredit-load-idx
Browse files Browse the repository at this point in the history
Fix issue 6899: Drag and drop designer uses first field after project re...
  • Loading branch information
NathanW2 committed Jan 7, 2013
2 parents 4ff5b29 + c4115cf commit 1afd153
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ QgsAttributeEditorElement* QgsFieldsProperties::createAttributeEditorWidget( QTr

if ( item->data( 0, Qt::UserRole ) == "field" )
{
int idx = *mLayer->dataProvider()->fieldNameMap().find( item->text( 0 ) );
int idx = *( mLayer->dataProvider()->fieldNameMap() ).find( item->text( 0 ) );
widgetDef = new QgsAttributeEditorField( item->text( 0 ), idx, parent );
}
else
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3387,7 +3387,9 @@ QgsAttributeEditorElement* QgsVectorLayer::attributeEditorElementFromDomElement(
}
else if ( elem.tagName() == "attributeEditorField" )
{
newElement = new QgsAttributeEditorField( elem.attribute( "name" ), elem.attribute( "idx" ).toInt(), parent );
QString name = elem.attribute( "name" );
int idx = *( dataProvider()->fieldNameMap() ).find( name );
newElement = new QgsAttributeEditorField( name, idx, parent );
}

return newElement;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
* @param elem the DOM element
* @param parent the QObject which will own this object
*/
static QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent );
QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent );

/** Read the symbology for the current layer from the Dom node supplied.
* @param node node that will contain the symbology definition for this layer.
Expand Down
14 changes: 12 additions & 2 deletions src/gui/qgsattributeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <qgsmaplayerregistry.h>
#include <qgslogger.h>

#include <QScrollArea>
#include <QPushButton>
#include <QLineEdit>
#include <QTextEdit>
Expand Down Expand Up @@ -987,13 +988,23 @@ QWidget* QgsAttributeEditor::createWidgetFromDef( const QgsAttributeEditorElemen
QGroupBox* groupBox = new QGroupBox( parent );
groupBox->setTitle( container->name() );
myContainer = groupBox;
newWidget = myContainer;
}
else
{
myContainer = new QWidget( parent );
QScrollArea *scrollArea = new QScrollArea( parent );

myContainer = new QWidget( scrollArea );

scrollArea->setWidget( myContainer );
scrollArea->setWidgetResizable( true );
scrollArea->setFrameShape( QFrame::NoFrame );

newWidget = scrollArea;
}

QGridLayout* gbLayout = new QGridLayout( myContainer );
myContainer->setLayout( gbLayout );

int index = 0;

Expand Down Expand Up @@ -1026,7 +1037,6 @@ QWidget* QgsAttributeEditor::createWidgetFromDef( const QgsAttributeEditorElemen
}
gbLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ), index , 0 );

newWidget = myContainer;
break;
}

Expand Down

0 comments on commit 1afd153

Please sign in to comment.