mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
More boring duplicate code cleanup
This commit is contained in:
parent
0e8be09fd0
commit
a08af65b42
@ -753,6 +753,36 @@ Emitted whenever an ``entity``'s tags are changed.
|
||||
Emitted whenever an ``entity`` is either favorited or un-favorited.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
void entityAdded( QgsStyle::StyleEntity entity, const QString &name );
|
||||
%Docstring
|
||||
Emitted every time a new entity has been added to the database.
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void entityRemoved( QgsStyle::StyleEntity entity, const QString &name );
|
||||
%Docstring
|
||||
Emitted whenever an entity of the specified type is removed from the style and the database
|
||||
has been updated as a result.
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void entityRenamed( QgsStyle::StyleEntity entity, const QString &oldName, const QString &newName );
|
||||
%Docstring
|
||||
Emitted whenever a entity of the specified type has been renamed from ``oldName`` to ``newName``
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void entityChanged( QgsStyle::StyleEntity entity, const QString &name );
|
||||
%Docstring
|
||||
Emitted whenever an entity's definition is changed. This does not include
|
||||
name or tag changes.
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void symbolRemoved( const QString &name );
|
||||
|
@ -168,6 +168,7 @@ bool QgsStyle::saveSymbol( const QString &name, QgsSymbol *symbol, bool favorite
|
||||
tagSymbol( SymbolEntity, name, tags );
|
||||
|
||||
emit symbolSaved( name, symbol );
|
||||
emit entityAdded( SymbolEntity, name );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -201,6 +202,7 @@ bool QgsStyle::removeSymbol( const QString &name )
|
||||
mCachedTags[ SymbolEntity ].remove( name );
|
||||
mCachedFavorites[ SymbolEntity ].remove( name );
|
||||
emit symbolRemoved( name );
|
||||
emit entityRemoved( SymbolEntity, name );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -345,6 +347,7 @@ bool QgsStyle::saveColorRamp( const QString &name, QgsColorRamp *ramp, bool favo
|
||||
tagSymbol( ColorrampEntity, name, tags );
|
||||
|
||||
emit rampAdded( name );
|
||||
emit entityAdded( ColorrampEntity, name );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -366,6 +369,7 @@ bool QgsStyle::removeColorRamp( const QString &name )
|
||||
mCachedFavorites[ ColorrampEntity ].remove( name );
|
||||
|
||||
emit rampRemoved( name );
|
||||
emit entityRemoved( ColorrampEntity, name );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -689,7 +693,10 @@ bool QgsStyle::renameSymbol( const QString &oldName, const QString &newName )
|
||||
|
||||
const bool result = rename( SymbolEntity, symbolid, newName );
|
||||
if ( result )
|
||||
{
|
||||
emit symbolRenamed( oldName, newName );
|
||||
emit entityRenamed( SymbolEntity, oldName, newName );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -721,7 +728,10 @@ bool QgsStyle::renameColorRamp( const QString &oldName, const QString &newName )
|
||||
}
|
||||
const bool result = rename( ColorrampEntity, rampid, newName );
|
||||
if ( result )
|
||||
{
|
||||
emit rampRenamed( oldName, newName );
|
||||
emit entityRenamed( ColorrampEntity, oldName, newName );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -755,6 +765,7 @@ bool QgsStyle::saveTextFormat( const QString &name, const QgsTextFormat &format,
|
||||
tagSymbol( TextFormatEntity, name, tags );
|
||||
|
||||
emit textFormatAdded( name );
|
||||
emit entityAdded( TextFormatEntity, name );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -777,6 +788,7 @@ bool QgsStyle::removeTextFormat( const QString &name )
|
||||
mCachedFavorites[ TextFormatEntity ].remove( name );
|
||||
|
||||
emit textFormatRemoved( name );
|
||||
emit entityRemoved( TextFormatEntity, name );
|
||||
|
||||
return true;
|
||||
|
||||
@ -809,7 +821,10 @@ bool QgsStyle::renameTextFormat( const QString &oldName, const QString &newName
|
||||
}
|
||||
const bool result = rename( TextFormatEntity, textFormatId, newName );
|
||||
if ( result )
|
||||
{
|
||||
emit textFormatRenamed( oldName, newName );
|
||||
emit entityRenamed( TextFormatEntity, oldName, newName );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -843,6 +858,7 @@ bool QgsStyle::saveLabelSettings( const QString &name, const QgsPalLayerSettings
|
||||
tagSymbol( LabelSettingsEntity, name, tags );
|
||||
|
||||
emit labelSettingsAdded( name );
|
||||
emit entityAdded( LabelSettingsEntity, name );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -865,6 +881,7 @@ bool QgsStyle::removeLabelSettings( const QString &name )
|
||||
mCachedFavorites[ LabelSettingsEntity ].remove( name );
|
||||
|
||||
emit labelSettingsRemoved( name );
|
||||
emit entityRemoved( LabelSettingsEntity, name );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -896,7 +913,10 @@ bool QgsStyle::renameLabelSettings( const QString &oldName, const QString &newNa
|
||||
}
|
||||
const bool result = rename( LabelSettingsEntity, labelSettingsId, newName );
|
||||
if ( result )
|
||||
{
|
||||
emit labelSettingsRenamed( oldName, newName );
|
||||
emit entityRenamed( LabelSettingsEntity, oldName, newName );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -2778,6 +2798,7 @@ bool QgsStyle::updateSymbol( StyleEntity type, const QString &name )
|
||||
case SmartgroupEntity:
|
||||
break;
|
||||
}
|
||||
emit entityChanged( type, name );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -745,6 +745,35 @@ class CORE_EXPORT QgsStyle : public QObject
|
||||
*/
|
||||
void favoritedChanged( QgsStyle::StyleEntity entity, const QString &name, bool isFavorite );
|
||||
|
||||
/**
|
||||
* Emitted every time a new entity has been added to the database.
|
||||
*
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void entityAdded( QgsStyle::StyleEntity entity, const QString &name );
|
||||
|
||||
/**
|
||||
* Emitted whenever an entity of the specified type is removed from the style and the database
|
||||
* has been updated as a result.
|
||||
*
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void entityRemoved( QgsStyle::StyleEntity entity, const QString &name );
|
||||
|
||||
/**
|
||||
* Emitted whenever a entity of the specified type has been renamed from \a oldName to \a newName
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void entityRenamed( QgsStyle::StyleEntity entity, const QString &oldName, const QString &newName );
|
||||
|
||||
/**
|
||||
* Emitted whenever an entity's definition is changed. This does not include
|
||||
* name or tag changes.
|
||||
*
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void entityChanged( QgsStyle::StyleEntity entity, const QString &name );
|
||||
|
||||
/**
|
||||
* Emitted whenever a symbol has been removed from the style and the database
|
||||
* has been updated as a result.
|
||||
|
@ -38,26 +38,10 @@ QgsStyleModel::QgsStyleModel( QgsStyle *style, QObject *parent )
|
||||
mEntityNames.insert( entity, mStyle->allNames( entity ) );
|
||||
}
|
||||
|
||||
connect( mStyle, &QgsStyle::symbolSaved, this, [ = ]( const QString & name ) { onEntityAdded( QgsStyle::SymbolEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::symbolRemoved, this, [ = ]( const QString & name ) { onEntityRemoved( QgsStyle::SymbolEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::symbolRenamed, this, [ = ]( const QString & oldName, const QString & newName ) { onEntityRename( QgsStyle::SymbolEntity, oldName, newName ); } );
|
||||
connect( mStyle, &QgsStyle::symbolChanged, this, [ = ]( const QString & name ) { onEntityChanged( QgsStyle::SymbolEntity, name ); } );
|
||||
|
||||
connect( mStyle, &QgsStyle::rampAdded, this, [ = ]( const QString & name ) { onEntityAdded( QgsStyle::ColorrampEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::rampChanged, this, [ = ]( const QString & name ) { onEntityChanged( QgsStyle::ColorrampEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::rampRemoved, this, [ = ]( const QString & name ) { onEntityRemoved( QgsStyle::ColorrampEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::rampRenamed, this, [ = ]( const QString & oldName, const QString & newName ) { onEntityRename( QgsStyle::ColorrampEntity, oldName, newName ); } );
|
||||
|
||||
connect( mStyle, &QgsStyle::textFormatAdded, this, [ = ]( const QString & name ) { onEntityAdded( QgsStyle::TextFormatEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::textFormatChanged, this, [ = ]( const QString & name ) { onEntityChanged( QgsStyle::TextFormatEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::textFormatRemoved, this, [ = ]( const QString & name ) { onEntityRemoved( QgsStyle::TextFormatEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::textFormatRenamed, this, [ = ]( const QString & oldName, const QString & newName ) { onEntityRename( QgsStyle::TextFormatEntity, oldName, newName ); } );
|
||||
|
||||
connect( mStyle, &QgsStyle::labelSettingsAdded, this, [ = ]( const QString & name ) { onEntityAdded( QgsStyle::LabelSettingsEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::labelSettingsChanged, this, [ = ]( const QString & name ) { onEntityChanged( QgsStyle::LabelSettingsEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::labelSettingsRemoved, this, [ = ]( const QString & name ) { onEntityRemoved( QgsStyle::LabelSettingsEntity, name ); } );
|
||||
connect( mStyle, &QgsStyle::labelSettingsRenamed, this, [ = ]( const QString & oldName, const QString & newName ) { onEntityRename( QgsStyle::LabelSettingsEntity, oldName, newName ); } );
|
||||
|
||||
connect( mStyle, &QgsStyle::entityAdded, this, &QgsStyleModel::onEntityAdded );
|
||||
connect( mStyle, &QgsStyle::entityRemoved, this, &QgsStyleModel::onEntityRemoved );
|
||||
connect( mStyle, &QgsStyle::entityRenamed, this, &QgsStyleModel::onEntityRename );
|
||||
connect( mStyle, &QgsStyle::entityChanged, this, &QgsStyleModel::onEntityChanged );
|
||||
connect( mStyle, &QgsStyle::entityTagsChanged, this, &QgsStyleModel::onTagsChanged );
|
||||
|
||||
// when a remote svg or image has been fetched, update the model's decorations.
|
||||
|
Loading…
x
Reference in New Issue
Block a user