Skip to content
Permalink
Browse files
Merge pull request #377 from matthias-kuhn/attredit-load-idx
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 1afd1538f2e7ba1b92a59856081eff33c9710bd5
Showing with 17 additions and 5 deletions.
  1. +1 −1 src/app/qgsfieldsproperties.cpp
  2. +3 −1 src/core/qgsvectorlayer.cpp
  3. +1 −1 src/core/qgsvectorlayer.h
  4. +12 −2 src/gui/qgsattributeeditor.cpp
@@ -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
@@ -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;
@@ -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.
@@ -26,6 +26,7 @@
#include <qgsmaplayerregistry.h>
#include <qgslogger.h>

#include <QScrollArea>
#include <QPushButton>
#include <QLineEdit>
#include <QTextEdit>
@@ -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;

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

newWidget = myContainer;
break;
}

0 comments on commit 1afd153

Please sign in to comment.