33#include <QContextMenuEvent> 
   51    case Qt::DecorationRole:
 
   62          std::unique_ptr< QgsSymbol > symbol;
 
   63          switch ( layer->type() )
 
   65            case Qgis::LayerType::Vector:
 
   68              QgsVectorLayer *vLayer = qobject_cast< QgsVectorLayer * >( layer );
 
   70              switch ( elevationProperties->
type() )
 
   79                      symbol.reset( markerSymbol->clone() );
 
   87                      symbol.reset( fillSymbol->clone() );
 
   95                      symbol.reset( lineSymbol->clone() );
 
  103                      if ( renderer->symbol()->type() == symbol->type() )
 
  106                        symbol.reset( renderer->symbol()->clone() );
 
  111                        symbol->setColor( renderer->symbol()->color() );
 
  112                        symbol->setOpacity( renderer->symbol()->opacity() );
 
  129                        symbol.reset( lineSymbol->clone() );
 
  136                        symbol.reset( fillSymbol->clone() );
 
  146            case Qgis::LayerType::Raster:
 
  154                    symbol.reset( lineSymbol->clone() );
 
  161                    symbol.reset( fillSymbol->clone() );
 
  168            case Qgis::LayerType::Mesh:
 
  176                    symbol.reset( lineSymbol->clone() );
 
  183                    symbol.reset( fillSymbol->clone() );
 
  190            case Qgis::LayerType::Plugin:
 
  191            case Qgis::LayerType::VectorTile:
 
  192            case Qgis::LayerType::Annotation:
 
  193            case Qgis::LayerType::PointCloud:
 
  194            case Qgis::LayerType::Group:
 
  207    case Qt::ToolTipRole:
 
  216            !layer->title().isEmpty() ? layer->title() :
 
  217            !layer->shortName().isEmpty() ? layer->shortName() :
 
  220          title = 
"<b>" + title.toHtmlEscaped() + 
"</b>";
 
  225          const QString elevationPropertiesSummary = layer->elevationProperties() ? layer->elevationProperties()->htmlSummary() : QString();
 
  226          if ( !elevationPropertiesSummary.isEmpty( ) )
 
  227            parts << elevationPropertiesSummary;
 
  229          return parts.join( QLatin1String( 
"<br/>" ) );
 
  245    if ( role == Qt::CheckStateRole )
 
  247      const bool checked = 
static_cast< Qt::CheckState 
>( value.toInt() ) == Qt::Checked;
 
  250        layer->setCustomProperty( QStringLiteral( 
"_include_in_elevation_profiles" ), checked );
 
  260  if ( action == Qt::IgnoreAction )
 
  263  if ( !
data->hasFormat( QStringLiteral( 
"application/qgis.layertreemodeldata" ) ) )
 
  267  if ( action == Qt::MoveAction )
 
  269    const QString source = 
data->data( QStringLiteral( 
"application/qgis.layertree.source" ) );
 
  270    if ( source.isEmpty() || source != QStringLiteral( 
":0x%1" ).arg( 
reinterpret_cast<quintptr
>( 
this ), 2 * QT_POINTER_SIZE, 16, QLatin1Char( 
'0' ) ) )
 
  276  return QgsLayerTreeModel::canDropMimeData( 
data, action, row, column, 
parent );
 
  281  if ( action == Qt::IgnoreAction )
 
  284  if ( !
data->hasFormat( QStringLiteral( 
"application/qgis.layertreemodeldata" ) ) )
 
  288  const QString source = 
data->data( QStringLiteral( 
"application/qgis.layertree.source" ) );
 
  289  if ( source.isEmpty() || source != QStringLiteral( 
":0x%1" ).arg( 
reinterpret_cast<quintptr
>( 
this ), 2 * QT_POINTER_SIZE, 16, QLatin1Char( 
'0' ) ) )
 
  291    if ( action == Qt::CopyAction )
 
  293      QByteArray encodedLayerTreeData = 
data->data( QStringLiteral( 
"application/qgis.layertreemodeldata" ) );
 
  295      QDomDocument layerTreeDoc;
 
  296      if ( !layerTreeDoc.setContent( QString::fromUtf8( encodedLayerTreeData ) ) )
 
  299      QDomElement rootLayerTreeElem = layerTreeDoc.documentElement();
 
  300      if ( rootLayerTreeElem.tagName() != QLatin1String( 
"layer_tree_model_data" ) )
 
  303      QList<QgsMapLayer *> layersToAdd;
 
  305      QDomElement elem = rootLayerTreeElem.firstChildElement();
 
  306      while ( !elem.isNull() )
 
  311          if ( 
QgsMapLayer *layer = qobject_cast< QgsLayerTreeLayer * >( node.get() )->layer() )
 
  313            layersToAdd << layer;
 
  316        elem = elem.nextSiblingElement();
 
  319      if ( !layersToAdd.empty() )
 
  338    mimeData->setData( QStringLiteral( 
"application/qgis.restrictlayertreemodelsubclass" ), 
"QgsElevationProfileLayerTreeModel" );
 
  349  : QSortFilterProxyModel( parent )
 
  352  setSourceModel( mModel );
 
  353  setDynamicSortFilter( 
true );
 
  358  const QModelIndex sourceIndex = mModel->
index( sourceRow, 0, sourceParent );
 
  361    switch ( node->nodeType() )
 
  367          if ( 
QgsMapLayer *layer = layerTreeLayer->layer() )
 
  370            if ( !layer->elevationProperties() || !layer->elevationProperties()->hasElevation() )
 
  388      if ( 
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layerTreeLayer->layer() ) )
 
  390        if ( !qgis::down_cast< QgsVectorLayerElevationProperties * >( layer->elevationProperties() )->respectLayerSymbology() )
 
  414  : QTreeView( parent )
 
  415  , mLayerTree( rootNode )
 
  421  setHeaderHidden( 
true );
 
  423  setDragEnabled( 
true );
 
  424  setAcceptDrops( 
true );
 
  425  setDropIndicatorShown( 
true );
 
  426  setExpandsOnDoubleClick( 
false );
 
  429  header()->setStretchLastSection( 
false );
 
  430  header()->setSectionResizeMode( QHeaderView::ResizeToContents );
 
  433  setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
 
  435  setDefaultDropAction( Qt::MoveAction );
 
  437  setModel( mProxyModel );
 
  446      return layerTreeLayerNode->layer();
 
  454  const QList< QgsMapLayer * > layers = project->
layers< 
QgsMapLayer * >().toList();
 
  461    Qgis::LayerType::Raster,
 
  462    Qgis::LayerType::Mesh,
 
  463    Qgis::LayerType::Vector,
 
  464    Qgis::LayerType::PointCloud
 
  467  std::reverse( sortedLayers.begin(), sortedLayers.end() );
 
  468  for ( 
QgsMapLayer *layer : std::as_const( sortedLayers ) )
 
  472    if ( layer->customProperty( QStringLiteral( 
"_include_in_elevation_profiles" ) ).isValid() )
 
  474      node->
setItemVisibilityChecked( layer->customProperty( QStringLiteral( 
"_include_in_elevation_profiles" ) ).toBool() );
 
  478      node->
setItemVisibilityChecked( layer->elevationProperties() && layer->elevationProperties()->showByDefaultInElevationProfilePlots() );
 
  490  header()->setMinimumSectionSize( viewport()->width() );
 
  491  QTreeView::resizeEvent( event );
 
@ ContinuousSurface
The features should be treated as representing values on a continuous surface (eg contour lines)
 
@ IndividualFeatures
Treat each feature as an individual object (eg buildings)
 
@ Line
The elevation surface will be rendered using a line symbol.
 
@ FillBelow
The elevation surface will be rendered using a fill symbol below the surface level.
 
@ FillAbove
The elevation surface will be rendered using a fill symbol above the surface level (since QGIS 3....
 
A layer tree model subclass for elevation profiles.
 
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 
void addLayers(const QList< QgsMapLayer * > &layers)
Emitted when layers should be added to the profile, e.g.
 
QgsElevationProfileLayerTreeModel(QgsLayerTree *rootNode, QObject *parent=nullptr)
Construct a new tree model with given layer tree (root node must not be nullptr).
 
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 
QMimeData * mimeData(const QModelIndexList &indexes) const override
 
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
 
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
 
A proxy model for elevation profiles.
 
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
 
QgsElevationProfileLayerTreeProxyModel(QgsElevationProfileLayerTreeModel *model, QObject *parent=nullptr)
Constructor for QgsElevationProfileLayerTreeProxyModel.
 
QgsElevationProfileLayerTreeProxyModel * proxyModel()
Returns the view's proxy model.
 
QgsMapLayer * indexToLayer(const QModelIndex &index)
Converts a view index to a map layer.
 
QgsElevationProfileLayerTreeView(QgsLayerTree *rootNode, QWidget *parent=nullptr)
Construct a new tree view with given layer tree (root node must not be nullptr).
 
void resizeEvent(QResizeEvent *event) override
 
void addLayers(const QList< QgsMapLayer * > &layers)
Emitted when layers should be added to the profile, e.g.
 
void populateInitialLayers(QgsProject *project)
Initially populates the tree view using layers from a project.
 
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
 
QgsLayerTreeLayer * addLayer(QgsMapLayer *layer)
Append a new layer node for given map layer.
 
Layer tree node points to a map layer.
 
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
 
QgsLayerTreeLayer * layerNode() const
Returns pointer to the parent layer node.
 
The QgsLayerTreeModel class is model implementation for Qt item views framework.
 
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
 
QModelIndex parent(const QModelIndex &child) const override
 
void setFlag(Flag f, bool on=true)
Enable or disable a model flag.
 
QgsRenderContext * createTemporaryRenderContext() const
Returns a temporary render context.
 
QgsLayerTreeNode * index2node(const QModelIndex &index) const
Returns layer tree node for given index.
 
QMimeData * mimeData(const QModelIndexList &indexes) const override
 
static int scaleIconSize(int standardSize)
Scales an layer tree model icon size to compensate for display pixel density, making the icon size hi...
 
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
static QgsLayerTreeModelLegendNode * index2legendNode(const QModelIndex &index)
Returns legend node for given index.
 
@ AllowNodeChangeVisibility
Allow user to set node visibility with a checkbox.
 
@ ShowLegendAsTree
For legends that support it, will show them in a tree instead of a list (needs also ShowLegend)....
 
@ AllowNodeReorder
Allow reordering with drag'n'drop.
 
@ AllowLegendChangeState
Allow check boxes for legend nodes (if supported by layer's legend)
 
This class is a base class for nodes in a layer tree.
 
@ NodeGroup
Container of other groups and layers.
 
@ NodeLayer
Leaf node pointing to a layer.
 
static QgsLayerTreeNode * readXml(QDomElement &element, const QgsReadWriteContext &context)
Read layer tree from XML.
 
NodeType nodeType() const
Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree...
 
void setItemVisibilityChecked(bool checked)
Check or uncheck a node (independently of its ancestors or children)
 
Namespace with helper functions for layer tree operations.
 
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
 
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
 
A line symbol type, for rendering LineString and MultiLineString geometries.
 
static QList< QgsMapLayer * > sortLayersByType(const QList< QgsMapLayer * > &layers, const QList< Qgis::LayerType > &order)
Sorts a list of map layers by their layer type, respecting the order of types specified.
 
Base class for all map layer types.
 
A marker symbol type, for rendering Point and MultiPoint geometries.
 
Mesh layer specific subclass of QgsMapLayerElevationProperties.
 
Qgis::ProfileSurfaceSymbology profileSymbology() const
Returns the symbology option used to render the mesh profile in elevation profile plots.
 
QgsLineSymbol * profileLineSymbol() const
Returns the line symbol used to render the mesh profile in elevation profile plots.
 
QgsFillSymbol * profileFillSymbol() const
Returns the fill symbol used to render the mesh profile in elevation profile plots.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
QVector< T > layers() const
Returns a list of registered map layers with a specified layer type.
 
Raster layer specific subclass of QgsMapLayerElevationProperties.
 
QgsLineSymbol * profileLineSymbol() const
Returns the line symbol used to render the raster profile in elevation profile plots.
 
Qgis::ProfileSurfaceSymbology profileSymbology() const
Returns the symbology option used to render the raster profile in elevation profile plots.
 
QgsFillSymbol * profileFillSymbol() const
Returns the fill symbol used to render the raster profile in elevation profile plots.
 
static QPixmap symbolPreviewPixmap(const QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Returns a pixmap preview for a color ramp.
 
Vector layer specific subclass of QgsMapLayerElevationProperties.
 
QgsFillSymbol * profileFillSymbol() const
Returns the symbol used to render polygons for the layer in elevation profile plots.
 
Qgis::VectorProfileType type() const
Returns the type of profile the layer represents.
 
QgsLineSymbol * profileLineSymbol() const
Returns the symbol used to render lines for the layer in elevation profile plots.
 
QgsMarkerSymbol * profileMarkerSymbol() const
Returns the symbol used to render points for the layer in elevation profile plots.
 
Qgis::ProfileSurfaceSymbology profileSymbology() const
Returns the symbology option used to render the vector profile in elevation profile plots.
 
bool respectLayerSymbology() const
Returns true if layer symbology should be respected when rendering elevation profile plots.
 
bool extrusionEnabled() const
Returns true if extrusion is enabled.
 
Represents a vector layer which manages a vector based data sets.
 
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
 
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
 
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)