Skip to content

Commit 42dc71f

Browse files
committed
fix attribute dialog (iterate layer attributes, not feature attributes)
1 parent 3d8e3bd commit 42dc71f

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

‎src/app/qgsattributedialog.cpp‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,13 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
128128
QGridLayout *mypInnerLayout = new QGridLayout( mypInnerFrame );
129129

130130
int index = 0;
131-
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
131+
for ( QgsFieldMap::const_iterator it = theFieldMap.begin(); it != theFieldMap.end(); ++it )
132132
{
133-
const QgsField &field = theFieldMap[it.key()];
134-
135133
//show attribute alias if available
136134
QString myFieldName = vl->attributeDisplayName( it.key() );
137-
int myFieldType = field.type();
135+
int myFieldType = it->type();
138136

139-
QWidget *myWidget = QgsAttributeEditor::createAttributeEditor( 0, 0, vl, it.key(), it.value() );
137+
QWidget *myWidget = QgsAttributeEditor::createAttributeEditor( 0, 0, vl, it.key(), myAttributes.value( it.key(), QVariant() ) );
140138
if ( !myWidget )
141139
continue;
142140

@@ -179,15 +177,13 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
179177
}
180178
else
181179
{
182-
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
180+
for ( QgsFieldMap::const_iterator it = theFieldMap.begin(); it != theFieldMap.end(); ++it )
183181
{
184-
const QgsField &field = theFieldMap[it.key()];
185-
186-
QWidget *myWidget = mDialog->findChild<QWidget*>( field.name() );
182+
QWidget *myWidget = mDialog->findChild<QWidget*>( it->name() );
187183
if ( !myWidget )
188184
continue;
189185

190-
QgsAttributeEditor::createAttributeEditor( mDialog, myWidget, vl, it.key(), it.value() );
186+
QgsAttributeEditor::createAttributeEditor( mDialog, myWidget, vl, it.key(), myAttributes.value( it.key(), QVariant() ) );
191187

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

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

‎src/core/raster/qgsrasterlayer.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,11 +919,11 @@ bool QgsRasterLayer::hasCompatibleSymbology( const QgsMapLayer& theOther ) const
919919
return false;
920920
} //todo
921921

922+
#if 0
922923
/**
923924
* @param theBandNo The number of the band to check
924925
* @return true if statistics have already been build for this band otherwise false
925926
*/
926-
/*
927927
bool QgsRasterLayer::hasStatistics( int theBandNo )
928928
{
929929
if ( theBandNo <= mRasterStatsList.size() && theBandNo > 0 )
@@ -936,7 +936,7 @@ bool QgsRasterLayer::hasStatistics( int theBandNo )
936936
return false;
937937
}
938938
}
939-
*/
939+
#endif
940940

941941
/**
942942
* @param thePoint the QgsPoint for which to obtain pixel values

‎src/providers/postgres/qgspostgresprovider.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ const QgsField &QgsPostgresProvider::field( int index ) const
917917

918918
if ( it == mAttributeFields.constEnd() )
919919
{
920-
QgsLogger::warning( QString( "FAILURE: Field %1 not found." ).arg( index ) );
920+
QgsMessageLog::logMessage( tr( "FAILURE: Field %1 not found." ).arg( index ), tr( "PostGIS" ) );
921921
throw PGFieldNotFound();
922922
}
923923

‎src/providers/spatialite/qgsspatialiteprovider.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4896,7 +4896,7 @@ const QgsField & QgsSpatiaLiteProvider::field( int index ) const
48964896

48974897
if ( it == attributeFields.constEnd() )
48984898
{
4899-
QgsLogger::warning( QString( "FAILURE: Field %1 not found." ).arg( index ) );
4899+
QgsMessageLog::logMessage( tr( "FAILURE: Field %1 not found." ).arg( index ), tr( "SpatiaLite" ) );
49004900
throw SLFieldNotFound();
49014901
}
49024902

0 commit comments

Comments
 (0)