59#define QGSCLIPBOARD_STYLE_MIME "application/qgis.style"
196 QString name()
const;
204 void setName(
const QString &name );
226 bool isReadOnly()
const;
237 void setReadOnly(
bool readOnly );
283 bool addTextFormat(
const QString &name,
const QgsTextFormat &format,
bool update =
false );
295 bool addLabelSettings(
const QString &name,
const QgsPalLayerSettings &settings,
bool update =
false );
307 bool addLegendPatchShape(
const QString &name,
const QgsLegendPatchShape &shape,
bool update =
false );
327 int addTag(
const QString &tagName );
352 int addSmartgroup(
const QString &name,
const QString &op,
const QStringList &matchTag,
const QStringList &noMatchTag,
353 const QStringList &matchName,
const QStringList &noMatchName );
360 QStringList tags()
const;
372 int colorRampCount();
375 QStringList colorRampNames()
const;
378 const QgsColorRamp *colorRampRef(
const QString &name )
const;
384 int colorrampId(
const QString &name );
397 int textFormatCount()
const;
403 QStringList textFormatNames()
const;
411 int textFormatId(
const QString &name );
431 int legendPatchShapesCount()
const;
453 int symbol3DCount()
const;
461 QList< Qgis::GeometryType > symbol3DCompatibleGeometryTypes(
const QString &name )
const;
476 int labelSettingsCount()
const;
482 QStringList labelSettingsNames()
const;
490 int labelSettingsId(
const QString &name );
500 static QgsStyle *defaultStyle(
bool initialize =
true );
503 static void cleanDefaultStyle()
SIP_SKIP;
514 bool tagSymbol( StyleEntity type, const QString &symbol, const QStringList &tags );
525 bool detagSymbol( StyleEntity type, const QString &symbol, const QStringList &tags );
535 bool detagSymbol( StyleEntity type, const QString &symbol );
538 bool removeSymbol( const QString &name );
547 bool renameEntity( StyleEntity type, const QString &oldName, const QString &newName );
554 bool renameSymbol( const QString &oldName, const QString &newName );
560 const
QgsSymbol *symbolRef( const QString &name ) const;
566 QStringList symbolNames() const;
572 int symbolId( const QString &name );
578 int entityId( StyleEntity type, const QString &name );
581 int tagId( const QString &tag );
583 int smartgroupId( const QString &smartgroup );
589 QStringList allNames( StyleEntity type ) const;
597 QStringList symbolsOfFavorite( StyleEntity type ) const;
606 QStringList symbolsWithTag( StyleEntity type,
int tagid ) const;
615 bool addFavorite( StyleEntity type, const QString &name );
624 bool removeFavorite( StyleEntity type, const QString &name );
633 bool rename( StyleEntity type,
int id, const QString &newName );
643 bool remove( StyleEntity type,
int id );
651 bool removeEntityByName( StyleEntity type, const QString &name );
662 bool saveSymbol( const QString &name,
QgsSymbol *symbol,
bool favorite, const QStringList &tags );
673 bool saveColorRamp( const QString &name,
QgsColorRamp *ramp,
bool favorite, const QStringList &tags );
676 bool removeColorRamp( const QString &name );
679 bool renameColorRamp( const QString &oldName, const QString &newName );
690 bool saveTextFormat( const QString &name, const
QgsTextFormat &format,
bool favorite, const QStringList &tags );
696 bool removeTextFormat( const QString &name );
703 bool renameTextFormat( const QString &oldName, const QString &newName );
714 bool saveLabelSettings( const QString &name, const
QgsPalLayerSettings &settings,
bool favorite, const QStringList &tags );
720 bool removeLabelSettings( const QString &name );
727 bool renameLabelSettings( const QString &oldName, const QString &newName );
740 bool saveLegendPatchShape( const QString &name, const
QgsLegendPatchShape &shape,
bool favorite, const QStringList &tags );
747 bool renameLegendPatchShape( const QString &oldName, const QString &newName );
753 QStringList legendPatchShapeNames() const;
778 QList< QList< QPolygonF > > defaultPatchAsQPolygonF(
Qgis::SymbolType type, QSizeF size ) const;
822 bool renameSymbol3D(
const QString &oldName,
const QString &newName );
828 QStringList symbol3DNames()
const;
837 bool createDatabase(
const QString &filename );
846 bool createMemoryDatabase();
867 bool load(
const QString &filename );
883 Q_DECL_DEPRECATED
bool save(
const QString &filename = QString() )
SIP_DEPRECATED;
890 QString errorString()
const {
return mErrorString; }
914 void setFileName(
const QString &filename );
923 QStringList findSymbols( StyleEntity type,
const QString &qword );
932 QStringList tagsOfSymbol( StyleEntity type,
const QString &symbol );
940 bool isFavorite( StyleEntity type,
const QString &name );
950 bool symbolHasTag( StyleEntity type,
const QString &symbol,
const QString &tag );
953 QString tag(
int id )
const;
959 QStringList smartgroupNames()
const;
967 QString smartgroupOperator(
int id );
970 QStringList symbolsOfSmartgroup( StyleEntity type,
int id );
973 bool exportXml(
const QString &filename );
976 bool importXml(
const QString &filename );
986 static bool isXmlStyleFile(
const QString &path );
998 void triggerIconRebuild();
1220 bool mInitialized =
true;
1222 bool mReadOnly =
false;
1228 QMap<QString, QgsLegendPatchShape > mLegendPatchShapes;
1229 QMap<QString, QgsAbstract3DSymbol * > m3dSymbols;
1231 QHash< QgsStyle::StyleEntity, QHash< QString, QStringList > > mCachedTags;
1232 QHash< QgsStyle::StyleEntity, QHash< QString, bool > > mCachedFavorites;
1234 QString mErrorString;
1239 std::unique_ptr< QgsSymbol > mPatchMarkerSymbol;
1240 std::unique_ptr< QgsSymbol > mPatchLineSymbol;
1241 std::unique_ptr< QgsSymbol > mPatchFillSymbol;
1243 mutable QHash< int, QHash< QSizeF, QgsLegendPatchShape > > mDefaultPatchCache;
1244 mutable QHash< int, QHash< QSizeF, QList< QList< QPolygonF > > > > mDefaultPatchQPolygonFCache;
1246 QMap< QString, QDomElement > mDeferred3DsymbolElements;
1247 void handleDeferred3DSymbolCreation();
1256 void initializeDefaultStyle(
const QString &filename );
1259 bool openDatabase(
const QString &filename );
1262 bool importXml(
const QString &filename,
int sinceVersion );
1270 bool runEmptyQuery(
const QString &query );
1273 int getId(
const QString &table,
const QString &name );
1276 QString getName(
const QString &table,
int id )
const;
1286 bool updateSymbol(
StyleEntity type,
const QString &name );
1288 void clearCachedTags(
StyleEntity type,
const QString &name );
1293 bool createStyleMetadataTableIfNeeded();
1294 void upgradeIfRequired();
1299 static QString entityTableName(
StyleEntity type );
1304 static QString tagmapTableName(
StyleEntity type );
1309 static QString tagmapEntityIdFieldName(
StyleEntity type );
1312 friend class TestStyle;
1328 switch ( sipCpp->type() )
1331 sipType = sipType_QgsStyleSymbolEntity;
1335 sipType = sipType_QgsStyleColorRampEntity;
1339 sipType = sipType_QgsStyleTextFormatEntity;
1343 sipType = sipType_QgsStyleLabelSettingsEntity;
1472 : mSettings( settings )
The Qgis class provides global constants for use throughout the application.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Qgs3D is a singleton class containing various registries and other global members related to 3D class...
Abstract base class for color ramps.
Represents a patch shape for use in map legends.
Contains settings for how a map layer will be labeled.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A color ramp entity for QgsStyle databases.
QgsStyleColorRampEntity(QgsColorRamp *ramp)
Constructor for QgsStyleColorRampEntity, with the specified color ramp.
QgsColorRamp * ramp() const
Returns the entity's color ramp.
An interface for entities which can be placed in a QgsStyle database.
virtual QgsStyle::StyleEntity type() const =0
Returns the type of style entity.
virtual ~QgsStyleEntityInterface()=default
A label settings entity for QgsStyle databases.
const QgsPalLayerSettings & settings() const
Returns the entity's label settings.
QgsStyleLabelSettingsEntity(const QgsPalLayerSettings &settings)
Constructor for QgsStyleLabelSettingsEntity, with the specified label settings.
A legend patch shape entity for QgsStyle databases.
const QgsLegendPatchShape & shape() const
Returns the entity's legend patch shape.
QgsStyleLegendPatchShapeEntity(const QgsLegendPatchShape &shape)
Constructor for QgsStyleLegendPatchShapeEntity, with the specified legend patch shape.
A 3d symbol entity for QgsStyle databases.
const QgsAbstract3DSymbol * symbol() const
Returns the entity's symbol.
QgsStyleSymbol3DEntity(const QgsAbstract3DSymbol *symbol)
Constructor for QgsStyleSymbol3DEntity, with the specified symbol.
A symbol entity for QgsStyle databases.
QgsStyleSymbolEntity(QgsSymbol *symbol)
Constructor for QgsStyleSymbolEntity, with the specified symbol.
QgsSymbol * symbol() const
Returns the entity's symbol.
A text format entity for QgsStyle databases.
QgsTextFormat format() const
Returns the entity's text format.
QgsStyleTextFormatEntity(const QgsTextFormat &format)
Constructor for QgsStyleTextFormatEntity, with the specified text format.
void labelSettingsChanged(const QString &name)
Emitted whenever a label setting's definition is changed.
void entityChanged(QgsStyle::StyleEntity entity, const QString &name)
Emitted whenever an entity's definition is changed.
void labelSettingsAdded(const QString &name)
Emitted whenever label settings have been added to the style and the database has been updated as a r...
void rampAdded(const QString &name)
Emitted whenever a color ramp has been added to the style and the database has been updated as a resu...
void rebuildIconPreviews()
Emitted whenever icon previews for entities in the style must be rebuilt.
void symbolSaved(const QString &name, QgsSymbol *symbol)
Emitted every time a new symbol has been added to the database.
void aboutToBeDestroyed()
Emitted just before the style object is destroyed.
void labelSettingsRemoved(const QString &name)
Emitted whenever label settings have been removed from the style and the database has been updated as...
StyleEntity
Enum for Entities involved in a style.
@ LabelSettingsEntity
Label settings.
@ TextFormatEntity
Text formats.
@ SmartgroupEntity
Smart groups.
@ Symbol3DEntity
3D symbol entity (since QGIS 3.14)
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
void symbolRenamed(const QString &oldName, const QString &newName)
Emitted whenever a symbol has been renamed from oldName to newName.
void groupsModified()
Emitted every time a tag or smartgroup has been added, removed, or renamed.
void rampRemoved(const QString &name)
Emitted whenever a color ramp has been removed from the style and the database has been updated as a ...
void entityRenamed(QgsStyle::StyleEntity entity, const QString &oldName, const QString &newName)
Emitted whenever a entity of the specified type has been renamed from oldName to newName.
void textFormatChanged(const QString &name)
Emitted whenever a text format's definition is changed.
void textFormatRenamed(const QString &oldName, const QString &newName)
Emitted whenever a text format has been renamed from oldName to newName.
void labelSettingsRenamed(const QString &oldName, const QString &newName)
Emitted whenever label settings have been renamed from oldName to newName.
void initialized()
Emitted when the style database has been fully initialized.
QString fileName() const
Returns the current file name of the style database.
void rampRenamed(const QString &oldName, const QString &newName)
Emitted whenever a color ramp has been renamed from oldName to newName.
bool isInitialized() const
Returns true if the style is initialized and ready for use.
void textFormatAdded(const QString &name)
Emitted whenever a text format has been added to the style and the database has been updated as a res...
void rampChanged(const QString &name)
Emitted whenever a color ramp's definition is changed.
void entityTagsChanged(QgsStyle::StyleEntity entity, const QString &name, const QStringList &newTags)
Emitted whenever an entity's tags are changed.
void favoritedChanged(QgsStyle::StyleEntity entity, const QString &name, bool isFavorite)
Emitted whenever an entity is either favorited or un-favorited.
void entityRemoved(QgsStyle::StyleEntity entity, const QString &name)
Emitted whenever an entity of the specified type is removed from the style and the database has been ...
void entityAdded(QgsStyle::StyleEntity entity, const QString &name)
Emitted every time a new entity has been added to the database.
TextFormatContext
Text format context.
@ Labeling
Text format used in labeling.
void symbolRemoved(const QString &name)
Emitted whenever a symbol has been removed from the style and the database has been updated as a resu...
void symbolChanged(const QString &name)
Emitted whenever a symbol's definition is changed.
void textFormatRemoved(const QString &name)
Emitted whenever a text format has been removed from the style and the database has been updated as a...
Abstract base class for all rendered symbols.
Container for all settings relating to text rendering.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
QMap< QString, QgsSymbol * > QgsSymbolMap
QMap< QString, QgsPalLayerSettings > QgsLabelSettingsMap
Map of name to label settings.
TextFormatTable
Columns available in the text format table.
@ TextFormatFavoriteId
Text format is favorite flag.
@ TextFormatName
Text format name.
@ TextFormatId
Text format ID.
@ TextFormatXML
Text format definition (as XML)
QMap< QString, QgsTextFormat > QgsTextFormatMap
Map of name to text format.
SymbolTable
Columns available in the Symbols table.
@ SymbolFavoriteId
Symbol is favorite flag.
@ SymbolXML
Symbol definition (as XML)
TagmapTable
Columns available in the tag to symbol table.
@ TagmapSymbolId
Symbol ID.
QMap< QString, QgsColorRamp * > QgsVectorColorRampMap
TagTable
Columns available in the Tags table.
SmartgroupTable
Columns available in the smart group table.
@ SmartgroupXML
Smart group definition (as XML)
@ SmartgroupName
Smart group name.
@ SmartgroupId
Smart group ID.
QMap< int, QString > QgsSymbolGroupMap
LabelSettingsTable
Columns available in the label settings table.
@ LabelSettingsName
Label settings name.
@ LabelSettingsXML
Label settings definition (as XML)
@ LabelSettingsFavoriteId
Label settings is favorite flag.
@ LabelSettingsId
Label settings ID.
ColorrampTable
Columns available in the color ramp table.
@ ColorrampId
Color ramp ID.
@ ColorrampName
Color ramp name.
@ ColorrampFavoriteId
Color ramp is favorite flag.
@ ColorrampXML
Color ramp definition (as XML)