Skip to content

Commit ff52a9f

Browse files
committed
setAttributeAlias is now setFieldAlias
1 parent 37e06ae commit ff52a9f

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

doc/api_break.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,8 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.</li>
14161416
<li>editFormConfig() returns a copy instead of direct access (Use setEditFormConfig to update)
14171417
<li>Removed valueRelation(), replaced with QgsEditFormConfig::editorWidgetConfig
14181418
<li>Removed fieldNameIndex(), use fields().lookupField() or fields().indexFromName() instead
1419-
<li>Renamed addAttributeAlias() to setAttributeAlias()
1420-
<li>Renamed remAttributeAlias() to removeAttributeAlias()
1419+
<li>Renamed addAttributeAlias() to setFieldAlias()
1420+
<li>Renamed remAttributeAlias() to removeFieldAlias()
14211421
</ul>
14221422

14231423
\subsection qgis_api_break_3_0_QgsVectorLayerEditBuffer QgsVectorLayerEditBuffer

python/core/qgsvectorlayer.sip

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,32 +1078,32 @@ class QgsVectorLayer : QgsMapLayer
10781078
*
10791079
* @note Added in QGIS 3.0
10801080
*/
1081-
void setAttributeAlias( int index, const QString& aliasString );
1081+
void setFieldAlias( int index, const QString& aliasString );
10821082

10831083
/**
10841084
* Removes an alias (a display name) for attributes to display in dialogs
10851085
*
10861086
* @note Added in QGIS 3.0
10871087
*/
1088-
void removeAttributeAlias( int index );
1088+
void removeFieldAlias( int index );
10891089

10901090
/** Renames an attribute field (but does not commit it).
10911091
* @param attIndex attribute index
10921092
* @param newName new name of field
10931093
* @note added in QGIS 2.16
10941094
*/
1095-
bool renameAttribute( int attIndex, const QString& newName );
1095+
bool renameAttribute( int index, const QString& newName );
10961096

10971097
/**
10981098
* Returns the alias of an attribute name or a null string if there is no alias.
10991099
*
11001100
* @see {attributeDisplayName( int attributeIndex )} which returns the field name
11011101
* if no alias is defined.
11021102
*/
1103-
QString attributeAlias( int attributeIndex ) const;
1103+
QString attributeAlias( int index ) const;
11041104

11051105
/** Convenience function that returns the attribute alias if defined or the field name else */
1106-
QString attributeDisplayName( int attributeIndex ) const;
1106+
QString attributeDisplayName( int index ) const;
11071107

11081108
const QMap< QString, QString >& attributeAliases() const;
11091109

src/app/qgsfieldsproperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,11 +765,11 @@ void QgsFieldsProperties::attributesListCellChanged( int row, int column )
765765
{
766766
if ( !aliasItem->text().trimmed().isEmpty() )
767767
{
768-
mLayer->setAttributeAlias( idx, aliasItem->text() );
768+
mLayer->setFieldAlias( idx, aliasItem->text() );
769769
}
770770
else
771771
{
772-
mLayer->removeAttributeAlias( idx );
772+
mLayer->removeFieldAlias( idx );
773773
}
774774
}
775775
}

src/core/qgsvectorlayer.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,7 @@ bool QgsVectorLayer::addAttribute( const QgsField &field )
21072107
return mEditBuffer->addAttribute( field );
21082108
}
21092109

2110-
void QgsVectorLayer::removeAttributeAlias( int attIndex )
2110+
void QgsVectorLayer::removeFieldAlias( int attIndex )
21112111
{
21122112
if ( attIndex < 0 || attIndex >= fields().count() )
21132113
return;
@@ -2123,15 +2123,15 @@ void QgsVectorLayer::removeAttributeAlias( int attIndex )
21232123
}
21242124
}
21252125

2126-
bool QgsVectorLayer::renameAttribute( int attIndex, const QString& newName )
2126+
bool QgsVectorLayer::renameAttribute( int index, const QString& newName )
21272127
{
21282128
if ( !mEditBuffer || !mDataProvider )
21292129
return false;
21302130

2131-
return mEditBuffer->renameAttribute( attIndex, newName );
2131+
return mEditBuffer->renameAttribute( index, newName );
21322132
}
21332133

2134-
void QgsVectorLayer::setAttributeAlias( int attIndex, const QString& aliasString )
2134+
void QgsVectorLayer::setFieldAlias( int attIndex, const QString& aliasString )
21352135
{
21362136
if ( attIndex < 0 || attIndex >= fields().count() )
21372137
return;
@@ -2144,18 +2144,18 @@ void QgsVectorLayer::setAttributeAlias( int attIndex, const QString& aliasString
21442144
emit layerModified(); // TODO[MD]: should have a different signal?
21452145
}
21462146

2147-
QString QgsVectorLayer::attributeAlias( int attributeIndex ) const
2147+
QString QgsVectorLayer::attributeAlias( int index ) const
21482148
{
2149-
if ( attributeIndex < 0 || attributeIndex >= fields().count() )
2149+
if ( index < 0 || index >= fields().count() )
21502150
return QString();
21512151

2152-
return fields().at( attributeIndex ).alias();
2152+
return fields().at( index ).alias();
21532153
}
21542154

2155-
QString QgsVectorLayer::attributeDisplayName( int attributeIndex ) const
2155+
QString QgsVectorLayer::attributeDisplayName( int index ) const
21562156
{
2157-
if ( attributeIndex >= 0 && attributeIndex < mFields.count() )
2158-
return mFields.at( attributeIndex ).displayName();
2157+
if ( index >= 0 && index < mFields.count() )
2158+
return mFields.at( index ).displayName();
21592159
else
21602160
return QString();
21612161
}

src/core/qgsvectorlayer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,32 +1202,32 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
12021202
*
12031203
* @note Added in QGIS 3.0
12041204
*/
1205-
void setAttributeAlias( int index, const QString& aliasString );
1205+
void setFieldAlias( int index, const QString& aliasString );
12061206

12071207
/**
12081208
* Removes an alias (a display name) for attributes to display in dialogs
12091209
*
12101210
* @note Added in QGIS 3.0
12111211
*/
1212-
void removeAttributeAlias( int index );
1212+
void removeFieldAlias( int index );
12131213

12141214
/** Renames an attribute field (but does not commit it).
1215-
* @param attIndex attribute index
1215+
* @param index attribute index
12161216
* @param newName new name of field
12171217
* @note added in QGIS 2.16
12181218
*/
1219-
bool renameAttribute( int attIndex, const QString& newName );
1219+
bool renameAttribute( int index, const QString& newName );
12201220

12211221
/**
12221222
* Returns the alias of an attribute name or a null string if there is no alias.
12231223
*
12241224
* @see {attributeDisplayName( int attributeIndex )} which returns the field name
12251225
* if no alias is defined.
12261226
*/
1227-
QString attributeAlias( int attributeIndex ) const;
1227+
QString attributeAlias( int index ) const;
12281228

12291229
/** Convenience function that returns the attribute alias if defined or the field name else */
1230-
QString attributeDisplayName( int attributeIndex ) const;
1230+
QString attributeDisplayName( int index ) const;
12311231

12321232
//! Returns a map of field name to attribute alias
12331233
QgsStringMap attributeAliases() const;

tests/src/python/test_qgsvectorlayer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,27 +1615,27 @@ def testGetSetAliases(self):
16151615
self.assertFalse(layer.attributeAlias(1))
16161616
self.assertFalse(layer.attributeAlias(2))
16171617

1618-
layer.addAttributeAlias(0, "test")
1618+
layer.setFieldAlias(0, "test")
16191619
self.assertEqual(layer.attributeAlias(0), "test")
16201620
self.assertFalse(layer.attributeAlias(1))
16211621
self.assertFalse(layer.attributeAlias(2))
16221622
self.assertEqual(layer.fields().at(0).alias(), "test")
16231623

1624-
layer.addAttributeAlias(1, "test2")
1624+
layer.setFieldAlias(1, "test2")
16251625
self.assertEqual(layer.attributeAlias(0), "test")
16261626
self.assertEqual(layer.attributeAlias(1), "test2")
16271627
self.assertFalse(layer.attributeAlias(2))
16281628
self.assertEqual(layer.fields().at(0).alias(), "test")
16291629
self.assertEqual(layer.fields().at(1).alias(), "test2")
16301630

1631-
layer.addAttributeAlias(1, None)
1631+
layer.setFieldAlias(1, None)
16321632
self.assertEqual(layer.attributeAlias(0), "test")
16331633
self.assertFalse(layer.attributeAlias(1))
16341634
self.assertFalse(layer.attributeAlias(2))
16351635
self.assertEqual(layer.fields().at(0).alias(), "test")
16361636
self.assertFalse(layer.fields().at(1).alias())
16371637

1638-
layer.remAttributeAlias(0)
1638+
layer.removeFieldAlias(0)
16391639
self.assertFalse(layer.attributeAlias(0))
16401640
self.assertFalse(layer.attributeAlias(1))
16411641
self.assertFalse(layer.attributeAlias(2))
@@ -1657,8 +1657,8 @@ def testSaveRestoreAliases(self):
16571657
self.assertFalse(layer2.attributeAlias(1))
16581658

16591659
# set some aliases
1660-
layer.addAttributeAlias(0, "test")
1661-
layer.addAttributeAlias(1, "test2")
1660+
layer.setFieldAlias(0, "test")
1661+
layer.setFieldAlias(1, "test2")
16621662

16631663
doc = QDomDocument("testdoc")
16641664
elem = doc.createElement("maplayer")

0 commit comments

Comments
 (0)