Skip to content

Commit

Permalink
fix attribute dialog (iterate layer attributes, not feature attributes)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 28, 2012
1 parent 3d8e3bd commit 42dc71f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
19 changes: 7 additions & 12 deletions src/app/qgsattributedialog.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -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 )
Expand All @@ -936,7 +936,7 @@ bool QgsRasterLayer::hasStatistics( int theBandNo )
return false;
}
}
*/
#endif

/**
* @param thePoint the QgsPoint for which to obtain pixel values
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -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();
}

Expand Down

0 comments on commit 42dc71f

Please sign in to comment.