QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
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
19#include "ui_qgsvectortilebasiclabelingwidget.h"
20
21#include <memory>
22
24
25#include <QSortFilterProxyModel>
26
27#define SIP_NO_FILE
28
30
32class QgsVectorTileBasicLabelingListModel;
34class QgsMapCanvas;
35class QgsMessageBar;
36class QgsVectorTileBasicLabelingProxyModel;
37
44class GUI_EXPORT QgsVectorTileBasicLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsVectorTileBasicLabelingWidget
45{
46 Q_OBJECT
47 public:
48 QgsVectorTileBasicLabelingWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent = nullptr );
49 ~QgsVectorTileBasicLabelingWidget() override;
50
51 void setLayer( QgsVectorTileLayer *layer );
52
53 public slots:
55 void apply() override;
56
57 private slots:
58 void addStyle( Qgis::GeometryType geomType );
59 //void addStyle();
60 void editStyle();
61 void editStyleAtIndex( const QModelIndex &index );
62 void removeStyle();
63
64 void labelModeChanged();
65 void updateLabelingFromWidget();
66 void resyncToCurrentLayer();
67
68 private:
69 QPointer<QgsVectorTileLayer> mVTLayer;
70 std::unique_ptr<QgsVectorTileBasicLabeling> mLabeling;
71 QgsVectorTileBasicLabelingListModel *mModel = nullptr;
72 QgsVectorTileBasicLabelingProxyModel *mProxyModel = nullptr;
73 QgsMapCanvas *mMapCanvas = nullptr;
74 QgsMessageBar *mMessageBar = nullptr;
75};
76
77
79class QgsVectorLayer;
81class QgsLabelingGui;
82
89class QgsLabelingPanelWidget : public QgsPanelWidget
90{
91 Q_OBJECT
92 public:
93 QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent = nullptr );
94
95 void setDockMode( bool dockMode ) override;
96
97 void setContext( const QgsSymbolWidgetContext &context );
98 QgsPalLayerSettings labelSettings();
99
100 private:
101 QgsLabelingGui *mLabelingGui = nullptr;
102};
103
104
106
107class QgsVectorTileBasicLabelingListModel : public QAbstractListModel
108{
109 Q_OBJECT
110 public:
111 enum Role
112 {
113 MinZoom = Qt::UserRole + 1,
114 MaxZoom,
115 Label,
116 Layer,
117 Filter
118 };
119
120 QgsVectorTileBasicLabelingListModel( QgsVectorTileBasicLabeling *r, QObject *parent = nullptr );
121
122 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
123 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
124 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
125 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
126 Qt::ItemFlags flags( const QModelIndex &index ) const override;
127 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
128
129 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
130
131 void insertStyle( int row, const QgsVectorTileBasicLabelingStyle &style );
132
133 // drag'n'drop support
134 Qt::DropActions supportedDropActions() const override;
135 QStringList mimeTypes() const override;
136 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
137 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
138
139 private:
140 QgsVectorTileBasicLabeling *mLabeling = nullptr;
141};
142
143class QgsVectorTileBasicLabelingProxyModel : public QSortFilterProxyModel
144{
145 Q_OBJECT
146 public:
147 QgsVectorTileBasicLabelingProxyModel( QgsVectorTileBasicLabelingListModel *source, QObject *parent = nullptr );
148
149 void setCurrentZoom( int zoom );
150 void setFilterVisible( bool enabled );
151 void setFilterString( const QString &string );
152
153 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
154
155 private:
156 bool mFilterVisible = false;
157 QString mFilterString;
158 int mCurrentZoom = -1;
159};
160
161
163
164#endif // QGSVECTORTILEBASICLABELINGWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:376
Map canvas is a class for displaying all GIS data types on a canvas.
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.
Contains settings for how a map layer will be labeled.
Base class for any widget that can be shown as an 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 dataset.
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.