23 : QConcatenateTablesProxyModel( parent )
30 return QgsStyleModel::headerDataStatic( section, orientation, role );
35 connect( style, &QgsStyle::destroyed,
this, [
this, style]()
39 removeSourceModel( model );
40 mTitleModels.remove( style );
44 if (
QgsStyleModel *model = mOwnedStyleModels.value( style ) )
46 removeSourceModel( model );
47 mOwnedStyleModels.remove( style );
50 mStyles.removeAll( style );
53 mStyles.append( style );
58 { Qt::DisplayRole, style->
name() },
59 { Qt::ToolTipRole, style->
name() },
69 addSourceModel( titleModel );
70 mTitleModels.insert( style, titleModel );
74 for ( QSize size : std::as_const( mAdditionalSizes ) )
79 addSourceModel( styleModel );
80 mOwnedStyleModels.insert( style, styleModel );
87 removeSourceModel( model );
88 mTitleModels.remove( style );
92 if (
QgsStyleModel *model = mOwnedStyleModels.value( style ) )
94 removeSourceModel( model );
95 mOwnedStyleModels.remove( style );
98 mStyles.removeAll( style );
105 if ( !defaultStyle || !styleModel )
108 mStyles.append( defaultStyle );
113 { Qt::DisplayRole, defaultStyle->
name() },
114 { Qt::ToolTipRole, defaultStyle->
name() },
125 addSourceModel( titleModel );
126 mTitleModels.insert( defaultStyle, titleModel );
128 for ( QSize size : std::as_const( mAdditionalSizes ) )
133 addSourceModel( styleModel );
143 if ( !mAdditionalSizes.contains( size ) )
144 mAdditionalSizes.append( size );
146 for (
auto it = mOwnedStyleModels.constBegin(); it != mOwnedStyleModels.constEnd(); ++it )
148 it.value()->addDesiredIconSize( size );
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
QList< QgsStyle * > styles() const
Returns a list of all styles shown in the model.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QgsCombinedStyleModel(QObject *parent=nullptr)
Constructor for QgsCombinedStyleModel with the specified parent object.
void removeStyle(QgsStyle *style)
Removes a style from the model.
void addStyle(QgsStyle *style)
Adds a style to the model.
void addDefaultStyle()
Adds the default style (QgsStyle::defaultStyle()) to the model.
void addDesiredIconSize(QSize size)
Adds an additional icon size to generate for Qt::DecorationRole data.
A QgsSingleItemModel subclass which contains a single read-only item.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
@ StyleName
Name of associated QgsStyle (QgsStyle::name()) (since QGIS 3.26)
@ StyleFileName
File name of associated QgsStyle (QgsStyle::fileName()) (since QGIS 3.26)
@ IsTitleRole
True if the index corresponds to a title item (since QGIS 3.26)
void addDesiredIconSize(QSize size)
Adds an additional icon size to generate for Qt::DecorationRole data.
static QgsStyle * defaultStyle()
Returns default application-wide style.
QString fileName() const
Returns the current file name of the style database.
QString name() const
Returns the name of the style.