383 changes: 320 additions & 63 deletions src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp

Large diffs are not rendered by default.

59 changes: 54 additions & 5 deletions src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,52 @@
#include "qgsgraduatedsymbolrendererv2.h"
#include "qgsrendererv2widget.h"
#include <QStandardItem>
#include <QProxyStyle>

#include "ui_qgsgraduatedsymbolrendererv2widget.h"

class GUI_EXPORT QgsGraduatedSymbolRendererV2Model : public QAbstractItemModel
{
Q_OBJECT
public:
QgsGraduatedSymbolRendererV2Model( QObject * parent = 0 );
Qt::ItemFlags flags( const QModelIndex & index ) const;
Qt::DropActions supportedDropActions() const;
QVariant data( const QModelIndex &index, int role ) const;
bool setData( const QModelIndex & index, const QVariant & value, int role );
QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
int columnCount( const QModelIndex & = QModelIndex() ) const;
QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
QModelIndex parent( const QModelIndex &index ) const;
QStringList mimeTypes() const;
QMimeData *mimeData( const QModelIndexList &indexes ) const;
bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );

void setRenderer( QgsGraduatedSymbolRendererV2* renderer );

void addClass( QgsSymbolV2* symbol );
void removeRows( QList<int> rows );
void removeAllRows( );
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );

signals:
void rowsMoved();

private:
QgsGraduatedSymbolRendererV2* mRenderer;
QString mMimeFormat;
};

// View style which shows drop indicator line between items
class QgsGraduatedSymbolRendererV2ViewStyle: public QProxyStyle
{
public:
QgsGraduatedSymbolRendererV2ViewStyle( QStyle* style = 0 );

void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const;
};

class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsGraduatedSymbolRendererV2Widget
{
Q_OBJECT
Expand All @@ -45,26 +88,30 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget

/**Adds a class manually to the classification*/
void addClass();
/**Removes a class from the classification*/
void deleteCurrentClass();
/**Removes currently selected classes */
void deleteClasses();
/**Removes all classes from the classification*/
void deleteAllClasses();

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );

void showSymbolLevels();

void rowsMoved();

protected:
void updateUiFromRenderer();

void updateGraduatedSymbolIcon();

//! return a list of indexes for the classes under selection
QList<int> selectedClasses();

//! populate column combos in categorized and graduated page
void populateColumns();

//! populate ranges of graduated symbol renderer
void populateRanges();

void changeRangeSymbol( int rangeIdx );
void changeRange( int rangeIdx );

Expand All @@ -84,6 +131,8 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget

QgsRendererV2DataDefinedMenus* mDataDefinedMenus;

QgsGraduatedSymbolRendererV2Model* mModel;

};


Expand Down
15 changes: 14 additions & 1 deletion src/ui/qgsgraduatedsymbolrendererv2widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="showDropIndicator" stdset="0">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
Expand Down Expand Up @@ -186,7 +192,14 @@
<item>
<widget class="QPushButton" name="btnGraduatedDelete">
<property name="text">
<string>Delete class</string>
<string>Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnDeleteAllClasses">
<property name="text">
<string>Delete all</string>
</property>
</widget>
</item>
Expand Down