QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsmaplayerstylecategoriesmodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayerstylecategoriesmodel.h
3 --------------------------------------
4 Date : September 2018
5 Copyright : (C) 2018 by Denis Rouzaud
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMAPLAYERSTYLECATEGORIESMODEL_H
17#define QGSMAPLAYERSTYLECATEGORIESMODEL_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include "qgsmaplayer.h"
22
23#include <QAbstractListModel>
24#include <QItemDelegate>
25#include <QLabel>
26
32class GUI_EXPORT QgsMapLayerStyleCategoriesModel : public QAbstractListModel
33{
34 Q_OBJECT
35
36 public:
38 enum class Role : int
39 {
40 NameRole = Qt::UserRole + 1,
41 };
42
46 explicit QgsMapLayerStyleCategoriesModel( Qgis::LayerType type, QObject *parent = nullptr );
47
49 void setCategories( QgsMapLayer::StyleCategories categories );
50
52 QgsMapLayer::StyleCategories categories() const;
53
55 void setShowAllCategories( bool showAll );
56
57 int rowCount( const QModelIndex & = QModelIndex() ) const override;
58 int columnCount( const QModelIndex & = QModelIndex() ) const override;
59 QVariant data( const QModelIndex &index, int role ) const override;
60 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
61 Qt::ItemFlags flags( const QModelIndex & ) const override;
62
63 private:
69 QList<QgsMapLayer::StyleCategory> mCategoryList;
71 bool mShowAllCategories = false;
72};
73
80class GUI_EXPORT QgsCategoryDisplayLabelDelegate : public QItemDelegate
81{
82 Q_OBJECT
83
84 public:
86 explicit QgsCategoryDisplayLabelDelegate( QObject *parent = nullptr );
87
88 protected:
89 void drawDisplay( QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text ) const override;
90 QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
91};
92
93#endif // QGSMAPLAYERSTYLECATEGORIESMODEL_H
LayerType
Types of layers that can be added to a map.
Definition qgis.h:190
@ Vector
Vector layer.
Definition qgis.h:191
void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
QgsCategoryDisplayLabelDelegate(QObject *parent=nullptr)
constructor
QgsMapLayerStyleCategoriesModel(Qgis::LayerType type, QObject *parent=nullptr)
Constructor for QgsMapLayerStyleCategoriesModel, for the specified layer type.
QFlags< StyleCategory > StyleCategories