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