QGIS API Documentation  2.10.1-Pisa
 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 
29 {
30  Q_OBJECT
31  public:
33  Qt::ItemFlags flags( const QModelIndex & index ) const override;
34  Qt::DropActions supportedDropActions() const override;
35  QVariant data( const QModelIndex &index, int role ) const override;
36  bool setData( const QModelIndex & index, const QVariant & value, int role ) override;
37  QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
38  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
39  int columnCount( const QModelIndex & = QModelIndex() ) const override;
40  QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
41  QModelIndex parent( const QModelIndex &index ) const override;
42  QStringList mimeTypes() const override;
43  QMimeData *mimeData( const QModelIndexList &indexes ) const override;
44  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
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 ) override;
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
65 {
66  public:
68 
69  void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const override;
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() override;
82 
91  int matchToSymbols( QgsStyleV2* style );
92 
93  public slots:
94  void changeCategorizedSymbol();
95  void categoryColumnChanged( QString field );
96  void categoriesDoubleClicked( const QModelIndex & idx );
97  void addCategory();
98  void addCategories();
99  void applyColorRamp();
100  void deleteCategories();
101  void deleteAllCategories();
102 
103  void rotationFieldChanged( QString fldName );
104  void sizeScaleFieldChanged( QString fldName );
105  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
106 
107  void showSymbolLevels();
108 
109  void rowsMoved();
110 
117  void matchToSymbolsFromLibrary();
118 
125  void matchToSymbolsFromXml();
126 
127  protected:
128 
129  void updateUiFromRenderer();
130 
131  void updateCategorizedSymbolIcon();
132 
133  // Called by virtual refreshSymbolView()
134  void populateCategories();
135 
137  int currentCategoryRow();
138 
140  QList<int> selectedCategories();
141 
143  void changeSelectedSymbols();
144 
145  void changeCategorySymbol();
146 
147  QgsVectorColorRampV2* getColorRamp();
148 
150  QgsCategoryList selectedCategoryList();
151  void refreshSymbolView() override { populateCategories(); }
152  void keyPressEvent( QKeyEvent* event ) override;
153 
154  protected:
156 
158 
160 
162 
163  private:
164  QString mOldClassificationAttribute;
165  QgsCategoryList mCopyBuffer;
166 };
167 
168 #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
virtual int rowCount(const QModelIndex &parent) const =0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
void create(WId window, bool initializeWindow, bool destroyOldWindow)
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
virtual QStringList mimeTypes() const
virtual void sort(int column, Qt::SortOrder order)
Utility class for providing GUI for data-defined rendering.
void rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
virtual Qt::DropActions supportedDropActions() const
virtual QVariant data(const QModelIndex &index, int role) const =0
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const override
typedef DropActions
virtual int columnCount(const QModelIndex &parent) const =0
virtual void keyPressEvent(QKeyEvent *event)
Base class for renderer settings widgets.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
virtual Qt::ItemFlags flags(const QModelIndex &index) const
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
virtual QgsFeatureRendererV2 * renderer()=0
return pointer to the renderer (no transfer of ownership)
typedef ItemFlags