QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgslayertreemapcanvasbridge.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayertreemapcanvasbridge.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 QGSLAYERTREEMAPCANVASBRIDGE_H
17 #define QGSLAYERTREEMAPCANVASBRIDGE_H
18 
19 #include <QObject>
20 #include <QStringList>
21 
23 
24 class QgsMapCanvas;
25 class QgsMapCanvasLayer;
26 class QgsLayerTreeGroup;
27 class QgsLayerTreeNode;
28 
44 class GUI_EXPORT QgsLayerTreeMapCanvasBridge : public QObject
45 {
46  Q_OBJECT
47  public:
49  QgsLayerTreeMapCanvasBridge( QgsLayerTreeGroup* root, QgsMapCanvas* canvas, QObject* parent = 0 );
50 
51  void clear();
52 
53  QgsLayerTreeGroup* rootGroup() const { return mRoot; }
54  QgsMapCanvas* mapCanvas() const { return mCanvas; }
55 
56  bool hasCustomLayerOrder() const { return mHasCustomLayerOrder; }
57  QStringList customLayerOrder() const { return mCustomLayerOrder; }
58 
59  QStringList defaultLayerOrder() const;
60 
63  void setAutoSetupOnFirstLayer( bool enabled ) { mAutoSetupOnFirstLayer = enabled; }
64  bool autoSetupOnFirstLayer() const { return mAutoSetupOnFirstLayer; }
65 
68  void setAutoEnableCrsTransform( bool enabled ) { mAutoEnableCrsTransform = enabled; }
69  bool autoEnableCrsTransform() const { return mAutoEnableCrsTransform; }
70 
71  public slots:
72  void setHasCustomLayerOrder( bool override );
73  void setCustomLayerOrder( const QStringList& order );
74 
76  void setCanvasLayers();
77 
78  void readProject( const QDomDocument& doc );
79  void writeProject( QDomDocument& doc );
80 
81  signals:
82  void hasCustomLayerOrderChanged( bool );
83  void customLayerOrderChanged( const QStringList& order );
84 
85  protected:
86 
87  void defaultLayerOrder( QgsLayerTreeNode* node, QStringList& order ) const;
88 
89  void setCanvasLayers( QgsLayerTreeNode* node, QList<QgsMapCanvasLayer>& layers );
90 
91  void deferredSetCanvasLayers();
92 
93  protected slots:
94  void nodeAddedChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
95  void nodeRemovedChildren();
96  void nodeVisibilityChanged();
97  void nodeCustomPropertyChanged( QgsLayerTreeNode* node, QString key );
98 
99  protected:
102 
104 
106  QStringList mCustomLayerOrder;
107 
110 
114 };
115 
116 #endif // QGSLAYERTREEMAPCANVASBRIDGE_H