QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgscustomlayerorderwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscustomlayerorderwidget.h
3 --------------------------------------
4 Date : May 2014
5 Copyright : (C) 2014 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCUSTOMLAYERORDERWIDGET_H
17#define QGSCUSTOMLAYERORDERWIDGET_H
18
19#include <QWidget>
20#include "qgis.h"
21#include <QAbstractListModel>
22#include "qgis_gui.h"
23
24class CustomLayerOrderModel;
27class QgsMapLayer;
28
29class QCheckBox;
30class QListView;
31
42class GUI_EXPORT QgsCustomLayerOrderWidget : public QWidget
43{
44 Q_OBJECT
45 public:
46
48 explicit QgsCustomLayerOrderWidget( QgsLayerTreeMapCanvasBridge *bridge, QWidget *parent SIP_TRANSFERTHIS = nullptr );
49
50 signals:
51
52 private slots:
53 void bridgeHasCustomLayerOrderChanged( bool state );
54 void bridgeCustomLayerOrderChanged();
56 void nodeVisibilityChanged( QgsLayerTreeNode *node );
57
58 void modelUpdated();
59
60 private:
61 QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
62
63 QCheckBox *mChkOverride = nullptr;
64 CustomLayerOrderModel *mModel = nullptr;
65 QListView *mView = nullptr;
66};
67
68
69#ifndef SIP_RUN
71class CustomLayerOrderModel : public QAbstractListModel
72{
73 Q_OBJECT
74
75 public:
76 CustomLayerOrderModel( QgsLayerTreeMapCanvasBridge *bridge, QObject *parent = nullptr );
77
78 int rowCount( const QModelIndex & ) const override;
79
80 QVariant data( const QModelIndex &index, int role ) const override;
81
82 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
83
84 Qt::ItemFlags flags( const QModelIndex &index ) const override;
85
86 Qt::DropActions supportedDropActions() const override;
87
88 QStringList mimeTypes() const override;
89
90 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
91
92 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
93
94 bool removeRows( int row, int count, const QModelIndex &parent ) override;
95
96 void refreshModel( const QList<QgsMapLayer *> &order );
97
98 QStringList order() const { return mOrder; }
99
100 void updateLayerVisibility( const QString &layerId );
101
102 protected:
103 QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
104 QStringList mOrder;
105};
107#endif
108
109#endif // QGSCUSTOMLAYERORDERWIDGET_H
The QgsCustomLayerOrderWidget class provides a list box where the user can define custom order for dr...
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
This class is a base class for nodes in a layer tree.
Base class for all map layer types.
Definition qgsmaplayer.h:76
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53