|
QGIS API Documentation
master-6227475
|
00001 /*************************************************************************** 00002 qgscategorizedsymbolrendererv2widget.h 00003 --------------------- 00004 begin : November 2009 00005 copyright : (C) 2009 by Martin Dobias 00006 email : wonder dot sk at gmail dot com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 #ifndef QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H 00016 #define QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H 00017 00018 #include "qgscategorizedsymbolrendererv2.h" 00019 #include "qgsrendererv2widget.h" 00020 #include <QStandardItem> 00021 #include <QProxyStyle> 00022 00023 class QgsCategorizedSymbolRendererV2; 00024 class QgsRendererCategoryV2; 00025 00026 #include "ui_qgscategorizedsymbolrendererv2widget.h" 00027 00028 class GUI_EXPORT QgsCategorizedSymbolRendererV2Model : public QAbstractItemModel 00029 { 00030 Q_OBJECT 00031 public: 00032 QgsCategorizedSymbolRendererV2Model( QObject * parent = 0 ); 00033 Qt::ItemFlags flags( const QModelIndex & index ) const; 00034 Qt::DropActions supportedDropActions() const; 00035 QVariant data( const QModelIndex &index, int role ) const; 00036 bool setData( const QModelIndex & index, const QVariant & value, int role ); 00037 QVariant headerData( int section, Qt::Orientation orientation, int role ) const; 00038 int rowCount( const QModelIndex &parent = QModelIndex() ) const; 00039 int columnCount( const QModelIndex & = QModelIndex() ) const; 00040 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; 00041 QModelIndex parent( const QModelIndex &index ) const; 00042 QStringList mimeTypes() const; 00043 QMimeData *mimeData( const QModelIndexList &indexes ) const; 00044 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ); 00045 00046 void setRenderer( QgsCategorizedSymbolRendererV2* renderer ); 00047 00048 void addCategory( const QgsRendererCategoryV2 &cat ); 00049 void deleteRows( QList<int> rows ); 00050 void removeAllRows( ); 00051 void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ); 00052 00053 signals: 00054 void rowsMoved(); 00055 00056 private: 00057 QgsCategorizedSymbolRendererV2* mRenderer; 00058 QString mMimeFormat; 00059 }; 00060 00061 // View style which shows drop indicator line between items 00062 class QgsCategorizedSymbolRendererV2ViewStyle: public QProxyStyle 00063 { 00064 public: 00065 QgsCategorizedSymbolRendererV2ViewStyle( QStyle* style = 0 ); 00066 00067 void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const; 00068 }; 00069 00070 class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsCategorizedSymbolRendererV2Widget 00071 { 00072 Q_OBJECT 00073 public: 00074 static QgsRendererV2Widget* create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ); 00075 00076 QgsCategorizedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ); 00077 ~QgsCategorizedSymbolRendererV2Widget(); 00078 00079 virtual QgsFeatureRendererV2* renderer(); 00080 00081 public slots: 00082 void changeCategorizedSymbol(); 00083 void categoryColumnChanged(); 00084 void categoriesDoubleClicked( const QModelIndex & idx ); 00085 void addCategory(); 00086 void addCategories(); 00087 void deleteCategories(); 00088 void deleteAllCategories(); 00089 00090 void rotationFieldChanged( QString fldName ); 00091 void sizeScaleFieldChanged( QString fldName ); 00092 void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod ); 00093 00094 void showSymbolLevels(); 00095 00096 void rowsMoved(); 00097 00098 protected: 00099 00100 void updateUiFromRenderer(); 00101 00102 void updateCategorizedSymbolIcon(); 00103 00104 // Called by virtual refreshSymbolView() 00105 void populateCategories(); 00106 00108 void populateColumns(); 00109 00111 int currentCategoryRow(); 00112 00114 QList<int> selectedCategories(); 00115 00117 void changeSelectedSymbols(); 00118 00119 void changeCategorySymbol(); 00120 00121 QList<QgsSymbolV2*> selectedSymbols(); 00122 void refreshSymbolView() { populateCategories(); } 00123 00124 protected: 00125 QgsCategorizedSymbolRendererV2* mRenderer; 00126 00127 QgsSymbolV2* mCategorizedSymbol; 00128 00129 QgsRendererV2DataDefinedMenus* mDataDefinedMenus; 00130 00131 QgsCategorizedSymbolRendererV2Model* mModel; 00132 00133 private: 00134 QString mOldClassificationAttribute; 00135 }; 00136 00137 #endif // QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H