QGIS API Documentation  2.14.0-Essen
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 
39 class GUI_EXPORT QgsCustomLayerOrderWidget : public QWidget
40 {
41  Q_OBJECT
42  public:
43  explicit QgsCustomLayerOrderWidget( QgsLayerTreeMapCanvasBridge* bridge, QWidget *parent = nullptr );
44 
45  signals:
46 
47  protected slots:
48  void bridgeHasCustomLayerOrderChanged( bool state );
49  void bridgeCustomLayerOrderChanged( const QStringList& order );
50  void nodeVisibilityChanged( QgsLayerTreeNode* node, Qt::CheckState state );
51 
52  void modelUpdated();
53 
54  protected:
56 
58  CustomLayerOrderModel* mModel;
60 };
61 
62 
64 class CustomLayerOrderModel : public QAbstractListModel
65 {
66  Q_OBJECT
67 
68  public:
69  CustomLayerOrderModel( QgsLayerTreeMapCanvasBridge* bridge, QObject* parent = nullptr );
70 
71  int rowCount( const QModelIndex & ) const override;
72 
73  QVariant data( const QModelIndex &index, int role ) const override;
74 
75  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
76 
77  Qt::ItemFlags flags( const QModelIndex &index ) const override;
78 
79  Qt::DropActions supportedDropActions() const override;
80 
81  QStringList mimeTypes() const override;
82 
83  QMimeData* mimeData( const QModelIndexList& indexes ) const override;
84 
85  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
86 
87  bool removeRows( int row, int count, const QModelIndex& parent ) override;
88 
89  void refreshModel( const QStringList& order );
90 
91  QStringList order() const { return mOrder; }
92 
93  void updateLayerVisibility( const QString& layerId );
94 
95  protected:
97  QStringList mOrder;
98 };
100 
101 #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