QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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  case Label:
117  return style.styleName();
118 
119  case Layer:
120  return style.layerName();
121 
122  case Filter:
123  return style.filterExpression();
124 
125  }
126  return QVariant();
127 }
128 
129 QVariant QgsVectorTileBasicLabelingListModel::headerData( int section, Qt::Orientation orientation, int role ) const
130 {
131  if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 5 )
132  {
133  QStringList lst;
134  lst << tr( "Label" ) << tr( "Layer" ) << tr( "Min. Zoom" ) << tr( "Max. Zoom" ) << tr( "Filter" );
135  return lst[section];
136  }
137 
138  return QVariant();
139 }
140 
141 Qt::ItemFlags QgsVectorTileBasicLabelingListModel::flags( const QModelIndex &index ) const
142 {
143  if ( !index.isValid() )
144  return Qt::ItemIsDropEnabled;
145 
146  const Qt::ItemFlag checkable = ( index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
147 
148  return Qt::ItemIsEnabled | Qt::ItemIsSelectable |
149  Qt::ItemIsEditable | checkable |
150  Qt::ItemIsDragEnabled;
151 }
152 
153 bool QgsVectorTileBasicLabelingListModel::setData( const QModelIndex &index, const QVariant &value, int role )
154 {
155  if ( !index.isValid() )
156  return false;
157 
158  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
159 
160  if ( role == Qt::CheckStateRole )
161  {
162  style.setEnabled( value.toInt() == Qt::Checked );
163  mLabeling->setStyle( index.row(), style );
164  emit dataChanged( index, index );
165  return true;
166  }
167 
168  if ( role == Qt::EditRole )
169  {
170  if ( index.column() == 0 )
171  style.setStyleName( value.toString() );
172  else if ( index.column() == 1 )
173  style.setLayerName( value.toString() );
174  else if ( index.column() == 2 )
175  style.setMinZoomLevel( value.toInt() );
176  else if ( index.column() == 3 )
177  style.setMaxZoomLevel( value.toInt() );
178  else if ( index.column() == 4 )
179  style.setFilterExpression( value.toString() );
180 
181  mLabeling->setStyle( index.row(), style );
182  emit dataChanged( index, index );
183  return true;
184  }
185 
186  return false;
187 }
188 
189 bool QgsVectorTileBasicLabelingListModel::removeRows( int row, int count, const QModelIndex &parent )
190 {
191  QList<QgsVectorTileBasicLabelingStyle> styles = mLabeling->styles();
192 
193  if ( row < 0 || row >= styles.count() )
194  return false;
195 
196  beginRemoveRows( parent, row, row + count - 1 );
197 
198  for ( int i = 0; i < count; i++ )
199  {
200  if ( row < styles.count() )
201  {
202  styles.removeAt( row );
203  }
204  }
205 
206  mLabeling->setStyles( styles );
207 
208  endRemoveRows();
209  return true;
210 }
211 
212 void QgsVectorTileBasicLabelingListModel::insertStyle( int row, const QgsVectorTileBasicLabelingStyle &style )
213 {
214  beginInsertRows( QModelIndex(), row, row );
215 
216  QList<QgsVectorTileBasicLabelingStyle> styles = mLabeling->styles();
217  styles.insert( row, style );
218  mLabeling->setStyles( styles );
219 
220  endInsertRows();
221 }
222 
223 Qt::DropActions QgsVectorTileBasicLabelingListModel::supportedDropActions() const
224 {
225  return Qt::MoveAction;
226 }
227 
228 QStringList QgsVectorTileBasicLabelingListModel::mimeTypes() const
229 {
230  QStringList types;
231  types << QStringLiteral( "application/vnd.text.list" );
232  return types;
233 }
234 
235 QMimeData *QgsVectorTileBasicLabelingListModel::mimeData( const QModelIndexList &indexes ) const
236 {
237  QMimeData *mimeData = new QMimeData();
238  QByteArray encodedData;
239 
240  QDataStream stream( &encodedData, QIODevice::WriteOnly );
241 
242  const auto constIndexes = indexes;
243  for ( const QModelIndex &index : constIndexes )
244  {
245  // each item consists of several columns - let's add it with just first one
246  if ( !index.isValid() || index.column() != 0 )
247  continue;
248 
249  const QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
250 
251  QDomDocument doc;
252  QDomElement rootElem = doc.createElement( QStringLiteral( "vector_tile_basic_labeling_style_mime" ) );
253  style.writeXml( rootElem, QgsReadWriteContext() );
254  doc.appendChild( rootElem );
255 
256  stream << doc.toString( -1 );
257  }
258 
259  mimeData->setData( QStringLiteral( "application/vnd.text.list" ), encodedData );
260  return mimeData;
261 }
262 
263 bool QgsVectorTileBasicLabelingListModel::dropMimeData( const QMimeData *data,
264  Qt::DropAction action, int row, int column, const QModelIndex &parent )
265 {
266  Q_UNUSED( column )
267 
268  if ( action == Qt::IgnoreAction )
269  return true;
270 
271  if ( !data->hasFormat( QStringLiteral( "application/vnd.text.list" ) ) )
272  return false;
273 
274  if ( parent.column() > 0 )
275  return false;
276 
277  QByteArray encodedData = data->data( QStringLiteral( "application/vnd.text.list" ) );
278  QDataStream stream( &encodedData, QIODevice::ReadOnly );
279  int rows = 0;
280 
281  if ( row == -1 )
282  {
283  // the item was dropped at a parent - we may decide where to put the items - let's append them
284  row = rowCount( parent );
285  }
286 
287  while ( !stream.atEnd() )
288  {
289  QString text;
290  stream >> text;
291 
292  QDomDocument doc;
293  if ( !doc.setContent( text ) )
294  continue;
295  const QDomElement rootElem = doc.documentElement();
296  if ( rootElem.tagName() != QLatin1String( "vector_tile_basic_labeling_style_mime" ) )
297  continue;
298 
300  style.readXml( rootElem, QgsReadWriteContext() );
301 
302  insertStyle( row + rows, style );
303  ++rows;
304  }
305  return true;
306 }
307 
308 
309 //
310 
311 
312 QgsVectorTileBasicLabelingWidget::QgsVectorTileBasicLabelingWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent )
313  : QgsMapLayerConfigWidget( layer, canvas, parent )
314  , mMapCanvas( canvas )
315  , mMessageBar( messageBar )
316 {
317 
318  setupUi( this );
319  layout()->setContentsMargins( 0, 0, 0, 0 );
320 
321  mFilterLineEdit->setShowClearButton( true );
322  mFilterLineEdit->setShowSearchIcon( true );
323  mFilterLineEdit->setPlaceholderText( tr( "Filter rules" ) );
324 
325  QMenu *menuAddRule = new QMenu( btnAddRule );
326  menuAddRule->addAction( tr( "Marker" ), this, [this] { addStyle( QgsWkbTypes::PointGeometry ); } );
327  menuAddRule->addAction( tr( "Line" ), this, [this] { addStyle( QgsWkbTypes::LineGeometry ); } );
328  menuAddRule->addAction( tr( "Fill" ), this, [this] { addStyle( QgsWkbTypes::PolygonGeometry ); } );
329  btnAddRule->setMenu( menuAddRule );
330 
331  //connect( btnAddRule, &QPushButton::clicked, this, &QgsVectorTileBasicLabelingWidget::addStyle );
332  connect( btnEditRule, &QPushButton::clicked, this, &QgsVectorTileBasicLabelingWidget::editStyle );
333  connect( btnRemoveRule, &QAbstractButton::clicked, this, &QgsVectorTileBasicLabelingWidget::removeStyle );
334 
335  connect( viewStyles, &QAbstractItemView::doubleClicked, this, &QgsVectorTileBasicLabelingWidget::editStyleAtIndex );
336 
337  if ( mMapCanvas )
338  {
339  connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, [ = ]( double scale )
340  {
341  const QgsMapSettings &mapSettings = mMapCanvas->mapSettings();
342  const double tileScale = mVTLayer ? mVTLayer->tileMatrixSet().calculateTileScaleForMap( scale,
343  mapSettings.destinationCrs(),
344  mapSettings.visibleExtent(),
345  mapSettings.outputSize(),
346  mapSettings.outputDpi() ) : scale;
347  const int zoom = mVTLayer ? mVTLayer->tileMatrixSet().scaleToZoomLevel( tileScale ) : QgsVectorTileUtils::scaleToZoomLevel( tileScale, 0, 99 );
348  mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( zoom ) );
349  if ( mProxyModel )
350  mProxyModel->setCurrentZoom( zoom );
351  } );
352 
353  const QgsMapSettings &mapSettings = mMapCanvas->mapSettings();
354  const double tileScale = mVTLayer ? mVTLayer->tileMatrixSet().calculateTileScaleForMap( mMapCanvas->scale(),
355  mapSettings.destinationCrs(),
356  mapSettings.visibleExtent(),
357  mapSettings.outputSize(),
358  mapSettings.outputDpi() ) : mMapCanvas->scale();
359  mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( mVTLayer ? mVTLayer->tileMatrixSet().scaleToZoomLevel( tileScale ) : QgsVectorTileUtils::scaleToZoomLevel( tileScale, 0, 99 ) ) );
360  }
361 
362  connect( mCheckVisibleOnly, &QCheckBox::toggled, this, [ = ]( bool filter )
363  {
364  mProxyModel->setFilterVisible( filter );
365  } );
366 
367  connect( mFilterLineEdit, &QgsFilterLineEdit::textChanged, this, [ = ]( const QString & text )
368  {
369  mProxyModel->setFilterString( text );
370  } );
371 
372  setLayer( layer );
373 }
374 
375 void QgsVectorTileBasicLabelingWidget::setLayer( QgsVectorTileLayer *layer )
376 {
377  mVTLayer = layer;
378 
379  if ( layer && layer->labeling() && layer->labeling()->type() == QLatin1String( "basic" ) )
380  {
381  mLabeling.reset( static_cast<QgsVectorTileBasicLabeling *>( layer->labeling()->clone() ) );
382  }
383  else
384  {
385  mLabeling.reset( new QgsVectorTileBasicLabeling() );
386  }
387 
388  mModel = new QgsVectorTileBasicLabelingListModel( mLabeling.get(), viewStyles );
389  mProxyModel = new QgsVectorTileBasicLabelingProxyModel( mModel, viewStyles );
390  viewStyles->setModel( mProxyModel );
391 
392  if ( mMapCanvas )
393  {
394  const QgsMapSettings &mapSettings = mMapCanvas->mapSettings();
395  const double tileScale = mVTLayer ? mVTLayer->tileMatrixSet().calculateTileScaleForMap( mMapCanvas->scale(),
396  mapSettings.destinationCrs(),
397  mapSettings.visibleExtent(),
398  mapSettings.outputSize(),
399  mapSettings.outputDpi() ) : mMapCanvas->scale();
400  const int zoom = mVTLayer ? mVTLayer->tileMatrixSet().scaleToZoomLevel( tileScale ) : QgsVectorTileUtils::scaleToZoomLevel( tileScale, 0, 99 );
401  mProxyModel->setCurrentZoom( zoom );
402  }
403 
404  connect( mModel, &QAbstractItemModel::dataChanged, this, &QgsPanelWidget::widgetChanged );
405  connect( mModel, &QAbstractItemModel::rowsInserted, this, &QgsPanelWidget::widgetChanged );
406  connect( mModel, &QAbstractItemModel::rowsRemoved, this, &QgsPanelWidget::widgetChanged );
407 }
408 
409 QgsVectorTileBasicLabelingWidget::~QgsVectorTileBasicLabelingWidget() = default;
410 
411 void QgsVectorTileBasicLabelingWidget::apply()
412 {
413  mVTLayer->setLabeling( mLabeling->clone() );
414 }
415 
416 void QgsVectorTileBasicLabelingWidget::addStyle( QgsWkbTypes::GeometryType geomType )
417 {
419  style.setGeometryType( geomType );
420  switch ( geomType )
421  {
423  style.setFilterExpression( QStringLiteral( "geometry_type($geometry)='Point'" ) );
424  break;
426  style.setFilterExpression( QStringLiteral( "geometry_type($geometry)='Line'" ) );
427  break;
429  style.setFilterExpression( QStringLiteral( "geometry_type($geometry)='Polygon'" ) );
430  break;
433  break;
434  }
435 
436  const int rows = mModel->rowCount();
437  mModel->insertStyle( rows, style );
438  viewStyles->selectionModel()->setCurrentIndex( mProxyModel->mapFromSource( mModel->index( rows, 0 ) ), QItemSelectionModel::ClearAndSelect );
439 }
440 
441 void QgsVectorTileBasicLabelingWidget::editStyle()
442 {
443  editStyleAtIndex( viewStyles->selectionModel()->currentIndex() );
444 }
445 
446 void QgsVectorTileBasicLabelingWidget::editStyleAtIndex( const QModelIndex &proxyIndex )
447 {
448  const QModelIndex index = mProxyModel->mapToSource( proxyIndex );
449  if ( index.row() < 0 || index.row() >= mLabeling->styles().count() )
450  return;
451 
452  const QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
453 
454  QgsPalLayerSettings labelSettings = style.labelSettings();
455  if ( labelSettings.layerType == QgsWkbTypes::UnknownGeometry )
456  labelSettings.layerType = style.geometryType();
457 
458  QgsSymbolWidgetContext context;
459  context.setMapCanvas( mMapCanvas );
460  context.setMessageBar( mMessageBar );
461 
462  if ( mMapCanvas )
463  {
464  const QgsMapSettings &mapSettings = mMapCanvas->mapSettings();
465  const double tileScale = mVTLayer ? mVTLayer->tileMatrixSet().calculateTileScaleForMap( mMapCanvas->scale(),
466  mapSettings.destinationCrs(),
467  mapSettings.visibleExtent(),
468  mapSettings.outputSize(),
469  mapSettings.outputDpi() ) : mMapCanvas->scale();
470  const int zoom = mVTLayer ? mVTLayer->tileMatrixSet().scaleToZoomLevel( tileScale ) : QgsVectorTileUtils::scaleToZoomLevel( tileScale, 0, 99 );
471  QList<QgsExpressionContextScope> scopes = context.additionalExpressionContextScopes();
472  QgsExpressionContextScope tileScope;
473  tileScope.setVariable( "zoom_level", zoom, true );
474  tileScope.setVariable( "vector_tile_zoom", mVTLayer ? mVTLayer->tileMatrixSet().scaleToZoom( mMapCanvas->scale() ) : QgsVectorTileUtils::scaleToZoom( mMapCanvas->scale() ), true );
475  scopes << tileScope;
476  context.setAdditionalExpressionContextScopes( scopes );
477  }
478 
479  QgsVectorLayer *vectorLayer = nullptr; // TODO: have a temporary vector layer with sub-layer's fields?
480 
482  if ( panel && panel->dockMode() )
483  {
484  QgsLabelingPanelWidget *widget = new QgsLabelingPanelWidget( labelSettings, vectorLayer, mMapCanvas, panel );
485  widget->setContext( context );
486  widget->setPanelTitle( style.styleName() );
487  connect( widget, &QgsPanelWidget::widgetChanged, this, &QgsVectorTileBasicLabelingWidget::updateLabelingFromWidget );
488  openPanel( widget );
489  }
490  else
491  {
492  QgsLabelSettingsDialog dlg( labelSettings, vectorLayer, mMapCanvas, this, labelSettings.layerType );
493  if ( dlg.exec() )
494  {
495  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index.row() );
496  style.setLabelSettings( dlg.settings() );
497  mLabeling->setStyle( index.row(), style );
498  emit widgetChanged();
499  }
500  }
501 }
502 
503 void QgsVectorTileBasicLabelingWidget::updateLabelingFromWidget()
504 {
505  const int index = mProxyModel->mapToSource( viewStyles->selectionModel()->currentIndex() ).row();
506  if ( index < 0 )
507  return;
508 
509  QgsVectorTileBasicLabelingStyle style = mLabeling->style( index );
510 
511  QgsLabelingPanelWidget *widget = qobject_cast<QgsLabelingPanelWidget *>( sender() );
512  style.setLabelSettings( widget->labelSettings() );
513 
514  mLabeling->setStyle( index, style );
515  emit widgetChanged();
516 }
517 
518 void QgsVectorTileBasicLabelingWidget::removeStyle()
519 {
520  const QModelIndexList sel = viewStyles->selectionModel()->selectedIndexes();
521 
522  QList<int > res;
523  for ( const QModelIndex &proxyIndex : sel )
524  {
525  const QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
526  if ( !res.contains( sourceIndex.row() ) )
527  res << sourceIndex.row();
528  }
529  std::sort( res.begin(), res.end() );
530 
531  for ( int i = res.size() - 1; i >= 0; --i )
532  {
533  mModel->removeRow( res[ i ] );
534  }
535  // make sure that the selection is gone
536  viewStyles->selectionModel()->clear();
537 }
538 
539 
540 //
541 
542 
543 QgsLabelingPanelWidget::QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent )
544  : QgsPanelWidget( parent )
545 {
546  mLabelingGui = new QgsLabelingGui( vectorLayer, mapCanvas, labelSettings, this, labelSettings.layerType );
547  mLabelingGui->setLabelMode( QgsLabelingGui::Labels );
548 
549  mLabelingGui->layout()->setContentsMargins( 0, 0, 0, 0 );
550  QVBoxLayout *l = new QVBoxLayout;
551  l->addWidget( mLabelingGui );
552  setLayout( l );
553 
554  connect( mLabelingGui, &QgsTextFormatWidget::widgetChanged, this, &QgsLabelingPanelWidget::widgetChanged );
555 }
556 
557 void QgsLabelingPanelWidget::setDockMode( bool dockMode )
558 {
559  QgsPanelWidget::setDockMode( dockMode );
560  mLabelingGui->setDockMode( dockMode );
561 }
562 
563 void QgsLabelingPanelWidget::setContext( const QgsSymbolWidgetContext &context )
564 {
565  mLabelingGui->setContext( context );
566 }
567 
568 QgsPalLayerSettings QgsLabelingPanelWidget::labelSettings()
569 {
570  return mLabelingGui->layerSettings();
571 }
572 
573 
574 QgsVectorTileBasicLabelingProxyModel::QgsVectorTileBasicLabelingProxyModel( QgsVectorTileBasicLabelingListModel *source, QObject *parent )
575  : QSortFilterProxyModel( parent )
576 {
577  setSourceModel( source );
578  setDynamicSortFilter( true );
579 }
580 
581 void QgsVectorTileBasicLabelingProxyModel::setCurrentZoom( int zoom )
582 {
583  mCurrentZoom = zoom;
584  invalidateFilter();
585 }
586 
587 void QgsVectorTileBasicLabelingProxyModel::setFilterVisible( bool enabled )
588 {
589  mFilterVisible = enabled;
590  invalidateFilter();
591 }
592 
593 void QgsVectorTileBasicLabelingProxyModel::setFilterString( const QString &string )
594 {
595  mFilterString = string;
596  invalidateFilter();
597 }
598 
599 bool QgsVectorTileBasicLabelingProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
600 {
601  if ( mCurrentZoom >= 0 && mFilterVisible )
602  {
603  const int rowMinZoom = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::MinZoom ).toInt();
604  const int rowMaxZoom = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::MaxZoom ).toInt();
605 
606  if ( rowMinZoom >= 0 && rowMinZoom > mCurrentZoom )
607  return false;
608 
609  if ( rowMaxZoom >= 0 && rowMaxZoom < mCurrentZoom )
610  return false;
611  }
612 
613  if ( !mFilterString.isEmpty() )
614  {
615  const QString name = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::Label ).toString();
616  const QString layer = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::Layer ).toString();
617  const QString filter = sourceModel()->data( sourceModel()->index( source_row, 0, source_parent ), QgsVectorTileBasicLabelingListModel::Filter ).toString();
618  if ( !name.contains( mFilterString, Qt::CaseInsensitive )
619  && !layer.contains( mFilterString, Qt::CaseInsensitive )
620  && !filter.contains( mFilterString, Qt::CaseInsensitive ) )
621  {
622  return false;
623  }
624  }
625 
626  return true;
627 }
628 
QgsVectorTileBasicLabelingStyle::setGeometryType
void setGeometryType(QgsWkbTypes::GeometryType geomType)
Sets type of the geometry that will be used (point / line / polygon)
Definition: qgsvectortilebasiclabeling.h:51
qgsvectortilebasiclabelingwidget.h
QgsVectorTileLayer
Implements a map layer that is dedicated to rendering of vector tiles. Vector tiles compared to "ordi...
Definition: qgsvectortilelayer.h:84
QgsExpressionContextScope::setVariable
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.
Definition: qgsexpressioncontext.cpp:83
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsMapSettings::outputSize
QSize outputSize() const
Returns the size of the resulting map image, in pixels.
Definition: qgsmapsettings.cpp:239
qgsmapcanvas.h
QgsWkbTypes::NullGeometry
@ NullGeometry
Definition: qgswkbtypes.h:146
QgsVectorTileBasicLabelingStyle::setLabelSettings
void setLabelSettings(const QgsPalLayerSettings &settings)
Sets labeling configuration of this style.
Definition: qgsvectortilebasiclabeling.h:36
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
Contains settings for how a map layer will be labeled.
Definition: qgspallabeling.h:86
QgsPanelWidget::findParentPanel
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
Definition: qgspanelwidget.cpp:54
QgsVectorTileBasicLabelingStyle
Configuration of a single style within QgsVectorTileBasicLabeling.
Definition: qgsvectortilebasiclabeling.h:31
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:35
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsVectorTileBasicLabeling
Basic labeling configuration for vector tile layers. It contains a definition of a list of labeling s...
Definition: qgsvectortilebasiclabeling.h:107
QgsVectorTileBasicLabelingStyle::geometryType
QgsWkbTypes::GeometryType geometryType() const
Returns type of the geometry that will be used (point / line / polygon)
Definition: qgsvectortilebasiclabeling.h:53
QgsVectorTileBasicLabelingStyle::setMaxZoomLevel
void setMaxZoomLevel(int maxZoom)
Sets maximum zoom level index (negative number means no limit)
Definition: qgsvectortilebasiclabeling.h:71
QgsPanelWidget::dockMode
bool dockMode()
Returns the dock mode state.
Definition: qgspanelwidget.h:93
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:144
QgsVectorTileBasicLabelingStyle::filterExpression
QString filterExpression() const
Returns filter expression (empty filter means that all features match)
Definition: qgsvectortilebasiclabeling.h:58
QgsGuiUtils::iconSize
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
Definition: qgsguiutils.cpp:264
QgsMapLayerConfigWidget
A panel widget that can be shown in the map style dock.
Definition: qgsmaplayerconfigwidget.h:115
QgsMapCanvas::scaleChanged
void scaleChanged(double)
Emitted when the scale of the map changes.
QgsSymbolWidgetContext::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:49
qgsvectortilelayer.h
QgsPalLayerSettings::labelSettingsPreviewPixmap
static QPixmap labelSettingsPreviewPixmap(const QgsPalLayerSettings &settings, QSize size, const QString &previewText=QString(), int padding=0)
Returns a pixmap preview for label settings.
Definition: qgspallabeling.cpp:1338
QgsVectorTileUtils::scaleToZoomLevel
static int scaleToZoomLevel(double mapScale, int sourceMinZoom, int sourceMaxZoom, double z0Scale=559082264.0287178)
Finds the best fitting zoom level given a map scale denominator and allowed zoom level range.
Definition: qgsvectortileutils.cpp:71
QgsSymbolWidgetContext::setMessageBar
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:59
QgsVectorTileBasicLabelingStyle::setEnabled
void setEnabled(bool enabled)
Sets whether this style is enabled (used for rendering)
Definition: qgsvectortilebasiclabeling.h:61
QgsVectorTileBasicLabelingStyle::setLayerName
void setLayerName(const QString &name)
Sets name of the sub-layer to render (empty layer means that all layers match)
Definition: qgsvectortilebasiclabeling.h:46
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsVectorTileBasicLabelingStyle::maxZoomLevel
int maxZoomLevel() const
Returns maxnimum zoom level index (negative number means no limit)
Definition: qgsvectortilebasiclabeling.h:73
QgsVectorTileBasicLabelingStyle::styleName
QString styleName() const
Returns human readable name of this style.
Definition: qgsvectortilebasiclabeling.h:43
QgsSymbolWidgetContext::setAdditionalExpressionContextScopes
void setAdditionalExpressionContextScopes(const QList< QgsExpressionContextScope > &scopes)
Sets a list of additional expression context scopes to show as available within the layer.
Definition: qgssymbolwidgetcontext.cpp:82
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:60
QgsPanelWidget::widgetChanged
void widgetChanged()
Emitted when the widget state changes.
QgsVectorTileBasicLabelingStyle::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads object content from given DOM element.
Definition: qgsvectortilebasiclabeling.cpp:41
QgsVectorTileBasicLabelingStyle::isEnabled
bool isEnabled() const
Returns whether this style is enabled (used for rendering)
Definition: qgsvectortilebasiclabeling.h:63
QgsMapSettings::scale
double scale() const
Returns the calculated map scale.
Definition: qgsmapsettings.cpp:458
QgsVectorTileLabeling::clone
virtual QgsVectorTileLabeling * clone() const =0SIP_FACTORY
Returns a new copy of the object.
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext....
Definition: qgsexpressioncontext.h:113
QgsVectorTileBasicLabelingStyle::setStyleName
void setStyleName(const QString &name)
Sets human readable name of this style.
Definition: qgsvectortilebasiclabeling.h:41
QgsMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Definition: qgsmapsettings.cpp:358
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:143
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsVectorTileBasicLabelingStyle::setFilterExpression
void setFilterExpression(const QString &expr)
Sets filter expression (empty filter means that all features match)
Definition: qgsvectortilebasiclabeling.h:56
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
QgsVectorTileLayer::labeling
QgsVectorTileLabeling * labeling() const
Returns currently assigned labeling.
Definition: qgsvectortilelayer.cpp:902
QgsTextFormatWidget::widgetChanged
void widgetChanged()
Emitted when the text format defined by the widget changes.
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsVectorTileLabeling::type
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
QgsVectorTileBasicLabelingStyle::writeXml
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes object content to given DOM element.
Definition: qgsvectortilebasiclabeling.cpp:26
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:145
QgsVectorTileUtils::scaleToZoom
static double scaleToZoom(double mapScale, double z0Scale=559082264.0287178)
Finds zoom level given map scale denominator.
Definition: qgsvectortileutils.cpp:63
ICON_PADDING_FACTOR
const double ICON_PADDING_FACTOR
Definition: qgsstylemodel.cpp:31
QgsVectorTileBasicLabelingStyle::labelSettings
QgsPalLayerSettings labelSettings() const
Returns labeling configuration of this style.
Definition: qgsvectortilebasiclabeling.h:38
QgsMapSettings::outputDpi
double outputDpi() const
Returns the DPI (dots per inch) used for conversion between real world units (e.g.
Definition: qgsmapsettings.cpp:267
QgsVectorTileBasicLabelingStyle::setMinZoomLevel
void setMinZoomLevel(int minZoom)
Sets minimum zoom level index (negative number means no limit)
Definition: qgsvectortilebasiclabeling.h:66
qgsvectortileutils.h
QgsGuiUtils::scaleIconSize
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
Definition: qgsguiutils.cpp:259
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
Definition: qgsmapsettings.h:88
QgsMapSettings::visibleExtent
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
Definition: qgsmapsettings.cpp:411
qgsvectortilebasiclabeling.h
QgsVectorTileBasicLabelingStyle::minZoomLevel
int minZoomLevel() const
Returns minimum zoom level index (negative number means no limit)
Definition: qgsvectortilebasiclabeling.h:68
QgsPalLayerSettings::layerType
QgsWkbTypes::GeometryType layerType
Geometry type of layers associated with these settings.
Definition: qgspallabeling.h:739
QgsVectorTileBasicLabelingStyle::layerName
QString layerName() const
Returns name of the sub-layer to render (empty layer means that all layers match)
Definition: qgsvectortilebasiclabeling.h:48
qgslabelinggui.h
QgsSymbolWidgetContext::additionalExpressionContextScopes
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
Definition: qgssymbolwidgetcontext.cpp:87