QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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  const 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  const 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  const 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  switch ( geomType )
384  {
386  style.setFilterExpression( QStringLiteral( "geometry_type($geometry)='Point'" ) );
387  break;
389  style.setFilterExpression( QStringLiteral( "geometry_type($geometry)='Line'" ) );
390  break;
392  style.setFilterExpression( QStringLiteral( "geometry_type($geometry)='Polygon'" ) );
393  break;
396  break;
397  }
398 
399  const int rows = mModel->rowCount();
400  mModel->insertStyle( rows, style );
401  viewStyles->selectionModel()->setCurrentIndex( mProxyModel->mapFromSource( mModel->index( rows, 0 ) ), QItemSelectionModel::ClearAndSelect );
402 }
403 
404 void QgsVectorTileBasicLabelingWidget::editStyle()
405 {
406  editStyleAtIndex( viewStyles->selectionModel()->currentIndex() );
407 }
408 
409 void QgsVectorTileBasicLabelingWidget::editStyleAtIndex( const QModelIndex &proxyIndex )
410 {
411  const QModelIndex index = mProxyModel->mapToSource( proxyIndex );
412  if ( index.row() < 0 || index.row() >= mLabeling->styles().count() )
413  return;
414 
415  const QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
416 
417  QgsPalLayerSettings labelSettings = style.labelSettings();
418  if ( labelSettings.layerType == QgsWkbTypes::UnknownGeometry )
419  labelSettings.layerType = style.geometryType();
420 
421  QgsSymbolWidgetContext context;
422  context.setMapCanvas( mMapCanvas );
423  context.setMessageBar( mMessageBar );
424 
425  if ( mMapCanvas )
426  {
427  const int zoom = QgsVectorTileUtils::scaleToZoomLevel( mMapCanvas->scale(), 0, 99 );
428  QList<QgsExpressionContextScope> scopes = context.additionalExpressionContextScopes();
429  QgsExpressionContextScope tileScope;
430  tileScope.setVariable( "zoom_level", zoom, true );
431  tileScope.setVariable( "vector_tile_zoom", QgsVectorTileUtils::scaleToZoom( mMapCanvas->scale() ), true );
432  scopes << tileScope;
433  context.setAdditionalExpressionContextScopes( scopes );
434  }
435 
436  QgsVectorLayer *vectorLayer = nullptr; // TODO: have a temporary vector layer with sub-layer's fields?
437 
439  if ( panel && panel->dockMode() )
440  {
441  QgsLabelingPanelWidget *widget = new QgsLabelingPanelWidget( labelSettings, vectorLayer, mMapCanvas, panel );
442  widget->setContext( context );
443  widget->setPanelTitle( style.styleName() );
444  connect( widget, &QgsPanelWidget::widgetChanged, this, &QgsVectorTileBasicLabelingWidget::updateLabelingFromWidget );
445  openPanel( widget );
446  }
447  else
448  {
449  QgsLabelSettingsDialog dlg( labelSettings, vectorLayer, mMapCanvas, this, labelSettings.layerType );
450  if ( dlg.exec() )
451  {
452  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
453  style.setLabelSettings( dlg.settings() );
454  mLabeling->setStyle( index.row(), style );
455  emit widgetChanged();
456  }
457  }
458 }
459 
460 void QgsVectorTileBasicLabelingWidget::updateLabelingFromWidget()
461 {
462  const int index = mProxyModel->mapToSource( viewStyles->selectionModel()->currentIndex() ).row();
463  if ( index < 0 )
464  return;
465 
466  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index );
467 
468  QgsLabelingPanelWidget *widget = qobject_cast<QgsLabelingPanelWidget *>( sender() );
469  style.setLabelSettings( widget->labelSettings() );
470 
471  mLabeling->setStyle( index, style );
472  emit widgetChanged();
473 }
474 
475 void QgsVectorTileBasicLabelingWidget::removeStyle()
476 {
477  const QModelIndexList sel = viewStyles->selectionModel()->selectedIndexes();
478 
479  QList<int > res;
480  for ( const QModelIndex &proxyIndex : sel )
481  {
482  const QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
483  if ( !res.contains( sourceIndex.row() ) )
484  res << sourceIndex.row();
485  }
486  std::sort( res.begin(), res.end() );
487 
488  for ( int i = res.size() - 1; i >= 0; --i )
489  {
490  mModel->removeRow( res[ i ] );
491  }
492  // make sure that the selection is gone
493  viewStyles->selectionModel()->clear();
494 }
495 
496 
497 //
498 
499 
500 QgsLabelingPanelWidget::QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent )
501  : QgsPanelWidget( parent )
502 {
503  mLabelingGui = new QgsLabelingGui( vectorLayer, mapCanvas, labelSettings, this, labelSettings.layerType );
504  mLabelingGui->setLabelMode( QgsLabelingGui::Labels );
505 
506  mLabelingGui->layout()->setContentsMargins( 0, 0, 0, 0 );
507  QVBoxLayout *l = new QVBoxLayout;
508  l->addWidget( mLabelingGui );
509  setLayout( l );
510 
511  connect( mLabelingGui, &QgsTextFormatWidget::widgetChanged, this, &QgsLabelingPanelWidget::widgetChanged );
512 }
513 
514 void QgsLabelingPanelWidget::setDockMode( bool dockMode )
515 {
516  QgsPanelWidget::setDockMode( dockMode );
517  mLabelingGui->setDockMode( dockMode );
518 }
519 
520 void QgsLabelingPanelWidget::setContext( const QgsSymbolWidgetContext &context )
521 {
522  mLabelingGui->setContext( context );
523 }
524 
525 QgsPalLayerSettings QgsLabelingPanelWidget::labelSettings()
526 {
527  return mLabelingGui->layerSettings();
528 }
529 
530 
531 QgsVectorTileBasicLabelingProxyModel::QgsVectorTileBasicLabelingProxyModel( QgsVectorTileBasicLabelingListModel *source, QObject *parent )
532  : QSortFilterProxyModel( parent )
533 {
534  setSourceModel( source );
535  setDynamicSortFilter( true );
536 }
537 
538 void QgsVectorTileBasicLabelingProxyModel::setCurrentZoom( int zoom )
539 {
540  mCurrentZoom = zoom;
541  invalidateFilter();
542 }
543 
544 void QgsVectorTileBasicLabelingProxyModel::setFilterVisible( bool enabled )
545 {
546  mFilterVisible = enabled;
547  invalidateFilter();
548 }
549 
550 bool QgsVectorTileBasicLabelingProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
551 {
552  if ( mCurrentZoom < 0 || !mFilterVisible )
553  return true;
554 
555  const int rowMinZoom = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::MinZoom ).toInt();
556  const int rowMaxZoom = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::MaxZoom ).toInt();
557 
558  if ( rowMinZoom >= 0 && rowMinZoom > mCurrentZoom )
559  return false;
560 
561  if ( rowMaxZoom >= 0 && rowMaxZoom < mCurrentZoom )
562  return false;
563 
564  return true;
565 }
566 
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:89
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