QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgselevationprofilelayertreeview.h
Go to the documentation of this file.
1/***************************************************************************
2 qgselevationprofilelayertreeview.h
3 ---------------
4 begin : April 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSELEVATIONPROFILELAYERTREEVIEW_H
19#define QGSELEVATIONPROFILELAYERTREEVIEW_H
20
21#include "qgsconfig.h"
22
23#include "qgis_gui.h"
24#include "qgslayertreemodel.h"
25#include "qgslayertreeview.h"
26
27#include <QSortFilterProxyModel>
28#include <QTreeView>
29
30#define SIP_NO_FILE
31
32
33class QgsLayerTree;
36class QgsMapLayer;
37
38
48{
49 Q_OBJECT
50
51 public:
56 explicit QgsElevationProfileLayerTreeModel( QgsLayerTree *rootNode, QObject *parent = nullptr );
57
58 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
59 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
60 Qt::ItemFlags flags( const QModelIndex &index ) const override;
61 bool canDropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) const override;
62 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
63 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
64
65 signals:
66
72 void addLayers( const QList<QgsMapLayer *> &layers );
73
74 private:
75#ifdef SIP_RUN
77#endif
78};
79
88class GUI_EXPORT QgsElevationProfileLayerTreeProxyModel : public QSortFilterProxyModel
89{
90 Q_OBJECT
91
92 public:
96 explicit QgsElevationProfileLayerTreeProxyModel( QgsElevationProfileLayerTreeModel *model, QObject *parent = nullptr );
97
98 protected:
99 bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
100
101 private:
102 QgsElevationProfileLayerTreeModel *mModel = nullptr;
103};
104
114{
115 Q_OBJECT
116
117 public:
119
124 explicit QgsElevationProfileLayerTreeView( QgsLayerTree *rootNode, QWidget *parent = nullptr );
125
129 void populateInitialSources( QgsProject *project );
130
137
138 public slots:
139
151 void addNodeForRegisteredSource( const QString &sourceId, const QString &sourceName );
152
160 void removeNodeForUnregisteredSource( const QString &sourceId );
161
167 void populateMissingLayers( QgsProject *project );
168
169 signals:
170
176 void addLayers( const QList<QgsMapLayer *> &layers );
177
178 protected:
179 void resizeEvent( QResizeEvent *event ) override;
180
181 private:
182 QgsElevationProfileLayerTreeModel *mModel = nullptr;
183 QgsElevationProfileLayerTreeProxyModel *mProxyModel = nullptr;
184 QgsLayerTree *mLayerTree = nullptr;
185};
186
187
188#endif // QGSELEVATIONPROFILELAYERTREEVIEW_H
A layer tree model subclass for elevation profiles.
void addLayers(const QList< QgsMapLayer * > &layers)
Emitted when layers should be added to the profile, e.g.
QgsElevationProfileLayerTreeModel(QgsLayerTree *rootNode, QObject *parent=nullptr)
Construct a new tree model with given layer tree (root node must not be nullptr).
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
QgsElevationProfileLayerTreeProxyModel(QgsElevationProfileLayerTreeModel *model, QObject *parent=nullptr)
Constructor for QgsElevationProfileLayerTreeProxyModel.
void populateInitialSources(QgsProject *project)
Initially populates the tree view using layers from a project, as well as sources from the source reg...
QgsElevationProfileLayerTreeProxyModel * proxyModel()
Returns the view's proxy model.
QgsElevationProfileLayerTreeView(QgsLayerTree *rootNode, QWidget *parent=nullptr)
Construct a new tree view with given layer tree (root node must not be nullptr).
void removeNodeForUnregisteredSource(const QString &sourceId)
Removes a custom node from the layer tree corresponding to an unregistered profile source.
void addNodeForRegisteredSource(const QString &sourceId, const QString &sourceName)
Adds a custom node in the layer tree corresponding to a registered profile source.
void populateMissingLayers(QgsProject *project)
Adds any layers from a project which currently aren't within the profile's layer tree.
void resizeEvent(QResizeEvent *event) override
void addLayers(const QList< QgsMapLayer * > &layers)
Emitted when layers should be added to the profile, e.g.
Flags flags() const
Returns OR-ed combination of model flags.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QgsLayerTreeModel(QgsLayerTree *rootNode, QObject *parent=nullptr)
Construct a new tree model with given layer tree (root node must not be nullptr).
QModelIndex parent(const QModelIndex &child) const override
QMimeData * mimeData(const QModelIndexList &indexes) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QgsLayerTreeViewBase(QWidget *parent=nullptr)
Constructor for QgsLayerTreeViewBase.
Namespace with helper functions for layer tree operations.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109