QGIS API Documentation 3.41.0-Master (3440c17df1d)
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 <QAbstractListModel>
20
21#include "qgis.h"
22#include "qgsmaplayer.h"
23#include "qgis_gui.h"
24#include <QItemDelegate>
25#include <QLabel>
26
32class GUI_EXPORT QgsMapLayerStyleCategoriesModel : public QAbstractListModel
33{
34 Q_OBJECT
35
36 public:
37
39 enum class Role : int
40 {
41 NameRole = Qt::UserRole + 1,
42 };
43
47 explicit QgsMapLayerStyleCategoriesModel( Qgis::LayerType type, QObject *parent = nullptr );
48
50 void setCategories( QgsMapLayer::StyleCategories categories );
51
53 QgsMapLayer::StyleCategories categories() const;
54
56 void setShowAllCategories( bool showAll );
57
58 int rowCount( const QModelIndex & = QModelIndex() ) const override;
59 int columnCount( const QModelIndex & = QModelIndex() ) const override;
60 QVariant data( const QModelIndex &index, int role ) const override;
61 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
62 Qt::ItemFlags flags( const QModelIndex & ) const override;
63
64 private:
68 QList<QgsMapLayer::StyleCategory> mCategoryList;
70 bool mShowAllCategories = false;
71};
72
79class GUI_EXPORT QgsCategoryDisplayLabelDelegate : public QItemDelegate
80{
81 Q_OBJECT
82
83 public:
85 explicit QgsCategoryDisplayLabelDelegate( QObject *parent = nullptr );
86
87 protected:
88 void drawDisplay( QPainter *painter, const QStyleOptionViewItem &option,
89 const QRect &rect, const QString &text ) const override;
90 QSize sizeHint( const QStyleOptionViewItem &option,
91 const QModelIndex &index ) const override;
92};
93
94#endif // QGSMAPLAYERSTYLECATEGORIESMODEL_H
LayerType
Types of layers that can be added to a map.
Definition qgis.h:169
A label delegate being able to display html encoded content.
QFlags< StyleCategory > StyleCategories