QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
22 class CustomLayerOrderModel;
24 class QgsLayerTreeNode;
25 
26 class QCheckBox;
27 class QListView;
28 
40 class GUI_EXPORT QgsCustomLayerOrderWidget : public QWidget
41 {
42  Q_OBJECT
43  public:
44  explicit QgsCustomLayerOrderWidget( QgsLayerTreeMapCanvasBridge* bridge, QWidget *parent = nullptr );
45 
46  signals:
47 
48  protected slots:
49  void bridgeHasCustomLayerOrderChanged( bool state );
50  void bridgeCustomLayerOrderChanged( const QStringList& order );
51  void nodeVisibilityChanged( QgsLayerTreeNode* node, Qt::CheckState state );
52 
53  void modelUpdated();
54 
55  protected:
57 
59  CustomLayerOrderModel* mModel;
61 };
62 
63 
65 class CustomLayerOrderModel : public QAbstractListModel
66 {
67  Q_OBJECT
68 
69  public:
70  CustomLayerOrderModel( QgsLayerTreeMapCanvasBridge* bridge, QObject* parent = nullptr );
71 
72  int rowCount( const QModelIndex & ) const override;
73 
74  QVariant data( const QModelIndex &index, int role ) const override;
75 
76  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
77 
78  Qt::ItemFlags flags( const QModelIndex &index ) const override;
79 
80  Qt::DropActions supportedDropActions() const override;
81 
82  QStringList mimeTypes() const override;
83 
84  QMimeData* mimeData( const QModelIndexList& indexes ) const override;
85 
86  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
87 
88  bool removeRows( int row, int count, const QModelIndex& parent ) override;
89 
90  void refreshModel( const QStringList& order );
91 
92  QStringList order() const { return mOrder; }
93 
94  void updateLayerVisibility( const QString& layerId );
95 
96  protected:
98  QStringList mOrder;
99 };
101 
102 #endif // QGSCUSTOMLAYERORDERWIDGET_H
static unsigned index
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
QgsLayerTreeMapCanvasBridge * mBridge
CustomLayerOrderModel * mModel
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.
typedef DropActions
typedef ItemFlags