QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerlegenditem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerlegenditem.h - description
3  ------------------------
4  begin : May 2010
5  copyright : (C) 2010 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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 
18 #ifndef QGSCOMPOSERLEGENDITEM_H
19 #define QGSCOMPOSERLEGENDITEM_H
20 
21 #include "qgscomposerlegendstyle.h"
22 #include <QStandardItem>
23 class QDomDocument;
24 class QDomElement;
25 
27 class CORE_EXPORT QgsComposerLegendItem: public QStandardItem
28 {
29  public:
33  virtual ~QgsComposerLegendItem();
34 
35  enum ItemType
36  {
37  GroupItem = QStandardItem::UserType,
41  StyleItem
42  };
43 
44  virtual void writeXML( QDomElement& elem, QDomDocument& doc ) const = 0;
48  virtual void readXML( const QDomElement& itemElem, bool xServerAvailable = true ) = 0;
49 
50  virtual ItemType itemType() const = 0;
51  virtual QStandardItem* clone() const = 0;
52 
53  QgsComposerLegendStyle::Style style() const { return mStyle; }
54  void setStyle( QgsComposerLegendStyle::Style style ) { mStyle = style; }
55 
56  // Get text defined by user
57  virtual QString userText() const { return mUserText; }
58  // Set text defined by user
59  virtual void setUserText( const QString & text ) { mUserText = text; }
60 
61 
62  protected:
63  void writeXMLChildren( QDomElement& elem, QDomDocument& doc ) const;
64 
66 
67  // User defined text
68  QString mUserText;
69 };
70 
71 
72 class QgsSymbolV2;
73 
75 {
76  public:
78  QgsComposerSymbolV2Item( const QString& text );
79  QgsComposerSymbolV2Item( const QIcon& icon, const QString& text );
80  virtual ~QgsComposerSymbolV2Item();
81 
82  virtual QStandardItem* clone() const;
83 
84  virtual void writeXML( QDomElement& elem, QDomDocument& doc ) const;
85  virtual void readXML( const QDomElement& itemElem, bool xServerAvailable = true );
86 
88  void setSymbolV2( QgsSymbolV2* s );
89  QgsSymbolV2* symbolV2() {return mSymbolV2;}
90 
91  ItemType itemType() const { return SymbologyV2Item; }
92 
93  private:
94  QgsSymbolV2* mSymbolV2;
95 };
96 
98 {
99  public:
101  QgsComposerRasterSymbolItem( const QString& text );
102  QgsComposerRasterSymbolItem( const QIcon& icon, const QString& text );
103  virtual ~QgsComposerRasterSymbolItem();
104 
105  virtual QStandardItem* clone() const;
106 
107  virtual void writeXML( QDomElement& elem, QDomDocument& doc ) const;
108  virtual void readXML( const QDomElement& itemElem, bool xServerAvailable = true );
109 
110  void setLayerID( const QString& id ) { mLayerID = id; }
111  QString layerID() const { return mLayerID; }
112  ItemType itemType() const { return RasterSymbolItem; }
113 
114  void setColor( const QColor& c ) { mColor = c; }
115  QColor color() const { return mColor; }
116 
117  private:
118  QString mLayerID;
119  QColor mColor;
120 };
121 
122 class CORE_EXPORT QgsComposerLayerItem : public QgsComposerLegendItem
123 {
124  public:
126  QgsComposerLayerItem( const QString& text );
127  virtual ~QgsComposerLayerItem();
128  virtual QStandardItem* clone() const;
129 
130  virtual void writeXML( QDomElement& elem, QDomDocument& doc ) const;
131  virtual void readXML( const QDomElement& itemElem, bool xServerAvailable = true );
132 
133  ItemType itemType() const { return LayerItem; }
134 
135  void setLayerID( const QString& id ) { mLayerID = id; }
136  QString layerID() const { return mLayerID; }
137 
138  void setShowFeatureCount( bool show ) { mShowFeatureCount = show; }
139  bool showFeatureCount() const { return mShowFeatureCount; }
140 
141  void setDefaultStyle( double scaleDenominator = -1, QString rule = "" );
142 
143  private:
144  QString mLayerID;
145  // Show vector feature counts
146  bool mShowFeatureCount;
147 };
148 
150 {
151  public:
153  QgsComposerGroupItem( const QString& text );
154  virtual ~QgsComposerGroupItem();
155  virtual QStandardItem* clone() const;
156 
157  virtual void writeXML( QDomElement& elem, QDomDocument& doc ) const;
158  virtual void readXML( const QDomElement& itemElem, bool xServerAvailable = true );
159 
160  ItemType itemType() const { return GroupItem; }
161 };
162 
163 class CORE_EXPORT QgsComposerStyleItem: public QStandardItem
164 {
165  public:
169 };
170 
171 #endif // QGSCOMPOSERLEGENDITEM_H