From 09a9a6171ac26eaaa1705cd65ed72435d35f54d7 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Mon, 12 May 2014 09:04:39 +0200 Subject: [PATCH] field proxy model to filter fields on their type (also fix #10181) --- python/gui/gui.sip | 1 + python/gui/qgsfieldcombobox.sip | 6 ++ python/gui/qgsfieldexpressionwidget.sip | 10 ++- python/gui/qgsfieldmodel.sip | 3 +- python/gui/qgsfieldproxymodel.sip | 47 ++++++++++++ src/gui/CMakeLists.txt | 3 + src/gui/qgsfieldcombobox.cpp | 40 ++++++---- src/gui/qgsfieldcombobox.h | 13 +++- src/gui/qgsfieldexpressionwidget.cpp | 43 ++++++----- src/gui/qgsfieldexpressionwidget.h | 11 ++- src/gui/qgsfieldmodel.cpp | 9 +++ src/gui/qgsfieldmodel.h | 3 +- src/gui/qgsfieldproxymodel.cpp | 74 +++++++++++++++++++ src/gui/qgsfieldproxymodel.h | 72 ++++++++++++++++++ .../qgsgraduatedsymbolrendererv2widget.cpp | 1 + 15 files changed, 298 insertions(+), 38 deletions(-) create mode 100644 python/gui/qgsfieldproxymodel.sip create mode 100644 src/gui/qgsfieldproxymodel.cpp create mode 100644 src/gui/qgsfieldproxymodel.h diff --git a/python/gui/gui.sip b/python/gui/gui.sip index f19f777a9a3..b2abba48da3 100644 --- a/python/gui/gui.sip +++ b/python/gui/gui.sip @@ -32,6 +32,7 @@ %Include qgsfieldexpressionwidget.sip %Include qgsfieldmodel.sip %Include qgsfieldvalidator.sip +%Include qgsfieldproxymodel.sip %Include qgsfiledropedit.sip %Include qgsfilterlineedit.sip %Include qgsformannotationitem.sip diff --git a/python/gui/qgsfieldcombobox.sip b/python/gui/qgsfieldcombobox.sip index 2a0b3c90b27..ceef9363f73 100644 --- a/python/gui/qgsfieldcombobox.sip +++ b/python/gui/qgsfieldcombobox.sip @@ -19,6 +19,12 @@ class QgsFieldComboBox : QComboBox */ explicit QgsFieldComboBox( QWidget *parent /TransferThis/ = 0 ); + //! setFilters allows fitering according to the type of field + void setFilters( QgsFieldProxyModel::Filters filters ); + + //! currently used filter on list of fields + QgsFieldProxyModel::Filters filters(); + //! return the currently selected field QString currentField(); diff --git a/python/gui/qgsfieldexpressionwidget.sip b/python/gui/qgsfieldexpressionwidget.sip index 039f31d76f4..a1f0759867a 100644 --- a/python/gui/qgsfieldexpressionwidget.sip +++ b/python/gui/qgsfieldexpressionwidget.sip @@ -13,13 +13,19 @@ class QgsFieldExpressionWidget : QWidget //! define the title used in the expression dialog void setExpressionDialogTitle( QString title ); + + //! setFilters allows fitering according to the type of field + void setFilters( QgsFieldProxyModel::Filters filters ); - //! set the geometry calculator used in the expression dialog - void setGeomCalculator( const QgsDistanceArea &da ); + //! currently used filter on list of fields + QgsFieldProxyModel::Filters filters(); //! return the title used for the expression dialog const QString expressionDialogTitle(); + //! set the geometry calculator used in the expression dialog + void setGeomCalculator( const QgsDistanceArea &da ); + /** * @brief currentField returns the currently selected field or expression if allowed * @param isExpression determines if the string returned is the name of a field or an expression diff --git a/python/gui/qgsfieldmodel.sip b/python/gui/qgsfieldmodel.sip index 52aa3f4a08d..2dcb3314db0 100644 --- a/python/gui/qgsfieldmodel.sip +++ b/python/gui/qgsfieldmodel.sip @@ -18,7 +18,8 @@ class QgsFieldModel : QAbstractItemModel FieldIndexRole = 34, /* return field index if index corresponds to a field */ ExpressionRole = 35, /* return field name or expression */ IsExpressionRole = 36, /* return if index corresponds to an expression */ - ExpressionValidityRole = 37 /* return if expression is valid or not */ + ExpressionValidityRole = 37, /* return if expression is valid or not */ + FieldTypeRole = 38 /* return the field type (if a field, return QVariant if expression) */ }; /** diff --git a/python/gui/qgsfieldproxymodel.sip b/python/gui/qgsfieldproxymodel.sip new file mode 100644 index 00000000000..fd361f9aee3 --- /dev/null +++ b/python/gui/qgsfieldproxymodel.sip @@ -0,0 +1,47 @@ +/** + * @brief The QgsMapLayerProxModel class provides an easy to use model to display the list of layers in widgets. + * @note added in 2.3 + */ +class QgsFieldProxyModel : QSortFilterProxyModel +{ + +%TypeHeaderCode +#include "qgsfieldproxymodel.h" +%End + + public: + enum Filter + { + String = 1, + Int = 2, + LongLong = 4, + Double = 8, + Numeric = 14, + Date = 16, + All = 31 + }; + typedef QFlags Filters; + + /** + * @brief QgsFieldProxModel creates a proxy model with a QgsFieldModel as source model. + * It can be used to filter the fields based on their types. + */ + explicit QgsFieldProxyModel( QObject *parent /TransferThis/ = 0 ); + + //! sourceFieldModel returns the QgsFieldModel used in this QSortFilterProxyModel + QgsFieldModel* sourceFieldModel() ; + + /** + * @brief setFilters set flags that affect how fields are filtered + * @param filters are Filter flags + * @note added in 2.3 + */ + QgsFieldProxyModel* setFilters( Filters filters ); + const Filters& filters() const ; + + // QSortFilterProxyModel interface + public: + bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const; + bool lessThan( const QModelIndex &left, const QModelIndex &right ) const; +}; + diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index fb51f83252c..7ad4f44839d 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -92,6 +92,7 @@ qgsfieldcombobox.cpp qgsfieldexpressionwidget.cpp qgsfieldmodel.cpp qgsfieldvalidator.cpp +qgsfieldproxymodel.cpp qgsfiledropedit.cpp qgsfilterlineedit.cpp qgsformannotationitem.cpp @@ -238,6 +239,7 @@ qgsfieldcombobox.h qgsfieldexpressionwidget.h qgsfieldmodel.h qgsfieldvalidator.h +qgsfieldproxymodel.h qgsfilterlineedit.h qgsformannotationitem.h qgsgenericprojectionselector.h @@ -310,6 +312,7 @@ qgsfieldcombobox.h qgsfieldexpressionwidget.h qgsfieldmodel.h qgsfieldvalidator.h +qgsfieldproxymodel.h qgsfiledropedit.h qgsfilterlineedit.h qgsgenericprojectionselector.h diff --git a/src/gui/qgsfieldcombobox.cpp b/src/gui/qgsfieldcombobox.cpp index ca1a3ce43cd..49e35822700 100644 --- a/src/gui/qgsfieldcombobox.cpp +++ b/src/gui/qgsfieldcombobox.cpp @@ -14,18 +14,24 @@ ***************************************************************************/ #include "qgsfieldcombobox.h" -#include "qgsfieldmodel.h" +#include "qgsfieldproxymodel.h" #include "qgsmaplayer.h" +#include "qgsvectorlayer.h" QgsFieldComboBox::QgsFieldComboBox( QWidget *parent ) : QComboBox( parent ) { - mFieldModel = new QgsFieldModel( this ); - setModel( mFieldModel ); + mFieldProxyModel = new QgsFieldProxyModel( this ); + setModel( mFieldProxyModel ); connect( this, SIGNAL( currentIndexChanged( int ) ), this, SLOT( indexChanged( int ) ) ); } +void QgsFieldComboBox::setFilters( QgsFieldProxyModel::Filters filters ) +{ + mFieldProxyModel->setFilters( filters ); +} + void QgsFieldComboBox::setLayer( QgsMapLayer *layer ) { QgsVectorLayer* vl = dynamic_cast( layer ); @@ -37,38 +43,46 @@ void QgsFieldComboBox::setLayer( QgsMapLayer *layer ) void QgsFieldComboBox::setLayer( QgsVectorLayer *layer ) { - mFieldModel->setLayer( layer ); + mFieldProxyModel->sourceFieldModel()->setLayer( layer ); } QgsVectorLayer *QgsFieldComboBox::layer() { - return mFieldModel->layer(); + return mFieldProxyModel->sourceFieldModel()->layer(); } void QgsFieldComboBox::setField( QString fieldName ) { - QModelIndex idx = mFieldModel->indexFromName( fieldName ); + QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName ); if ( idx.isValid() ) { - setCurrentIndex( idx.row() ); - } - else - { - setCurrentIndex( -1 ); + QModelIndex proxyIdx = mFieldProxyModel->mapFromSource( idx ); + if ( proxyIdx.isValid() ) + { + setCurrentIndex( idx.row() ); + return; + } } + setCurrentIndex( -1 ); } QString QgsFieldComboBox::currentField() { int i = currentIndex(); - const QModelIndex index = mFieldModel->index( i, 0 ); + const QModelIndex proxyIndex = mFieldProxyModel->index( i, 0 ); + if ( !proxyIndex.isValid() ) + { + return ""; + } + + const QModelIndex index = mFieldProxyModel->mapToSource( proxyIndex ); if ( !index.isValid() ) { return ""; } - QString name = mFieldModel->data( index, QgsFieldModel::FieldNameRole ).toString(); + QString name = mFieldProxyModel->data( index, QgsFieldModel::FieldNameRole ).toString(); return name; } diff --git a/src/gui/qgsfieldcombobox.h b/src/gui/qgsfieldcombobox.h index 6b125c7e285..11de453a103 100644 --- a/src/gui/qgsfieldcombobox.h +++ b/src/gui/qgsfieldcombobox.h @@ -18,7 +18,8 @@ #include -class QgsFieldModel; +#include "qgsfieldproxymodel.h" + class QgsMapLayer; class QgsVectorLayer; @@ -32,6 +33,8 @@ class QgsVectorLayer; class GUI_EXPORT QgsFieldComboBox : public QComboBox { Q_OBJECT + Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters ) + public: /** * @brief QgsFieldComboBox creates a combo box to display the fields of a layer. @@ -39,6 +42,12 @@ class GUI_EXPORT QgsFieldComboBox : public QComboBox */ explicit QgsFieldComboBox( QWidget *parent = 0 ); + //! setFilters allows fitering according to the type of field + void setFilters( QgsFieldProxyModel::Filters filters ); + + //! currently used filter on list of fields + QgsFieldProxyModel::Filters filters() { return mFieldProxyModel->filters(); } + //! return the currently selected field QString currentField(); @@ -63,7 +72,7 @@ class GUI_EXPORT QgsFieldComboBox : public QComboBox void indexChanged( int i ); private: - QgsFieldModel* mFieldModel; + QgsFieldProxyModel* mFieldProxyModel; }; #endif // QGSFIELDCOMBOBOX_H diff --git a/src/gui/qgsfieldexpressionwidget.cpp b/src/gui/qgsfieldexpressionwidget.cpp index 47c4d3839ee..f05ac9932db 100644 --- a/src/gui/qgsfieldexpressionwidget.cpp +++ b/src/gui/qgsfieldexpressionwidget.cpp @@ -19,7 +19,7 @@ #include "qgsapplication.h" #include "qgsfieldexpressionwidget.h" #include "qgsexpressionbuilderdialog.h" -#include "qgsfieldmodel.h" +#include "qgsfieldproxymodel.h" #include "qgsdistancearea.h" QgsFieldExpressionWidget::QgsFieldExpressionWidget( QWidget *parent ) @@ -32,9 +32,9 @@ QgsFieldExpressionWidget::QgsFieldExpressionWidget( QWidget *parent ) mCombo = new QComboBox( this ); mCombo->setEditable( true ); mCombo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); - mFieldModel = new QgsFieldModel( mCombo ); - mFieldModel->setAllowExpression( true ); - mCombo->setModel( mFieldModel ); + mFieldProxyModel = new QgsFieldProxyModel( mCombo ); + mFieldProxyModel->sourceFieldModel()->setAllowExpression( true ); + mCombo->setModel( mFieldProxyModel ); mButton = new QToolButton( this ); mButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); @@ -59,6 +59,11 @@ void QgsFieldExpressionWidget::setExpressionDialogTitle( QString title ) mExpressionDialogTitle = title; } +void QgsFieldExpressionWidget::setFilters( QgsFieldProxyModel::Filters filters ) +{ + mFieldProxyModel->setFilters( filters ); +} + void QgsFieldExpressionWidget::setGeomCalculator( const QgsDistanceArea &da ) { mDa = QSharedPointer( new QgsDistanceArea( da ) ); @@ -76,27 +81,28 @@ QString QgsFieldExpressionWidget::currentField( bool *isExpression , bool *isVal } int i = mCombo->currentIndex(); - const QModelIndex index = mFieldModel->index( i, 0 ); - if ( !index.isValid() ) - { + const QModelIndex proxyIndex = mFieldProxyModel->index( i, 0 ); + if ( !proxyIndex.isValid() ) + return ""; + const QModelIndex index = mFieldProxyModel->mapToSource( proxyIndex ); + if ( !index.isValid() ) return ""; - } if ( isExpression ) { - *isExpression = mFieldModel->data( index, QgsFieldModel::IsExpressionRole ).toBool(); + *isExpression = mFieldProxyModel->data( index, QgsFieldModel::IsExpressionRole ).toBool(); } if ( isValid ) { - *isValid = mFieldModel->data( index, QgsFieldModel::ExpressionValidityRole ).toBool(); + *isValid = mFieldProxyModel->data( index, QgsFieldModel::ExpressionValidityRole ).toBool(); } - QString expression = mFieldModel->data( index, QgsFieldModel::ExpressionRole ).toString(); + QString expression = mFieldProxyModel->data( index, QgsFieldModel::ExpressionRole ).toString(); return expression; } QgsVectorLayer *QgsFieldExpressionWidget::layer() { - return mFieldModel->layer(); + return mFieldProxyModel->sourceFieldModel()->layer(); } void QgsFieldExpressionWidget::setLayer( QgsMapLayer *layer ) @@ -110,7 +116,7 @@ void QgsFieldExpressionWidget::setLayer( QgsMapLayer *layer ) void QgsFieldExpressionWidget::setLayer( QgsVectorLayer *layer ) { - mFieldModel->setLayer( layer ); + mFieldProxyModel->sourceFieldModel()->setLayer( layer ); } void QgsFieldExpressionWidget::setField( const QString fieldName ) @@ -118,13 +124,16 @@ void QgsFieldExpressionWidget::setField( const QString fieldName ) if ( fieldName.isEmpty() ) return; - QModelIndex idx = mFieldModel->indexFromName( fieldName ); + QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName ); if ( !idx.isValid() ) { // new expression - idx = mFieldModel->setExpression( fieldName ); + idx = mFieldProxyModel->sourceFieldModel()->setExpression( fieldName ); } - mCombo->setCurrentIndex( idx.row() ); + + QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx ); + + mCombo->setCurrentIndex( proxyIndex.row() ); currentFieldChanged(); } @@ -159,7 +168,7 @@ void QgsFieldExpressionWidget::expressionEdited( const QString expression ) void QgsFieldExpressionWidget::expressionEditingFinished() { const QString expression = mCombo->lineEdit()->text(); - QModelIndex idx = mFieldModel->setExpression( expression ); + QModelIndex idx = mFieldProxyModel->sourceFieldModel()->setExpression( expression ); mCombo->setCurrentIndex( idx.row() ); currentFieldChanged(); } diff --git a/src/gui/qgsfieldexpressionwidget.h b/src/gui/qgsfieldexpressionwidget.h index 02fbe69e075..ed9fb72d628 100644 --- a/src/gui/qgsfieldexpressionwidget.h +++ b/src/gui/qgsfieldexpressionwidget.h @@ -23,10 +23,10 @@ #include #include "qgsdistancearea.h" +#include "qgsfieldproxymodel.h" class QgsMapLayer; class QgsVectorLayer; -class QgsFieldModel; /** @@ -41,6 +41,7 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget { Q_OBJECT Q_PROPERTY( QString expressionDialogTitle READ expressionDialogTitle WRITE setExpressionDialogTitle ) + Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters ) public: /** @@ -54,6 +55,12 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget //! return the title used for the expression dialog const QString expressionDialogTitle() { return mExpressionDialogTitle; } + //! setFilters allows fitering according to the type of field + void setFilters( QgsFieldProxyModel::Filters filters ); + + //! currently used filter on list of fields + QgsFieldProxyModel::Filters filters() { return mFieldProxyModel->filters(); } + //! set the geometry calculator used in the expression dialog void setGeomCalculator( const QgsDistanceArea &da ); @@ -111,7 +118,7 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget private: QComboBox* mCombo; QToolButton* mButton; - QgsFieldModel* mFieldModel; + QgsFieldProxyModel* mFieldProxyModel; QString mExpressionDialogTitle; QSharedPointer mDa; }; diff --git a/src/gui/qgsfieldmodel.cpp b/src/gui/qgsfieldmodel.cpp index 56947cd98c9..12881a1e028 100644 --- a/src/gui/qgsfieldmodel.cpp +++ b/src/gui/qgsfieldmodel.cpp @@ -212,6 +212,15 @@ QVariant QgsFieldModel::data( const QModelIndex &index, int role ) const return true; } + case FieldTypeRole: + { + if ( exprIdx < 0 ) + { + QgsField field = mFields[index.internalId()]; + return ( int )field.type(); + } + } + case Qt::DisplayRole: case Qt::EditRole: { diff --git a/src/gui/qgsfieldmodel.h b/src/gui/qgsfieldmodel.h index 612e0e39a5c..b5ffcd099a4 100644 --- a/src/gui/qgsfieldmodel.h +++ b/src/gui/qgsfieldmodel.h @@ -38,7 +38,8 @@ class GUI_EXPORT QgsFieldModel : public QAbstractItemModel FieldIndexRole = Qt::UserRole + 2, /* return field index if index corresponds to a field */ ExpressionRole = Qt::UserRole + 3, /* return field name or expression */ IsExpressionRole = Qt::UserRole + 4, /* return if index corresponds to an expression */ - ExpressionValidityRole = Qt::UserRole + 5 /* return if expression is valid or not */ + ExpressionValidityRole = Qt::UserRole + 5, /* return if expression is valid or not */ + FieldTypeRole = Qt::UserRole + 6 /* return the field type (if a field, return QVariant if expression) */ }; /** diff --git a/src/gui/qgsfieldproxymodel.cpp b/src/gui/qgsfieldproxymodel.cpp new file mode 100644 index 00000000000..ad1bcdb21e9 --- /dev/null +++ b/src/gui/qgsfieldproxymodel.cpp @@ -0,0 +1,74 @@ +/*************************************************************************** + qgsfieldproxymodel.cpp + -------------------------------------- + Date : 01.04.2014 + Copyright : (C) 2014 Denis Rouzaud + Email : denis.rouzaud@gmail.com +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +***************************************************************************/ + +#include "qgsfieldproxymodel.h" +#include "qgsfieldmodel.h" +#include "qgsvectorlayer.h" + +QgsFieldProxyModel::QgsFieldProxyModel( QObject *parent ) + : QSortFilterProxyModel( parent ) + , mFilters( All ) + , mModel( new QgsFieldModel( this ) ) +{ + setSourceModel( mModel ); +} + +QgsFieldProxyModel *QgsFieldProxyModel::setFilters( Filters filters ) +{ + mFilters = filters; + return this; +} + +bool QgsFieldProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const +{ + if ( mFilters.testFlag( All ) ) + return true; + + QModelIndex index = sourceModel()->index( source_row, 0, source_parent ); + QVariant typeVar = sourceModel()->data( index, QgsFieldModel::FieldTypeRole ); + + // if expression, consider valid + if ( typeVar.isNull() ) + return true; + + bool ok; + QVariant::Type type = ( QVariant::Type )typeVar.toInt( &ok ); + if ( !ok ) + return true; + + if (( mFilters.testFlag( String ) && type == QVariant::String ) || + ( mFilters.testFlag( LongLong ) && type == QVariant::LongLong ) || + ( mFilters.testFlag( Int ) && type == QVariant::Int ) || + ( mFilters.testFlag( Double ) && type == QVariant::Double ) || + ( mFilters.testFlag( Date ) && type == QVariant::Date ) ) + return true; + + return false; +} + +bool QgsFieldProxyModel::lessThan( const QModelIndex &left, const QModelIndex &right ) const +{ + // order is field order, then expressions + bool lok, rok; + int leftId = sourceModel()->data( left, QgsFieldModel::FieldIndexRole ).toInt( &lok ); + int rightId = sourceModel()->data( right, QgsFieldModel::FieldIndexRole ).toInt( &rok ); + + if ( !lok ) + return false; + if ( !rok ) + return true; + + return leftId < rightId; +} diff --git a/src/gui/qgsfieldproxymodel.h b/src/gui/qgsfieldproxymodel.h new file mode 100644 index 00000000000..c6b9b7439cf --- /dev/null +++ b/src/gui/qgsfieldproxymodel.h @@ -0,0 +1,72 @@ +/*************************************************************************** + qgsfieldproxymodel.h + -------------------------------------- + Date : 01.04.2014 + Copyright : (C) 2014 Denis Rouzaud + Email : denis.rouzaud@gmail.com +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +***************************************************************************/ + +#ifndef QGSFIELDPROXYMODEL_H +#define QGSFIELDPROXYMODEL_H + +#include + +#include "qgsfieldmodel.h" + +/** + * @brief The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer. + * @note added in 2.3 + */ +class GUI_EXPORT QgsFieldProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT + public: + enum Filter + { + String = 1, + Int = 2, + LongLong = 4, + Double = 8, + Numeric = Int | LongLong | Double, + Date = 16, + All = Numeric | Date | String + }; + Q_DECLARE_FLAGS( Filters, Filter ) + + /** + * @brief QgsFieldProxModel creates a proxy model with a QgsFieldModel as source model. + * It can be used to filter the fields based on their types. + */ + explicit QgsFieldProxyModel( QObject *parent = 0 ); + + //! sourceFieldModel returns the QgsFieldModel used in this QSortFilterProxyModel + QgsFieldModel* sourceFieldModel() { return mModel; } + + /** + * @brief setFilters set flags that affect how fields are filtered + * @param filters are Filter flags + * @note added in 2.3 + */ + QgsFieldProxyModel* setFilters( Filters filters ); + const Filters& filters() const { return mFilters; } + + private: + Filters mFilters; + QgsFieldModel* mModel; + + // QSortFilterProxyModel interface + public: + bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const; + bool lessThan( const QModelIndex &left, const QModelIndex &right ) const; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFieldProxyModel::Filters ) + +#endif // QGSFIELDPROXYMODEL_H diff --git a/src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp b/src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp index 8ad2da53077..2baa8f9eaf8 100644 --- a/src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp +++ b/src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp @@ -358,6 +358,7 @@ QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget( QgsVecto // setup user interface setupUi( this ); + mExpressionWidget->setFilters( QgsFieldProxyModel::Numeric | QgsFieldProxyModel::Date ); mExpressionWidget->setLayer( mLayer ); cboGraduatedColorRamp->populate( mStyle );