Skip to content

Commit

Permalink
__repr__ fro QgsSymbolLayerReference, QgsSymbolLayerId
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 24, 2021
1 parent 22c2d72 commit 5ded8b6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Expand Up @@ -73,6 +73,18 @@ Returns the symbol layer index path inside the symbol

bool operator<( const QgsSymbolLayerId &other ) const;

SIP_PYOBJECT __repr__();
%MethodCode

QStringList pathString;
for ( int path : sipCpp->symbolLayerIndexPath() )
{
pathString.append( QString::number( path ) );
}
QString str = QStringLiteral( "<QgsSymbolLayerId: %1 (%2)>" ).arg( sipCpp->symbolKey(), pathString.join( ',' ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};

class QgsSymbolLayerReference
Expand Down Expand Up @@ -110,6 +122,18 @@ The symbol layer's id

bool operator==( const QgsSymbolLayerReference &other ) const;

SIP_PYOBJECT __repr__();
%MethodCode

QStringList pathString;
for ( int path : sipCpp->symbolLayerId().symbolLayerIndexPath() )
{
pathString.append( QString::number( path ) );
}
QString str = QStringLiteral( "<QgsSymbolLayerReference: %1 - %2 (%3)>" ).arg( sipCpp->layerId(), sipCpp->symbolLayerId().symbolKey(), pathString.join( ',' ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};

uint qHash( const QgsSymbolLayerId &id );
Expand Down
28 changes: 28 additions & 0 deletions src/core/symbology/qgssymbollayerreference.h
Expand Up @@ -99,6 +99,20 @@ class CORE_EXPORT QgsSymbolLayerId
: mSymbolKey < other.mSymbolKey;
}

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode

QStringList pathString;
for ( int path : sipCpp->symbolLayerIndexPath() )
{
pathString.append( QString::number( path ) );
}
QString str = QStringLiteral( "<QgsSymbolLayerId: %1 (%2)>" ).arg( sipCpp->symbolKey(), pathString.join( ',' ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

private:
//! Symbol unique identifier (legend key)
QString mSymbolKey;
Expand Down Expand Up @@ -142,6 +156,20 @@ class CORE_EXPORT QgsSymbolLayerReference
mSymbolLayerId == other.mSymbolLayerId;
}

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode

QStringList pathString;
for ( int path : sipCpp->symbolLayerId().symbolLayerIndexPath() )
{
pathString.append( QString::number( path ) );
}
QString str = QStringLiteral( "<QgsSymbolLayerReference: %1 - %2 (%3)>" ).arg( sipCpp->layerId(), sipCpp->symbolLayerId().symbolKey(), pathString.join( ',' ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

private:
QString mLayerId;
QgsSymbolLayerId mSymbolLayerId;
Expand Down

0 comments on commit 5ded8b6

Please sign in to comment.