Skip to content
Permalink
Browse files

fix attribute dialog (iterate layer attributes, not feature attributes)

  • Loading branch information
jef-n committed Jul 28, 2012
1 parent 3d8e3bd commit 42dc71ff88f5efc0670186a725c8029b69d575ed
@@ -128,15 +128,13 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
QGridLayout *mypInnerLayout = new QGridLayout( mypInnerFrame );

int index = 0;
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
for ( QgsFieldMap::const_iterator it = theFieldMap.begin(); it != theFieldMap.end(); ++it )
{
const QgsField &field = theFieldMap[it.key()];

//show attribute alias if available
QString myFieldName = vl->attributeDisplayName( it.key() );
int myFieldType = field.type();
int myFieldType = it->type();

QWidget *myWidget = QgsAttributeEditor::createAttributeEditor( 0, 0, vl, it.key(), it.value() );
QWidget *myWidget = QgsAttributeEditor::createAttributeEditor( 0, 0, vl, it.key(), myAttributes.value( it.key(), QVariant() ) );
if ( !myWidget )
continue;

@@ -179,15 +177,13 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
}
else
{
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
for ( QgsFieldMap::const_iterator it = theFieldMap.begin(); it != theFieldMap.end(); ++it )
{
const QgsField &field = theFieldMap[it.key()];

QWidget *myWidget = mDialog->findChild<QWidget*>( field.name() );
QWidget *myWidget = mDialog->findChild<QWidget*>( it->name() );
if ( !myWidget )
continue;

QgsAttributeEditor::createAttributeEditor( mDialog, myWidget, vl, it.key(), it.value() );
QgsAttributeEditor::createAttributeEditor( mDialog, myWidget, vl, it.key(), myAttributes.value( it.key(), QVariant() ) );

if ( vl->editType( it.key() ) != QgsVectorLayer::Immutable )
{
@@ -348,9 +344,8 @@ void QgsAttributeDialog::accept()
return;

//write the new values back to the feature
QgsAttributeMap myAttributes = mFeature->attributeMap();
int myIndex = 0;
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
for ( QgsFieldMap::const_iterator it = mLayer->pendingFields().begin(); it != mLayer->pendingFields().end(); ++it )
{
QVariant value;

@@ -919,11 +919,11 @@ bool QgsRasterLayer::hasCompatibleSymbology( const QgsMapLayer& theOther ) const
return false;
} //todo

#if 0
/**
* @param theBandNo The number of the band to check
* @return true if statistics have already been build for this band otherwise false
*/
/*
bool QgsRasterLayer::hasStatistics( int theBandNo )
{
if ( theBandNo <= mRasterStatsList.size() && theBandNo > 0 )
@@ -936,7 +936,7 @@ bool QgsRasterLayer::hasStatistics( int theBandNo )
return false;
}
}
*/
#endif

/**
* @param thePoint the QgsPoint for which to obtain pixel values
@@ -917,7 +917,7 @@ const QgsField &QgsPostgresProvider::field( int index ) const

if ( it == mAttributeFields.constEnd() )
{
QgsLogger::warning( QString( "FAILURE: Field %1 not found." ).arg( index ) );
QgsMessageLog::logMessage( tr( "FAILURE: Field %1 not found." ).arg( index ), tr( "PostGIS" ) );
throw PGFieldNotFound();
}

@@ -4896,7 +4896,7 @@ const QgsField & QgsSpatiaLiteProvider::field( int index ) const

if ( it == attributeFields.constEnd() )
{
QgsLogger::warning( QString( "FAILURE: Field %1 not found." ).arg( index ) );
QgsMessageLog::logMessage( tr( "FAILURE: Field %1 not found." ).arg( index ), tr( "SpatiaLite" ) );
throw SLFieldNotFound();
}

0 comments on commit 42dc71f

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