Skip to content
Permalink
Browse files
Remove alias from vector layer if it's an empty string
  • Loading branch information
giohappy committed Jun 23, 2014
1 parent 4b2c00c commit 26587af616b56229f58f8d6687e6e0d4c092904d
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
@@ -602,7 +602,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);
}
}
}
}
@@ -2040,6 +2040,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() )
@@ -1103,6 +1103,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 26587af

Please sign in to comment.