16 #ifndef QGSLAYERTREEMODEL_H 17 #define QGSLAYERTREEMODEL_H 19 #include "qgis_core.h" 20 #include <QAbstractItemModel> 58 if ( sipCpp->inherits(
"QgsLayerTreeModel" ) )
59 sipType = sipType_QgsLayerTreeModel;
78 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
79 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
80 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
81 QModelIndex parent(
const QModelIndex &child )
const override;
82 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
83 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
84 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
85 Qt::DropActions supportedDropActions()
const override;
86 QStringList mimeTypes()
const override;
87 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
88 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
89 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
97 ShowLegendAsTree = 0x0004,
98 DeferredLegendInvalidation = 0x0008,
99 UseEmbeddedWidgets = 0x0010,
102 AllowNodeReorder = 0x1000,
103 AllowNodeRename = 0x2000,
104 AllowNodeChangeVisibility = 0x4000,
105 AllowLegendChangeState = 0x8000,
106 ActionHierarchical = 0x10000,
108 Q_DECLARE_FLAGS( Flags,
Flag )
113 void setFlag(
Flag f,
bool on = true );
117 bool testFlag(
Flag f ) const;
132 QList<
QgsLayerTreeNode *> indexes2nodes( const QModelIndexList &list,
bool skipInternal = false ) const;
195 QModelIndex currentIndex() const;
197 void setCurrentIndex( const QModelIndex ¤tIndex );
200 void setLayerTreeNodeFont(
int nodeType, const QFont &font );
202 QFont layerTreeNodeFont(
int nodeType ) const;
205 void setAutoCollapseLegendNodes(
int nodeCount ) { mAutoCollapseLegendNodesCount = nodeCount; }
216 void setLegendFilterByScale(
double scale );
256 void setLegendMapViewData(
double mapUnitsPerPixel,
int dpi,
double scale );
263 void legendMapViewData(
double *mapUnitsPerPixel
SIP_OUT,
int *dpi SIP_OUT,
double *scale SIP_OUT )
const;
269 QMap<QString, QString> layerStyleOverrides()
const;
275 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
289 void nodeWillAddChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
290 void nodeAddedChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
291 void nodeWillRemoveChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
292 void nodeRemovedChildren();
302 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
304 void nodeLayerLoaded();
305 void nodeLayerWillBeUnloaded();
306 void layerLegendChanged();
308 void layerNeedsUpdate();
310 void legendNodeDataChanged();
312 void invalidateLegendMapBasedData();
323 void connectToRootNode();
324 void disconnectFromRootNode();
327 void recursivelyEmitDataChanged(
const QModelIndex &index = QModelIndex() );
334 void refreshScaleBasedLayers(
const QModelIndex &index = QModelIndex() );
336 static QIcon iconGroup();
339 QList<QgsLayerTreeModelLegendNode *> filterLegendNodes(
const QList<QgsLayerTreeModelLegendNode *> &nodes );
341 QModelIndex indexOfParentLayerTreeNode(
QgsLayerTreeNode *parentNode )
const;
352 void legendCleanup();
353 void legendInvalidateMapBasedData();
377 QMap<QgsLayerTreeModelLegendNode *, QgsLayerTreeModelLegendNode *>
parents;
379 QMap<QgsLayerTreeModelLegendNode *, QList<QgsLayerTreeModelLegendNode *> >
children;
425 QMap<QgsLayerTreeLayer *, LayerLegendData>
mLegend;
450 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayerTreeModel::Flags )
470 mRuleKey = QStringLiteral(
"embedded-widget-" ) + QUuid::createUuid().toString();
473 QVariant data(
int role )
const override 475 if ( role == RuleKeyRole )
487 #endif // QGSLAYERTREEMODEL_H Class for parsing and evaluation of expressions (formerly called "search strings").
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.
QList< QgsLayerTreeModelLegendNode * > originalNodes
Data structure for storage of legend nodes.
double legendFilterByScale() const
Returns the scale which restricts the legend nodes which are visible.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
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
Sets 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.
int autoCollapseLegendNodes() const
Returns at what number of legend nodes the layer node should be collapsed. -1 means no auto-collapse ...
This class is a base class for nodes in a layer tree.
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) ...
Contains information about the context of a rendering operation.
int mAutoCollapseLegendNodesCount
Minimal number of nodes when legend should be automatically collapsed. -1 = disabled.
#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.