QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposermapitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermapitem.h
3  -------------------
4  begin : September 2014
5  copyright : (C) 2014 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSCOMPOSERMAPITEM_H
18 #define QGSCOMPOSERMAPITEM_H
19 
20 #include "qgscomposerobject.h"
21 
22 class QgsComposerMap;
23 
29 class CORE_EXPORT QgsComposerMapItem : public QgsComposerObject
30 {
31  Q_OBJECT
32 
33  public:
34 
39  QgsComposerMapItem( const QString& name, QgsComposerMap* map );
40 
41  virtual ~QgsComposerMapItem();
42 
46  virtual void draw( QPainter* painter ) = 0;
47 
53  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
54 
60  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
61 
66  virtual void setComposerMap( QgsComposerMap* map );
67 
72  virtual const QgsComposerMap* composerMap() const { return mComposerMap; }
73 
77  QString id() const { return mUuid; }
78 
83  virtual void setName( const QString& name ) { mName = name; }
84 
89  virtual QString name() const { return mName; }
90 
95  virtual void setEnabled( const bool enabled ) { mEnabled = enabled; }
96 
101  virtual bool enabled() const { return mEnabled; }
102 
106  virtual bool usesAdvancedEffects() const { return false; }
107 
108  protected:
109 
111  QString mName;
112 
115 
117  QString mUuid;
118 
120  bool mEnabled;
121 
122 };
123 
124 
125 
134 class CORE_EXPORT QgsComposerMapItemStack
135 {
136  public:
137 
142 
143  virtual ~QgsComposerMapItemStack();
144 
148  int size() const { return mItems.size(); }
149 
156  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
157 
164  virtual bool readXML( const QDomElement& elem, const QDomDocument& doc ) = 0;
165 
169  void drawItems( QPainter* painter );
170 
175  bool containsAdvancedEffects() const;
176 
177  protected:
178 
187  void addItem( QgsComposerMapItem* item );
188 
195  void removeItem( const QString& itemId );
196 
203  void moveItemUp( const QString& itemId );
204 
211  void moveItemDown( const QString& itemId );
212 
218  const QgsComposerMapItem* constItem( const QString& itemId ) const;
219 
225  QgsComposerMapItem* item( const QString& itemId ) const;
226 
232  QgsComposerMapItem* item( const int index ) const;
233 
241  QgsComposerMapItem &operator[]( int idx );
242 
246  QList< QgsComposerMapItem* > asList() const;
247 
248  protected:
249 
250  QList< QgsComposerMapItem* > mItems;
251 
253 
257  void removeItems();
258 };
259 
260 #endif //QGSCOMPOSERMAPITEM_H
261