Skip to content
Permalink
Browse files

Merge pull request #1481 from giohappy/alias_remove_when_empty

Remove alias from vector layer if it's an empty string.  Fix #10437
  • Loading branch information
NathanW2 committed Aug 10, 2014
2 parents fe4e552 + 26587af commit c3bd82aa7be2d20528a2b380dac65f7650e5d8ac
Showing with 27 additions and 1 deletion.
  1. +8 −1 src/app/qgsfieldsproperties.cpp
  2. +13 −0 src/core/qgsvectorlayer.cpp
  3. +6 −0 src/core/qgsvectorlayer.h
@@ -605,7 +605,14 @@ void QgsFieldsProperties::attributesListCellChanged( int row, int column )
QTableWidgetItem *aliasItem = mFieldsList->item( row, column );
if ( aliasItem )
{
mLayer->addAttributeAlias( idx, aliasItem->text() );
if ( !aliasItem->text().trimmed().isEmpty() )
{
mLayer->addAttributeAlias( idx, aliasItem->text() );
}
else
{
mLayer->remAttributeAlias(idx);
}
}
}
}
@@ -2046,6 +2046,19 @@ bool QgsVectorLayer::addAttribute( const QgsField &field )
return mEditBuffer->addAttribute( field );
}

void QgsVectorLayer::remAttributeAlias( int attIndex)
{
if ( attIndex < 0 || attIndex >= pendingFields().count() )
return;

QString name = pendingFields()[ attIndex ].name();
if ( mAttributeAliasMap.contains(name) )
{
mAttributeAliasMap.remove( name );
emit layerModified();
}
}

void QgsVectorLayer::addAttributeAlias( int attIndex, QString aliasString )
{
if ( attIndex < 0 || attIndex >= pendingFields().count() )
@@ -1116,6 +1116,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
void addAttributeAlias( int attIndex, QString aliasString );

/**
* Removes an alias (a display name) for attributes to display in dialogs
* @note added in version 2.4
*/
void remAttributeAlias( int attIndex );

/**
* Adds a tab (for the attribute editor form) holding groups and fields
* @note added in version 2.0

0 comments on commit c3bd82a

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