20 : QAbstractListModel( parent )
25 mCategoryList = qgsEnumMap<QgsMapLayer::StyleCategory>().keys();
29 mCategoryList << QgsMapLayer::StyleCategory::Symbology << QgsMapLayer::StyleCategory::Labeling << QgsMapLayer::StyleCategory::AllStyleCategories;
63 mShowAllCategories = showAll;
69 int count = mCategoryList.count();
70 if ( !mShowAllCategories )
82 if ( !index.isValid() || index.row() >=
rowCount() )
87 if ( role == Qt::UserRole )
91 if ( role == Qt::CheckStateRole )
93 return mCategories.testFlag( category ) ? Qt::Checked : Qt::Unchecked;
98 case QgsMapLayer::StyleCategory::LayerConfiguration:
101 case Qt::DisplayRole:
102 return tr(
"Layer Configuration" );
103 case Qt::ToolTipRole:
104 return tr(
"Identifiable, removable, searchable, display expression, read-only, hidden" );
105 case Qt::DecorationRole:
109 case QgsMapLayer::StyleCategory::Symbology:
112 case Qt::DisplayRole:
113 return tr(
"Symbology" );
114 case Qt::ToolTipRole:
116 case Qt::DecorationRole:
120 case QgsMapLayer::StyleCategory::Symbology3D:
123 case Qt::DisplayRole:
124 return tr(
"3D Symbology" );
125 case Qt::ToolTipRole:
127 case Qt::DecorationRole:
131 case QgsMapLayer::StyleCategory::Labeling:
134 case Qt::DisplayRole:
135 return tr(
"Labels" );
136 case Qt::ToolTipRole:
138 case Qt::DecorationRole:
142 case QgsMapLayer::StyleCategory::Fields:
145 case Qt::DisplayRole:
146 return tr(
"Fields" );
147 case Qt::ToolTipRole:
148 return tr(
"Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields" );
149 case Qt::DecorationRole:
153 case QgsMapLayer::StyleCategory::Forms:
156 case Qt::DisplayRole:
157 return tr(
"Forms" );
158 case Qt::ToolTipRole:
160 case Qt::DecorationRole:
164 case QgsMapLayer::StyleCategory::Actions:
167 case Qt::DisplayRole:
168 return tr(
"Actions" );
169 case Qt::ToolTipRole:
171 case Qt::DecorationRole:
175 case QgsMapLayer::StyleCategory::MapTips:
178 case Qt::DisplayRole:
179 return tr(
"Map Tips" );
180 case Qt::ToolTipRole:
182 case Qt::DecorationRole:
186 case QgsMapLayer::StyleCategory::Diagrams:
189 case Qt::DisplayRole:
190 return tr(
"Diagrams" );
191 case Qt::ToolTipRole:
193 case Qt::DecorationRole:
197 case QgsMapLayer::StyleCategory::AttributeTable:
200 case Qt::DisplayRole:
201 return tr(
"Attribute Table Settings" );
202 case Qt::ToolTipRole:
203 return tr(
"Choice and order of columns, conditional styling" );
204 case Qt::DecorationRole:
208 case QgsMapLayer::StyleCategory::Rendering:
211 case Qt::DisplayRole:
212 return tr(
"Rendering" );
213 case Qt::ToolTipRole:
214 return tr(
"Scale visibility, simplify method, opacity" );
215 case Qt::DecorationRole:
219 case QgsMapLayer::StyleCategory::CustomProperties:
222 case Qt::DisplayRole:
223 return tr(
"Custom Properties" );
224 case Qt::ToolTipRole:
226 case Qt::DecorationRole:
230 case QgsMapLayer::StyleCategory::GeometryOptions:
233 case Qt::DisplayRole:
234 return tr(
"Geometry Options" );
235 case Qt::ToolTipRole:
236 return tr(
"Geometry constraints and validity checks" );
237 case Qt::DecorationRole:
241 case QgsMapLayer::StyleCategory::Relations:
244 case Qt::DisplayRole:
245 return tr(
"Relations" );
246 case Qt::ToolTipRole:
247 return tr(
"Relations with other layers" );
248 case Qt::DecorationRole:
253 case QgsMapLayer::StyleCategory::Temporal:
256 case Qt::DisplayRole:
257 return tr(
"Temporal Properties" );
258 case Qt::ToolTipRole:
259 return tr(
"Temporal properties" );
260 case Qt::DecorationRole:
265 case QgsMapLayer::StyleCategory::Legend:
268 case Qt::DisplayRole:
269 return tr(
"Legend Settings" );
270 case Qt::ToolTipRole:
271 return tr(
"Legend settings" );
272 case Qt::DecorationRole:
277 case QgsMapLayer::StyleCategory::Elevation:
280 case Qt::DisplayRole:
281 return tr(
"Elevation Properties" );
282 case Qt::ToolTipRole:
283 return tr(
"Elevation properties" );
284 case Qt::DecorationRole:
289 case QgsMapLayer::StyleCategory::Notes:
292 case Qt::DisplayRole:
293 case Qt::ToolTipRole:
294 return tr(
"Notes" );
295 case Qt::DecorationRole:
300 case QgsMapLayer::StyleCategory::AllStyleCategories:
303 case Qt::DisplayRole:
304 return tr(
"All Style Categories" );
305 case Qt::ToolTipRole:
307 case Qt::DecorationRole:
318 if ( !index.isValid() || index.row() >=
rowCount() )
321 if ( role == Qt::CheckStateRole )
324 if ( value.value<Qt::CheckState>() == Qt::Checked )
326 mCategories |= category;
327 emit dataChanged( index, index );
330 else if ( value.value<Qt::CheckState>() == Qt::Unchecked )
332 mCategories &= ~category;
333 emit dataChanged( index, index );
343 return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
void setCategories(QgsMapLayer::StyleCategories categories)
Reset the model data.
int columnCount(const QModelIndex &=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &) const override
QVariant data(const QModelIndex &index, int role) const override
QgsMapLayerStyleCategoriesModel(QgsMapLayerType type, QObject *parent=nullptr)
Constructor for QgsMapLayerStyleCategoriesModel, for the specified layer type.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QgsMapLayer::StyleCategories categories() const
Returns the categories as defined in the model.
void setShowAllCategories(bool showAll)
Defines if the model should list the AllStyleCategories entry.
int rowCount(const QModelIndex &=QModelIndex()) const override
StyleCategory
Categories of style to distinguish appropriate sections for import/export.
QgsMapLayerType
Types of layers that can be added to a map.
@ PointCloudLayer
Added in 3.18.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.