QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
24 class CustomLayerOrderModel;
26 class QgsLayerTreeNode;
27 class QgsMapLayer;
28 
29 class QCheckBox;
30 class QListView;
31 
43 class GUI_EXPORT QgsCustomLayerOrderWidget : public QWidget
44 {
45  Q_OBJECT
46  public:
47 
49  explicit QgsCustomLayerOrderWidget( QgsLayerTreeMapCanvasBridge *bridge, QWidget *parent SIP_TRANSFERTHIS = nullptr );
50 
51  signals:
52 
53  private slots:
54  void bridgeHasCustomLayerOrderChanged( bool state );
55  void bridgeCustomLayerOrderChanged();
57  void nodeVisibilityChanged( QgsLayerTreeNode *node );
58 
59  void modelUpdated();
60 
61  private:
62  QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
63 
64  QCheckBox *mChkOverride = nullptr;
65  CustomLayerOrderModel *mModel = nullptr;
66  QListView *mView = nullptr;
67 };
68 
69 
70 #ifndef SIP_RUN
71 class CustomLayerOrderModel : public QAbstractListModel
73 {
74  Q_OBJECT
75 
76  public:
77  CustomLayerOrderModel( QgsLayerTreeMapCanvasBridge *bridge, QObject *parent = nullptr );
78 
79  int rowCount( const QModelIndex & ) const override;
80 
81  QVariant data( const QModelIndex &index, int role ) const override;
82 
83  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
84 
85  Qt::ItemFlags flags( const QModelIndex &index ) const override;
86 
87  Qt::DropActions supportedDropActions() const override;
88 
89  QStringList mimeTypes() const override;
90 
91  QMimeData *mimeData( const QModelIndexList &indexes ) const override;
92 
93  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
94 
95  bool removeRows( int row, int count, const QModelIndex &parent ) override;
96 
97  void refreshModel( const QList<QgsMapLayer *> &order );
98 
99  QStringList order() const { return mOrder; }
100 
101  void updateLayerVisibility( const QString &layerId );
102 
103  protected:
104  QgsLayerTreeMapCanvasBridge *mBridge = nullptr;
105  QStringList mOrder;
106 };
108 #endif
109 
110 #endif // QGSCUSTOMLAYERORDERWIDGET_H
Base class for all map layer types.
Definition: qgsmaplayer.h:63
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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.