QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
47 explicit QgsCustomLayerOrderWidget( QgsLayerTreeMapCanvasBridge *bridge, QWidget *parent SIP_TRANSFERTHIS = nullptr );
48
49 signals:
50
51 private slots:
52 void bridgeHasCustomLayerOrderChanged( bool state );
53 void bridgeCustomLayerOrderChanged();
55 void nodeVisibilityChanged( QgsLayerTreeNode *node );
56
57 void modelUpdated();
58
59 private:
60 QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
61
62 QCheckBox *mChkOverride = nullptr;
63 CustomLayerOrderModel *mModel = nullptr;
64 QListView *mView = nullptr;
65};
66
67
68#ifndef SIP_RUN
70class CustomLayerOrderModel : public QAbstractListModel
71{
72 Q_OBJECT
73
74 public:
75 CustomLayerOrderModel( QgsLayerTreeMapCanvasBridge *bridge, QObject *parent = nullptr );
76
77 int rowCount( const QModelIndex & ) const override;
78
79 QVariant data( const QModelIndex &index, int role ) const override;
80
81 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
82
83 Qt::ItemFlags flags( const QModelIndex &index ) const override;
84
85 Qt::DropActions supportedDropActions() const override;
86
87 QStringList mimeTypes() const override;
88
89 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
90
91 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
92
93 bool removeRows( int row, int count, const QModelIndex &parent ) override;
94
95 void refreshModel( const QList<QgsMapLayer *> &order );
96
97 QStringList order() const { return mOrder; }
98
99 void updateLayerVisibility( const QString &layerId );
100
101 protected:
102 QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
103 QStringList mOrder;
104};
106#endif
107
108#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