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 );
298 void nodeWillAddChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
299 void nodeAddedChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
300 void nodeWillRemoveChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
301 void nodeRemovedChildren();
311 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
313 void nodeLayerLoaded();
314 void nodeLayerWillBeUnloaded();
315 void layerLegendChanged();
317 void layerNeedsUpdate();
319 void legendNodeDataChanged();
321 void invalidateLegendMapBasedData();
332 void connectToRootNode();
333 void disconnectFromRootNode();
336 void recursivelyEmitDataChanged(
const QModelIndex &index = QModelIndex() );
343 void refreshScaleBasedLayers(
const QModelIndex &index = QModelIndex(),
double previousScale = 0.0 );
345 static QIcon iconGroup();
348 QList<QgsLayerTreeModelLegendNode *> filterLegendNodes(
const QList<QgsLayerTreeModelLegendNode *> &nodes );
350 QModelIndex indexOfParentLayerTreeNode(
QgsLayerTreeNode *parentNode )
const;
361 void legendCleanup();
362 void legendInvalidateMapBasedData();
388 QMap<QgsLayerTreeModelLegendNode *, QgsLayerTreeModelLegendNode *>
parents;
390 QMap<QgsLayerTreeModelLegendNode *, QList<QgsLayerTreeModelLegendNode *> >
children;
436 QHash<QgsLayerTreeLayer *, LayerLegendData>
mLegend;
462 void legendNodeSizeChanged();
490 mRuleKey = QStringLiteral(
"embedded-widget-" ) + QUuid::createUuid().toString();
493 QVariant
data(
int role )
const override
495 if ( role == RuleKeyRole )
507 #endif // QGSLAYERTREEMODEL_H