444 changes: 314 additions & 130 deletions src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp

Large diffs are not rendered by default.

57 changes: 42 additions & 15 deletions src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,39 @@ class QgsRendererCategoryV2;

#include "ui_qgscategorizedsymbolrendererv2widget.h"

class GUI_EXPORT QgsCategorizedSymbolRendererV2Model : public QAbstractItemModel
{
Q_OBJECT
public:
QgsCategorizedSymbolRendererV2Model( 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( QgsCategorizedSymbolRendererV2* renderer );

void addCategory( const QgsRendererCategoryV2 &cat );
void removeRows( QList<int> rows );
void removeAllRows( );
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );

signals:
void rowsMoved();

private:
QgsCategorizedSymbolRendererV2* mRenderer;
QString mMimeFormat;
};

class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsCategorizedSymbolRendererV2Widget
{
Q_OBJECT
Expand All @@ -39,39 +72,36 @@ class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widg
void changeCategorizedSymbol();
void categoryColumnChanged();
void categoriesDoubleClicked( const QModelIndex & idx );
void addCategory();
void addCategories();
void deleteCategory();
void deleteCategories();
void deleteAllCategories();
void changeCurrentValue( QStandardItem * item );

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

void showSymbolLevels();

void rowsMoved();

protected:

void updateUiFromRenderer();

void updateCategorizedSymbolIcon();

//! populate categories view
// Called by virtual refreshSymbolView()
void populateCategories();

//! populate column combo
void populateColumns();

void addCategory( const QgsRendererCategoryV2& cat );

//! return row index for the currently selected category (-1 if on no selection)
int currentCategoryRow();

//! return key for the currently selected category
QVariant currentCategory();

//! return a list of keys for the categories unders selection
QList<QVariant> selectedCategories();
//! return a list of indexes for the categories unders selection
QList<int> selectedCategories();

//! change the selected symbols alone for the change button, if there is a selection
void changeSelectedSymbols();
Expand All @@ -81,20 +111,17 @@ class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widg
QList<QgsSymbolV2*> selectedSymbols();
void refreshSymbolView() { populateCategories(); }

protected slots:
void addCategory();

protected:
QgsCategorizedSymbolRendererV2* mRenderer;

QgsSymbolV2* mCategorizedSymbol;

QgsRendererV2DataDefinedMenus* mDataDefinedMenus;

QgsCategorizedSymbolRendererV2Model* mModel;

private:
QString mOldClassificationAttribute;
};



#endif // QGSCATEGORIZEDSYMBOLRENDERERV2WIDGET_H
13 changes: 11 additions & 2 deletions src/ui/qgscategorizedsymbolrendererv2widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::IgnoreAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
Expand All @@ -106,6 +112,9 @@
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
Expand All @@ -131,7 +140,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="btnDeleteCategory">
<widget class="QPushButton" name="btnDeleteCategories">
<property name="text">
<string>Delete</string>
</property>
Expand Down Expand Up @@ -191,7 +200,7 @@
<tabstop>cboCategorizedColorRamp</tabstop>
<tabstop>viewCategories</tabstop>
<tabstop>btnAddCategories</tabstop>
<tabstop>btnDeleteCategory</tabstop>
<tabstop>btnDeleteCategories</tabstop>
<tabstop>btnDeleteAllCategories</tabstop>
<tabstop>btnJoinCategories</tabstop>
</tabstops>
Expand Down