20 : QAbstractListModel( parent )
25 mCategoryList = qgsEnumList<QgsMapLayer::StyleCategory>();
29 mCategoryList << QgsMapLayer::StyleCategory::Symbology << QgsMapLayer::StyleCategory::Labeling << QgsMapLayer::StyleCategory::AllStyleCategories;
33 mCategoryList << QgsMapLayer::StyleCategory::Symbology << QgsMapLayer::StyleCategory::AllStyleCategories;
47 if ( idxAllStyleCategories > 0 )
49 mCategoryList.move( idxAllStyleCategories, 0 );
71 mShowAllCategories = showAll;
77 int count = mCategoryList.count();
78 if ( count > 0 && !mShowAllCategories )
90 if ( !index.isValid() || index.row() >=
rowCount() )
95 if ( role == Qt::UserRole )
99 if ( role == Qt::CheckStateRole )
101 return mCategories.testFlag( category ) ? Qt::Checked : Qt::Unchecked;
106 case QgsMapLayer::StyleCategory::LayerConfiguration:
109 case Qt::DisplayRole:
110 return tr(
"Layer Configuration" );
111 case Qt::ToolTipRole:
112 return tr(
"Identifiable, removable, searchable, display expression, read-only, hidden" );
113 case Qt::DecorationRole:
117 case QgsMapLayer::StyleCategory::Symbology:
120 case Qt::DisplayRole:
121 case Qt::ToolTipRole:
122 return tr(
"Symbology" );
123 case Qt::DecorationRole:
127 case QgsMapLayer::StyleCategory::Symbology3D:
130 case Qt::DisplayRole:
131 return tr(
"3D Symbology" );
132 case Qt::ToolTipRole:
133 return tr(
"3D symbology" );
134 case Qt::DecorationRole:
138 case QgsMapLayer::StyleCategory::Labeling:
141 case Qt::DisplayRole:
142 case Qt::ToolTipRole:
143 return tr(
"Labels" );
144 case Qt::DecorationRole:
148 case QgsMapLayer::StyleCategory::Fields:
151 case Qt::DisplayRole:
152 return tr(
"Fields" );
153 case Qt::ToolTipRole:
154 return tr(
"Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields" );
155 case Qt::DecorationRole:
159 case QgsMapLayer::StyleCategory::Forms:
162 case Qt::DisplayRole:
163 return tr(
"Attribute Form" );
164 case Qt::ToolTipRole:
165 return tr(
"Attribute form settings, widget configuration" );
166 case Qt::DecorationRole:
170 case QgsMapLayer::StyleCategory::Actions:
173 case Qt::DisplayRole:
174 return tr(
"Actions" );
175 case Qt::ToolTipRole:
176 return tr(
"Map layer actions" );
177 case Qt::DecorationRole:
181 case QgsMapLayer::StyleCategory::MapTips:
184 case Qt::DisplayRole:
185 return tr(
"Map Tips" );
186 case Qt::ToolTipRole:
187 return tr(
"Map tips" );
188 case Qt::DecorationRole:
192 case QgsMapLayer::StyleCategory::Diagrams:
195 case Qt::DisplayRole:
196 case Qt::ToolTipRole:
197 return tr(
"Diagrams" );
198 case Qt::DecorationRole:
202 case QgsMapLayer::StyleCategory::AttributeTable:
205 case Qt::DisplayRole:
206 return tr(
"Attribute Table Configuration" );
207 case Qt::ToolTipRole:
208 return tr(
"Choice and order of columns, conditional styling" );
209 case Qt::DecorationRole:
213 case QgsMapLayer::StyleCategory::Rendering:
216 case Qt::DisplayRole:
217 return tr(
"Rendering" );
218 case Qt::ToolTipRole:
219 return tr(
"Scale visibility, simplify method, opacity" );
220 case Qt::DecorationRole:
224 case QgsMapLayer::StyleCategory::CustomProperties:
227 case Qt::DisplayRole:
228 return tr(
"Custom Properties" );
229 case Qt::ToolTipRole:
230 return tr(
"Variables, custom properties (often used by plugins and custom python code)" );
231 case Qt::DecorationRole:
235 case QgsMapLayer::StyleCategory::GeometryOptions:
238 case Qt::DisplayRole:
239 return tr(
"Geometry Options" );
240 case Qt::ToolTipRole:
241 return tr(
"Geometry constraints and validity checks" );
242 case Qt::DecorationRole:
246 case QgsMapLayer::StyleCategory::Relations:
249 case Qt::DisplayRole:
250 return tr(
"Relations" );
251 case Qt::ToolTipRole:
252 return tr(
"Relations with other layers" );
253 case Qt::DecorationRole:
258 case QgsMapLayer::StyleCategory::Temporal:
261 case Qt::DisplayRole:
262 return tr(
"Temporal Properties" );
263 case Qt::ToolTipRole:
264 return tr(
"Temporal properties" );
265 case Qt::DecorationRole:
270 case QgsMapLayer::StyleCategory::Legend:
273 case Qt::DisplayRole:
274 return tr(
"Legend Settings" );
275 case Qt::ToolTipRole:
276 return tr(
"Legend settings" );
277 case Qt::DecorationRole:
282 case QgsMapLayer::StyleCategory::Elevation:
285 case Qt::DisplayRole:
286 return tr(
"Elevation Properties" );
287 case Qt::ToolTipRole:
288 return tr(
"Elevation properties" );
289 case Qt::DecorationRole:
294 case QgsMapLayer::StyleCategory::Notes:
297 case Qt::DisplayRole:
298 case Qt::ToolTipRole:
299 return tr(
"Notes" );
300 case Qt::DecorationRole:
305 case QgsMapLayer::StyleCategory::AllStyleCategories:
308 case Qt::DisplayRole:
309 return tr(
"All Style Categories" );
310 case Qt::ToolTipRole:
312 case Qt::DecorationRole:
323 if ( !index.isValid() || index.row() >=
rowCount() )
326 if ( role == Qt::CheckStateRole )
329 if ( value.value<Qt::CheckState>() == Qt::Checked )
331 mCategories |= category;
332 emit dataChanged( index, index );
335 else if ( value.value<Qt::CheckState>() == Qt::Unchecked )
337 mCategories &= ~category;
338 emit dataChanged( index, index );
348 return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
LayerType
Types of layers that can be added to a map.
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
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
QgsMapLayerStyleCategoriesModel(Qgis::LayerType type, QObject *parent=nullptr)
Constructor for QgsMapLayerStyleCategoriesModel, for the specified layer type.
Qt::ItemFlags flags(const QModelIndex &) const override
QVariant data(const QModelIndex &index, int role) const override
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
QFlags< StyleCategory > StyleCategories
StyleCategory
Categories of style to distinguish appropriate sections for import/export.