16 #ifndef QGSLAYERTREEMODEL_H 17 #define QGSLAYERTREEMODEL_H 19 #include "qgis_core.h" 20 #include <QAbstractItemModel> 60 if ( sipCpp->inherits(
"QgsLayerTreeModel" ) )
61 sipType = sipType_QgsLayerTreeModel;
80 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
81 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
82 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
83 QModelIndex parent(
const QModelIndex &child )
const override;
84 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
85 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
86 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
87 Qt::DropActions supportedDropActions()
const override;
88 QStringList mimeTypes()
const override;
89 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
90 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
91 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
99 ShowLegendAsTree = 0x0004,
100 DeferredLegendInvalidation = 0x0008,
101 UseEmbeddedWidgets = 0x0010,
104 AllowNodeReorder = 0x1000,
105 AllowNodeRename = 0x2000,
106 AllowNodeChangeVisibility = 0x4000,
107 AllowLegendChangeState = 0x8000,
108 ActionHierarchical = 0x10000,
110 Q_DECLARE_FLAGS( Flags,
Flag )
113 void setFlags( QgsLayerTreeModel::Flags
f );
115 void setFlag(
Flag f,
bool on =
true );
119 bool testFlag(
Flag f )
const;
134 QList<QgsLayerTreeNode *> indexes2nodes(
const QModelIndexList &list,
bool skipInternal =
false )
const;
156 QList<QgsLayerTreeModelLegendNode *> layerLegendNodes(
QgsLayerTreeLayer *nodeLayer,
bool skipNodeEmbeddedInParent =
false );
163 QList<QgsLayerTreeModelLegendNode *> layerOriginalLegendNodes(
QgsLayerTreeLayer *nodeLayer );
197 QModelIndex currentIndex()
const;
199 void setCurrentIndex(
const QModelIndex ¤tIndex );
202 void setLayerTreeNodeFont(
int nodeType,
const QFont &font );
204 QFont layerTreeNodeFont(
int nodeType )
const;
218 void setLegendFilterByScale(
double scale );
258 void setLegendMapViewData(
double mapUnitsPerPixel,
int dpi,
double scale );
265 void legendMapViewData(
double *mapUnitsPerPixel
SIP_OUT,
int *dpi SIP_OUT,
double *scale SIP_OUT )
const;
271 QMap<QString, QString> layerStyleOverrides()
const;
277 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
280 void nodeWillAddChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
281 void nodeAddedChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
282 void nodeWillRemoveChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
283 void nodeRemovedChildren();
293 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
295 void nodeLayerLoaded();
296 void nodeLayerWillBeUnloaded();
297 void layerLegendChanged();
299 void layerNeedsUpdate();
301 void legendNodeDataChanged();
303 void invalidateLegendMapBasedData();
314 void connectToRootNode();
315 void disconnectFromRootNode();
318 void recursivelyEmitDataChanged(
const QModelIndex &index = QModelIndex() );
325 void refreshScaleBasedLayers(
const QModelIndex &index = QModelIndex() );
327 static QIcon iconGroup();
330 QList<QgsLayerTreeModelLegendNode *> filterLegendNodes(
const QList<QgsLayerTreeModelLegendNode *> &nodes );
332 QModelIndex indexOfParentLayerTreeNode(
QgsLayerTreeNode *parentNode )
const;
343 void legendCleanup();
344 void legendInvalidateMapBasedData();
368 QMap<QgsLayerTreeModelLegendNode *, QgsLayerTreeModelLegendNode *>
parents;
370 QMap<QgsLayerTreeModelLegendNode *, QList<QgsLayerTreeModelLegendNode *> >
children;
416 QMap<QgsLayerTreeLayer *, LayerLegendData>
mLegend;
441 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayerTreeModel::Flags )
461 mRuleKey = QStringLiteral(
"embedded-widget-" ) + QUuid::createUuid().toString();
464 QVariant data(
int role )
const override 466 if ( role == RuleKeyRole )
478 #endif // QGSLAYERTREEMODEL_H Layer tree group node serves as a container for layers and further groups.
double mLegendMapViewMupp
QMap< QgsLayerTreeLayer *, LayerLegendData > mLegend
Per layer data about layer's legend nodes.
Base class for all map layer types.
QList< QgsLayerTreeModelLegendNode * > originalNodes
Data structure for storage of legend nodes.
Structure that stores tree representation of map layer's legend.
A geometry is the spatial representation of a feature.
QMap< QgsLayerTreeModelLegendNode *, QList< QgsLayerTreeModelLegendNode * > > children
List of children for each active node. Top-level nodes are under null pointer key. Pointers are not owned.
std::unique_ptr< QgsMapHitTest > mLegendFilterHitTest
bool mLegendFilterUsesExtent
whether to use map filtering
Flags mFlags
Set of flags for the model.
std::unique_ptr< QgsMapSettings > mLegendFilterMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
QTimer mDeferLegendInvalidationTimer
Namespace with helper functions for layer tree operations.
This class is a base class for nodes in a layer tree.
int autoCollapseLegendNodes() const
Return at what number of legend nodes the layer node should be collapsed. -1 means no auto-collapse (...
Class that runs a hit test with given map settings.
QPersistentModelIndex mCurrentIndex
Current index - will be underlined.
double mLegendMapViewScale
double mLegendFilterByScale
scale denominator for filtering of legend nodes (<= 0 means no filtering)
QMap< QgsLayerTreeModelLegendNode *, QgsLayerTreeModelLegendNode * > parents
Pointer to parent for each active node. Top-level nodes have null parent. Pointers are not owned...
const QgsMapSettings * legendFilterMapSettings() const
Returns the current map settings used for the current legend filter (or null if none is enabled) ...
void setAutoCollapseLegendNodes(int nodeCount)
Set at what number of legend nodes the layer node should be collapsed. Setting -1 disables the auto-c...
Contains information about the context of a rendering operation.
int mAutoCollapseLegendNodesCount
Minimal number of nodes when legend should be automatically collapsed. -1 = disabled.
double legendFilterByScale() const
Returns the scale which restricts the legend nodes which are visible.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
QList< QgsLayerTreeModelLegendNode * > activeNodes
Active legend nodes.
QMap< QString, QString > mLayerStyleOverrides
Overrides of map layers' styles: key = layer ID, value = style XML.
Layer tree node points to a map layer.
Structure that stores all data associated with one map layer.