QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgslayoutitemattributetable.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutitemattributetable.cpp
3  -------------------------------
4  begin : November 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
19 #include "qgslayout.h"
20 #include "qgslayouttablecolumn.h"
21 #include "qgslayoutitemmap.h"
22 #include "qgslayoututils.h"
23 #include "qgsfeatureiterator.h"
24 #include "qgsvectorlayer.h"
25 #include "qgslayoutframe.h"
26 #include "qgsproject.h"
27 #include "qgsrelationmanager.h"
28 #include "qgsgeometry.h"
29 #include "qgsexception.h"
30 #include "qgsmapsettings.h"
32 #include "qgsgeometryengine.h"
33 #include "qgsconditionalstyle.h"
34 
35 //
36 // QgsLayoutItemAttributeTable
37 //
38 
40  : QgsLayoutTable( layout )
41 {
42  if ( mLayout )
43  {
44  connect( mLayout->project(), static_cast < void ( QgsProject::* )( const QString & ) >( &QgsProject::layerWillBeRemoved ), this, &QgsLayoutItemAttributeTable::removeLayer );
45 
46  //coverage layer change = regenerate columns
47  connect( &mLayout->reportContext(), &QgsLayoutReportContext::layerChanged, this, &QgsLayoutItemAttributeTable::atlasLayerChanged );
48  }
50 }
51 
53 {
55 }
56 
58 {
59  return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemTable.svg" ) );
60 }
61 
63 {
64  return new QgsLayoutItemAttributeTable( layout );
65 }
66 
68 {
69  return tr( "<Attribute table frame>" );
70 }
71 
73 {
74  if ( layer == mVectorLayer.get() )
75  {
76  //no change
77  return;
78  }
79 
80  QgsVectorLayer *prevLayer = sourceLayer();
81  mVectorLayer.setLayer( layer );
82 
83  if ( mSource == QgsLayoutItemAttributeTable::LayerAttributes && layer != prevLayer )
84  {
85  if ( prevLayer )
86  {
87  //disconnect from previous layer
88  disconnect( prevLayer, &QgsVectorLayer::layerModified, this, &QgsLayoutTable::refreshAttributes );
89  }
90 
91  //rebuild column list to match all columns from layer
92  resetColumns();
93 
94  //listen for modifications to layer and refresh table when they occur
95  connect( mVectorLayer.get(), &QgsVectorLayer::layerModified, this, &QgsLayoutTable::refreshAttributes );
96  }
97 
99  emit changed();
100 }
101 
102 void QgsLayoutItemAttributeTable::setRelationId( const QString &relationId )
103 {
104  if ( relationId == mRelationId )
105  {
106  //no change
107  return;
108  }
109 
110  QgsVectorLayer *prevLayer = sourceLayer();
111  mRelationId = relationId;
112  QgsRelation relation = mLayout->project()->relationManager()->relation( mRelationId );
113  QgsVectorLayer *newLayer = relation.referencingLayer();
114 
115  if ( mSource == QgsLayoutItemAttributeTable::RelationChildren && newLayer != prevLayer )
116  {
117  if ( prevLayer )
118  {
119  //disconnect from previous layer
120  disconnect( prevLayer, &QgsVectorLayer::layerModified, this, &QgsLayoutTable::refreshAttributes );
121  }
122 
123  //rebuild column list to match all columns from layer
124  resetColumns();
125 
126  //listen for modifications to layer and refresh table when they occur
128  }
129 
131  emit changed();
132 }
133 
134 void QgsLayoutItemAttributeTable::atlasLayerChanged( QgsVectorLayer *layer )
135 {
136  if ( mSource != QgsLayoutItemAttributeTable::AtlasFeature || layer == mCurrentAtlasLayer )
137  {
138  //nothing to do
139  return;
140  }
141 
142  //atlas feature mode, atlas layer changed, so we need to reset columns
143  if ( mCurrentAtlasLayer )
144  {
145  //disconnect from previous layer
146  disconnect( mCurrentAtlasLayer, &QgsVectorLayer::layerModified, this, &QgsLayoutTable::refreshAttributes );
147  }
148 
149  const bool mustRebuildColumns = static_cast< bool >( mCurrentAtlasLayer ) || mColumns.empty();
150  mCurrentAtlasLayer = layer;
151 
152  if ( mustRebuildColumns )
153  {
154  //rebuild column list to match all columns from layer
155  resetColumns();
156  }
157 
159 
160  //listen for modifications to layer and refresh table when they occur
162 }
163 
165 {
167  if ( !source )
168  {
169  return;
170  }
171 
172  //remove existing columns
173  mColumns.clear();
174  mSortColumns.clear();
175 
176  //rebuild columns list from vector layer fields
177  int idx = 0;
178  const QgsFields sourceFields = source->fields();
179  for ( const auto &field : sourceFields )
180  {
181  QString currentAlias = source->attributeDisplayName( idx );
183  col.setAttribute( field.name() );
184  col.setHeading( currentAlias );
185  mColumns.append( col );
186  idx++;
187  }
188 }
189 
190 void QgsLayoutItemAttributeTable::disconnectCurrentMap()
191 {
192  if ( !mMap )
193  {
194  return;
195  }
196 
199  disconnect( mMap, &QObject::destroyed, this, &QgsLayoutItemAttributeTable::disconnectCurrentMap );
200  mMap = nullptr;
201 }
202 
204 {
205  return mUseConditionalStyling;
206 }
207 
209 {
210  if ( useConditionalStyling == mUseConditionalStyling )
211  {
212  return;
213  }
214 
215  mUseConditionalStyling = useConditionalStyling;
217  emit changed();
218 }
219 
221 {
222  if ( map == mMap )
223  {
224  //no change
225  return;
226  }
227  disconnectCurrentMap();
228 
229  mMap = map;
230  if ( mMap )
231  {
232  //listen out for extent changes in linked map
235  connect( mMap, &QObject::destroyed, this, &QgsLayoutItemAttributeTable::disconnectCurrentMap );
236  }
238  emit changed();
239 }
240 
242 {
243  if ( features == mMaximumNumberOfFeatures )
244  {
245  return;
246  }
247 
248  mMaximumNumberOfFeatures = features;
250  emit changed();
251 }
252 
254 {
255  if ( uniqueOnly == mShowUniqueRowsOnly )
256  {
257  return;
258  }
259 
260  mShowUniqueRowsOnly = uniqueOnly;
262  emit changed();
263 }
264 
266 {
267  if ( visibleOnly == mShowOnlyVisibleFeatures )
268  {
269  return;
270  }
271 
272  mShowOnlyVisibleFeatures = visibleOnly;
274  emit changed();
275 }
276 
278 {
279  if ( filterToAtlas == mFilterToAtlasIntersection )
280  {
281  return;
282  }
283 
284  mFilterToAtlasIntersection = filterToAtlas;
286  emit changed();
287 }
288 
290 {
291  if ( filter == mFilterFeatures )
292  {
293  return;
294  }
295 
296  mFilterFeatures = filter;
298  emit changed();
299 }
300 
301 void QgsLayoutItemAttributeTable::setFeatureFilter( const QString &expression )
302 {
303  if ( expression == mFeatureFilter )
304  {
305  return;
306  }
307 
308  mFeatureFilter = expression;
310  emit changed();
311 }
312 
313 void QgsLayoutItemAttributeTable::setDisplayedFields( const QStringList &fields, bool refresh )
314 {
316  if ( !source )
317  {
318  return;
319  }
320 
321  //rebuild columns list, taking only fields contained in supplied list
322  mColumns.clear();
323 
324  const QgsFields layerFields = source->fields();
325 
326  if ( !fields.isEmpty() )
327  {
328  for ( const QString &field : fields )
329  {
330  int attrIdx = layerFields.lookupField( field );
331  if ( attrIdx < 0 )
332  continue;
333 
334  QString currentAlias = source->attributeDisplayName( attrIdx );
336  col.setAttribute( layerFields.at( attrIdx ).name() );
337  col.setHeading( currentAlias );
338  mColumns.append( col );
339  }
340  }
341  else
342  {
343  //resetting, so add all attributes to columns
344  int idx = 0;
345  for ( const QgsField &field : layerFields )
346  {
347  QString currentAlias = source->attributeDisplayName( idx );
349  col.setAttribute( field.name() );
350  col.setHeading( currentAlias );
351  mColumns.append( col );
352  idx++;
353  }
354  }
355 
356  if ( refresh )
357  {
359  }
360 }
361 
362 void QgsLayoutItemAttributeTable::restoreFieldAliasMap( const QMap<int, QString> &map )
363 {
365  if ( !source )
366  {
367  return;
368  }
369 
370  for ( int i = 0; i < mColumns.count(); i++ )
371  {
372  int attrIdx = source->fields().lookupField( mColumns[i].attribute() );
373  if ( map.contains( attrIdx ) )
374  {
375  mColumns[i].setHeading( map.value( attrIdx ) );
376  }
377  else
378  {
379  mColumns[i].setHeading( source->attributeDisplayName( attrIdx ) );
380  }
381  }
382 }
383 
385 {
386  contents.clear();
387 
388  QgsVectorLayer *layer = sourceLayer();
389  if ( !layer )
390  {
391  //no source layer
392  return false;
393  }
394 
395  const QgsConditionalLayerStyles *conditionalStyles = layer->conditionalStyles();
396 
398  context.setFields( layer->fields() );
399 
400  QgsFeatureRequest req;
401  req.setExpressionContext( context );
402 
403  //prepare filter expression
404  std::unique_ptr<QgsExpression> filterExpression;
405  bool activeFilter = false;
406  if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
407  {
408  filterExpression = qgis::make_unique< QgsExpression >( mFeatureFilter );
409  if ( !filterExpression->hasParserError() )
410  {
411  activeFilter = true;
412  req.setFilterExpression( mFeatureFilter );
413  }
414  }
415 
416  QgsRectangle selectionRect;
417  QgsGeometry visibleRegion;
418  std::unique_ptr< QgsGeometryEngine > visibleMapEngine;
419  if ( mMap && mShowOnlyVisibleFeatures )
420  {
421  visibleRegion = QgsGeometry::fromQPolygonF( mMap->visibleExtentPolygon() );
422  selectionRect = visibleRegion.boundingBox();
423  //transform back to layer CRS
424  QgsCoordinateTransform coordTransform( layer->crs(), mMap->crs(), mLayout->project() );
425  try
426  {
427  selectionRect = coordTransform.transformBoundingBox( selectionRect, QgsCoordinateTransform::ReverseTransform );
428  visibleRegion.transform( coordTransform, QgsCoordinateTransform::ReverseTransform );
429  }
430  catch ( QgsCsException &cse )
431  {
432  Q_UNUSED( cse )
433  return false;
434  }
435  visibleMapEngine.reset( QgsGeometry::createGeometryEngine( visibleRegion.constGet() ) );
436  visibleMapEngine->prepareGeometry();
437  }
438 
439  QgsGeometry atlasGeometry;
440  std::unique_ptr< QgsGeometryEngine > atlasGeometryEngine;
441  if ( mFilterToAtlasIntersection )
442  {
443  atlasGeometry = mLayout->reportContext().currentGeometry( layer->crs() );
444  if ( !atlasGeometry.isNull() )
445  {
446  if ( selectionRect.isNull() )
447  {
448  selectionRect = atlasGeometry.boundingBox();
449  }
450  else
451  {
452  selectionRect = selectionRect.intersect( atlasGeometry.boundingBox() );
453  }
454 
455  atlasGeometryEngine.reset( QgsGeometry::createGeometryEngine( atlasGeometry.constGet() ) );
456  atlasGeometryEngine->prepareGeometry();
457  }
458  }
459 
461  {
462  QgsRelation relation = mLayout->project()->relationManager()->relation( mRelationId );
463  QgsFeature atlasFeature = mLayout->reportContext().feature();
464  req = relation.getRelatedFeaturesRequest( atlasFeature );
465  }
466 
467  if ( !selectionRect.isEmpty() )
468  req.setFilterRect( selectionRect );
469 
470  req.setFlags( mShowOnlyVisibleFeatures ? QgsFeatureRequest::ExactIntersect : QgsFeatureRequest::NoFlags );
471 
473  {
474  //source mode is current atlas feature
475  QgsFeature atlasFeature = mLayout->reportContext().feature();
476  req.setFilterFid( atlasFeature.id() );
477  }
478 
479  for ( const QgsLayoutTableColumn &column : qgis::as_const( mSortColumns ) )
480  {
481  req.addOrderBy( column.attribute(), column.sortOrder() == Qt::AscendingOrder );
482  }
483 
484  QgsFeature f;
485  int counter = 0;
486  QgsFeatureIterator fit = layer->getFeatures( req );
487 
488  mConditionalStyles.clear();
489  mFeatures.clear();
490 
491  QVector< QVector< Cell > > tempContents;
492  QgsLayoutTableContents existingContents;
493 
494  while ( fit.nextFeature( f ) && counter < mMaximumNumberOfFeatures )
495  {
496  context.setFeature( f );
497  //check feature against filter
498  if ( activeFilter && filterExpression )
499  {
500  QVariant result = filterExpression->evaluate( &context );
501  // skip this feature if the filter evaluation is false
502  if ( !result.toBool() )
503  {
504  continue;
505  }
506  }
507 
508  // check against exact map bounds
509  if ( visibleMapEngine )
510  {
511  if ( !f.hasGeometry() )
512  continue;
513 
514  if ( !visibleMapEngine->intersects( f.geometry().constGet() ) )
515  continue;
516  }
517 
518  //check against atlas feature intersection
519  if ( mFilterToAtlasIntersection )
520  {
521  if ( !f.hasGeometry() || !atlasGeometryEngine )
522  {
523  continue;
524  }
525 
526  if ( !atlasGeometryEngine->intersects( f.geometry().constGet() ) )
527  continue;
528  }
529 
530  QgsConditionalStyle rowStyle;
531 
532  if ( mUseConditionalStyling )
533  {
534  const QList<QgsConditionalStyle> styles = QgsConditionalStyle::matchingConditionalStyles( conditionalStyles->rowStyles(), QVariant(), context );
535  rowStyle = QgsConditionalStyle::compressStyles( styles );
536  }
537 
538  // We need to build up two different lists here -- one is a pair of the cell contents along with the cell style.
539  // We need this one because we do a sorting step later, and we need to ensure that the cell styling is attached to the right row and sorted
540  // correctly when this occurs
541  // We also need a list of just the cell contents, so that we can do a quick check for row uniqueness (when the
542  // corresponding option is enabled)
543  QVector< Cell > currentRow;
544  currentRow.reserve( mColumns.count() );
545  QgsLayoutTableRow rowContents;
546  rowContents.reserve( mColumns.count() );
547 
548  for ( const QgsLayoutTableColumn &column : qgis::as_const( mColumns ) )
549  {
550  int idx = layer->fields().lookupField( column.attribute() );
551 
552  QgsConditionalStyle style;
553 
554  if ( idx != -1 )
555  {
556  const QVariant val = f.attributes().at( idx );
557 
558  if ( mUseConditionalStyling )
559  {
560  QList<QgsConditionalStyle> styles = conditionalStyles->fieldStyles( layer->fields().at( idx ).name() );
561  styles = QgsConditionalStyle::matchingConditionalStyles( styles, val, context );
562  styles.insert( 0, rowStyle );
563  style = QgsConditionalStyle::compressStyles( styles );
564  }
565 
566  QVariant v = replaceWrapChar( val );
567  currentRow << Cell( v, style, f );
568  rowContents << v;
569  }
570  else
571  {
572  // Lets assume it's an expression
573  std::unique_ptr< QgsExpression > expression = qgis::make_unique< QgsExpression >( column.attribute() );
574  context.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "row_number" ), counter + 1, true ) );
575  expression->prepare( &context );
576  QVariant value = expression->evaluate( &context );
577 
578  currentRow << Cell( value, rowStyle, f );
579  rowContents << value;
580  }
581  }
582 
583  if ( mShowUniqueRowsOnly )
584  {
585  if ( contentsContainsRow( existingContents, rowContents ) )
586  continue;
587  }
588 
589  tempContents << currentRow;
590  existingContents << rowContents;
591  ++counter;
592  }
593 
594  // build final table contents
595  contents.reserve( tempContents.size() );
596  mConditionalStyles.reserve( tempContents.size() );
597  mFeatures.reserve( tempContents.size() );
598  for ( auto it = tempContents.constBegin(); it != tempContents.constEnd(); ++it )
599  {
600  QgsLayoutTableRow row;
601  QList< QgsConditionalStyle > rowStyles;
602  row.reserve( it->size() );
603  rowStyles.reserve( it->size() );
604 
605  for ( auto cellIt = it->constBegin(); cellIt != it->constEnd(); ++cellIt )
606  {
607  row << cellIt->content;
608  rowStyles << cellIt->style;
609  if ( cellIt == it->constBegin() )
610  mFeatures << cellIt->feature;
611  }
612  contents << row;
613  mConditionalStyles << rowStyles;
614  }
615 
617  return true;
618 }
619 
621 {
622  if ( row >= mConditionalStyles.size() )
623  return QgsConditionalStyle();
624 
625  return mConditionalStyles.at( row ).at( column );
626 }
627 
629 {
630  std::unique_ptr< QgsExpressionContextScope >scope( QgsLayoutTable::scopeForCell( row, column ) );
631  scope->setFeature( mFeatures.value( row ) );
632  scope->setFields( scope->feature().fields() );
633  return scope.release();
634 }
635 
637 {
639 
640  if ( mSource == LayerAttributes )
641  {
642  context.appendScope( QgsExpressionContextUtils::layerScope( mVectorLayer.get() ) );
643  }
644 
645  return context;
646 }
647 
649 {
651  if ( !mMap && !mMapUuid.isEmpty() && mLayout )
652  {
653  mMap = qobject_cast< QgsLayoutItemMap *>( mLayout->itemByUuid( mMapUuid, true ) );
654  if ( mMap )
655  {
656  //if we have found a valid map item, listen out to extent changes on it and refresh the table
659  }
660  }
661 }
662 
664 {
666 
669  {
670  mDataDefinedVectorLayer = nullptr;
671 
672  QString currentLayerIdentifier;
673  if ( QgsVectorLayer *currentLayer = mVectorLayer.get() )
674  currentLayerIdentifier = currentLayer->id();
675 
676  const QString layerIdentifier = mDataDefinedProperties.valueAsString( QgsLayoutObject::AttributeTableSourceLayer, context, currentLayerIdentifier );
677  QgsVectorLayer *ddLayer = qobject_cast< QgsVectorLayer * >( QgsLayoutUtils::mapLayerFromString( layerIdentifier, mLayout->project() ) );
678  if ( ddLayer )
679  mDataDefinedVectorLayer = ddLayer;
680  }
681 
683 }
684 
685 QVariant QgsLayoutItemAttributeTable::replaceWrapChar( const QVariant &variant ) const
686 {
687  //avoid converting variants to string if not required (try to maintain original type for sorting)
688  if ( mWrapString.isEmpty() || !variant.toString().contains( mWrapString ) )
689  return variant;
690 
691  QString replaced = variant.toString();
692  replaced.replace( mWrapString, QLatin1String( "\n" ) );
693  return replaced;
694 }
695 
697 {
698  switch ( mSource )
699  {
701  return mLayout->reportContext().layer();
703  {
704  if ( mDataDefinedVectorLayer )
705  return mDataDefinedVectorLayer;
706  else
707  return mVectorLayer.get();
708  }
710  {
711  QgsRelation relation = mLayout->project()->relationManager()->relation( mRelationId );
712  return relation.referencingLayer();
713  }
714  }
715  return nullptr;
716 }
717 
718 void QgsLayoutItemAttributeTable::removeLayer( const QString &layerId )
719 {
720  if ( mVectorLayer && mSource == QgsLayoutItemAttributeTable::LayerAttributes )
721  {
722  if ( layerId == mVectorLayer->id() )
723  {
724  mVectorLayer.setLayer( nullptr );
725  //remove existing columns
726  mColumns.clear();
727  }
728  }
729 }
730 
731 void QgsLayoutItemAttributeTable::setWrapString( const QString &wrapString )
732 {
733  if ( wrapString == mWrapString )
734  {
735  return;
736  }
737 
738  mWrapString = wrapString;
740  emit changed();
741 }
742 
743 bool QgsLayoutItemAttributeTable::writePropertiesToElement( QDomElement &tableElem, QDomDocument &doc, const QgsReadWriteContext &context ) const
744 {
745  if ( !QgsLayoutTable::writePropertiesToElement( tableElem, doc, context ) )
746  return false;
747 
748  tableElem.setAttribute( QStringLiteral( "source" ), QString::number( static_cast< int >( mSource ) ) );
749  tableElem.setAttribute( QStringLiteral( "relationId" ), mRelationId );
750  tableElem.setAttribute( QStringLiteral( "showUniqueRowsOnly" ), mShowUniqueRowsOnly );
751  tableElem.setAttribute( QStringLiteral( "showOnlyVisibleFeatures" ), mShowOnlyVisibleFeatures );
752  tableElem.setAttribute( QStringLiteral( "filterToAtlasIntersection" ), mFilterToAtlasIntersection );
753  tableElem.setAttribute( QStringLiteral( "maxFeatures" ), mMaximumNumberOfFeatures );
754  tableElem.setAttribute( QStringLiteral( "filterFeatures" ), mFilterFeatures ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
755  tableElem.setAttribute( QStringLiteral( "featureFilter" ), mFeatureFilter );
756  tableElem.setAttribute( QStringLiteral( "wrapString" ), mWrapString );
757  tableElem.setAttribute( QStringLiteral( "useConditionalStyling" ), mUseConditionalStyling );
758 
759  if ( mMap )
760  {
761  tableElem.setAttribute( QStringLiteral( "mapUuid" ), mMap->uuid() );
762  }
763 
764  if ( mVectorLayer )
765  {
766  tableElem.setAttribute( QStringLiteral( "vectorLayer" ), mVectorLayer.layerId );
767  tableElem.setAttribute( QStringLiteral( "vectorLayerName" ), mVectorLayer.name );
768  tableElem.setAttribute( QStringLiteral( "vectorLayerSource" ), mVectorLayer.source );
769  tableElem.setAttribute( QStringLiteral( "vectorLayerProvider" ), mVectorLayer.provider );
770  }
771  return true;
772 }
773 
774 bool QgsLayoutItemAttributeTable::readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context )
775 {
776  if ( QgsVectorLayer *prevLayer = sourceLayer() )
777  {
778  //disconnect from previous layer
779  disconnect( prevLayer, &QgsVectorLayer::layerModified, this, &QgsLayoutTable::refreshAttributes );
780  }
781 
782  if ( !QgsLayoutTable::readPropertiesFromElement( itemElem, doc, context ) )
783  return false;
784 
785  mSource = QgsLayoutItemAttributeTable::ContentSource( itemElem.attribute( QStringLiteral( "source" ), QStringLiteral( "0" ) ).toInt() );
786  mRelationId = itemElem.attribute( QStringLiteral( "relationId" ), QString() );
787 
789  {
790  mCurrentAtlasLayer = mLayout->reportContext().layer();
791  }
792 
793  mShowUniqueRowsOnly = itemElem.attribute( QStringLiteral( "showUniqueRowsOnly" ), QStringLiteral( "0" ) ).toInt();
794  mShowOnlyVisibleFeatures = itemElem.attribute( QStringLiteral( "showOnlyVisibleFeatures" ), QStringLiteral( "1" ) ).toInt();
795  mFilterToAtlasIntersection = itemElem.attribute( QStringLiteral( "filterToAtlasIntersection" ), QStringLiteral( "0" ) ).toInt();
796  mFilterFeatures = itemElem.attribute( QStringLiteral( "filterFeatures" ), QStringLiteral( "false" ) ) == QLatin1String( "true" );
797  mFeatureFilter = itemElem.attribute( QStringLiteral( "featureFilter" ), QString() );
798  mMaximumNumberOfFeatures = itemElem.attribute( QStringLiteral( "maxFeatures" ), QStringLiteral( "5" ) ).toInt();
799  mWrapString = itemElem.attribute( QStringLiteral( "wrapString" ) );
800  mUseConditionalStyling = itemElem.attribute( QStringLiteral( "useConditionalStyling" ), QStringLiteral( "0" ) ).toInt();
801 
802  //map
803  mMapUuid = itemElem.attribute( QStringLiteral( "mapUuid" ) );
804  if ( mMap )
805  {
808  mMap = nullptr;
809  }
810  // setting new mMap occurs in finalizeRestoreFromXml
811 
812  //vector layer
813  QString layerId = itemElem.attribute( QStringLiteral( "vectorLayer" ) );
814  QString layerName = itemElem.attribute( QStringLiteral( "vectorLayerName" ) );
815  QString layerSource = itemElem.attribute( QStringLiteral( "vectorLayerSource" ) );
816  QString layerProvider = itemElem.attribute( QStringLiteral( "vectorLayerProvider" ) );
817  mVectorLayer = QgsVectorLayerRef( layerId, layerName, layerSource, layerProvider );
818  mVectorLayer.resolveWeakly( mLayout->project() );
819 
820  //connect to new layer
821  if ( QgsVectorLayer *newLayer = sourceLayer() )
823 
825 
826  emit changed();
827  return true;
828 }
829 
831 {
832  if ( source == mSource )
833  {
834  return;
835  }
836 
837  QgsVectorLayer *prevLayer = sourceLayer();
838  mSource = source;
839  QgsVectorLayer *newLayer = sourceLayer();
840 
841  if ( newLayer != prevLayer )
842  {
843  //disconnect from previous layer
844  if ( prevLayer )
845  {
846  disconnect( prevLayer, &QgsVectorLayer::layerModified, this, &QgsLayoutTable::refreshAttributes );
847  }
848 
849  //connect to new layer
852  {
853  mCurrentAtlasLayer = newLayer;
854  }
855 
856  //layer has changed as a result of the source change, so reset column list
857  resetColumns();
858  }
859 
861  emit changed();
862 }
QgsVectorLayer::getFeatures
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
Definition: qgsvectorlayer.cpp:993
QgsProject::layerWillBeRemoved
void layerWillBeRemoved(const QString &layerId)
Emitted when a layer is about to be removed from the registry.
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:89
QgsLayoutObject::layout
const QgsLayout * layout() const
Returns the layout the object is attached to.
Definition: qgslayoutobject.cpp:126
qgsexpressioncontextutils.h
qgsconditionalstyle.h
QgsLayoutMultiFrame::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgslayoutmultiframe.cpp:283
QgsFeature::id
Q_GADGET QgsFeatureId id
Definition: qgsfeature.h:64
QgsLayoutItemAttributeTable::setDisplayedFields
void setDisplayedFields(const QStringList &fields, bool refresh=true)
Sets the attributes to display in the table.
Definition: qgslayoutitemattributetable.cpp:313
QgsGeometry::transform
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
Definition: qgsgeometry.cpp:2813
qgslayoutitemattributetable.h
QgsLayoutItemAttributeTable::setFilterToAtlasFeature
void setFilterToAtlasFeature(bool filterToAtlas)
Sets attribute table to only show features which intersect the current atlas feature.
Definition: qgslayoutitemattributetable.cpp:277
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:626
QgsFeatureRequest::addOrderBy
QgsFeatureRequest & addOrderBy(const QString &expression, bool ascending=true)
Adds a new OrderByClause, appending it as the least important one.
Definition: qgsfeaturerequest.cpp:150
QgsLayoutItemAttributeTable::refreshDataDefinedProperty
void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties) override
Refreshes a data defined property for the multi frame by reevaluating the property's value and redraw...
Definition: qgslayoutitemattributetable.cpp:663
QgsLayoutTableContents
QVector< QgsLayoutTableRow > QgsLayoutTableContents
List of QgsLayoutTableRows, representing rows and column cell contents for a QgsLayoutTable.
Definition: qgslayouttable.h:47
_LayerRef::resolveWeakly
TYPE * resolveWeakly(const QgsProject *project, MatchType matchType=MatchType::All)
Resolves the map layer by attempting to find a matching layer in a project using a weak match.
Definition: qgsmaplayerref.h:210
QgsLayoutItemAttributeTable::sourceLayer
QgsVectorLayer * sourceLayer() const
Returns the source layer for the table, considering the table source mode.
Definition: qgslayoutitemattributetable.cpp:696
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsFeatureRequest::ExactIntersect
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
Definition: qgsfeaturerequest.h:83
QgsExpressionContextScope::addVariable
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
Definition: qgsexpressioncontext.cpp:93
QgsVectorLayer::layerModified
void layerModified()
Emitted when modifications has been done on layer.
QgsLayoutMultiFrame::refreshDataDefinedProperty
virtual void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties)
Refreshes a data defined property for the multi frame by reevaluating the property's value and redraw...
Definition: qgslayoutmultiframe.cpp:242
QgsGeometry::isNull
Q_GADGET bool isNull
Definition: qgsgeometry.h:126
QgsLayoutItemMap::extentChanged
void extentChanged()
Emitted when the map's extent changes.
QgsExpressionContext::lastScope
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
Definition: qgsexpressioncontext.cpp:373
qgsfeatureiterator.h
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:265
QgsLayoutMultiFrame::finalizeRestoreFromXml
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
Definition: qgslayoutmultiframe.cpp:310
QgsLayoutItemAttributeTable::icon
QIcon icon() const override
Returns the item's icon.
Definition: qgslayoutitemattributetable.cpp:57
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:67
QgsLayoutItemAttributeTable::relationId
QString relationId() const
Returns the relation id which the table displays child features from.
Definition: qgslayoutitemattributetable.h:119
QgsLayoutObject::mDataDefinedProperties
QgsPropertyCollection mDataDefinedProperties
Definition: qgslayoutobject.h:345
QgsLayoutItemAttributeTable::setFilterFeatures
void setFilterFeatures(bool filter)
Sets whether the feature filter is active for the attribute table.
Definition: qgslayoutitemattributetable.cpp:289
QgsExpressionContext::setFields
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
Definition: qgsexpressioncontext.cpp:553
QgsLayoutTable::writePropertiesToElement
bool writePropertiesToElement(QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Stores multiframe state within an XML DOM element.
Definition: qgslayouttable.cpp:69
QgsLayoutObject::AttributeTableSourceLayer
@ AttributeTableSourceLayer
Attribute table source layer.
Definition: qgslayoutobject.h:201
field
const QgsField & field
Definition: qgsfield.h:456
qgsmapsettings.h
QgsConditionalLayerStyles
The QgsConditionalLayerStyles class holds conditional style information for a layer.
Definition: qgsconditionalstyle.h:39
QgsRectangle::intersect
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
Definition: qgsrectangle.h:312
QgsLayoutObject::changed
void changed()
Emitted when the object's properties change.
QgsLayoutItemAttributeTable::setFeatureFilter
void setFeatureFilter(const QString &expression)
Sets the expression used for filtering features in the table.
Definition: qgslayoutitemattributetable.cpp:301
QgsField::name
QString name
Definition: qgsfield.h:59
QgsConditionalStyle
Conditional styling for a rule.
Definition: qgsconditionalstyle.h:113
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsCoordinateTransform::ReverseTransform
@ ReverseTransform
Transform from destination to source CRS.
Definition: qgscoordinatetransform.h:61
QgsLayoutItemAttributeTable::setUniqueRowsOnly
void setUniqueRowsOnly(bool uniqueOnly)
Sets attribute table to only show unique rows.
Definition: qgslayoutitemattributetable.cpp:253
QgsLayoutItemAttributeTable::setUseConditionalStyling
void setUseConditionalStyling(bool enabled)
Sets whether the attribute table will be rendered using the conditional styling properties of the lin...
Definition: qgslayoutitemattributetable.cpp:208
QgsCoordinateTransform::transformBoundingBox
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, TransformDirection direction=ForwardTransform, bool handle180Crossover=false) const SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:511
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsConditionalStyle::compressStyles
static QgsConditionalStyle compressStyles(const QList< QgsConditionalStyle > &styles)
Compress a list of styles into a single style.
Definition: qgsconditionalstyle.cpp:261
QgsFeatureRequest::setExpressionContext
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
Definition: qgsfeaturerequest.cpp:144
QgsFeatureRequest::setFilterFid
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
Definition: qgsfeaturerequest.cpp:98
QgsLayoutItemAttributeTable::QgsLayoutItemAttributeTable
QgsLayoutItemAttributeTable(QgsLayout *layout)
Constructor for QgsLayoutItemAttributeTable, attached to the specified layout.
Definition: qgslayoutitemattributetable.cpp:39
QgsRelation::referencingLayer
QgsVectorLayer * referencingLayer
Definition: qgsrelation.h:46
QgsFeatureRequest::setFilterExpression
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
Definition: qgsfeaturerequest.cpp:124
qgslayoutframe.h
qgslayoututils.h
QgsFeatureRequest::setFilterRect
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
Definition: qgsfeaturerequest.cpp:92
QgsLayoutTable::mSortColumns
QgsLayoutTableSortColumns mSortColumns
Columns to sort the table.
Definition: qgslayouttable.h:618
_LayerRef::layerId
QString layerId
Original layer ID.
Definition: qgsmaplayerref.h:116
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition: qgsvectorlayer.cpp:3283
QgsLayoutTable::readPropertiesFromElement
bool readPropertiesFromElement(const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context) override
Sets multiframe state from a DOM element.
Definition: qgslayouttable.cpp:133
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:76
QgsLayoutObject::AllProperties
@ AllProperties
All properties for item.
Definition: qgslayoutobject.h:135
QgsLayoutItemAttributeTable::useConditionalStyling
bool useConditionalStyling() const
Returns true if the attribute table will be rendered using the conditional styling properties of the ...
Definition: qgslayoutitemattributetable.cpp:203
qgsgeometryengine.h
QgsFeatureRequest::NoFlags
@ NoFlags
Definition: qgsfeaturerequest.h:80
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
QgsLayoutItemAttributeTable::displayName
QString displayName() const override
Returns the multiframe display name.
Definition: qgslayoutitemattributetable.cpp:67
QgsLayoutTable::contents
QgsLayoutTableContents & contents()
Returns the current contents of the table.
Definition: qgslayouttable.h:550
_LayerRef::setLayer
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
Definition: qgsmaplayerref.h:77
_LayerRef::provider
QString provider
Weak reference to layer provider.
Definition: qgsmaplayerref.h:123
QgsLayoutTable::scopeForCell
virtual QgsExpressionContextScope * scopeForCell(int row, int column) const
Creates a new QgsExpressionContextScope for the cell at row, column.
Definition: qgslayouttable.cpp:994
QgsLayoutItemAttributeTable::RelationChildren
@ RelationChildren
Table shows attributes from related child features.
Definition: qgslayoutitemattributetable.h:47
QgsLayoutItemAttributeTable::LayerAttributes
@ LayerAttributes
Table shows attributes from features in a vector layer.
Definition: qgslayoutitemattributetable.h:45
_LayerRef::name
QString name
Weak reference to layer name.
Definition: qgsmaplayerref.h:121
QgsLayoutItemAttributeTable::type
int type() const override
Returns unique multiframe type id.
Definition: qgslayoutitemattributetable.cpp:52
QgsMapLayer::id
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Definition: qgsmaplayer.cpp:148
QgsLayoutItemAttributeTable::finalizeRestoreFromXml
void finalizeRestoreFromXml() override
Called after all pending items have been restored from XML.
Definition: qgslayoutitemattributetable.cpp:648
QgsLayoutItemAttributeTable::ContentSource
ContentSource
Specifies the content source for the attribute table.
Definition: qgslayoutitemattributetable.h:44
QgsLayoutItemAttributeTable
A layout table subclass that displays attributes from a vector layer.
Definition: qgslayoutitemattributetable.h:35
QgsLayoutTableColumn::setAttribute
void setAttribute(const QString &attribute)
Sets the attribute name or expression used for the column's values.
Definition: qgslayouttablecolumn.h:134
QgsLayoutTable
A class to display a table in the print layout, and allow the table to span over multiple frames.
Definition: qgslayouttable.h:113
QgsLayoutItemAttributeTable::wrapString
QString wrapString() const
Returns the string used to wrap the contents of the table cells by.
Definition: qgslayoutitemattributetable.h:272
QgsLayoutTable::refreshAttributes
virtual void refreshAttributes()
Refreshes the contents shown in the table by querying for new data.
Definition: qgslayouttable.cpp:1031
QgsConditionalStyle::matchingConditionalStyles
static QList< QgsConditionalStyle > matchingConditionalStyles(const QList< QgsConditionalStyle > &styles, const QVariant &value, QgsExpressionContext &context)
Find and return the matching styles for the value and feature.
Definition: qgsconditionalstyle.cpp:238
qgsrelationmanager.h
QgsGeometry::constGet
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Definition: qgsgeometry.cpp:128
QgsFeature::attributes
QgsAttributes attributes
Definition: qgsfeature.h:65
qgslayout.h
QgsLayoutItemMap::crs
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used for rendering the map.
Definition: qgslayoutitemmap.cpp:292
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition: qgsexpressioncontext.h:112
QgsAbstractPropertyCollection::valueAsString
QString valueAsString(int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a string.
Definition: qgspropertycollection.cpp:42
QgsLayoutItemAttributeTable::conditionalCellStyle
QgsConditionalStyle conditionalCellStyle(int row, int column) const override
Returns the conditional style to use for the cell at row, column.
Definition: qgslayoutitemattributetable.cpp:620
QgsLayoutTable::recalculateTableSize
void recalculateTableSize()
Recalculates and updates the size of the table and all table frames.
Definition: qgslayouttable.cpp:1530
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:490
qgsvectorlayer.h
QgsLayoutTableColumn::setHeading
void setHeading(const QString &heading)
Sets the heading for a column, which is the value displayed in the column's header cell.
Definition: qgslayouttablecolumn.h:86
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:318
QgsLayoutUtils::mapLayerFromString
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProject *project)
Resolves a string into a map layer from a given project.
Definition: qgslayoututils.cpp:413
QgsConditionalLayerStyles::rowStyles
QgsConditionalStyles rowStyles() const
Returns a list of row styles associated with the layer.
Definition: qgsconditionalstyle.cpp:27
QgsLayoutItemAttributeTable::create
static QgsLayoutItemAttributeTable * create(QgsLayout *layout)
Returns a new QgsLayoutItemAttributeTable for the specified parent layout.
Definition: qgslayoutitemattributetable.cpp:62
QgsLayoutItemAttributeTable::setMaximumNumberOfFeatures
void setMaximumNumberOfFeatures(int features)
Sets the maximum number of features shown by the table.
Definition: qgslayoutitemattributetable.cpp:241
QgsGeometry::createGeometryEngine
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
Definition: qgsgeometry.cpp:3636
QgsLayoutItem::uuid
virtual QString uuid() const
Returns the item identification string.
Definition: qgslayoutitem.h:343
QgsRelation::getRelatedFeaturesRequest
QgsFeatureRequest getRelatedFeaturesRequest(const QgsFeature &feature) const
Creates a request to return all the features on the referencing (child) layer which have a foreign ke...
Definition: qgsrelation.cpp:191
qgsgeometry.h
QgsLayoutItemAttributeTable::setMap
void setMap(QgsLayoutItemMap *map)
Sets a layout map to use to limit the extent of features shown in the attribute table.
Definition: qgslayoutitemattributetable.cpp:220
QgsLayoutItemAttributeTable::setWrapString
void setWrapString(const QString &wrapString)
Sets a string to wrap the contents of the table cells by.
Definition: qgslayoutitemattributetable.cpp:731
QgsLayoutObject::mLayout
QPointer< QgsLayout > mLayout
Definition: qgslayoutobject.h:343
QgsFeatureIterator::nextFeature
bool nextFeature(QgsFeature &f)
Definition: qgsfeatureiterator.h:374
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
_LayerRef::source
QString source
Weak reference to layer public source.
Definition: qgsmaplayerref.h:119
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:199
QgsLayoutItemMap::mapRotationChanged
void mapRotationChanged(double newRotation)
Emitted when the map's rotation changes.
qgslayouttablecolumn.h
QgsLayoutItemAttributeTable::getTableContents
bool getTableContents(QgsLayoutTableContents &contents) override
Queries the attribute table's vector layer for attributes to show in the table.
Definition: qgslayoutitemattributetable.cpp:384
QgsLayoutItemAttributeTable::AtlasFeature
@ AtlasFeature
Table shows attributes from the current atlas feature.
Definition: qgslayoutitemattributetable.h:46
QgsVectorLayer::conditionalStyles
QgsConditionalLayerStyles * conditionalStyles() const
Returns the conditional styles that are set for this layer.
Definition: qgsvectorlayer.cpp:988
QgsLayoutTable::contentsContainsRow
bool contentsContainsRow(const QgsLayoutTableContents &contents, const QgsLayoutTableRow &row) const
Checks whether a table contents contains a given row.
Definition: qgslayouttable.cpp:1539
QgsRelation
Definition: qgsrelation.h:42
QgsLayoutItemAttributeTable::setRelationId
void setRelationId(const QString &id)
Sets the relation id from which to display child features.
Definition: qgslayoutitemattributetable.cpp:102
QgsVectorLayerRef
_LayerRef< QgsVectorLayer > QgsVectorLayerRef
Definition: qgsvectorlayerref.h:23
QgsLayoutItemAttributeTable::setVectorLayer
void setVectorLayer(QgsVectorLayer *layer)
Sets the vector layer from which to display feature attributes.
Definition: qgslayoutitemattributetable.cpp:72
QgsGeometry::boundingBox
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Definition: qgsgeometry.cpp:996
QgsConditionalLayerStyles::fieldStyles
QList< QgsConditionalStyle > fieldStyles(const QString &fieldName) const
Returns the conditional styles set for the field with matching fieldName.
Definition: qgsconditionalstyle.cpp:50
qgsexception.h
QgsGeometry::fromQPolygonF
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
Definition: qgsgeometry.cpp:3072
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsLayoutItemAttributeTable::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgslayoutitemattributetable.cpp:636
QgsLayoutTableRow
QVector< QVariant > QgsLayoutTableRow
List of QVariants, representing a the contents of a single row in a QgsLayoutTable.
Definition: qgslayouttable.h:30
QgsLayoutTable::mColumns
QgsLayoutTableColumns mColumns
Columns to show in table.
Definition: qgslayouttable.h:615
QgsLayoutTableColumn
Stores properties of a column for a QgsLayoutTable.
Definition: qgslayouttablecolumn.h:37
QgsLayoutReportContext::layerChanged
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
QgsFields::lookupField
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Definition: qgsfields.cpp:344
QgsExpressionContextScope::StaticVariable
Single variable definition for use within a QgsExpressionContextScope.
Definition: qgsexpressioncontext.h:119
QgsLayoutItemAttributeTable::readPropertiesFromElement
bool readPropertiesFromElement(const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context) override
Sets multiframe state from a DOM element.
Definition: qgslayoutitemattributetable.cpp:774
QgsFields::at
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
Definition: qgsfields.cpp:163
QgsLayoutItemAttributeTable::setDisplayOnlyVisibleFeatures
void setDisplayOnlyVisibleFeatures(bool visibleOnly)
Sets the attribute table to only show features which are visible in a map item.
Definition: qgslayoutitemattributetable.cpp:265
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:265
QgsLayoutItemRegistry::LayoutAttributeTable
@ LayoutAttributeTable
Attribute table.
Definition: qgslayoutitemregistry.h:333
QgsRectangle::isEmpty
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:437
QgsFeatureRequest::setFlags
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
Definition: qgsfeaturerequest.cpp:179
QgsLayoutTable::refresh
void refresh() override
Definition: qgslayouttable.cpp:279
QgsLayoutItemAttributeTable::writePropertiesToElement
bool writePropertiesToElement(QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Stores multiframe state within an XML DOM element.
Definition: qgslayoutitemattributetable.cpp:743
QgsRectangle::isNull
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
Definition: qgsrectangle.h:447
QgsLayoutItemAttributeTable::resetColumns
void resetColumns()
Resets the attribute table's columns to match the vector layer's fields.
Definition: qgslayoutitemattributetable.cpp:164
qgsproject.h
QgsLayoutItemAttributeTable::source
ContentSource source() const
Returns the source for attributes shown in the table body.
Definition: qgslayoutitemattributetable.h:76
QgsLayoutItemAttributeTable::map
QgsLayoutItemMap * map() const
Returns the layout map whose extents are controlling the features shown in the table.
Definition: qgslayoutitemattributetable.h:144
QgsLayoutItemAttributeTable::scopeForCell
QgsExpressionContextScope * scopeForCell(int row, int column) const override
Creates a new QgsExpressionContextScope for the cell at row, column.
Definition: qgslayoutitemattributetable.cpp:628
QgsLayoutItemAttributeTable::setSource
void setSource(ContentSource source)
Sets the source for attributes to show in table body.
Definition: qgslayoutitemattributetable.cpp:830
QgsLayoutObject::DataDefinedProperty
DataDefinedProperty
Data defined properties for different item types.
Definition: qgslayoutobject.h:133
QgsLayoutItemMap::visibleExtentPolygon
QPolygonF visibleExtentPolygon() const
Returns a polygon representing the current visible map extent, considering map extents and rotation.
Definition: qgslayoutitemmap.cpp:287
_LayerRef::get
TYPE * get() const
Returns a pointer to the layer, or nullptr if the reference has not yet been matched to a layer.
Definition: qgsmaplayerref.h:107
qgslayoutitemmap.h
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:521
QgsField
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:50