QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
28 #define SIP_NO_FILE
29 
31 class QgsVectorTileBasicLabelingListModel;
32 class QgsVectorTileLayer;
33 class QgsMapCanvas;
34 class QgsMessageBar;
35 
42 class GUI_EXPORT QgsVectorTileBasicLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsVectorTileBasicLabelingWidget
43 {
44  Q_OBJECT
45  public:
46  QgsVectorTileBasicLabelingWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent = nullptr );
47  ~QgsVectorTileBasicLabelingWidget() override;
48 
49  void setLayer( QgsVectorTileLayer *layer );
50 
51  public slots:
53  void apply() override;
54 
55  private slots:
56  void addStyle( QgsWkbTypes::GeometryType geomType );
57  //void addStyle();
58  void editStyle();
59  void editStyleAtIndex( const QModelIndex &index );
60  void removeStyle();
61 
62  void updateLabelingFromWidget();
63 
64  private:
65  QgsVectorTileLayer *mVTLayer = nullptr;
66  std::unique_ptr<QgsVectorTileBasicLabeling> mLabeling;
67  QgsVectorTileBasicLabelingListModel *mModel = nullptr;
68  QgsMessageBar *mMessageBar = nullptr;
69 };
70 
71 
73 class QgsVectorLayer;
75 class QgsLabelingGui;
76 
83 class QgsLabelingPanelWidget : public QgsPanelWidget
84 {
85  Q_OBJECT
86  public:
87  QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent = nullptr );
88 
89  void setDockMode( bool dockMode ) override;
90 
91  void setContext( const QgsSymbolWidgetContext &context );
92  QgsPalLayerSettings labelSettings();
93 
94  private:
95  QgsLabelingGui *mLabelingGui = nullptr;
96 };
97 
98 
100 
101 class QgsVectorTileBasicLabelingListModel : public QAbstractListModel
102 {
103  Q_OBJECT
104  public:
105  QgsVectorTileBasicLabelingListModel( QgsVectorTileBasicLabeling *r, QObject *parent = nullptr );
106 
107  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
108  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
109  QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
110  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
111  Qt::ItemFlags flags( const QModelIndex &index ) const override;
112  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
113 
114  bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
115 
116  void insertStyle( int row, const QgsVectorTileBasicLabelingStyle &style );
117 
118  // drag'n'drop support
119  Qt::DropActions supportedDropActions() const override;
120  QStringList mimeTypes() const override;
121  QMimeData *mimeData( const QModelIndexList &indexes ) const override;
122  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
123 
124  private:
125  QgsVectorTileBasicLabeling *mLabeling = nullptr;
126 };
127 
129 
130 #endif // QGSVECTORTILEBASICLABELINGWIDGET_H
QgsVectorTileLayer
Definition: qgsvectortilelayer.h:83
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
Definition: qgspallabeling.h:205
QgsVectorTileBasicLabelingStyle
Definition: qgsvectortilebasiclabeling.h:31
QgsSymbolWidgetContext
Definition: qgssymbolwidgetcontext.h:35
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsVectorTileBasicLabeling
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:33
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsMessageBar
Definition: qgsmessagebar.h:60
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
qgsmaplayerconfigwidget.h
QgsVectorLayer
Definition: qgsvectorlayer.h:385
qgswkbtypes.h