QGIS API Documentation  2.8.2-Wien
 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 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
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 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 
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() override;
124  QgsCategoryList selectedCategoryList();
125  void refreshSymbolView() override { populateCategories(); }
126  void keyPressEvent( QKeyEvent* event ) override;
127 
128  protected:
130 
132 
134 
136 
137  private:
138  QString mOldClassificationAttribute;
139  QgsCategoryList mCopyBuffer;
140 };
141 
142 #endif // QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H