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