16 #ifndef QGSLAYERTREEMODEL_H 17 #define QGSLAYERTREEMODEL_H 19 #include <QAbstractItemModel> 57 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
58 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
59 QModelIndex
index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
60 QModelIndex parent(
const QModelIndex &child )
const override;
61 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
62 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
63 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
64 Qt::DropActions supportedDropActions()
const override;
65 QStringList mimeTypes()
const override;
66 QMimeData* mimeData(
const QModelIndexList& indexes )
const override;
67 bool dropMimeData(
const QMimeData* data, Qt::DropAction action,
int row,
int column,
const QModelIndex& parent )
override;
68 bool removeRows(
int row,
int count,
const QModelIndex& parent = QModelIndex() )
override;
76 ShowSymbology = 0x0001,
77 ShowRasterPreviewIcon = 0x0002,
78 ShowLegendAsTree = 0x0004,
81 AllowNodeReorder = 0x1000,
82 AllowNodeRename = 0x2000,
83 AllowNodeChangeVisibility = 0x4000,
84 AllowLegendChangeState = 0x8000,
85 AllowSymbologyChangeState = 0x8000,
87 Q_DECLARE_FLAGS( Flags,
Flag )
90 void setFlags( Flags f );
92 void setFlag(
Flag f,
bool on = true );
96 bool testFlag(
Flag f ) const;
106 QList<
QgsLayerTreeNode*> indexes2nodes( const QModelIndexList& list,
bool skipInternal = false ) const;
131 QModelIndex currentIndex() const;
133 void setCurrentIndex( const QModelIndex& currentIndex );
136 void setLayerTreeNodeFont(
int nodeType, const QFont& font );
138 QFont layerTreeNodeFont(
int nodeType ) const;
141 void setAutoCollapseLegendNodes(
int nodeCount ) { mAutoCollapseLegendNodesCount = nodeCount; }
148 void setLegendFilterByScale(
double scaleDenominator );
161 void setLegendMapViewData(
double mapUnitsPerPixel,
int dpi,
double scale );
165 void legendMapViewData(
double *mapUnitsPerPixel,
int *dpi,
double *scale );
169 Q_DECL_DEPRECATED
bool isIndexSymbologyNode(
const QModelIndex& index )
const;
172 Q_DECL_DEPRECATED
QgsLayerTreeLayer* layerNodeForSymbologyNode(
const QModelIndex& index )
const;
183 void nodeWillAddChildren(
QgsLayerTreeNode* node,
int indexFrom,
int indexTo );
184 void nodeAddedChildren(
QgsLayerTreeNode* node,
int indexFrom,
int indexTo );
185 void nodeWillRemoveChildren(
QgsLayerTreeNode* node,
int indexFrom,
int indexTo );
186 void nodeRemovedChildren();
190 void nodeCustomPropertyChanged(
QgsLayerTreeNode* node,
const QString& key );
192 void nodeLayerLoaded();
193 void nodeLayerWillBeUnloaded();
194 void layerLegendChanged();
196 void layerNeedsUpdate();
198 void legendNodeDataChanged();
209 void connectToRootNode();
210 void disconnectFromRootNode();
213 void recursivelyEmitDataChanged(
const QModelIndex& index = QModelIndex() );
215 static const QIcon& iconGroup();
218 QList<QgsLayerTreeModelLegendNode*> filterLegendNodes(
const QList<QgsLayerTreeModelLegendNode*>& nodes );
220 QModelIndex indexOfParentLayerTreeNode(
QgsLayerTreeNode* parentNode )
const;
231 void legendCleanup();
232 void legendInvalidateMapBasedData();
252 QMap<QgsLayerTreeModelLegendNode*, QgsLayerTreeModelLegendNode*>
parents;
254 QMap<QgsLayerTreeModelLegendNode*, QList<QgsLayerTreeModelLegendNode*> >
children;
273 QMap<QgsLayerTreeLayer*, LayerLegendData>
mLegend;
289 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayerTreeModel::Flags )
291 #endif // QGSLAYERTREEMODEL_H Layer tree group node serves as a container for layers and further groups.
double mLegendMapViewMupp
QList< QgsLayerTreeModelLegendNode * > originalNodes
Data structure for storage of legend nodes.
Base class for all map layer types.
double legendFilterByScale() const
LayerLegendTree * tree
Optional pointer to a tree structure - see LayerLegendTree for details.
Structure that stores tree representation of map layer's legend.
QScopedPointer< QgsMapSettings > mLegendFilterByMapSettings
QScopedPointer< QgsMapHitTest > mLegendFilterByMapHitTest
Flags mFlags
Set of flags for the model.
The QgsMapSettings class contains configuration for rendering of the map.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
QMap< QgsLayerTreeModelLegendNode *, QgsLayerTreeModelLegendNode * > parents
Pointer to parent for each active node. Top-level nodes have null parent. Pointers are not owned...
int autoCollapseLegendNodes() const
Return 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.
QgsLayerTreeGroup * mRootNode
Pointer to the root node of the layer tree. Not owned by the model.
QMap< QgsLayerTreeModelLegendNode *, QList< QgsLayerTreeModelLegendNode * > > children
List of children for each active node. Top-level nodes are under null pointer key. Pointers are not owned.
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)
const QgsMapSettings * legendFilterByMap() const
int mAutoCollapseLegendNodesCount
Minimal number of nodes when legend should be automatically collapsed. -1 = disabled.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
QList< QgsLayerTreeModelLegendNode * > activeNodes
Active legend nodes.
Q_DECL_DEPRECATED void refreshLayerSymbology(QgsLayerTreeLayer *nodeLayer)
Q_DECL_DEPRECATED void setAutoCollapseSymbologyNodes(int nodeCount)
QMap< QgsLayerTreeLayer *, LayerLegendData > mLegend
Per layer data about layer's legend nodes.
Layer tree node points to a map layer.
Q_DECL_DEPRECATED int autoCollapseSymbologyNodes() const
Structure that stores all data associated with one map layer.