QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsvectortilebasicrendererwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectortilebasicrendererwidget.h
3  --------------------------------------
4  Date : April 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 QGSVECTORTILEBASICRENDERERWIDGET_H
17 #define QGSVECTORTILEBASICRENDERERWIDGET_H
18 
20 
21 #include "ui_qgsvectortilebasicrendererwidget.h"
22 
23 #include "qgswkbtypes.h"
24 
25 #include <memory>
26 #include <QSortFilterProxyModel>
27 
28 
30 #define SIP_NO_FILE
31 
33 class QgsVectorTileBasicRendererListModel;
34 class QgsVectorTileLayer;
35 class QgsMapCanvas;
36 class QgsMessageBar;
37 class QgsVectorTileBasicRendererProxyModel;
38 
45 class GUI_EXPORT QgsVectorTileBasicRendererWidget : public QgsMapLayerConfigWidget, private Ui::QgsVectorTileBasicRendererWidget
46 {
47  Q_OBJECT
48  public:
49  QgsVectorTileBasicRendererWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent = nullptr );
50  ~QgsVectorTileBasicRendererWidget() override;
51 
52  void setLayer( QgsVectorTileLayer *layer );
53 
54  public slots:
56  void apply() override;
57 
58  private slots:
59  void addStyle( QgsWkbTypes::GeometryType geomType );
60  void editStyle();
61  void editStyleAtIndex( const QModelIndex &index );
62  void removeStyle();
63 
64  void updateSymbolsFromWidget();
65  void cleanUpSymbolSelector( QgsPanelWidget *container );
66 
67  private:
68  QPointer< QgsVectorTileLayer > mVTLayer;
69  std::unique_ptr<QgsVectorTileBasicRenderer> mRenderer;
70  QgsVectorTileBasicRendererListModel *mModel = nullptr;
71  QgsVectorTileBasicRendererProxyModel *mProxyModel = nullptr;
72  QgsMapCanvas *mMapCanvas = nullptr;
73  QgsMessageBar *mMessageBar = nullptr;
74 };
75 
76 
78 
79 class QgsVectorTileBasicRendererListModel : public QAbstractListModel
80 {
81  Q_OBJECT
82  public:
83 
84  enum Role
85  {
86  MinZoom = Qt::UserRole + 1,
87  MaxZoom,
88  Label,
89  Layer,
90  Filter
91  };
92 
93  QgsVectorTileBasicRendererListModel( QgsVectorTileBasicRenderer *r, QObject *parent = nullptr );
94 
95  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
96  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
97  QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
98  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
99  Qt::ItemFlags flags( const QModelIndex &index ) const override;
100  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
101 
102  bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
103 
104  void insertStyle( int row, const QgsVectorTileBasicRendererStyle &style );
105 
106  // drag'n'drop support
107  Qt::DropActions supportedDropActions() const override;
108  QStringList mimeTypes() const override;
109  QMimeData *mimeData( const QModelIndexList &indexes ) const override;
110  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
111 
112  private:
113  QgsVectorTileBasicRenderer *mRenderer = nullptr;
114 };
115 
116 class QgsVectorTileBasicRendererProxyModel : public QSortFilterProxyModel
117 {
118  Q_OBJECT
119  public:
120  QgsVectorTileBasicRendererProxyModel( QgsVectorTileBasicRendererListModel *source, QObject *parent = nullptr );
121 
122  void setCurrentZoom( int zoom );
123  void setFilterVisible( bool enabled );
124  void setFilterString( const QString &string );
125 
126  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
127 
128  private:
129 
130  bool mFilterVisible = false;
131  QString mFilterString;
132  int mCurrentZoom = -1;
133 };
134 
136 
137 #endif // QGSVECTORTILEBASICRENDERERWIDGET_H
QgsVectorTileLayer
Implements a map layer that is dedicated to rendering of vector tiles. Vector tiles compared to "ordi...
Definition: qgsvectortilelayer.h:84
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsVectorTileBasicRenderer
The default vector tile renderer implementation. It has an ordered list of "styles",...
Definition: qgsvectortilebasicrenderer.h:127
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
QgsVectorTileBasicRendererStyle
Definition of map rendering of a subset of vector tile data. The subset of data is defined by:
Definition: qgsvectortilebasicrenderer.h:47
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
qgswkbtypes.h