23#include "moc_qgscombinedstylemodel.cpp"
26 : QConcatenateTablesProxyModel( parent )
31 return QgsStyleModel::headerDataStatic( section, orientation, role );
36 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() },
68 addSourceModel( titleModel );
69 mTitleModels.insert( style, titleModel );
73 for ( QSize size : std::as_const( mAdditionalSizes ) )
78 for (
auto it = mTargetScreenProperties.constBegin(); it != mTargetScreenProperties.constEnd(); ++it )
83 addSourceModel( styleModel );
84 mOwnedStyleModels.insert( style, styleModel );
91 removeSourceModel( model );
92 mTitleModels.remove( style );
96 if (
QgsStyleModel *model = mOwnedStyleModels.value( style ) )
98 removeSourceModel( model );
99 mOwnedStyleModels.remove( style );
102 mStyles.removeAll( style );
109 if ( !defaultStyle || !styleModel )
112 mStyles.append( defaultStyle );
117 { Qt::DisplayRole, defaultStyle->
name() },
118 { Qt::ToolTipRole, defaultStyle->
name() },
128 addSourceModel( titleModel );
129 mTitleModels.insert( defaultStyle, titleModel );
131 for ( QSize size : std::as_const( mAdditionalSizes ) )
136 for (
auto it = mTargetScreenProperties.constBegin(); it != mTargetScreenProperties.constEnd(); ++it )
141 addSourceModel( styleModel );
151 if ( !mAdditionalSizes.contains( size ) )
152 mAdditionalSizes.append( size );
154 for (
auto it = mOwnedStyleModels.constBegin(); it != mOwnedStyleModels.constEnd(); ++it )
156 it.value()->addDesiredIconSize( size );
167 if ( !mTargetScreenProperties.contains( properties ) )
168 mTargetScreenProperties.insert( properties );
170 for (
auto it = mOwnedStyleModels.constBegin(); it != mOwnedStyleModels.constEnd(); ++it )
172 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.