From 533ab61543166008f1c49ba80dce2f39fe19a5c2 Mon Sep 17 00:00:00 2001 From: signedav Date: Tue, 11 Sep 2018 18:36:44 +0200 Subject: [PATCH] last fixes and sip_include --- .../auto_generated/qgsattributeeditorcontext.sip.in | 2 +- python/gui/auto_generated/qgsattributeform.sip.in | 10 ++++++++++ python/gui/gui_auto.sip | 2 +- src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp | 2 +- src/gui/qgsattributeeditorcontext.h | 4 ++-- src/gui/qgsattributeform.cpp | 4 ++-- src/gui/qgsattributeform.h | 12 ++++++++++++ 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/python/gui/auto_generated/qgsattributeeditorcontext.sip.in b/python/gui/auto_generated/qgsattributeeditorcontext.sip.in index e1d9b757e7e8..529558f82d17 100644 --- a/python/gui/auto_generated/qgsattributeeditorcontext.sip.in +++ b/python/gui/auto_generated/qgsattributeeditorcontext.sip.in @@ -225,7 +225,7 @@ Set ``attributeFormMode`` for the edited form .. versionadded:: 3.4 %End - QString attributeFormModeString( const Mode &attributeFormMode ); + QString attributeFormModeString() const; %Docstring Returns given ``attributeFormMode`` as string diff --git a/python/gui/auto_generated/qgsattributeform.sip.in b/python/gui/auto_generated/qgsattributeform.sip.in index b934d8df54c4..bdcec82a77fc 100644 --- a/python/gui/auto_generated/qgsattributeform.sip.in +++ b/python/gui/auto_generated/qgsattributeform.sip.in @@ -19,6 +19,16 @@ class QgsAttributeForm : QWidget %End public: + enum Mode + { + SingleEditMode, + AddFeatureMode, + MultiEditMode, + SearchMode, + AggregateSearchMode, + IdentifyMode + }; + enum FilterType { ReplaceFilter, diff --git a/python/gui/gui_auto.sip b/python/gui/gui_auto.sip index 612ba817d744..830ec3e2f451 100644 --- a/python/gui/gui_auto.sip +++ b/python/gui/gui_auto.sip @@ -1,5 +1,4 @@ // Include auto-generated SIP files -%Include auto_generated/qgsattributeeditorcontext.sip %Include auto_generated/qgsattributeforminterface.sip %Include auto_generated/qgsdetaileditemdata.sip %Include auto_generated/qgsexpressionbuilderdialog.sip @@ -208,6 +207,7 @@ %Include auto_generated/qgsvariableeditorwidget.sip %Include auto_generated/qgsvscrollarea.sip %Include auto_generated/qgsfiledownloaderdialog.sip +%Include auto_generated/qgsattributeeditorcontext.sip %Include auto_generated/raster/qgscolorrampshaderwidget.sip %Include auto_generated/raster/qgsmultibandcolorrendererwidget.sip %Include auto_generated/raster/qgspalettedrendererwidget.sip diff --git a/src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp b/src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp index c143956264b7..3637aa29a79e 100644 --- a/src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp +++ b/src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp @@ -87,7 +87,7 @@ void QgsQmlWidgetWrapper::setQmlContext( ) QgsAttributeEditorContext attributecontext = context(); QgsExpressionContext expressionContext = layer()->createExpressionContext(); - expressionContext << QgsExpressionContextUtils::formScope( mFeature, attributecontext.attributeFormModeString( attributecontext.attributeFormMode() ) ); + expressionContext << QgsExpressionContextUtils::formScope( mFeature, attributecontext.attributeFormModeString() ); expressionContext.setFeature( mFeature ); QmlExpression *qmlExpression = new QmlExpression(); diff --git a/src/gui/qgsattributeeditorcontext.h b/src/gui/qgsattributeeditorcontext.h index 37e6dfe63baa..2542e105a60b 100644 --- a/src/gui/qgsattributeeditorcontext.h +++ b/src/gui/qgsattributeeditorcontext.h @@ -236,10 +236,10 @@ class GUI_EXPORT QgsAttributeEditorContext * Returns given \a attributeFormMode as string * \since QGIS 3.4 */ - QString attributeFormModeString( const Mode &attributeFormMode ) + QString attributeFormModeString() const { const QMetaEnum metaEnum( QMetaEnum::fromType() ); - return metaEnum.valueToKey( static_cast( attributeFormMode ) ); + return metaEnum.valueToKey( static_cast( mAttributeFormMode ) ); } private: diff --git a/src/gui/qgsattributeform.cpp b/src/gui/qgsattributeform.cpp index 89cd6bcf9cf6..dc77ae38e0a9 100644 --- a/src/gui/qgsattributeform.cpp +++ b/src/gui/qgsattributeform.cpp @@ -805,7 +805,7 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww ) mExpressionContext.setFeature( ft ); - mExpressionContext << QgsExpressionContextUtils::formScope( ft, mContext.attributeFormModeString( mMode ) ); + mExpressionContext << QgsExpressionContextUtils::formScope( ft, mContext.attributeFormModeString() ); // Recheck visibility for all containers which are controlled by this value const QVector infos = mContainerInformationDependency.value( eww->field().name() ); @@ -819,7 +819,7 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww ) void QgsAttributeForm::updateContainersVisibility() { - mExpressionContext << QgsExpressionContextUtils::formScope( QgsFeature( mFeature ), mContext.attributeFormModeString( mMode ) ); + mExpressionContext << QgsExpressionContextUtils::formScope( QgsFeature( mFeature ), mContext.attributeFormModeString() ); const QVector infos = mContainerVisibilityInformation; diff --git a/src/gui/qgsattributeform.h b/src/gui/qgsattributeform.h index c5298456c069..645d7573229f 100644 --- a/src/gui/qgsattributeform.h +++ b/src/gui/qgsattributeform.h @@ -46,6 +46,18 @@ class GUI_EXPORT QgsAttributeForm : public QWidget public: + //! Form modes \deprecated Use QgsAttributeEditorContext::Mode instead. + enum Mode + { + SingleEditMode, //!< Single edit mode, for editing a single feature + AddFeatureMode, /*!< Add feature mode, for setting attributes for a new feature. In this mode the dialog will be editable even with an invalid feature and + will add a new feature when the form is accepted. */ + MultiEditMode, //!< Multi edit mode, for editing fields of multiple features at once + SearchMode, //!< Form values are used for searching/filtering the layer + AggregateSearchMode, //!< Form is in aggregate search mode, show each widget in this mode \since QGIS 3.0 + IdentifyMode //!< Identify the feature \since QGIS 3.0 + }; + //! Filter types enum FilterType {