QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgswkbtypes.h"
24 
25 #include <memory>
26 #include <QSortFilterProxyModel>
27 
29 #define SIP_NO_FILE
30 
32 class QgsVectorTileBasicLabelingListModel;
33 class QgsVectorTileLayer;
34 class QgsMapCanvas;
35 class QgsMessageBar;
36 class QgsVectorTileBasicLabelingProxyModel;
37 
44 class 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( QgsWkbTypes::GeometryType geomType );
59  //void addStyle();
60  void editStyle();
61  void editStyleAtIndex( const QModelIndex &index );
62  void removeStyle();
63 
64  void updateLabelingFromWidget();
65 
66  private:
67  QPointer< QgsVectorTileLayer > mVTLayer;
68  std::unique_ptr<QgsVectorTileBasicLabeling> mLabeling;
69  QgsVectorTileBasicLabelingListModel *mModel = nullptr;
70  QgsVectorTileBasicLabelingProxyModel *mProxyModel = nullptr;
71  QgsMapCanvas *mMapCanvas = nullptr;
72  QgsMessageBar *mMessageBar = nullptr;
73 };
74 
75 
77 class QgsVectorLayer;
79 class QgsLabelingGui;
80 
87 class QgsLabelingPanelWidget : public QgsPanelWidget
88 {
89  Q_OBJECT
90  public:
91  QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent = nullptr );
92 
93  void setDockMode( bool dockMode ) override;
94 
95  void setContext( const QgsSymbolWidgetContext &context );
96  QgsPalLayerSettings labelSettings();
97 
98  private:
99  QgsLabelingGui *mLabelingGui = nullptr;
100 };
101 
102 
104 
105 class QgsVectorTileBasicLabelingListModel : public QAbstractListModel
106 {
107  Q_OBJECT
108  public:
109 
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 
142 class 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 
156  bool mFilterVisible = false;
157  QString mFilterString;
158  int mCurrentZoom = -1;
159 };
160 
161 
163 
164 #endif // QGSVECTORTILEBASICLABELINGWIDGET_H
QgsVectorTileLayer
Implements a map layer that is dedicated to rendering of vector tiles. Vector tiles compared to "ordi...
Definition: qgsvectortilelayer.h:84
QgsPanelWidget::setDockMode
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Definition: qgspanelwidget.cpp:44
QgsPalLayerSettings
Contains settings for how a map layer will be labeled.
Definition: qgspallabeling.h:86
QgsVectorTileBasicLabelingStyle
Configuration of a single style within QgsVectorTileBasicLabeling.
Definition: qgsvectortilebasiclabeling.h:31
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:35
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsVectorTileBasicLabeling
Basic labeling configuration for vector tile layers. It contains a definition of a list of labeling s...
Definition: qgsvectortilebasiclabeling.h:107
QgsMapLayerConfigWidget::apply
virtual void apply()=0
Called when changes to the layer need to be made.
QgsMapLayerConfigWidget
A panel widget that can be shown in the map style dock.
Definition: qgsmaplayerconfigwidget.h:115
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:60
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
qgsmaplayerconfigwidget.h
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
qgswkbtypes.h