23#include "moc_qgscombinedstylemodel.cpp"
26 : QConcatenateTablesProxyModel( parent )
33 return QgsStyleModel::headerDataStatic( section, orientation, role );
38 connect( style, &QgsStyle::destroyed,
this, [
this, style]()
42 removeSourceModel( model );
43 mTitleModels.remove( style );
47 if (
QgsStyleModel *model = mOwnedStyleModels.value( style ) )
49 removeSourceModel( model );
50 mOwnedStyleModels.remove( style );
53 mStyles.removeAll( style );
56 mStyles.append( style );
61 { Qt::DisplayRole, style->
name() },
62 { Qt::ToolTipRole, style->
name() },
72 addSourceModel( titleModel );
73 mTitleModels.insert( style, titleModel );
77 for ( QSize size : std::as_const( mAdditionalSizes ) )
82 for (
auto it = mTargetScreenProperties.constBegin(); it != mTargetScreenProperties.constEnd(); ++it )
87 addSourceModel( styleModel );
88 mOwnedStyleModels.insert( style, styleModel );
95 removeSourceModel( model );
96 mTitleModels.remove( style );
100 if (
QgsStyleModel *model = mOwnedStyleModels.value( style ) )
102 removeSourceModel( model );
103 mOwnedStyleModels.remove( style );
106 mStyles.removeAll( style );
113 if ( !defaultStyle || !styleModel )
116 mStyles.append( defaultStyle );
121 { Qt::DisplayRole, defaultStyle->
name() },
122 { Qt::ToolTipRole, defaultStyle->
name() },
133 addSourceModel( titleModel );
134 mTitleModels.insert( defaultStyle, titleModel );
136 for ( QSize size : std::as_const( mAdditionalSizes ) )
141 for (
auto it = mTargetScreenProperties.constBegin(); it != mTargetScreenProperties.constEnd(); ++it )
146 addSourceModel( styleModel );
156 if ( !mAdditionalSizes.contains( size ) )
157 mAdditionalSizes.append( size );
159 for (
auto it = mOwnedStyleModels.constBegin(); it != mOwnedStyleModels.constEnd(); ++it )
161 it.value()->addDesiredIconSize( size );
172 if ( !mTargetScreenProperties.contains( properties ) )
173 mTargetScreenProperties.insert( properties );
175 for (
auto it = mOwnedStyleModels.constBegin(); it != mOwnedStyleModels.constEnd(); ++it )
177 it.value()->addTargetScreenProperties( properties );
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
void addTargetScreenProperties(const QgsScreenProperties &properties)
Adds additional target screen properties to use when generating icons for Qt::DecorationRole data.
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.
Stores properties relating to a screen.
A QAbstractItemModel subclass which contains a single read-only item.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
@ IsTitle
True if the index corresponds to a title item.
@ StyleFileName
File name of associated QgsStyle (QgsStyle::fileName()).
@ StyleName
Name of associated QgsStyle (QgsStyle::name()).
void addTargetScreenProperties(const QgsScreenProperties &properties)
Adds additional target screen properties to use when generating icons for Qt::DecorationRole data.
void addDesiredIconSize(QSize size)
Adds an additional icon size to generate for Qt::DecorationRole data.
A database of saved style entities, including symbols, color ramps, text formats and others.
QString fileName() const
Returns the current file name of the style database.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
QString name() const
Returns the name of the style.