QGIS API Documentation 3.99.0-Master (18a1e75d814)
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
19#include "ui_qgsvectortilebasicrendererwidget.h"
20
21#include <memory>
22
24
25#include <QSortFilterProxyModel>
26
27#define SIP_NO_FILE
28
30
32class QgsVectorTileBasicRendererListModel;
34class QgsMapCanvas;
35class QgsMessageBar;
36class QgsVectorTileBasicRendererProxyModel;
38
45class 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 syncToLayer( QgsMapLayer *mapLayer ) final;
53
54 public slots:
56 void apply() override;
57
58 private slots:
59 void addStyle( Qgis::GeometryType geomType );
60 void editStyle();
61 void editStyleAtIndex( const QModelIndex &index );
62 void removeStyle();
63
64 void updateSymbolsFromWidget( QgsSymbolSelectorWidget *widget );
65
66 private:
67 QPointer<QgsVectorTileLayer> mVTLayer;
68 std::unique_ptr<QgsVectorTileBasicRenderer> mRenderer;
69 QgsVectorTileBasicRendererListModel *mModel = nullptr;
70 QgsVectorTileBasicRendererProxyModel *mProxyModel = nullptr;
71 QgsMapCanvas *mMapCanvas = nullptr;
72 QgsMessageBar *mMessageBar = nullptr;
73};
74
75
77
78class QgsVectorTileBasicRendererListModel : public QAbstractListModel
79{
80 Q_OBJECT
81 public:
82 enum Role
83 {
84 MinZoom = Qt::UserRole + 1,
85 MaxZoom,
86 Label,
87 Layer,
88 Filter
89 };
90
91 QgsVectorTileBasicRendererListModel( QgsVectorTileBasicRenderer *r, QObject *parent = nullptr, QScreen *screen = nullptr );
92
93 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
94 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
95 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
96 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
97 Qt::ItemFlags flags( const QModelIndex &index ) const override;
98 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
99
100 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
101
102 void insertStyle( int row, const QgsVectorTileBasicRendererStyle &style );
103
104 // drag'n'drop support
105 Qt::DropActions supportedDropActions() const override;
106 QStringList mimeTypes() const override;
107 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
108 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
109
110 private:
111 QgsVectorTileBasicRenderer *mRenderer = nullptr;
112 QPointer<QScreen> mScreen;
113};
114
115class QgsVectorTileBasicRendererProxyModel : public QSortFilterProxyModel
116{
117 Q_OBJECT
118 public:
119 QgsVectorTileBasicRendererProxyModel( QgsVectorTileBasicRendererListModel *source, QObject *parent = nullptr );
120
121 void setCurrentZoom( int zoom );
122 void setFilterVisible( bool enabled );
123 void setFilterString( const QString &string );
124
125 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
126
127 private:
128 bool mFilterVisible = false;
129 QString mFilterString;
130 int mCurrentZoom = -1;
131};
132
134
135#endif // QGSVECTORTILEBASICRENDERERWIDGET_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.
virtual void syncToLayer(QgsMapLayer *layer)
Reset to original (vector layer) values.
Base class for all map layer types.
Definition qgsmaplayer.h:83
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.