19 #include "qgis_core.h"
59 #define QGSCLIPBOARD_STYLE_MIME "application/qgis.style"
196 QString name()
const;
204 void setName(
const QString &name );
215 bool isReadOnly()
const;
226 void setReadOnly(
bool readOnly );
272 bool addTextFormat(
const QString &name,
const QgsTextFormat &format,
bool update =
false );
284 bool addLabelSettings(
const QString &name,
const QgsPalLayerSettings &settings,
bool update =
false );
296 bool addLegendPatchShape(
const QString &name,
const QgsLegendPatchShape &shape,
bool update =
false );
316 int addTag(
const QString &tagName );
341 int addSmartgroup(
const QString &name,
const QString &op,
const QStringList &matchTag,
const QStringList &noMatchTag,
342 const QStringList &matchName,
const QStringList &noMatchName );
350 QStringList tags()
const;
362 int colorRampCount();
365 QStringList colorRampNames()
const;
368 const QgsColorRamp *colorRampRef(
const QString &name )
const;
374 int colorrampId(
const QString &name );
387 int textFormatCount()
const;
393 QStringList textFormatNames()
const;
401 int textFormatId(
const QString &name );
421 int legendPatchShapesCount()
const;
443 int symbol3DCount()
const;
451 QList< QgsWkbTypes::GeometryType > symbol3DCompatibleGeometryTypes(
const QString &name )
const;
466 int labelSettingsCount()
const;
472 QStringList labelSettingsNames()
const;
480 int labelSettingsId(
const QString &name );
486 static void cleanDefaultStyle()
SIP_SKIP;
497 bool tagSymbol( StyleEntity type, const QString &symbol, const QStringList &tags );
508 bool detagSymbol( StyleEntity type, const QString &symbol, const QStringList &tags );
518 bool detagSymbol( StyleEntity type, const QString &symbol );
521 bool removeSymbol( const QString &name );
530 bool renameEntity( StyleEntity type, const QString &oldName, const QString &newName );
537 bool renameSymbol( const QString &oldName, const QString &newName );
543 const
QgsSymbol *symbolRef( const QString &name ) const;
549 QStringList symbolNames() const;
555 int symbolId( const QString &name );
561 int entityId( StyleEntity type, const QString &name );
564 int tagId( const QString &tag );
566 int smartgroupId( const QString &smartgroup );
572 QStringList allNames( StyleEntity type ) const;
580 QStringList symbolsOfFavorite( StyleEntity type ) const;
589 QStringList symbolsWithTag( StyleEntity type,
int tagid ) const;
598 bool addFavorite( StyleEntity type, const QString &name );
607 bool removeFavorite( StyleEntity type, const QString &name );
616 bool rename( StyleEntity type,
int id, const QString &newName );
626 bool remove( StyleEntity type,
int id );
634 bool removeEntityByName( StyleEntity type, const QString &name );
645 bool saveSymbol( const QString &name,
QgsSymbol *symbol,
bool favorite, const QStringList &tags );
656 bool saveColorRamp( const QString &name,
QgsColorRamp *ramp,
bool favorite, const QStringList &tags );
659 bool removeColorRamp( const QString &name );
662 bool renameColorRamp( const QString &oldName, const QString &newName );
673 bool saveTextFormat( const QString &name, const
QgsTextFormat &format,
bool favorite, const QStringList &tags );
679 bool removeTextFormat( const QString &name );
686 bool renameTextFormat( const QString &oldName, const QString &newName );
697 bool saveLabelSettings( const QString &name, const
QgsPalLayerSettings &settings,
bool favorite, const QStringList &tags );
703 bool removeLabelSettings( const QString &name );
710 bool renameLabelSettings( const QString &oldName, const QString &newName );
723 bool saveLegendPatchShape( const QString &name, const
QgsLegendPatchShape &shape,
bool favorite, const QStringList &tags );
730 bool renameLegendPatchShape( const QString &oldName, const QString &newName );
736 QStringList legendPatchShapeNames() const;
761 QList< QList< QPolygonF > > defaultPatchAsQPolygonF(
Qgis::SymbolType type, QSizeF size ) const;
805 bool renameSymbol3D(
const QString &oldName,
const QString &newName );
811 QStringList symbol3DNames()
const;
821 bool createDatabase(
const QString &filename );
831 bool createMemoryDatabase();
854 bool load(
const QString &filename );
870 Q_DECL_DEPRECATED
bool save(
const QString &filename = QString() )
SIP_DEPRECATED;
877 QString errorString()
const {
return mErrorString; }
901 void setFileName(
const QString &filename );
910 QStringList findSymbols( StyleEntity type,
const QString &qword );
919 QStringList tagsOfSymbol( StyleEntity type,
const QString &symbol );
927 bool isFavorite( StyleEntity type,
const QString &name );
937 bool symbolHasTag( StyleEntity type,
const QString &symbol,
const QString &tag );
940 QString tag(
int id )
const;
946 QStringList smartgroupNames()
const;
954 QString smartgroupOperator(
int id );
957 QStringList symbolsOfSmartgroup( StyleEntity type,
int id );
960 bool exportXml(
const QString &filename );
963 bool importXml(
const QString &filename );
973 static bool isXmlStyleFile(
const QString &path );
985 void triggerIconRebuild();
999 void aboutToBeDestroyed();
1009 void symbolSaved(
const QString &name,
QgsSymbol *symbol );
1019 void symbolChanged(
const QString &name );
1022 void groupsModified();
1029 void entityTagsChanged(
QgsStyle::StyleEntity entity,
const QString &name,
const QStringList &newTags );
1074 void symbolRemoved(
const QString &name );
1081 void symbolRenamed(
const QString &oldName,
const QString &newName );
1088 void rampRenamed(
const QString &oldName,
const QString &newName );
1097 void rampAdded(
const QString &name );
1106 void rampRemoved(
const QString &name );
1116 void rampChanged(
const QString &name );
1124 void textFormatRenamed(
const QString &oldName,
const QString &newName );
1133 void textFormatAdded(
const QString &name );
1142 void textFormatRemoved(
const QString &name );
1152 void textFormatChanged(
const QString &name );
1159 void labelSettingsRenamed(
const QString &oldName,
const QString &newName );
1168 void labelSettingsAdded(
const QString &name );
1177 void labelSettingsRemoved(
const QString &name );
1187 void labelSettingsChanged(
const QString &name );
1194 void rebuildIconPreviews();
1199 bool mReadOnly =
false;
1205 QMap<QString, QgsLegendPatchShape > mLegendPatchShapes;
1206 QMap<QString, QgsAbstract3DSymbol * > m3dSymbols;
1208 QHash< QgsStyle::StyleEntity, QHash< QString, QStringList > > mCachedTags;
1209 QHash< QgsStyle::StyleEntity, QHash< QString, bool > > mCachedFavorites;
1211 QString mErrorString;
1216 std::unique_ptr< QgsSymbol > mPatchMarkerSymbol;
1217 std::unique_ptr< QgsSymbol > mPatchLineSymbol;
1218 std::unique_ptr< QgsSymbol > mPatchFillSymbol;
1220 mutable QHash< int, QHash< QSizeF, QgsLegendPatchShape > > mDefaultPatchCache;
1221 mutable QHash< int, QHash< QSizeF, QList< QList< QPolygonF > > > > mDefaultPatchQPolygonFCache;
1223 QMap< QString, QDomElement > mDeferred3DsymbolElements;
1224 void handleDeferred3DSymbolCreation();
1229 bool openDatabase(
const QString &filename );
1232 bool importXml(
const QString &filename,
int sinceVersion );
1240 bool runEmptyQuery(
const QString &query );
1243 int getId(
const QString &table,
const QString &name );
1246 QString getName(
const QString &table,
int id )
const;
1256 bool updateSymbol( StyleEntity type,
const QString &name );
1258 void clearCachedTags( StyleEntity type,
const QString &name );
1263 bool createStyleMetadataTableIfNeeded();
1264 void upgradeIfRequired();
1269 static QString entityTableName( StyleEntity type );
1274 static QString tagmapTableName( StyleEntity type );
1279 static QString tagmapEntityIdFieldName( StyleEntity type );
1282 friend class TestStyle;
1298 switch ( sipCpp->type() )
1301 sipType = sipType_QgsStyleSymbolEntity;
1305 sipType = sipType_QgsStyleColorRampEntity;
1309 sipType = sipType_QgsStyleTextFormatEntity;
1313 sipType = sipType_QgsStyleLabelSettingsEntity;
1442 : mSettings( settings )