QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 
54  signals:
55  void rowsMoved();
56 
57  private:
59  QString mMimeFormat;
60 };
61 
62 // View style which shows drop indicator line between items
63 class QgsCategorizedSymbolRendererV2ViewStyle: public QProxyStyle
64 {
65  public:
66  QgsCategorizedSymbolRendererV2ViewStyle( QStyle* style = 0 );
67 
68  void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const;
69 };
70 
71 class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsCategorizedSymbolRendererV2Widget
72 {
73  Q_OBJECT
74  public:
75  static QgsRendererV2Widget* create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer );
76 
79 
80  virtual QgsFeatureRendererV2* renderer();
81 
82  public slots:
83  void changeCategorizedSymbol();
84  void categoryColumnChanged( QString field );
85  void categoriesDoubleClicked( const QModelIndex & idx );
86  void addCategory();
87  void addCategories();
88  void deleteCategories();
89  void deleteAllCategories();
90 
91  void rotationFieldChanged( QString fldName );
92  void sizeScaleFieldChanged( QString fldName );
93  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
94 
95  void showSymbolLevels();
96 
97  void rowsMoved();
98 
99  protected:
100 
101  void updateUiFromRenderer();
102 
103  void updateCategorizedSymbolIcon();
104 
105  // Called by virtual refreshSymbolView()
106  void populateCategories();
107 
109  int currentCategoryRow();
110 
112  QList<int> selectedCategories();
113 
115  void changeSelectedSymbols();
116 
117  void changeCategorySymbol();
118 
119  QList<QgsSymbolV2*> selectedSymbols();
120  QgsCategoryList selectedCategoryList();
121  void refreshSymbolView() { populateCategories(); }
122  void keyPressEvent( QKeyEvent* event );
123 
124  protected:
126 
128 
130 
132 
133  private:
136 };
137 
138 #endif // QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H
virtual QList< QgsSymbolV2 * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
static unsigned index
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
Utility class for providing GUI for data-defined rendering.
QList< QgsRendererCategoryV2 > QgsCategoryList
void sort(double *heap, int *x, int *y, int N)
Definition: util.cpp:72
Base class for renderer settings widgets.
Represents a vector layer which manages a vector based data sets.
virtual QgsFeatureRendererV2 * renderer()=0
return pointer to the renderer (no transfer of ownership)