QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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 <memory>
24#include <QSortFilterProxyModel>
25
26
28#define SIP_NO_FILE
29
31class QgsVectorTileBasicRendererListModel;
33class QgsMapCanvas;
34class QgsMessageBar;
35class QgsVectorTileBasicRendererProxyModel;
37
44class GUI_EXPORT QgsVectorTileBasicRendererWidget : public QgsMapLayerConfigWidget, private Ui::QgsVectorTileBasicRendererWidget
45{
46 Q_OBJECT
47 public:
48 QgsVectorTileBasicRendererWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent = nullptr );
49 ~QgsVectorTileBasicRendererWidget() override;
50
51 void syncToLayer( QgsMapLayer *mapLayer ) final;
52
53 public slots:
55 void apply() override;
56
57 private slots:
58 void addStyle( Qgis::GeometryType geomType );
59 void editStyle();
60 void editStyleAtIndex( const QModelIndex &index );
61 void removeStyle();
62
63 void updateSymbolsFromWidget( QgsSymbolSelectorWidget *widget );
64
65 private:
66 QPointer<QgsVectorTileLayer> mVTLayer;
67 std::unique_ptr<QgsVectorTileBasicRenderer> mRenderer;
68 QgsVectorTileBasicRendererListModel *mModel = nullptr;
69 QgsVectorTileBasicRendererProxyModel *mProxyModel = nullptr;
70 QgsMapCanvas *mMapCanvas = nullptr;
71 QgsMessageBar *mMessageBar = nullptr;
72};
73
74
76
77class QgsVectorTileBasicRendererListModel : public QAbstractListModel
78{
79 Q_OBJECT
80 public:
81 enum Role
82 {
83 MinZoom = Qt::UserRole + 1,
84 MaxZoom,
85 Label,
86 Layer,
87 Filter
88 };
89
90 QgsVectorTileBasicRendererListModel( QgsVectorTileBasicRenderer *r, QObject *parent = nullptr, QScreen *screen = nullptr );
91
92 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
93 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
94 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
95 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
96 Qt::ItemFlags flags( const QModelIndex &index ) const override;
97 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
98
99 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
100
101 void insertStyle( int row, const QgsVectorTileBasicRendererStyle &style );
102
103 // drag'n'drop support
104 Qt::DropActions supportedDropActions() const override;
105 QStringList mimeTypes() const override;
106 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
107 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
108
109 private:
110 QgsVectorTileBasicRenderer *mRenderer = nullptr;
111 QPointer<QScreen> mScreen;
112};
113
114class QgsVectorTileBasicRendererProxyModel : public QSortFilterProxyModel
115{
116 Q_OBJECT
117 public:
118 QgsVectorTileBasicRendererProxyModel( QgsVectorTileBasicRendererListModel *source, QObject *parent = nullptr );
119
120 void setCurrentZoom( int zoom );
121 void setFilterVisible( bool enabled );
122 void setFilterString( const QString &string );
123
124 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
125
126 private:
127 bool mFilterVisible = false;
128 QString mFilterString;
129 int mCurrentZoom = -1;
130};
131
133
134#endif // QGSVECTORTILEBASICRENDERERWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
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.
virtual void syncToLayer(QgsMapLayer *layer)
Reset to original (vector layer) values.
Base class for all map layer types.
Definition qgsmaplayer.h:76
A bar for displaying non-blocking messages to the user.
Symbol selector widget that can be used to select and build a symbol.
Definition of map rendering of a subset of vector tile data.
The default vector tile renderer implementation.
Implements a map layer that is dedicated to rendering of vector tiles.