QGIS API Documentation  2.99.0-Master (5169e0d)
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 <QAbstractListModel>
21 #include "qgis_gui.h"
22 
23 class CustomLayerOrderModel;
25 class QgsLayerTreeNode;
26 class QgsMapLayer;
27 
28 class QCheckBox;
29 class QListView;
30 
42 class GUI_EXPORT QgsCustomLayerOrderWidget : public QWidget
43 {
44  Q_OBJECT
45  public:
46  explicit QgsCustomLayerOrderWidget( QgsLayerTreeMapCanvasBridge *bridge, QWidget *parent = nullptr );
47 
48  signals:
49 
50  private slots:
51  void bridgeHasCustomLayerOrderChanged( bool state );
52  void bridgeCustomLayerOrderChanged();
54  void nodeVisibilityChanged( QgsLayerTreeNode *node );
55 
56  void modelUpdated();
57 
58  private:
59  QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
60 
61  QCheckBox *mChkOverride = nullptr;
62  CustomLayerOrderModel *mModel = nullptr;
63  QListView *mView = nullptr;
64 };
65 
66 
68 class CustomLayerOrderModel : public QAbstractListModel
69 {
70  Q_OBJECT
71 
72  public:
73  CustomLayerOrderModel( QgsLayerTreeMapCanvasBridge *bridge, QObject *parent = nullptr );
74 
75  int rowCount( const QModelIndex & ) const override;
76 
77  QVariant data( const QModelIndex &index, int role ) const override;
78 
79  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
80 
81  Qt::ItemFlags flags( const QModelIndex &index ) const override;
82 
83  Qt::DropActions supportedDropActions() const override;
84 
85  QStringList mimeTypes() const override;
86 
87  QMimeData *mimeData( const QModelIndexList &indexes ) const override;
88 
89  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
90 
91  bool removeRows( int row, int count, const QModelIndex &parent ) override;
92 
93  void refreshModel( const QList<QgsMapLayer *> &order );
94 
95  QStringList order() const { return mOrder; }
96 
97  void updateLayerVisibility( const QString &layerId );
98 
99  protected:
100  QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
101  QStringList mOrder;
102 };
104 
105 #endif // QGSCUSTOMLAYERORDERWIDGET_H
static unsigned index
Base class for all map layer types.
Definition: qgsmaplayer.h:53
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
The QgsCustomLayerOrderWidget class provides a list box where the user can define custom order for dr...
This class is a base class for nodes in a layer tree.