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,
102 UseTextFormatting = 0x0020,
105 AllowNodeReorder = 0x1000,
106 AllowNodeRename = 0x2000,
107 AllowNodeChangeVisibility = 0x4000,
108 AllowLegendChangeState = 0x8000,
109 ActionHierarchical = 0x10000,
111 Q_DECLARE_FLAGS( Flags, Flag )
114 void setFlags( QgsLayerTreeModel::Flags f );
116 void setFlag( Flag f,
bool on =
true );
120 bool testFlag( Flag f )
const;
135 QList<QgsLayerTreeNode *> indexes2nodes(
const QModelIndexList &list,
bool skipInternal =
false )
const;
157 QList<QgsLayerTreeModelLegendNode *> layerLegendNodes(
QgsLayerTreeLayer *nodeLayer,
bool skipNodeEmbeddedInParent =
false );
164 QList<QgsLayerTreeModelLegendNode *> layerOriginalLegendNodes(
QgsLayerTreeLayer *nodeLayer );
198 QModelIndex currentIndex()
const;
200 void setCurrentIndex(
const QModelIndex ¤tIndex );
203 void setLayerTreeNodeFont(
int nodeType,
const QFont &font );
205 QFont layerTreeNodeFont(
int nodeType )
const;
219 void setLegendFilterByScale(
double scale );
259 void setLegendMapViewData(
double mapUnitsPerPixel,
int dpi,
double scale );
266 void legendMapViewData(
double *mapUnitsPerPixel
SIP_OUT,
int *dpi
SIP_OUT,
double *scale
SIP_OUT )
const;
272 QMap<QString, QString> layerStyleOverrides()
const;
278 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
297 void messageEmitted(
const QString &message,
Qgis::MessageLevel level = Qgis::MessageLevel::Info,
int duration = 5 );
300 void nodeWillAddChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
301 void nodeAddedChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
302 void nodeWillRemoveChildren(
QgsLayerTreeNode *node,
int indexFrom,
int indexTo );
303 void nodeRemovedChildren();
313 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
315 void nodeLayerLoaded();
316 void nodeLayerWillBeUnloaded();
317 void layerLegendChanged();
323 void layerFlagsChanged();
325 void layerNeedsUpdate();
327 void legendNodeDataChanged();
329 void invalidateLegendMapBasedData();
340 void connectToRootNode();
341 void disconnectFromRootNode();
344 void recursivelyEmitDataChanged(
const QModelIndex &index = QModelIndex() );
351 void refreshScaleBasedLayers(
const QModelIndex &index = QModelIndex(),
double previousScale = 0.0 );
353 static QIcon iconGroup();
356 QList<QgsLayerTreeModelLegendNode *> filterLegendNodes(
const QList<QgsLayerTreeModelLegendNode *> &nodes );
358 QModelIndex indexOfParentLayerTreeNode(
QgsLayerTreeNode *parentNode )
const;
369 void legendCleanup();
370 void legendInvalidateMapBasedData();
386 QPersistentModelIndex mCurrentIndex;
388 int mAutoCollapseLegendNodesCount;
404 QMap<QgsLayerTreeModelLegendNode *, QgsLayerTreeModelLegendNode *>
parents;
406 QMap<QgsLayerTreeModelLegendNode *, QList<QgsLayerTreeModelLegendNode *> >
children;
452 QHash<QgsLayerTreeLayer *, LayerLegendData>
mLegend;
478 void legendNodeSizeChanged();
505 mRuleKey = QStringLiteral(
"embedded-widget-" ) + QUuid::createUuid().toString();
508 QVariant
data(
int role )
const override
510 if ( role == RuleKeyRole )
524 #endif // QGSLAYERTREEMODEL_H