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,
100 UseTextFormatting = 0x0020,
103 AllowNodeReorder = 0x1000,
104 AllowNodeRename = 0x2000,
105 AllowNodeChangeVisibility = 0x4000,
106 AllowLegendChangeState = 0x8000,
107 ActionHierarchical = 0x10000,
109 Q_DECLARE_FLAGS( Flags,
Flag )
112 void setFlags( QgsLayerTreeModel::Flags f );
114 void setFlag(
Flag f,
bool on =
true );
118 bool testFlag(
Flag f )
const;
133 QList<QgsLayerTreeNode *> indexes2nodes(
const QModelIndexList &list,
bool skipInternal =
false )
const;
155 QList<QgsLayerTreeModelLegendNode *> layerLegendNodes(
QgsLayerTreeLayer *nodeLayer,
bool skipNodeEmbeddedInParent =
false );
162 QList<QgsLayerTreeModelLegendNode *> layerOriginalLegendNodes(
QgsLayerTreeLayer *nodeLayer );
196 QModelIndex currentIndex()
const;
198 void setCurrentIndex(
const QModelIndex ¤tIndex );
201 void setLayerTreeNodeFont(
int nodeType,
const QFont &font );
203 QFont layerTreeNodeFont(
int nodeType )
const;
217 void setLegendFilterByScale(
double scale );
257 void setLegendMapViewData(
double mapUnitsPerPixel,
int dpi,
double scale );
264 void legendMapViewData(
double *mapUnitsPerPixel
SIP_OUT,
int *dpi SIP_OUT,
double *scale SIP_OUT )
const;
270 QMap<QString, QString> layerStyleOverrides()
const;
276 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
290 void nodeWillAddChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
291 void nodeAddedChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
292 void nodeWillRemoveChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
293 void nodeRemovedChildren();
303 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
305 void nodeLayerLoaded();
306 void nodeLayerWillBeUnloaded();
307 void layerLegendChanged();
309 void layerNeedsUpdate();
311 void legendNodeDataChanged();
313 void invalidateLegendMapBasedData();
324 void connectToRootNode();
325 void disconnectFromRootNode();
328 void recursivelyEmitDataChanged(
const QModelIndex &index = QModelIndex() );
335 void refreshScaleBasedLayers(
const QModelIndex &index = QModelIndex() );
337 static QIcon iconGroup();
340 QList<QgsLayerTreeModelLegendNode *> filterLegendNodes(
const QList<QgsLayerTreeModelLegendNode *> &nodes );
342 QModelIndex indexOfParentLayerTreeNode(
QgsLayerTreeNode *parentNode )
const;
353 void legendCleanup();
354 void legendInvalidateMapBasedData();
378 QMap<QgsLayerTreeModelLegendNode *, QgsLayerTreeModelLegendNode *>
parents;
380 QMap<QgsLayerTreeModelLegendNode *, QList<QgsLayerTreeModelLegendNode *> >
children;
426 QMap<QgsLayerTreeLayer *, LayerLegendData>
mLegend;
451 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayerTreeModel::Flags )
471 mRuleKey = QStringLiteral(
"embedded-widget-" ) + QUuid::createUuid().toString();
474 QVariant data(
int role )
const override 476 if ( role == RuleKeyRole )
488 #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.
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 nullptr 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.
This class is a base class for nodes in a layer tree.
int autoCollapseLegendNodes() const
Returns 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.
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)
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 nullptr parent. Pointers are not owned...
const QgsMapSettings * legendFilterMapSettings() const
Returns the current map settings used for the current legend filter (or nullptr if none is enabled) ...
void setAutoCollapseLegendNodes(int nodeCount)
Sets at what number of legend nodes the layer node should be collapsed. Setting -1 disables the auto-...
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.