QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsvectortilebasiclabelingwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectortilebasiclabelingwidget.cpp
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 
17 
19 #include "qgsvectortilelayer.h"
20 
21 #include "qgslabelinggui.h"
22 #include "qgsmapcanvas.h"
23 #include "qgsvectortileutils.h"
24 
25 #include <QMenu>
26 
28 
29 const double ICON_PADDING_FACTOR = 0.16;
30 
31 QgsVectorTileBasicLabelingListModel::QgsVectorTileBasicLabelingListModel( QgsVectorTileBasicLabeling *l, QObject *parent )
32  : QAbstractListModel( parent )
33  , mLabeling( l )
34 {
35 }
36 
37 int QgsVectorTileBasicLabelingListModel::rowCount( const QModelIndex &parent ) const
38 {
39  if ( parent.isValid() )
40  return 0;
41 
42  return mLabeling->styles().count();
43 }
44 
45 int QgsVectorTileBasicLabelingListModel::columnCount( const QModelIndex & ) const
46 {
47  return 5;
48 }
49 
50 QVariant QgsVectorTileBasicLabelingListModel::data( const QModelIndex &index, int role ) const
51 {
52  if ( index.row() < 0 || index.row() >= mLabeling->styles().count() )
53  return QVariant();
54 
55  const QList<QgsVectorTileBasicLabelingStyle> styles = mLabeling->styles();
56  const QgsVectorTileBasicLabelingStyle &style = styles[index.row()];
57 
58  switch ( role )
59  {
60  case Qt::DisplayRole:
61  case Qt::ToolTipRole:
62  {
63  if ( index.column() == 0 )
64  return style.styleName();
65  else if ( index.column() == 1 )
66  return style.layerName().isEmpty() ? tr( "(all layers)" ) : style.layerName();
67  else if ( index.column() == 2 )
68  return style.minZoomLevel() >= 0 ? style.minZoomLevel() : QVariant();
69  else if ( index.column() == 3 )
70  return style.maxZoomLevel() >= 0 ? style.maxZoomLevel() : QVariant();
71  else if ( index.column() == 4 )
72  return style.filterExpression().isEmpty() ? tr( "(no filter)" ) : style.filterExpression();
73 
74  break;
75  }
76 
77  case Qt::EditRole:
78  {
79  if ( index.column() == 0 )
80  return style.styleName();
81  else if ( index.column() == 1 )
82  return style.layerName();
83  else if ( index.column() == 2 )
84  return style.minZoomLevel();
85  else if ( index.column() == 3 )
86  return style.maxZoomLevel();
87  else if ( index.column() == 4 )
88  return style.filterExpression();
89 
90  break;
91  }
92 
93  case Qt::CheckStateRole:
94  {
95  if ( index.column() != 0 )
96  return QVariant();
97  return style.isEnabled() ? Qt::Checked : Qt::Unchecked;
98  }
99 
100  case Qt::DecorationRole:
101  {
102  if ( index.column() == 0 )
103  {
104  const int iconSize = QgsGuiUtils::scaleIconSize( 16 );
105  return QgsPalLayerSettings::labelSettingsPreviewPixmap( style.labelSettings(), QSize( iconSize, iconSize ), QString(), static_cast< int >( iconSize * ICON_PADDING_FACTOR ) );
106  }
107  break;
108  }
109 
110  case MinZoom:
111  return style.minZoomLevel();
112 
113  case MaxZoom:
114  return style.maxZoomLevel();
115 
116  }
117  return QVariant();
118 }
119 
120 QVariant QgsVectorTileBasicLabelingListModel::headerData( int section, Qt::Orientation orientation, int role ) const
121 {
122  if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 5 )
123  {
124  QStringList lst;
125  lst << tr( "Label" ) << tr( "Layer" ) << tr( "Min. Zoom" ) << tr( "Max. Zoom" ) << tr( "Filter" );
126  return lst[section];
127  }
128 
129  return QVariant();
130 }
131 
132 Qt::ItemFlags QgsVectorTileBasicLabelingListModel::flags( const QModelIndex &index ) const
133 {
134  if ( !index.isValid() )
135  return Qt::ItemIsDropEnabled;
136 
137  Qt::ItemFlag checkable = ( index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
138 
139  return Qt::ItemIsEnabled | Qt::ItemIsSelectable |
140  Qt::ItemIsEditable | checkable |
141  Qt::ItemIsDragEnabled;
142 }
143 
144 bool QgsVectorTileBasicLabelingListModel::setData( const QModelIndex &index, const QVariant &value, int role )
145 {
146  if ( !index.isValid() )
147  return false;
148 
149  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
150 
151  if ( role == Qt::CheckStateRole )
152  {
153  style.setEnabled( value.toInt() == Qt::Checked );
154  mLabeling->setStyle( index.row(), style );
155  emit dataChanged( index, index );
156  return true;
157  }
158 
159  if ( role == Qt::EditRole )
160  {
161  if ( index.column() == 0 )
162  style.setStyleName( value.toString() );
163  else if ( index.column() == 1 )
164  style.setLayerName( value.toString() );
165  else if ( index.column() == 2 )
166  style.setMinZoomLevel( value.toInt() );
167  else if ( index.column() == 3 )
168  style.setMaxZoomLevel( value.toInt() );
169  else if ( index.column() == 4 )
170  style.setFilterExpression( value.toString() );
171 
172  mLabeling->setStyle( index.row(), style );
173  emit dataChanged( index, index );
174  return true;
175  }
176 
177  return false;
178 }
179 
180 bool QgsVectorTileBasicLabelingListModel::removeRows( int row, int count, const QModelIndex &parent )
181 {
182  QList<QgsVectorTileBasicLabelingStyle> styles = mLabeling->styles();
183 
184  if ( row < 0 || row >= styles.count() )
185  return false;
186 
187  beginRemoveRows( parent, row, row + count - 1 );
188 
189  for ( int i = 0; i < count; i++ )
190  {
191  if ( row < styles.count() )
192  {
193  styles.removeAt( row );
194  }
195  }
196 
197  mLabeling->setStyles( styles );
198 
199  endRemoveRows();
200  return true;
201 }
202 
203 void QgsVectorTileBasicLabelingListModel::insertStyle( int row, const QgsVectorTileBasicLabelingStyle &style )
204 {
205  beginInsertRows( QModelIndex(), row, row );
206 
207  QList<QgsVectorTileBasicLabelingStyle> styles = mLabeling->styles();
208  styles.insert( row, style );
209  mLabeling->setStyles( styles );
210 
211  endInsertRows();
212 }
213 
214 Qt::DropActions QgsVectorTileBasicLabelingListModel::supportedDropActions() const
215 {
216  return Qt::MoveAction;
217 }
218 
219 QStringList QgsVectorTileBasicLabelingListModel::mimeTypes() const
220 {
221  QStringList types;
222  types << QStringLiteral( "application/vnd.text.list" );
223  return types;
224 }
225 
226 QMimeData *QgsVectorTileBasicLabelingListModel::mimeData( const QModelIndexList &indexes ) const
227 {
228  QMimeData *mimeData = new QMimeData();
229  QByteArray encodedData;
230 
231  QDataStream stream( &encodedData, QIODevice::WriteOnly );
232 
233  const auto constIndexes = indexes;
234  for ( const QModelIndex &index : constIndexes )
235  {
236  // each item consists of several columns - let's add it with just first one
237  if ( !index.isValid() || index.column() != 0 )
238  continue;
239 
240  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
241 
242  QDomDocument doc;
243  QDomElement rootElem = doc.createElement( QStringLiteral( "vector_tile_basic_labeling_style_mime" ) );
244  style.writeXml( rootElem, QgsReadWriteContext() );
245  doc.appendChild( rootElem );
246 
247  stream << doc.toString( -1 );
248  }
249 
250  mimeData->setData( QStringLiteral( "application/vnd.text.list" ), encodedData );
251  return mimeData;
252 }
253 
254 bool QgsVectorTileBasicLabelingListModel::dropMimeData( const QMimeData *data,
255  Qt::DropAction action, int row, int column, const QModelIndex &parent )
256 {
257  Q_UNUSED( column )
258 
259  if ( action == Qt::IgnoreAction )
260  return true;
261 
262  if ( !data->hasFormat( QStringLiteral( "application/vnd.text.list" ) ) )
263  return false;
264 
265  if ( parent.column() > 0 )
266  return false;
267 
268  QByteArray encodedData = data->data( QStringLiteral( "application/vnd.text.list" ) );
269  QDataStream stream( &encodedData, QIODevice::ReadOnly );
270  int rows = 0;
271 
272  if ( row == -1 )
273  {
274  // the item was dropped at a parent - we may decide where to put the items - let's append them
275  row = rowCount( parent );
276  }
277 
278  while ( !stream.atEnd() )
279  {
280  QString text;
281  stream >> text;
282 
283  QDomDocument doc;
284  if ( !doc.setContent( text ) )
285  continue;
286  QDomElement rootElem = doc.documentElement();
287  if ( rootElem.tagName() != QLatin1String( "vector_tile_basic_labeling_style_mime" ) )
288  continue;
289 
291  style.readXml( rootElem, QgsReadWriteContext() );
292 
293  insertStyle( row + rows, style );
294  ++rows;
295  }
296  return true;
297 }
298 
299 
300 //
301 
302 
303 QgsVectorTileBasicLabelingWidget::QgsVectorTileBasicLabelingWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent )
304  : QgsMapLayerConfigWidget( layer, canvas, parent )
305  , mMapCanvas( canvas )
306  , mMessageBar( messageBar )
307 {
308 
309  setupUi( this );
310  layout()->setContentsMargins( 0, 0, 0, 0 );
311 
312  QMenu *menuAddRule = new QMenu( btnAddRule );
313  menuAddRule->addAction( tr( "Marker" ), this, [this] { addStyle( QgsWkbTypes::PointGeometry ); } );
314  menuAddRule->addAction( tr( "Line" ), this, [this] { addStyle( QgsWkbTypes::LineGeometry ); } );
315  menuAddRule->addAction( tr( "Fill" ), this, [this] { addStyle( QgsWkbTypes::PolygonGeometry ); } );
316  btnAddRule->setMenu( menuAddRule );
317 
318  //connect( btnAddRule, &QPushButton::clicked, this, &QgsVectorTileBasicLabelingWidget::addStyle );
319  connect( btnEditRule, &QPushButton::clicked, this, &QgsVectorTileBasicLabelingWidget::editStyle );
320  connect( btnRemoveRule, &QAbstractButton::clicked, this, &QgsVectorTileBasicLabelingWidget::removeStyle );
321 
322  connect( viewStyles, &QAbstractItemView::doubleClicked, this, &QgsVectorTileBasicLabelingWidget::editStyleAtIndex );
323 
324  if ( mMapCanvas )
325  {
326  connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, [ = ]( double scale )
327  {
328  const int zoom = QgsVectorTileUtils::scaleToZoomLevel( scale, 0, 99 );
329  mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( zoom ) );
330  if ( mProxyModel )
331  mProxyModel->setCurrentZoom( zoom );
332  } );
333  mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( QgsVectorTileUtils::scaleToZoomLevel( mMapCanvas->scale(), 0, 99 ) ) );
334  }
335 
336  connect( mCheckVisibleOnly, &QCheckBox::toggled, this, [ = ]( bool filter )
337  {
338  mProxyModel->setFilterVisible( filter );
339  } );
340 
341  setLayer( layer );
342 }
343 
344 void QgsVectorTileBasicLabelingWidget::setLayer( QgsVectorTileLayer *layer )
345 {
346  mVTLayer = layer;
347 
348  if ( layer && layer->labeling() && layer->labeling()->type() == QLatin1String( "basic" ) )
349  {
350  mLabeling.reset( static_cast<QgsVectorTileBasicLabeling *>( layer->labeling()->clone() ) );
351  }
352  else
353  {
354  mLabeling.reset( new QgsVectorTileBasicLabeling() );
355  }
356 
357  mModel = new QgsVectorTileBasicLabelingListModel( mLabeling.get(), viewStyles );
358  mProxyModel = new QgsVectorTileBasicLabelingProxyModel( mModel, viewStyles );
359  viewStyles->setModel( mProxyModel );
360 
361  if ( mMapCanvas )
362  {
363  const int zoom = QgsVectorTileUtils::scaleToZoomLevel( mMapCanvas->scale(), 0, 99 );
364  mProxyModel->setCurrentZoom( zoom );
365  }
366 
367  connect( mModel, &QAbstractItemModel::dataChanged, this, &QgsPanelWidget::widgetChanged );
368  connect( mModel, &QAbstractItemModel::rowsInserted, this, &QgsPanelWidget::widgetChanged );
369  connect( mModel, &QAbstractItemModel::rowsRemoved, this, &QgsPanelWidget::widgetChanged );
370 }
371 
372 QgsVectorTileBasicLabelingWidget::~QgsVectorTileBasicLabelingWidget() = default;
373 
374 void QgsVectorTileBasicLabelingWidget::apply()
375 {
376  mVTLayer->setLabeling( mLabeling->clone() );
377 }
378 
379 void QgsVectorTileBasicLabelingWidget::addStyle( QgsWkbTypes::GeometryType geomType )
380 {
382  style.setGeometryType( geomType );
383 
384  int rows = mModel->rowCount();
385  mModel->insertStyle( rows, style );
386  viewStyles->selectionModel()->setCurrentIndex( mProxyModel->mapFromSource( mModel->index( rows, 0 ) ), QItemSelectionModel::ClearAndSelect );
387 }
388 
389 void QgsVectorTileBasicLabelingWidget::editStyle()
390 {
391  editStyleAtIndex( viewStyles->selectionModel()->currentIndex() );
392 }
393 
394 void QgsVectorTileBasicLabelingWidget::editStyleAtIndex( const QModelIndex &proxyIndex )
395 {
396  const QModelIndex index = mProxyModel->mapToSource( proxyIndex );
397  if ( index.row() < 0 || index.row() >= mLabeling->styles().count() )
398  return;
399 
400  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
401 
402  QgsPalLayerSettings labelSettings = style.labelSettings();
403  if ( labelSettings.layerType == QgsWkbTypes::UnknownGeometry )
404  labelSettings.layerType = style.geometryType();
405 
406  QgsSymbolWidgetContext context;
407  context.setMapCanvas( mMapCanvas );
408  context.setMessageBar( mMessageBar );
409 
410  if ( mMapCanvas )
411  {
412  const int zoom = QgsVectorTileUtils::scaleToZoomLevel( mMapCanvas->scale(), 0, 99 );
413  QList<QgsExpressionContextScope> scopes = context.additionalExpressionContextScopes();
414  QgsExpressionContextScope tileScope;
415  tileScope.setVariable( "zoom_level", zoom, true );
416  tileScope.setVariable( "vector_tile_zoom", QgsVectorTileUtils::scaleToZoom( mMapCanvas->scale() ), true );
417  scopes << tileScope;
418  context.setAdditionalExpressionContextScopes( scopes );
419  }
420 
421  QgsVectorLayer *vectorLayer = nullptr; // TODO: have a temporary vector layer with sub-layer's fields?
422 
424  if ( panel && panel->dockMode() )
425  {
426  QgsLabelingPanelWidget *widget = new QgsLabelingPanelWidget( labelSettings, vectorLayer, mMapCanvas, panel );
427  widget->setContext( context );
428  widget->setPanelTitle( style.styleName() );
429  connect( widget, &QgsPanelWidget::widgetChanged, this, &QgsVectorTileBasicLabelingWidget::updateLabelingFromWidget );
430  openPanel( widget );
431  }
432  else
433  {
434  QgsLabelSettingsDialog dlg( labelSettings, vectorLayer, mMapCanvas, this, labelSettings.layerType );
435  if ( dlg.exec() )
436  {
437  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
438  style.setLabelSettings( dlg.settings() );
439  mLabeling->setStyle( index.row(), style );
440  emit widgetChanged();
441  }
442  }
443 }
444 
445 void QgsVectorTileBasicLabelingWidget::updateLabelingFromWidget()
446 {
447  int index = mProxyModel->mapToSource( viewStyles->selectionModel()->currentIndex() ).row();
448  if ( index < 0 )
449  return;
450 
451  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index );
452 
453  QgsLabelingPanelWidget *widget = qobject_cast<QgsLabelingPanelWidget *>( sender() );
454  style.setLabelSettings( widget->labelSettings() );
455 
456  mLabeling->setStyle( index, style );
457  emit widgetChanged();
458 }
459 
460 void QgsVectorTileBasicLabelingWidget::removeStyle()
461 {
462  const QModelIndexList sel = viewStyles->selectionModel()->selectedIndexes();
463 
464  QList<int > res;
465  for ( const QModelIndex &proxyIndex : sel )
466  {
467  const QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
468  if ( !res.contains( sourceIndex.row() ) )
469  res << sourceIndex.row();
470  }
471  std::sort( res.begin(), res.end() );
472 
473  for ( int i = res.size() - 1; i >= 0; --i )
474  {
475  mModel->removeRow( res[ i ] );
476  }
477  // make sure that the selection is gone
478  viewStyles->selectionModel()->clear();
479 }
480 
481 
482 //
483 
484 
485 QgsLabelingPanelWidget::QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent )
486  : QgsPanelWidget( parent )
487 {
488  mLabelingGui = new QgsLabelingGui( vectorLayer, mapCanvas, labelSettings, this, labelSettings.layerType );
489  mLabelingGui->setLabelMode( QgsLabelingGui::Labels );
490 
491  mLabelingGui->layout()->setContentsMargins( 0, 0, 0, 0 );
492  QVBoxLayout *l = new QVBoxLayout;
493  l->addWidget( mLabelingGui );
494  setLayout( l );
495 
496  connect( mLabelingGui, &QgsTextFormatWidget::widgetChanged, this, &QgsLabelingPanelWidget::widgetChanged );
497 }
498 
499 void QgsLabelingPanelWidget::setDockMode( bool dockMode )
500 {
501  QgsPanelWidget::setDockMode( dockMode );
502  mLabelingGui->setDockMode( dockMode );
503 }
504 
505 void QgsLabelingPanelWidget::setContext( const QgsSymbolWidgetContext &context )
506 {
507  mLabelingGui->setContext( context );
508 }
509 
510 QgsPalLayerSettings QgsLabelingPanelWidget::labelSettings()
511 {
512  return mLabelingGui->layerSettings();
513 }
514 
515 
516 QgsVectorTileBasicLabelingProxyModel::QgsVectorTileBasicLabelingProxyModel( QgsVectorTileBasicLabelingListModel *source, QObject *parent )
517  : QSortFilterProxyModel( parent )
518 {
519  setSourceModel( source );
520  setDynamicSortFilter( true );
521 }
522 
523 void QgsVectorTileBasicLabelingProxyModel::setCurrentZoom( int zoom )
524 {
525  mCurrentZoom = zoom;
526  invalidateFilter();
527 }
528 
529 void QgsVectorTileBasicLabelingProxyModel::setFilterVisible( bool enabled )
530 {
531  mFilterVisible = enabled;
532  invalidateFilter();
533 }
534 
535 bool QgsVectorTileBasicLabelingProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
536 {
537  if ( mCurrentZoom < 0 || !mFilterVisible )
538  return true;
539 
540  const int rowMinZoom = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::MinZoom ).toInt();
541  const int rowMaxZoom = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::MaxZoom ).toInt();
542 
543  if ( rowMinZoom >= 0 && rowMinZoom > mCurrentZoom )
544  return false;
545 
546  if ( rowMaxZoom >= 0 && rowMaxZoom < mCurrentZoom )
547  return false;
548 
549  return true;
550 }
551 
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:86
void scaleChanged(double)
Emitted when the scale of the map changes.
A panel widget that can be shown in the map style dock.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
Contains settings for how a map layer will be labeled.
static QPixmap labelSettingsPreviewPixmap(const QgsPalLayerSettings &settings, QSize size, const QString &previewText=QString(), int padding=0)
Returns a pixmap preview for label settings.
QgsWkbTypes::GeometryType layerType
Geometry type of layers associated with these settings.
Base class for any widget that can be shown as a inline panel.
void widgetChanged()
Emitted when the widget state changes.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
bool dockMode()
Returns the dock mode state.
The class is used as a container of context for various read/write operations on other objects.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setAdditionalExpressionContextScopes(const QList< QgsExpressionContextScope > &scopes)
Sets a list of additional expression context scopes to show as available within the layer.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
void widgetChanged()
Emitted when the text format defined by the widget changes.
Represents a vector layer which manages a vector based data sets.
Configuration of a single style within QgsVectorTileBasicLabeling.
QgsPalLayerSettings labelSettings() const
Returns labeling configuration of this style.
void setGeometryType(QgsWkbTypes::GeometryType geomType)
Sets type of the geometry that will be used (point / line / polygon)
QString layerName() const
Returns name of the sub-layer to render (empty layer means that all layers match)
void setLayerName(const QString &name)
Sets name of the sub-layer to render (empty layer means that all layers match)
QString filterExpression() const
Returns filter expression (empty filter means that all features match)
void setMinZoomLevel(int minZoom)
Sets minimum zoom level index (negative number means no limit)
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes object content to given DOM element.
QgsWkbTypes::GeometryType geometryType() const
Returns type of the geometry that will be used (point / line / polygon)
int maxZoomLevel() const
Returns maxnimum zoom level index (negative number means no limit)
void setFilterExpression(const QString &expr)
Sets filter expression (empty filter means that all features match)
int minZoomLevel() const
Returns minimum zoom level index (negative number means no limit)
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads object content from given DOM element.
void setMaxZoomLevel(int maxZoom)
Sets maximum zoom level index (negative number means no limit)
void setStyleName(const QString &name)
Sets human readable name of this style.
void setLabelSettings(const QgsPalLayerSettings &settings)
Sets labeling configuration of this style.
void setEnabled(bool enabled)
Sets whether this style is enabled (used for rendering)
QString styleName() const
Returns human readable name of this style.
bool isEnabled() const
Returns whether this style is enabled (used for rendering)
Basic labeling configuration for vector tile layers.
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
virtual QgsVectorTileLabeling * clone() const =0SIP_FACTORY
Returns a new copy of the object.
Implements a map layer that is dedicated to rendering of vector tiles.
QgsVectorTileLabeling * labeling() const
Returns currently assigned labeling.
static int scaleToZoomLevel(double mapScale, int sourceMinZoom, int sourceMaxZoom)
Finds best fitting zoom level (assuming GoogleCRS84Quad tile matrix set) given map scale denominator ...
static double scaleToZoom(double mapScale)
Finds zoom level (assuming GoogleCRS84Quad tile matrix set) given map scale denominator.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
const double ICON_PADDING_FACTOR