QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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
6
Email : denis@opengis.ch
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
32
class
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
:
65
Qgis::LayerType
mLayerType =
Qgis::LayerType::Vector
;
67
QgsMapLayer::StyleCategories
mCategories;
69
QList<QgsMapLayer::StyleCategory> mCategoryList;
71
bool
mShowAllCategories =
false
;
72
};
73
80
class
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
Qgis::LayerType
LayerType
Types of layers that can be added to a map.
Definition
qgis.h:206
Qgis::LayerType::Vector
@ Vector
Vector layer.
Definition
qgis.h:207
QgsCategoryDisplayLabelDelegate::drawDisplay
void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override
Definition
qgsmaplayerstylecategoriesmodel.cpp:575
QgsCategoryDisplayLabelDelegate::sizeHint
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition
qgsmaplayerstylecategoriesmodel.cpp:590
QgsCategoryDisplayLabelDelegate::QgsCategoryDisplayLabelDelegate
QgsCategoryDisplayLabelDelegate(QObject *parent=nullptr)
constructor
Definition
qgsmaplayerstylecategoriesmodel.cpp:571
QgsMapLayerStyleCategoriesModel
Model for layer style categories.
Definition
qgsmaplayerstylecategoriesmodel.h:33
QgsMapLayerStyleCategoriesModel::QgsMapLayerStyleCategoriesModel
QgsMapLayerStyleCategoriesModel(Qgis::LayerType type, QObject *parent=nullptr)
Constructor for QgsMapLayerStyleCategoriesModel, for the specified layer type.
Definition
qgsmaplayerstylecategoriesmodel.cpp:27
QgsMapLayerStyleCategoriesModel::Role
Role
Custom model roles.
Definition
qgsmaplayerstylecategoriesmodel.h:39
QgsMapLayer::StyleCategories
QFlags< StyleCategory > StyleCategories
Definition
qgsmaplayer.h:204
qgis.h
qgsmaplayer.h
Generated on
for QGIS API Documentation by
1.17.0