17#include <QStackedWidget>
27 mEditPage =
new QWidget();
28 QHBoxLayout *l =
new QHBoxLayout();
29 l->setContentsMargins( 0, 0, 0, 0 );
30 mEditPage->setLayout( l );
32 l =
new QHBoxLayout();
33 l->setContentsMargins( 0, 0, 0, 0 );
34 mSearchFrame =
new QWidget();
35 mSearchFrame->setLayout( l );
37 mSearchPage =
new QWidget();
38 l =
new QHBoxLayout();
39 l->setContentsMargins( 0, 0, 0, 0 );
40 mSearchPage->setLayout( l );
41 l->addWidget( mSearchFrame, 1 );
43 mSearchWidgetToolButton->setObjectName( QStringLiteral(
"SearchWidgetToolButton" ) );
45 this, &QgsAttributeFormWidget::searchWidgetFlagsChanged );
46 l->addWidget( mSearchWidgetToolButton, 0 );
49 mStack =
new QStackedWidget;
50 mStack->addWidget( mEditPage );
51 mStack->addWidget( mSearchPage );
53 l =
new QHBoxLayout();
54 l->setContentsMargins( 0, 0, 0, 0 );
56 l->addWidget( mStack );
58 if ( !mWidget || !mForm )
61 mEditPage->layout()->addWidget( mWidget->
widget() );
64 setSizePolicy( mWidget->
widget()->sizePolicy() );
87 mSearchWidgets.clear();
88 mSearchWidgets << wrapper;
89 mSearchFrame->layout()->addWidget( wrapper->widget() );
90 mSearchWidgetToolButton->setAvailableFlags( wrapper->supportedFlags() );
91 mSearchWidgetToolButton->setActiveFlags( QgsSearchWidgetWrapper::FilterFlags() );
92 mSearchWidgetToolButton->setDefaultFlags( wrapper->defaultFlags() );
99 mSearchWidgets << wrapper;
101 mSearchFrame->layout()->addWidget( wrapper->
widget() );
102 wrapper->
widget()->hide();
107 return mSearchWidgets;
112 if ( mSearchWidgets.isEmpty() )
115 if ( !mSearchWidgetToolButton->
isActive() )
123 return QStringLiteral(
"%1 AND %2" ).arg( filter1, filter2 );
130 return QStringLiteral(
"%1 OR %2" ).arg( filter1, filter2 );
133 return mSearchWidgets.at( 0 )->createExpression( mSearchWidgetToolButton->
activeFlags() );
139 const auto constMSearchWidgets = mSearchWidgets;
142 widget->clearWidget();
148 return mWidget->
layer();
151void QgsAttributeFormWidget::searchWidgetFlagsChanged( QgsSearchWidgetWrapper::FilterFlags flags )
153 const auto constMSearchWidgets = mSearchWidgets;
158 if ( !mSearchWidgetToolButton->
isActive() )
160 widget->clearWidget();
164 if ( mSearchWidgets.count() >= 2 )
171void QgsAttributeFormWidget::updateWidgets()
177 mStack->setCurrentWidget( mEditPage );
183 mStack->setCurrentWidget( mSearchPage );
192 return mSearchWidgetToolButton->isVisible();
Represents a vector layer which manages a vector based data sets.