mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Add name to QgsStyle
This commit is contained in:
parent
a11b4ebf83
commit
6c73cfcd45
@ -99,6 +99,24 @@ Constructor for QgsStyle.
|
||||
Symbol3DEntity,
|
||||
};
|
||||
|
||||
QString name() const;
|
||||
%Docstring
|
||||
Returns the name of the style.
|
||||
|
||||
.. seealso:: :py:func:`setName`
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
void setName( const QString &name );
|
||||
%Docstring
|
||||
Sets the ``name`` of the style.
|
||||
|
||||
.. seealso:: :py:func:`name`
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
bool addEntity( const QString &name, const QgsStyleEntityInterface *entity, bool update = false );
|
||||
%Docstring
|
||||
Adds an ``entity`` to the style, with the specified ``name``. Ownership is not transferred.
|
||||
|
@ -96,6 +96,16 @@ QgsStyle::~QgsStyle()
|
||||
clear();
|
||||
}
|
||||
|
||||
void QgsStyle::setName( const QString &name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
QString QgsStyle::name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
bool QgsStyle::addEntity( const QString &name, const QgsStyleEntityInterface *entity, bool update )
|
||||
{
|
||||
switch ( entity->type() )
|
||||
@ -158,6 +168,7 @@ QgsStyle *QgsStyle::defaultStyle() // static
|
||||
sDefaultStyle->upgradeIfRequired();
|
||||
}
|
||||
}
|
||||
sDefaultStyle->setName( QObject::tr( "Default" ) );
|
||||
}
|
||||
return sDefaultStyle;
|
||||
}
|
||||
|
@ -187,6 +187,22 @@ class CORE_EXPORT QgsStyle : public QObject
|
||||
Symbol3DEntity, //!< 3D symbol entity (since QGIS 3.14)
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the name of the style.
|
||||
*
|
||||
* \see setName()
|
||||
* \since QGIS 3.26
|
||||
*/
|
||||
QString name() const;
|
||||
|
||||
/**
|
||||
* Sets the \a name of the style.
|
||||
*
|
||||
* \see name()
|
||||
* \since QGIS 3.26
|
||||
*/
|
||||
void setName( const QString &name );
|
||||
|
||||
/**
|
||||
* Adds an \a entity to the style, with the specified \a name. Ownership is not transferred.
|
||||
*
|
||||
@ -1078,6 +1094,8 @@ class CORE_EXPORT QgsStyle : public QObject
|
||||
|
||||
private:
|
||||
|
||||
QString mName;
|
||||
|
||||
QgsSymbolMap mSymbols;
|
||||
QgsVectorColorRampMap mColorRamps;
|
||||
QgsTextFormatMap mTextFormats;
|
||||
|
@ -104,6 +104,7 @@ class TestStyle : public QObject
|
||||
void cleanup() {}// will be called after every testfunction.
|
||||
// void initStyles();
|
||||
|
||||
void testProperties();
|
||||
void testCreateSymbols();
|
||||
void testCreateColorRamps();
|
||||
void testCreateTextFormats();
|
||||
@ -195,6 +196,13 @@ void TestStyle::cleanupTestCase()
|
||||
}
|
||||
}
|
||||
|
||||
void TestStyle::testProperties()
|
||||
{
|
||||
QgsStyle s;
|
||||
s.setName( QStringLiteral( "my name" ) );
|
||||
QCOMPARE( s.name(), QStringLiteral( "my name" ) );
|
||||
}
|
||||
|
||||
void TestStyle::testCreateSymbols()
|
||||
{
|
||||
// add some symbols to favorites
|
||||
|
Loading…
x
Reference in New Issue
Block a user