16 #include <QHBoxLayout>
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() );
84 mSearchWidgets.clear();
85 mSearchWidgets << wrapper;
86 mSearchFrame->layout()->addWidget( wrapper->widget() );
87 mSearchWidgetToolButton->setAvailableFlags( wrapper->supportedFlags() );
88 mSearchWidgetToolButton->setActiveFlags( QgsSearchWidgetWrapper::FilterFlags() );
89 mSearchWidgetToolButton->setDefaultFlags( wrapper->defaultFlags() );
96 mSearchWidgets << wrapper;
98 mSearchFrame->layout()->addWidget( wrapper->
widget() );
104 return mSearchWidgets;
109 if ( mSearchWidgets.isEmpty() )
112 if ( !mSearchWidgetToolButton->
isActive() )
120 return QStringLiteral(
"%1 AND %2" ).arg( filter1, filter2 );
127 return QStringLiteral(
"%1 OR %2" ).arg( filter1, filter2 );
130 return mSearchWidgets.at( 0 )->createExpression( mSearchWidgetToolButton->
activeFlags() );
136 const auto constMSearchWidgets = mSearchWidgets;
139 widget->clearWidget();
145 return mWidget->
layer();
148 void QgsAttributeFormWidget::searchWidgetFlagsChanged( QgsSearchWidgetWrapper::FilterFlags flags )
150 const auto constMSearchWidgets = mSearchWidgets;
155 if ( !mSearchWidgetToolButton->
isActive() )
157 widget->clearWidget();
161 if ( mSearchWidgets.count() >= 2 )
168 void QgsAttributeFormWidget::updateWidgets()
174 mStack->setCurrentWidget( mEditPage );
180 mStack->setCurrentWidget( mSearchPage );
189 return mSearchWidgetToolButton->isVisible();
Represents a vector layer which manages a vector based data sets.