QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsvectortilebasiclabelingwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortilebasiclabelingwidget.h
3 --------------------------------------
4 Date : May 2020
5 Copyright : (C) 2020 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
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 QGSVECTORTILEBASICLABELINGWIDGET_H
17#define QGSVECTORTILEBASICLABELINGWIDGET_H
18
20
21#include "ui_qgsvectortilebasiclabelingwidget.h"
22
23#include <memory>
24#include <QSortFilterProxyModel>
25
27#define SIP_NO_FILE
28
30class QgsVectorTileBasicLabelingListModel;
32class QgsMapCanvas;
33class QgsMessageBar;
34class QgsVectorTileBasicLabelingProxyModel;
35
42class GUI_EXPORT QgsVectorTileBasicLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsVectorTileBasicLabelingWidget
43{
44 Q_OBJECT
45 public:
46 QgsVectorTileBasicLabelingWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent = nullptr );
47 ~QgsVectorTileBasicLabelingWidget() override;
48
49 void setLayer( QgsVectorTileLayer *layer );
50
51 public slots:
53 void apply() override;
54
55 private slots:
56 void addStyle( Qgis::GeometryType geomType );
57 //void addStyle();
58 void editStyle();
59 void editStyleAtIndex( const QModelIndex &index );
60 void removeStyle();
61
62 void updateLabelingFromWidget();
63
64 private:
65 QPointer< QgsVectorTileLayer > mVTLayer;
66 std::unique_ptr<QgsVectorTileBasicLabeling> mLabeling;
67 QgsVectorTileBasicLabelingListModel *mModel = nullptr;
68 QgsVectorTileBasicLabelingProxyModel *mProxyModel = nullptr;
69 QgsMapCanvas *mMapCanvas = nullptr;
70 QgsMessageBar *mMessageBar = nullptr;
71};
72
73
75class QgsVectorLayer;
77class QgsLabelingGui;
78
85class QgsLabelingPanelWidget : public QgsPanelWidget
86{
87 Q_OBJECT
88 public:
89 QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent = nullptr );
90
91 void setDockMode( bool dockMode ) override;
92
93 void setContext( const QgsSymbolWidgetContext &context );
94 QgsPalLayerSettings labelSettings();
95
96 private:
97 QgsLabelingGui *mLabelingGui = nullptr;
98};
99
100
102
103class QgsVectorTileBasicLabelingListModel : public QAbstractListModel
104{
105 Q_OBJECT
106 public:
107
108 enum Role
109 {
110 MinZoom = Qt::UserRole + 1,
111 MaxZoom,
112 Label,
113 Layer,
114 Filter
115 };
116
117 QgsVectorTileBasicLabelingListModel( QgsVectorTileBasicLabeling *r, QObject *parent = nullptr );
118
119 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
120 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
121 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
122 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
123 Qt::ItemFlags flags( const QModelIndex &index ) const override;
124 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
125
126 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
127
128 void insertStyle( int row, const QgsVectorTileBasicLabelingStyle &style );
129
130 // drag'n'drop support
131 Qt::DropActions supportedDropActions() const override;
132 QStringList mimeTypes() const override;
133 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
134 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
135
136 private:
137 QgsVectorTileBasicLabeling *mLabeling = nullptr;
138};
139
140class QgsVectorTileBasicLabelingProxyModel : public QSortFilterProxyModel
141{
142 Q_OBJECT
143 public:
144 QgsVectorTileBasicLabelingProxyModel( QgsVectorTileBasicLabelingListModel *source, QObject *parent = nullptr );
145
146 void setCurrentZoom( int zoom );
147 void setFilterVisible( bool enabled );
148 void setFilterString( const QString &string );
149
150 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
151
152 private:
153
154 bool mFilterVisible = false;
155 QString mFilterString;
156 int mCurrentZoom = -1;
157};
158
159
161
162#endif // QGSVECTORTILEBASICLABELINGWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:227
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
A panel widget that can be shown in the map style dock.
virtual void apply()=0
Called when changes to the layer need to be made.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
Contains settings for how a map layer will be labeled.
Base class for any widget that can be shown as a inline panel.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Represents a vector layer which manages a vector based data sets.
Configuration of a single style within QgsVectorTileBasicLabeling.
Basic labeling configuration for vector tile layers.
Implements a map layer that is dedicated to rendering of vector tiles.