mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Add QgsAttributeFormWidget
This commit is contained in:
parent
6d0f2afe4f
commit
f5559b5143
@ -55,6 +55,7 @@
|
||||
%Include qgsattributedialog.sip
|
||||
%Include qgsattributeform.sip
|
||||
%Include qgsattributeformeditorwidget.sip
|
||||
%Include qgsattributeformwidget.sip
|
||||
%Include qgsattributetypeloaddialog.sip
|
||||
%Include qgsblendmodecombobox.sip
|
||||
%Include qgsbrowsertreeview.sip
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
|
||||
class QgsAttributeFormEditorWidget : QWidget
|
||||
class QgsAttributeFormEditorWidget : QgsAttributeFormWidget
|
||||
{
|
||||
%Docstring
|
||||
A widget consisting of both an editor widget and additional widgets for controlling the behavior
|
||||
@ -24,15 +24,8 @@ class QgsAttributeFormEditorWidget : QWidget
|
||||
%End
|
||||
public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
DefaultMode,
|
||||
MultiEditMode,
|
||||
SearchMode,
|
||||
};
|
||||
|
||||
explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget,
|
||||
QgsAttributeForm *form /TransferThis/ );
|
||||
explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, const QString &widgetType,
|
||||
QgsAttributeForm *form /TransferThis/ );
|
||||
%Docstring
|
||||
Constructor for QgsAttributeFormEditorWidget.
|
||||
\param editorWidget associated editor widget wrapper (for default/edit modes)
|
||||
@ -41,32 +34,7 @@ class QgsAttributeFormEditorWidget : QWidget
|
||||
|
||||
~QgsAttributeFormEditorWidget();
|
||||
|
||||
void createSearchWidgetWrappers( const QString &widgetId, int fieldIdx,
|
||||
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
|
||||
virtual void createSearchWidgetWrappers();
|
||||
|
||||
void initialize( const QVariant &initialValue, bool mixedValues = false );
|
||||
%Docstring
|
||||
@ -88,7 +56,8 @@ class QgsAttributeFormEditorWidget : QWidget
|
||||
:rtype: QVariant
|
||||
%End
|
||||
|
||||
QString currentFilterExpression() const;
|
||||
virtual QString currentFilterExpression() const;
|
||||
|
||||
%Docstring
|
||||
Creates an expression matching the current search filter value and
|
||||
search properties represented in the widget.
|
||||
@ -156,7 +125,7 @@ class QgsAttributeFormEditorWidget : QWidget
|
||||
.. note::
|
||||
|
||||
this method is in place for unit testing only, and is not considered
|
||||
stable AP
|
||||
stable API
|
||||
%End
|
||||
|
||||
QWidget *searchWidgetFrame();
|
||||
@ -177,7 +146,7 @@ class QgsAttributeFormEditorWidget : QWidget
|
||||
.. note::
|
||||
|
||||
this method is in place for unit testing only, and is not considered
|
||||
stable AP
|
||||
stable API
|
||||
:rtype: list of QgsSearchWidgetWrapper
|
||||
%End
|
||||
|
||||
|
79
python/gui/qgsattributeformwidget.sip
Normal file
79
python/gui/qgsattributeformwidget.sip
Normal 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 *
|
||||
************************************************************************/
|
@ -197,6 +197,7 @@ SET(QGIS_GUI_SRCS
|
||||
qgsattributeforminterface.cpp
|
||||
qgsattributeformlegacyinterface.cpp
|
||||
qgsattributetypeloaddialog.cpp
|
||||
qgsattributeformwidget.cpp
|
||||
qgsblendmodecombobox.cpp
|
||||
qgsbrowsertreeview.cpp
|
||||
qgsbrowserdockwidget.cpp
|
||||
@ -370,6 +371,7 @@ SET(QGIS_GUI_MOC_HDRS
|
||||
qgsattributedialog.h
|
||||
qgsattributeform.h
|
||||
qgsattributeformeditorwidget.h
|
||||
qgsattributeformwidget.h
|
||||
qgsattributetypeloaddialog.h
|
||||
qgsblendmodecombobox.h
|
||||
qgsbrowsertreeview.h
|
||||
|
@ -151,24 +151,24 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
|
||||
}
|
||||
|
||||
//update all form editor widget modes to match
|
||||
Q_FOREACH ( QgsAttributeFormEditorWidget *w, findChildren< QgsAttributeFormEditorWidget * >() )
|
||||
for ( QgsAttributeFormWidget *w : findChildren< QgsAttributeFormWidget * >() )
|
||||
{
|
||||
switch ( mode )
|
||||
{
|
||||
case QgsAttributeForm::SingleEditMode:
|
||||
w->setMode( QgsAttributeFormEditorWidget::DefaultMode );
|
||||
w->setMode( QgsAttributeFormWidget::DefaultMode );
|
||||
break;
|
||||
|
||||
case QgsAttributeForm::AddFeatureMode:
|
||||
w->setMode( QgsAttributeFormEditorWidget::DefaultMode );
|
||||
w->setMode( QgsAttributeFormWidget::DefaultMode );
|
||||
break;
|
||||
|
||||
case QgsAttributeForm::MultiEditMode:
|
||||
w->setMode( QgsAttributeFormEditorWidget::MultiEditMode );
|
||||
w->setMode( QgsAttributeFormWidget::MultiEditMode );
|
||||
break;
|
||||
|
||||
case QgsAttributeForm::SearchMode:
|
||||
w->setMode( QgsAttributeFormEditorWidget::SearchMode );
|
||||
w->setMode( QgsAttributeFormWidget::SearchMode );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1221,10 +1221,10 @@ void QgsAttributeForm::init()
|
||||
QWidget *w = nullptr;
|
||||
if ( eww )
|
||||
{
|
||||
QgsAttributeFormEditorWidget *formWidget = new QgsAttributeFormEditorWidget( eww, this );
|
||||
QgsAttributeFormEditorWidget *formWidget = new QgsAttributeFormEditorWidget( eww, widgetSetup.type(), this );
|
||||
w = formWidget;
|
||||
mFormEditorWidgets.insert( idx, formWidget );
|
||||
formWidget->createSearchWidgetWrappers( widgetSetup.type(), idx, widgetSetup.config(), mContext );
|
||||
formWidget->createSearchWidgetWrappers( mContext );
|
||||
|
||||
l->setBuddy( eww->widget() );
|
||||
}
|
||||
@ -1523,10 +1523,10 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, fieldDef->name() );
|
||||
|
||||
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 );
|
||||
|
||||
w->createSearchWidgetWrappers( widgetSetup.type(), fldIdx, widgetSetup.config(), mContext );
|
||||
w->createSearchWidgetWrappers( mContext );
|
||||
|
||||
newWidgetInfo.widget = w;
|
||||
addWidgetWrapper( eww );
|
||||
|
@ -34,6 +34,7 @@ class QgsMessageBar;
|
||||
class QgsMessageBarItem;
|
||||
class QgsWidgetWrapper;
|
||||
class QgsTabWidget;
|
||||
class QgsAttributeFormWidget;
|
||||
|
||||
/**
|
||||
* \ingroup gui
|
||||
|
@ -26,12 +26,11 @@
|
||||
#include <QLabel>
|
||||
#include <QStackedWidget>
|
||||
|
||||
QgsAttributeFormEditorWidget::QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget,
|
||||
QgsAttributeForm *form )
|
||||
: QWidget( form )
|
||||
QgsAttributeFormEditorWidget::QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, const QString &widgetType, QgsAttributeForm *form )
|
||||
: QgsAttributeFormWidget( editorWidget, form )
|
||||
, mWidgetType( widgetType )
|
||||
, mWidget( editorWidget )
|
||||
, mForm( form )
|
||||
, mMode( DefaultMode )
|
||||
, mMultiEditButton( new QgsMultiEditToolButton() )
|
||||
, mBlockValueUpdate( false )
|
||||
, mIsMixed( false )
|
||||
@ -99,16 +98,20 @@ QgsAttributeFormEditorWidget::~QgsAttributeFormEditorWidget()
|
||||
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 );
|
||||
setSearchWidgetWrapper( sww );
|
||||
if ( sww->supportedFlags() & QgsSearchWidgetWrapper::Between ||
|
||||
sww->supportedFlags() & QgsSearchWidgetWrapper::IsNotBetween )
|
||||
{
|
||||
// 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 );
|
||||
mSearchWidgets << sww2;
|
||||
mSearchFrame->layout()->addWidget( sww2->widget() );
|
||||
@ -164,12 +167,6 @@ void QgsAttributeFormEditorWidget::setConstraintResultVisible( bool editable )
|
||||
mConstraintResultLabel->setHidden( !editable );
|
||||
}
|
||||
|
||||
void QgsAttributeFormEditorWidget::setMode( QgsAttributeFormEditorWidget::Mode mode )
|
||||
{
|
||||
mMode = mode;
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
void QgsAttributeFormEditorWidget::setIsMixed( bool mixed )
|
||||
{
|
||||
if ( mWidget && mixed )
|
||||
@ -249,7 +246,7 @@ void QgsAttributeFormEditorWidget::editorWidgetChanged( const QVariant &value )
|
||||
|
||||
mIsChanged = true;
|
||||
|
||||
switch ( mMode )
|
||||
switch ( mode() )
|
||||
{
|
||||
case DefaultMode:
|
||||
case SearchMode:
|
||||
@ -269,7 +266,7 @@ void QgsAttributeFormEditorWidget::resetValue()
|
||||
mWidget->setValue( mPreviousValue );
|
||||
mBlockValueUpdate = false;
|
||||
|
||||
switch ( mMode )
|
||||
switch ( mode() )
|
||||
{
|
||||
case DefaultMode:
|
||||
case SearchMode:
|
||||
@ -313,11 +310,6 @@ QgsSearchWidgetToolButton *QgsAttributeFormEditorWidget::searchWidgetToolButton(
|
||||
return mSearchWidgetToolButton;
|
||||
}
|
||||
|
||||
QgsVectorLayer *QgsAttributeFormEditorWidget::layer()
|
||||
{
|
||||
return mForm ? mForm->layer() : nullptr;
|
||||
}
|
||||
|
||||
void QgsAttributeFormEditorWidget::updateWidgets()
|
||||
{
|
||||
//first update the tool buttons
|
||||
@ -326,7 +318,7 @@ void QgsAttributeFormEditorWidget::updateWidgets()
|
||||
|
||||
if ( hasMultiEditButton )
|
||||
{
|
||||
if ( mMode != MultiEditMode || fieldReadOnly )
|
||||
if ( mode() != MultiEditMode || fieldReadOnly )
|
||||
{
|
||||
mEditPage->layout()->removeWidget( mMultiEditButton );
|
||||
mMultiEditButton->setParent( nullptr );
|
||||
@ -334,13 +326,13 @@ void QgsAttributeFormEditorWidget::updateWidgets()
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mMode == MultiEditMode && !fieldReadOnly )
|
||||
if ( mode() == MultiEditMode && !fieldReadOnly )
|
||||
{
|
||||
mEditPage->layout()->addWidget( mMultiEditButton );
|
||||
}
|
||||
}
|
||||
|
||||
switch ( mMode )
|
||||
switch ( mode() )
|
||||
{
|
||||
case DefaultMode:
|
||||
case MultiEditMode:
|
||||
|
@ -16,16 +16,11 @@
|
||||
#ifndef QGSATTRIBUTEFORMEDITORWIDGET_H
|
||||
#define QGSATTRIBUTEFORMEDITORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "qgis_sip.h"
|
||||
#include "qgis.h"
|
||||
#include <QVariant>
|
||||
#include "qgsattributeeditorcontext.h"
|
||||
#include "qgssearchwidgetwrapper.h"
|
||||
#include "qgis_gui.h"
|
||||
#include "qgseditorwidgetwrapper.h"
|
||||
#include "qgsattributeformwidget.h"
|
||||
|
||||
class QgsAttributeForm;
|
||||
class QgsEditorWidgetWrapper;
|
||||
class QgsMultiEditToolButton;
|
||||
class QgsSearchWidgetToolButton;
|
||||
@ -43,55 +38,23 @@ class QLabel;
|
||||
* controlling the multi edit results.
|
||||
* \since QGIS 2.16
|
||||
*/
|
||||
class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
|
||||
class GUI_EXPORT QgsAttributeFormEditorWidget : public QgsAttributeFormWidget
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor for QgsAttributeFormEditorWidget.
|
||||
* \param editorWidget associated editor widget wrapper (for default/edit modes)
|
||||
* \param form parent attribute form
|
||||
*/
|
||||
explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget,
|
||||
QgsAttributeForm *form SIP_TRANSFERTHIS );
|
||||
explicit QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper *editorWidget, const QString &widgetType,
|
||||
QgsAttributeForm *form SIP_TRANSFERTHIS );
|
||||
|
||||
~QgsAttributeFormEditorWidget();
|
||||
|
||||
/**
|
||||
* 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; }
|
||||
virtual void createSearchWidgetWrappers( const QgsAttributeEditorContext &context SIP_PYARGREMOVE = QgsAttributeEditorContext() ) override;
|
||||
|
||||
/**
|
||||
* Resets the widget to an initial value.
|
||||
@ -116,7 +79,7 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
|
||||
* search properties represented in the widget.
|
||||
* \since QGIS 2.16
|
||||
*/
|
||||
QString currentFilterExpression() const;
|
||||
QString currentFilterExpression() const override;
|
||||
|
||||
/**
|
||||
* 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()
|
||||
* as its parent
|
||||
* \note this method is in place for unit testing only, and is not considered
|
||||
* stable AP
|
||||
* stable API
|
||||
*/
|
||||
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
|
||||
* first be created using createSearchWidgetWrapper()
|
||||
* \note this method is in place for unit testing only, and is not considered
|
||||
* stable AP
|
||||
* stable API
|
||||
*/
|
||||
QList< QgsSearchWidgetWrapper * > searchWidgetWrappers();
|
||||
|
||||
@ -211,11 +174,11 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
|
||||
QStackedWidget *mStack = nullptr;
|
||||
QWidget *mSearchFrame = nullptr;
|
||||
|
||||
QString mWidgetType;
|
||||
QgsEditorWidgetWrapper *mWidget = nullptr;
|
||||
QList< QgsSearchWidgetWrapper * > mSearchWidgets;
|
||||
QgsAttributeForm *mForm = nullptr;
|
||||
QLabel *mConstraintResultLabel = nullptr;
|
||||
Mode mMode;
|
||||
|
||||
QgsMultiEditToolButton *mMultiEditButton = nullptr;
|
||||
QgsSearchWidgetToolButton *mSearchWidgetToolButton = nullptr;
|
||||
@ -224,8 +187,7 @@ class GUI_EXPORT QgsAttributeFormEditorWidget : public QWidget
|
||||
bool mIsMixed;
|
||||
bool mIsChanged;
|
||||
|
||||
QgsVectorLayer *layer();
|
||||
void updateWidgets();
|
||||
void updateWidgets() override;
|
||||
};
|
||||
|
||||
#endif // QGSATTRIBUTEFORMEDITORWIDGET_H
|
||||
|
28
src/gui/qgsattributeformwidget.cpp
Normal file
28
src/gui/qgsattributeformwidget.cpp
Normal 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;
|
||||
}
|
70
src/gui/qgsattributeformwidget.h
Normal file
70
src/gui/qgsattributeformwidget.h
Normal 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
|
Loading…
x
Reference in New Issue
Block a user