QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscategorizedsymbolrendererv2widget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscategorizedsymbolrendererv2widget.h
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 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 #ifndef QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H
16 #define QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H
17 
19 #include "qgsrendererv2widget.h"
20 #include <QStandardItem>
21 #include <QProxyStyle>
22 
25 
26 #include "ui_qgscategorizedsymbolrendererv2widget.h"
27 
28 class GUI_EXPORT QgsCategorizedSymbolRendererV2Model : public QAbstractItemModel
29 {
30  Q_OBJECT
31  public:
32  QgsCategorizedSymbolRendererV2Model( QObject * parent = 0 );
33  Qt::ItemFlags flags( const QModelIndex & index ) const;
34  Qt::DropActions supportedDropActions() const;
35  QVariant data( const QModelIndex &index, int role ) const;
36  bool setData( const QModelIndex & index, const QVariant & value, int role );
37  QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
38  int rowCount( const QModelIndex &parent = QModelIndex() ) const;
39  int columnCount( const QModelIndex & = QModelIndex() ) const;
40  QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
41  QModelIndex parent( const QModelIndex &index ) const;
42  QStringList mimeTypes() const;
43  QMimeData *mimeData( const QModelIndexList &indexes ) const;
44  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
45 
46  void setRenderer( QgsCategorizedSymbolRendererV2* renderer );
47 
48  void addCategory( const QgsRendererCategoryV2 &cat );
49  QgsRendererCategoryV2 category( const QModelIndex &index );
50  void deleteRows( QList<int> rows );
51  void removeAllRows();
52  void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
53  void updateSymbology();
54 
55  signals:
56  void rowsMoved();
57 
58  private:
60  QString mMimeFormat;
61 };
62 
63 // View style which shows drop indicator line between items
64 class QgsCategorizedSymbolRendererV2ViewStyle: public QProxyStyle
65 {
66  public:
67  QgsCategorizedSymbolRendererV2ViewStyle( QStyle* style = 0 );
68 
69  void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const;
70 };
71 
72 class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsCategorizedSymbolRendererV2Widget
73 {
74  Q_OBJECT
75  public:
76  static QgsRendererV2Widget* create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer );
77 
80 
81  virtual QgsFeatureRendererV2* renderer();
82 
83  public slots:
84  void changeCategorizedSymbol();
85  void categoryColumnChanged( QString field );
86  void categoriesDoubleClicked( const QModelIndex & idx );
87  void addCategory();
88  void addCategories();
89  void applyColorRamp();
90  void deleteCategories();
91  void deleteAllCategories();
92 
93  void rotationFieldChanged( QString fldName );
94  void sizeScaleFieldChanged( QString fldName );
95  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
96 
97  void showSymbolLevels();
98 
99  void rowsMoved();
100 
101  protected:
102 
103  void updateUiFromRenderer();
104 
105  void updateCategorizedSymbolIcon();
106 
107  // Called by virtual refreshSymbolView()
108  void populateCategories();
109 
111  int currentCategoryRow();
112 
114  QList<int> selectedCategories();
115 
117  void changeSelectedSymbols();
118 
119  void changeCategorySymbol();
120 
121  QgsVectorColorRampV2* getColorRamp();
122 
123  QList<QgsSymbolV2*> selectedSymbols();
124  QgsCategoryList selectedCategoryList();
125  void refreshSymbolView() { populateCategories(); }
126  void keyPressEvent( QKeyEvent* event );
127 
128  protected:
130 
132 
134 
136 
137  private:
138  QString mOldClassificationAttribute;
139  QgsCategoryList mCopyBuffer;
140 };
141 
142 #endif // QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H