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