mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
setAttributeAlias is now setFieldAlias
This commit is contained in:
parent
37e06ae587
commit
ff52a9f29b
@ -1416,8 +1416,8 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.</li>
|
||||
<li>editFormConfig() returns a copy instead of direct access (Use setEditFormConfig to update)
|
||||
<li>Removed valueRelation(), replaced with QgsEditFormConfig::editorWidgetConfig
|
||||
<li>Removed fieldNameIndex(), use fields().lookupField() or fields().indexFromName() instead
|
||||
<li>Renamed addAttributeAlias() to setAttributeAlias()
|
||||
<li>Renamed remAttributeAlias() to removeAttributeAlias()
|
||||
<li>Renamed addAttributeAlias() to setFieldAlias()
|
||||
<li>Renamed remAttributeAlias() to removeFieldAlias()
|
||||
</ul>
|
||||
|
||||
\subsection qgis_api_break_3_0_QgsVectorLayerEditBuffer QgsVectorLayerEditBuffer
|
||||
|
@ -1078,21 +1078,21 @@ class QgsVectorLayer : QgsMapLayer
|
||||
*
|
||||
* @note Added in QGIS 3.0
|
||||
*/
|
||||
void setAttributeAlias( int index, const QString& aliasString );
|
||||
void setFieldAlias( int index, const QString& aliasString );
|
||||
|
||||
/**
|
||||
* Removes an alias (a display name) for attributes to display in dialogs
|
||||
*
|
||||
* @note Added in QGIS 3.0
|
||||
*/
|
||||
void removeAttributeAlias( int index );
|
||||
void removeFieldAlias( int index );
|
||||
|
||||
/** Renames an attribute field (but does not commit it).
|
||||
* @param attIndex attribute index
|
||||
* @param newName new name of field
|
||||
* @note added in QGIS 2.16
|
||||
*/
|
||||
bool renameAttribute( int attIndex, const QString& newName );
|
||||
bool renameAttribute( int index, const QString& newName );
|
||||
|
||||
/**
|
||||
* Returns the alias of an attribute name or a null string if there is no alias.
|
||||
@ -1100,10 +1100,10 @@ class QgsVectorLayer : QgsMapLayer
|
||||
* @see {attributeDisplayName( int attributeIndex )} which returns the field name
|
||||
* if no alias is defined.
|
||||
*/
|
||||
QString attributeAlias( int attributeIndex ) const;
|
||||
QString attributeAlias( int index ) const;
|
||||
|
||||
/** Convenience function that returns the attribute alias if defined or the field name else */
|
||||
QString attributeDisplayName( int attributeIndex ) const;
|
||||
QString attributeDisplayName( int index ) const;
|
||||
|
||||
const QMap< QString, QString >& attributeAliases() const;
|
||||
|
||||
|
@ -765,11 +765,11 @@ void QgsFieldsProperties::attributesListCellChanged( int row, int column )
|
||||
{
|
||||
if ( !aliasItem->text().trimmed().isEmpty() )
|
||||
{
|
||||
mLayer->setAttributeAlias( idx, aliasItem->text() );
|
||||
mLayer->setFieldAlias( idx, aliasItem->text() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mLayer->removeAttributeAlias( idx );
|
||||
mLayer->removeFieldAlias( idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2107,7 +2107,7 @@ bool QgsVectorLayer::addAttribute( const QgsField &field )
|
||||
return mEditBuffer->addAttribute( field );
|
||||
}
|
||||
|
||||
void QgsVectorLayer::removeAttributeAlias( int attIndex )
|
||||
void QgsVectorLayer::removeFieldAlias( int attIndex )
|
||||
{
|
||||
if ( attIndex < 0 || attIndex >= fields().count() )
|
||||
return;
|
||||
@ -2123,15 +2123,15 @@ void QgsVectorLayer::removeAttributeAlias( int attIndex )
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::renameAttribute( int attIndex, const QString& newName )
|
||||
bool QgsVectorLayer::renameAttribute( int index, const QString& newName )
|
||||
{
|
||||
if ( !mEditBuffer || !mDataProvider )
|
||||
return false;
|
||||
|
||||
return mEditBuffer->renameAttribute( attIndex, newName );
|
||||
return mEditBuffer->renameAttribute( index, newName );
|
||||
}
|
||||
|
||||
void QgsVectorLayer::setAttributeAlias( int attIndex, const QString& aliasString )
|
||||
void QgsVectorLayer::setFieldAlias( int attIndex, const QString& aliasString )
|
||||
{
|
||||
if ( attIndex < 0 || attIndex >= fields().count() )
|
||||
return;
|
||||
@ -2144,18 +2144,18 @@ void QgsVectorLayer::setAttributeAlias( int attIndex, const QString& aliasString
|
||||
emit layerModified(); // TODO[MD]: should have a different signal?
|
||||
}
|
||||
|
||||
QString QgsVectorLayer::attributeAlias( int attributeIndex ) const
|
||||
QString QgsVectorLayer::attributeAlias( int index ) const
|
||||
{
|
||||
if ( attributeIndex < 0 || attributeIndex >= fields().count() )
|
||||
if ( index < 0 || index >= fields().count() )
|
||||
return QString();
|
||||
|
||||
return fields().at( attributeIndex ).alias();
|
||||
return fields().at( index ).alias();
|
||||
}
|
||||
|
||||
QString QgsVectorLayer::attributeDisplayName( int attributeIndex ) const
|
||||
QString QgsVectorLayer::attributeDisplayName( int index ) const
|
||||
{
|
||||
if ( attributeIndex >= 0 && attributeIndex < mFields.count() )
|
||||
return mFields.at( attributeIndex ).displayName();
|
||||
if ( index >= 0 && index < mFields.count() )
|
||||
return mFields.at( index ).displayName();
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
|
@ -1202,21 +1202,21 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
*
|
||||
* @note Added in QGIS 3.0
|
||||
*/
|
||||
void setAttributeAlias( int index, const QString& aliasString );
|
||||
void setFieldAlias( int index, const QString& aliasString );
|
||||
|
||||
/**
|
||||
* Removes an alias (a display name) for attributes to display in dialogs
|
||||
*
|
||||
* @note Added in QGIS 3.0
|
||||
*/
|
||||
void removeAttributeAlias( int index );
|
||||
void removeFieldAlias( int index );
|
||||
|
||||
/** Renames an attribute field (but does not commit it).
|
||||
* @param attIndex attribute index
|
||||
* @param index attribute index
|
||||
* @param newName new name of field
|
||||
* @note added in QGIS 2.16
|
||||
*/
|
||||
bool renameAttribute( int attIndex, const QString& newName );
|
||||
bool renameAttribute( int index, const QString& newName );
|
||||
|
||||
/**
|
||||
* Returns the alias of an attribute name or a null string if there is no alias.
|
||||
@ -1224,10 +1224,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
* @see {attributeDisplayName( int attributeIndex )} which returns the field name
|
||||
* if no alias is defined.
|
||||
*/
|
||||
QString attributeAlias( int attributeIndex ) const;
|
||||
QString attributeAlias( int index ) const;
|
||||
|
||||
/** Convenience function that returns the attribute alias if defined or the field name else */
|
||||
QString attributeDisplayName( int attributeIndex ) const;
|
||||
QString attributeDisplayName( int index ) const;
|
||||
|
||||
//! Returns a map of field name to attribute alias
|
||||
QgsStringMap attributeAliases() const;
|
||||
|
@ -1615,27 +1615,27 @@ class TestQgsVectorLayer(unittest.TestCase):
|
||||
self.assertFalse(layer.attributeAlias(1))
|
||||
self.assertFalse(layer.attributeAlias(2))
|
||||
|
||||
layer.addAttributeAlias(0, "test")
|
||||
layer.setFieldAlias(0, "test")
|
||||
self.assertEqual(layer.attributeAlias(0), "test")
|
||||
self.assertFalse(layer.attributeAlias(1))
|
||||
self.assertFalse(layer.attributeAlias(2))
|
||||
self.assertEqual(layer.fields().at(0).alias(), "test")
|
||||
|
||||
layer.addAttributeAlias(1, "test2")
|
||||
layer.setFieldAlias(1, "test2")
|
||||
self.assertEqual(layer.attributeAlias(0), "test")
|
||||
self.assertEqual(layer.attributeAlias(1), "test2")
|
||||
self.assertFalse(layer.attributeAlias(2))
|
||||
self.assertEqual(layer.fields().at(0).alias(), "test")
|
||||
self.assertEqual(layer.fields().at(1).alias(), "test2")
|
||||
|
||||
layer.addAttributeAlias(1, None)
|
||||
layer.setFieldAlias(1, None)
|
||||
self.assertEqual(layer.attributeAlias(0), "test")
|
||||
self.assertFalse(layer.attributeAlias(1))
|
||||
self.assertFalse(layer.attributeAlias(2))
|
||||
self.assertEqual(layer.fields().at(0).alias(), "test")
|
||||
self.assertFalse(layer.fields().at(1).alias())
|
||||
|
||||
layer.remAttributeAlias(0)
|
||||
layer.removeFieldAlias(0)
|
||||
self.assertFalse(layer.attributeAlias(0))
|
||||
self.assertFalse(layer.attributeAlias(1))
|
||||
self.assertFalse(layer.attributeAlias(2))
|
||||
@ -1657,8 +1657,8 @@ class TestQgsVectorLayer(unittest.TestCase):
|
||||
self.assertFalse(layer2.attributeAlias(1))
|
||||
|
||||
# set some aliases
|
||||
layer.addAttributeAlias(0, "test")
|
||||
layer.addAttributeAlias(1, "test2")
|
||||
layer.setFieldAlias(0, "test")
|
||||
layer.setFieldAlias(1, "test2")
|
||||
|
||||
doc = QDomDocument("testdoc")
|
||||
elem = doc.createElement("maplayer")
|
||||
|
Loading…
x
Reference in New Issue
Block a user