Add QgsAttributeFormWidget

This commit is contained in:
Matthias Kuhn 2017-11-01 19:44:41 +01:00
parent 6d0f2afe4f
commit f5559b5143
10 changed files with 223 additions and 119 deletions

View File

@ -55,6 +55,7 @@
%Include qgsattributedialog.sip %Include qgsattributedialog.sip
%Include qgsattributeform.sip %Include qgsattributeform.sip
%Include qgsattributeformeditorwidget.sip %Include qgsattributeformeditorwidget.sip
%Include qgsattributeformwidget.sip
%Include qgsattributetypeloaddialog.sip %Include qgsattributetypeloaddialog.sip
%Include qgsblendmodecombobox.sip %Include qgsblendmodecombobox.sip
%Include qgsbrowsertreeview.sip %Include qgsbrowsertreeview.sip

View File

@ -9,7 +9,7 @@
class QgsAttributeFormEditorWidget : QWidget class QgsAttributeFormEditorWidget : QgsAttributeFormWidget
{ {
%Docstring %Docstring
A widget consisting of both an editor widget and additional widgets for controlling the behavior A widget consisting of both an editor widget and additional widgets for controlling the behavior
@ -24,15 +24,8 @@ class QgsAttributeFormEditorWidget : QWidget
%End %End
public: public:
enum Mode explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, const QString &widgetType,
{ QgsAttributeForm *form /TransferThis/ );
DefaultMode,
MultiEditMode,
SearchMode,
};
explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget,
QgsAttributeForm *form /TransferThis/ );
%Docstring %Docstring
Constructor for QgsAttributeFormEditorWidget. Constructor for QgsAttributeFormEditorWidget.
\param editorWidget associated editor widget wrapper (for default/edit modes) \param editorWidget associated editor widget wrapper (for default/edit modes)
@ -41,32 +34,7 @@ class QgsAttributeFormEditorWidget : QWidget
~QgsAttributeFormEditorWidget(); ~QgsAttributeFormEditorWidget();
void createSearchWidgetWrappers( const QString &widgetId, int fieldIdx, virtual void createSearchWidgetWrappers();
const QVariantMap &config );
%Docstring
Creates the search widget wrappers for the widget used when the form is in
search mode.
\param widgetId id of the widget type to create a search wrapper for
\param fieldIdx index of field associated with widget
\param config configuration which should be used for the widget creation
\param context editor context (not available in Python bindings)
%End
void setMode( Mode mode );
%Docstring
Sets the current mode for the widget. The widget will adapt its state and visible widgets to
reflect the updated mode. For example, showing multi edit tool buttons if the mode is set to MultiEditMode.
\param mode widget mode
.. seealso:: mode()
%End
Mode mode() const;
%Docstring
Returns the current mode for the widget.
.. seealso:: setMode()
:rtype: Mode
%End
void initialize( const QVariant &initialValue, bool mixedValues = false ); void initialize( const QVariant &initialValue, bool mixedValues = false );
%Docstring %Docstring
@ -88,7 +56,8 @@ class QgsAttributeFormEditorWidget : QWidget
:rtype: QVariant :rtype: QVariant
%End %End
QString currentFilterExpression() const; virtual QString currentFilterExpression() const;
%Docstring %Docstring
Creates an expression matching the current search filter value and Creates an expression matching the current search filter value and
search properties represented in the widget. search properties represented in the widget.
@ -156,7 +125,7 @@ class QgsAttributeFormEditorWidget : QWidget
.. note:: .. note::
this method is in place for unit testing only, and is not considered this method is in place for unit testing only, and is not considered
stable AP stable API
%End %End
QWidget *searchWidgetFrame(); QWidget *searchWidgetFrame();
@ -177,7 +146,7 @@ class QgsAttributeFormEditorWidget : QWidget
.. note:: .. note::
this method is in place for unit testing only, and is not considered this method is in place for unit testing only, and is not considered
stable AP stable API
:rtype: list of QgsSearchWidgetWrapper :rtype: list of QgsSearchWidgetWrapper
%End %End

View File

@ -0,0 +1,79 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsattributeformwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsAttributeFormWidget : QWidget /Abstract/
{
%TypeHeaderCode
#include "qgsattributeformwidget.h"
%End
public:
enum Mode
{
DefaultMode,
MultiEditMode,
SearchMode,
};
explicit QgsAttributeFormWidget( QgsWidgetWrapper *widget, QgsAttributeForm *form );
virtual void createSearchWidgetWrappers() = 0;
%Docstring
Creates the search widget wrappers for the widget used when the form is in
search mode.
\param context editor context (not available in Python bindings)
%End
virtual QString currentFilterExpression() const = 0;
%Docstring
Creates an expression matching the current search filter value and
search properties represented in the widget.
.. versionadded:: 2.16
:rtype: str
%End
void setMode( Mode mode );
%Docstring
Sets the current mode for the widget. The widget will adapt its state and visible widgets to
reflect the updated mode. For example, showing multi edit tool buttons if the mode is set to MultiEditMode.
\param mode widget mode
.. seealso:: mode()
%End
Mode mode() const;
%Docstring
Returns the current mode for the widget.
.. seealso:: setMode()
:rtype: Mode
%End
QgsVectorLayer *layer();
%Docstring
:rtype: QgsVectorLayer
%End
QgsAttributeForm *form() const;
%Docstring
:rtype: QgsAttributeForm
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsattributeformwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -197,6 +197,7 @@ SET(QGIS_GUI_SRCS
qgsattributeforminterface.cpp qgsattributeforminterface.cpp
qgsattributeformlegacyinterface.cpp qgsattributeformlegacyinterface.cpp
qgsattributetypeloaddialog.cpp qgsattributetypeloaddialog.cpp
qgsattributeformwidget.cpp
qgsblendmodecombobox.cpp qgsblendmodecombobox.cpp
qgsbrowsertreeview.cpp qgsbrowsertreeview.cpp
qgsbrowserdockwidget.cpp qgsbrowserdockwidget.cpp
@ -370,6 +371,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsattributedialog.h qgsattributedialog.h
qgsattributeform.h qgsattributeform.h
qgsattributeformeditorwidget.h qgsattributeformeditorwidget.h
qgsattributeformwidget.h
qgsattributetypeloaddialog.h qgsattributetypeloaddialog.h
qgsblendmodecombobox.h qgsblendmodecombobox.h
qgsbrowsertreeview.h qgsbrowsertreeview.h

View File

@ -151,24 +151,24 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
} }
//update all form editor widget modes to match //update all form editor widget modes to match
Q_FOREACH ( QgsAttributeFormEditorWidget *w, findChildren< QgsAttributeFormEditorWidget * >() ) for ( QgsAttributeFormWidget *w : findChildren< QgsAttributeFormWidget * >() )
{ {
switch ( mode ) switch ( mode )
{ {
case QgsAttributeForm::SingleEditMode: case QgsAttributeForm::SingleEditMode:
w->setMode( QgsAttributeFormEditorWidget::DefaultMode ); w->setMode( QgsAttributeFormWidget::DefaultMode );
break; break;
case QgsAttributeForm::AddFeatureMode: case QgsAttributeForm::AddFeatureMode:
w->setMode( QgsAttributeFormEditorWidget::DefaultMode ); w->setMode( QgsAttributeFormWidget::DefaultMode );
break; break;
case QgsAttributeForm::MultiEditMode: case QgsAttributeForm::MultiEditMode:
w->setMode( QgsAttributeFormEditorWidget::MultiEditMode ); w->setMode( QgsAttributeFormWidget::MultiEditMode );
break; break;
case QgsAttributeForm::SearchMode: case QgsAttributeForm::SearchMode:
w->setMode( QgsAttributeFormEditorWidget::SearchMode ); w->setMode( QgsAttributeFormWidget::SearchMode );
break; break;
} }
} }
@ -1221,10 +1221,10 @@ void QgsAttributeForm::init()
QWidget *w = nullptr; QWidget *w = nullptr;
if ( eww ) if ( eww )
{ {
QgsAttributeFormEditorWidget *formWidget = new QgsAttributeFormEditorWidget( eww, this ); QgsAttributeFormEditorWidget *formWidget = new QgsAttributeFormEditorWidget( eww, widgetSetup.type(), this );
w = formWidget; w = formWidget;
mFormEditorWidgets.insert( idx, formWidget ); mFormEditorWidgets.insert( idx, formWidget );
formWidget->createSearchWidgetWrappers( widgetSetup.type(), idx, widgetSetup.config(), mContext ); formWidget->createSearchWidgetWrappers( mContext );
l->setBuddy( eww->widget() ); l->setBuddy( eww->widget() );
} }
@ -1523,10 +1523,10 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, fieldDef->name() ); const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, fieldDef->name() );
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( widgetSetup.type(), mLayer, fldIdx, widgetSetup.config(), nullptr, this, mContext ); QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( widgetSetup.type(), mLayer, fldIdx, widgetSetup.config(), nullptr, this, mContext );
QgsAttributeFormEditorWidget *w = new QgsAttributeFormEditorWidget( eww, this ); QgsAttributeFormEditorWidget *w = new QgsAttributeFormEditorWidget( eww, widgetSetup.type(), this );
mFormEditorWidgets.insert( fldIdx, w ); mFormEditorWidgets.insert( fldIdx, w );
w->createSearchWidgetWrappers( widgetSetup.type(), fldIdx, widgetSetup.config(), mContext ); w->createSearchWidgetWrappers( mContext );
newWidgetInfo.widget = w; newWidgetInfo.widget = w;
addWidgetWrapper( eww ); addWidgetWrapper( eww );

View File

@ -34,6 +34,7 @@ class QgsMessageBar;
class QgsMessageBarItem; class QgsMessageBarItem;
class QgsWidgetWrapper; class QgsWidgetWrapper;
class QgsTabWidget; class QgsTabWidget;
class QgsAttributeFormWidget;
/** /**
* \ingroup gui * \ingroup gui

View File

@ -26,12 +26,11 @@
#include <QLabel> #include <QLabel>
#include <QStackedWidget> #include <QStackedWidget>
QgsAttributeFormEditorWidget::QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, QgsAttributeFormEditorWidget::QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, const QString &widgetType, QgsAttributeForm *form )
QgsAttributeForm *form ) : QgsAttributeFormWidget( editorWidget, form )
: QWidget( form ) , mWidgetType( widgetType )
, mWidget( editorWidget ) , mWidget( editorWidget )
, mForm( form ) , mForm( form )
, mMode( DefaultMode )
, mMultiEditButton( new QgsMultiEditToolButton() ) , mMultiEditButton( new QgsMultiEditToolButton() )
, mBlockValueUpdate( false ) , mBlockValueUpdate( false )
, mIsMixed( false ) , mIsMixed( false )
@ -99,16 +98,20 @@ QgsAttributeFormEditorWidget::~QgsAttributeFormEditorWidget()
delete mMultiEditButton; delete mMultiEditButton;
} }
void QgsAttributeFormEditorWidget::createSearchWidgetWrappers( const QString &widgetId, int fieldIdx, const QVariantMap &config, const QgsAttributeEditorContext &context ) void QgsAttributeFormEditorWidget::createSearchWidgetWrappers( const QgsAttributeEditorContext &context )
{ {
QgsSearchWidgetWrapper *sww = QgsGui::editorWidgetRegistry()->createSearchWidget( widgetId, layer(), fieldIdx, config, Q_ASSERT( !mWidgetType.isEmpty() );
const QVariantMap config = mWidget->config();
const int fieldIdx = mWidget->fieldIdx();
QgsSearchWidgetWrapper *sww = QgsGui::editorWidgetRegistry()->createSearchWidget( mWidgetType, layer(), fieldIdx, config,
mSearchFrame, context ); mSearchFrame, context );
setSearchWidgetWrapper( sww ); setSearchWidgetWrapper( sww );
if ( sww->supportedFlags() & QgsSearchWidgetWrapper::Between || if ( sww->supportedFlags() & QgsSearchWidgetWrapper::Between ||
sww->supportedFlags() & QgsSearchWidgetWrapper::IsNotBetween ) sww->supportedFlags() & QgsSearchWidgetWrapper::IsNotBetween )
{ {
// create secondary widget for between type searches // create secondary widget for between type searches
QgsSearchWidgetWrapper *sww2 = QgsGui::editorWidgetRegistry()->createSearchWidget( widgetId, layer(), fieldIdx, config, QgsSearchWidgetWrapper *sww2 = QgsGui::editorWidgetRegistry()->createSearchWidget( mWidgetType, layer(), fieldIdx, config,
mSearchFrame, context ); mSearchFrame, context );
mSearchWidgets << sww2; mSearchWidgets << sww2;
mSearchFrame->layout()->addWidget( sww2->widget() ); mSearchFrame->layout()->addWidget( sww2->widget() );
@ -164,12 +167,6 @@ void QgsAttributeFormEditorWidget::setConstraintResultVisible( bool editable )
mConstraintResultLabel->setHidden( !editable ); mConstraintResultLabel->setHidden( !editable );
} }
void QgsAttributeFormEditorWidget::setMode( QgsAttributeFormEditorWidget::Mode mode )
{
mMode = mode;
updateWidgets();
}
void QgsAttributeFormEditorWidget::setIsMixed( bool mixed ) void QgsAttributeFormEditorWidget::setIsMixed( bool mixed )
{ {
if ( mWidget && mixed ) if ( mWidget && mixed )
@ -249,7 +246,7 @@ void QgsAttributeFormEditorWidget::editorWidgetChanged( const QVariant &value )
mIsChanged = true; mIsChanged = true;
switch ( mMode ) switch ( mode() )
{ {
case DefaultMode: case DefaultMode:
case SearchMode: case SearchMode:
@ -269,7 +266,7 @@ void QgsAttributeFormEditorWidget::resetValue()
mWidget->setValue( mPreviousValue ); mWidget->setValue( mPreviousValue );
mBlockValueUpdate = false; mBlockValueUpdate = false;
switch ( mMode ) switch ( mode() )
{ {
case DefaultMode: case DefaultMode:
case SearchMode: case SearchMode:
@ -313,11 +310,6 @@ QgsSearchWidgetToolButton *QgsAttributeFormEditorWidget::searchWidgetToolButton(
return mSearchWidgetToolButton; return mSearchWidgetToolButton;
} }
QgsVectorLayer *QgsAttributeFormEditorWidget::layer()
{
return mForm ? mForm->layer() : nullptr;
}
void QgsAttributeFormEditorWidget::updateWidgets() void QgsAttributeFormEditorWidget::updateWidgets()
{ {
//first update the tool buttons //first update the tool buttons
@ -326,7 +318,7 @@ void QgsAttributeFormEditorWidget::updateWidgets()
if ( hasMultiEditButton ) if ( hasMultiEditButton )
{ {
if ( mMode != MultiEditMode || fieldReadOnly ) if ( mode() != MultiEditMode || fieldReadOnly )
{ {
mEditPage->layout()->removeWidget( mMultiEditButton ); mEditPage->layout()->removeWidget( mMultiEditButton );
mMultiEditButton->setParent( nullptr ); mMultiEditButton->setParent( nullptr );
@ -334,13 +326,13 @@ void QgsAttributeFormEditorWidget::updateWidgets()
} }
else else
{ {
if ( mMode == MultiEditMode && !fieldReadOnly ) if ( mode() == MultiEditMode && !fieldReadOnly )
{ {
mEditPage->layout()->addWidget( mMultiEditButton ); mEditPage->layout()->addWidget( mMultiEditButton );
} }
} }
switch ( mMode ) switch ( mode() )
{ {
case DefaultMode: case DefaultMode:
case MultiEditMode: case MultiEditMode:

View File

@ -16,16 +16,11 @@
#ifndef QGSATTRIBUTEFORMEDITORWIDGET_H #ifndef QGSATTRIBUTEFORMEDITORWIDGET_H
#define QGSATTRIBUTEFORMEDITORWIDGET_H #define QGSATTRIBUTEFORMEDITORWIDGET_H
#include <QWidget>
#include "qgis_sip.h" #include "qgis_sip.h"
#include "qgis.h"
#include <QVariant>
#include "qgsattributeeditorcontext.h"
#include "qgssearchwidgetwrapper.h"
#include "qgis_gui.h" #include "qgis_gui.h"
#include "qgseditorwidgetwrapper.h" #include "qgseditorwidgetwrapper.h"
#include "qgsattributeformwidget.h"
class QgsAttributeForm;
class QgsEditorWidgetWrapper; class QgsEditorWidgetWrapper;
class QgsMultiEditToolButton; class QgsMultiEditToolButton;
class QgsSearchWidgetToolButton; class QgsSearchWidgetToolButton;
@ -43,55 +38,23 @@ class QLabel;
* controlling the multi edit results. * controlling the multi edit results.
* \since QGIS 2.16 * \since QGIS 2.16
*/ */
class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget class GUI_EXPORT QgsAttributeFormEditorWidget : public QgsAttributeFormWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Widget modes
enum Mode
{
DefaultMode, //!< Default mode, only the editor widget is shown
MultiEditMode, //!< Multi edit mode, both the editor widget and a QgsMultiEditToolButton is shown
SearchMode, //!< Layer search/filter mode
};
/** /**
* Constructor for QgsAttributeFormEditorWidget. * Constructor for QgsAttributeFormEditorWidget.
* \param editorWidget associated editor widget wrapper (for default/edit modes) * \param editorWidget associated editor widget wrapper (for default/edit modes)
* \param form parent attribute form * \param form parent attribute form
*/ */
explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, const QString &widgetType,
QgsAttributeForm *form SIP_TRANSFERTHIS ); QgsAttributeForm *form SIP_TRANSFERTHIS );
~QgsAttributeFormEditorWidget(); ~QgsAttributeFormEditorWidget();
/** virtual void createSearchWidgetWrappers( const QgsAttributeEditorContext &context SIP_PYARGREMOVE = QgsAttributeEditorContext() ) override;
* Creates the search widget wrappers for the widget used when the form is in
* search mode.
* \param widgetId id of the widget type to create a search wrapper for
* \param fieldIdx index of field associated with widget
* \param config configuration which should be used for the widget creation
* \param context editor context (not available in Python bindings)
*/
void createSearchWidgetWrappers( const QString &widgetId, int fieldIdx,
const QVariantMap &config,
const QgsAttributeEditorContext &context SIP_PYARGREMOVE = QgsAttributeEditorContext() );
/**
* Sets the current mode for the widget. The widget will adapt its state and visible widgets to
* reflect the updated mode. For example, showing multi edit tool buttons if the mode is set to MultiEditMode.
* \param mode widget mode
* \see mode()
*/
void setMode( Mode mode );
/**
* Returns the current mode for the widget.
* \see setMode()
*/
Mode mode() const { return mMode; }
/** /**
* Resets the widget to an initial value. * Resets the widget to an initial value.
@ -116,7 +79,7 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
* search properties represented in the widget. * search properties represented in the widget.
* \since QGIS 2.16 * \since QGIS 2.16
*/ */
QString currentFilterExpression() const; QString currentFilterExpression() const override;
/** /**
* Set the constraint status for this widget. * Set the constraint status for this widget.
@ -184,7 +147,7 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
* \note the search widget wrapper should be created using searchWidgetFrame() * \note the search widget wrapper should be created using searchWidgetFrame()
* as its parent * as its parent
* \note this method is in place for unit testing only, and is not considered * \note this method is in place for unit testing only, and is not considered
* stable AP * stable API
*/ */
void setSearchWidgetWrapper( QgsSearchWidgetWrapper *wrapper ); void setSearchWidgetWrapper( QgsSearchWidgetWrapper *wrapper );
@ -200,7 +163,7 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
* Returns the search widget wrapper used in this widget. The wrapper must * Returns the search widget wrapper used in this widget. The wrapper must
* first be created using createSearchWidgetWrapper() * first be created using createSearchWidgetWrapper()
* \note this method is in place for unit testing only, and is not considered * \note this method is in place for unit testing only, and is not considered
* stable AP * stable API
*/ */
QList< QgsSearchWidgetWrapper * > searchWidgetWrappers(); QList< QgsSearchWidgetWrapper * > searchWidgetWrappers();
@ -211,11 +174,11 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
QStackedWidget *mStack = nullptr; QStackedWidget *mStack = nullptr;
QWidget *mSearchFrame = nullptr; QWidget *mSearchFrame = nullptr;
QString mWidgetType;
QgsEditorWidgetWrapper *mWidget = nullptr; QgsEditorWidgetWrapper *mWidget = nullptr;
QList< QgsSearchWidgetWrapper * > mSearchWidgets; QList< QgsSearchWidgetWrapper * > mSearchWidgets;
QgsAttributeForm *mForm = nullptr; QgsAttributeForm *mForm = nullptr;
QLabel *mConstraintResultLabel = nullptr; QLabel *mConstraintResultLabel = nullptr;
Mode mMode;
QgsMultiEditToolButton *mMultiEditButton = nullptr; QgsMultiEditToolButton *mMultiEditButton = nullptr;
QgsSearchWidgetToolButton *mSearchWidgetToolButton = nullptr; QgsSearchWidgetToolButton *mSearchWidgetToolButton = nullptr;
@ -224,8 +187,7 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
bool mIsMixed; bool mIsMixed;
bool mIsChanged; bool mIsChanged;
QgsVectorLayer *layer(); void updateWidgets() override;
void updateWidgets();
}; };
#endif // QGSATTRIBUTEFORMEDITORWIDGET_H #endif // QGSATTRIBUTEFORMEDITORWIDGET_H

View File

@ -0,0 +1,28 @@
#include "qgsattributeformwidget.h"
#include "qgsattributeform.h"
QgsAttributeFormWidget::QgsAttributeFormWidget( QgsWidgetWrapper *widget, QgsAttributeForm *form )
: QWidget( form )
, mMode( DefaultMode )
, mForm( form )
{
}
void QgsAttributeFormWidget::setMode( QgsAttributeFormWidget::Mode mode )
{
mMode = mode;
updateWidgets();
}
QgsAttributeForm *QgsAttributeFormWidget::form() const
{
return mForm;
}
QgsVectorLayer *QgsAttributeFormWidget::layer()
{
QgsAttributeForm *aform = form();
return aform ? aform->layer() : nullptr;
}

View File

@ -0,0 +1,70 @@
#ifndef QGSATTRIBUTEFORMWIDGET_H
#define QGSATTRIBUTEFORMWIDGET_H
#include "qgis.h"
#include "qgis_gui.h"
#include "qgsattributeeditorcontext.h"
#include "qgssearchwidgetwrapper.h"
#include <QWidget>
#include <QVariant>
class QgsAttributeForm;
class GUI_EXPORT QgsAttributeFormWidget : public QWidget // SIP_ABSTRACT
{
Q_OBJECT
public:
//! Widget modes
enum Mode
{
DefaultMode, //!< Default mode, only the editor widget is shown
MultiEditMode, //!< Multi edit mode, both the editor widget and a QgsMultiEditToolButton is shown
SearchMode, //!< Layer search/filter mode
};
explicit QgsAttributeFormWidget( QgsWidgetWrapper *widget, QgsAttributeForm *form );
/**
* Creates the search widget wrappers for the widget used when the form is in
* search mode.
*
* \param context editor context (not available in Python bindings)
*/
virtual void createSearchWidgetWrappers( const QgsAttributeEditorContext &context SIP_PYARGREMOVE = QgsAttributeEditorContext() ) = 0;
/**
* Creates an expression matching the current search filter value and
* search properties represented in the widget.
* \since QGIS 2.16
*/
virtual QString currentFilterExpression() const = 0;
/**
* Sets the current mode for the widget. The widget will adapt its state and visible widgets to
* reflect the updated mode. For example, showing multi edit tool buttons if the mode is set to MultiEditMode.
* \param mode widget mode
* \see mode()
*/
void setMode( Mode mode );
/**
* Returns the current mode for the widget.
* \see setMode()
*/
Mode mode() const { return mMode; }
QgsVectorLayer *layer();
QgsAttributeForm *form() const;
private:
QgsAttributeFormWidget::Mode mMode = DefaultMode;
virtual void updateWidgets() = 0;
QgsAttributeForm *mForm = nullptr;
};
#endif // QGSATTRIBUTEFORMWIDGET_H