16#include "moc_qgsattributeformwidget.cpp"
18#include <QStackedWidget>
28 mEditPage =
new QWidget();
29 QHBoxLayout *l =
new QHBoxLayout();
30 l->setContentsMargins( 0, 0, 0, 0 );
31 mEditPage->setLayout( l );
33 l =
new QHBoxLayout();
34 l->setContentsMargins( 0, 0, 0, 0 );
35 mSearchFrame =
new QWidget();
36 mSearchFrame->setLayout( l );
38 mSearchPage =
new QWidget();
39 l =
new QHBoxLayout();
40 l->setContentsMargins( 0, 0, 0, 0 );
41 mSearchPage->setLayout( l );
42 l->addWidget( mSearchFrame, 1 );
44 mSearchWidgetToolButton->setObjectName( QStringLiteral(
"SearchWidgetToolButton" ) );
46 this, &QgsAttributeFormWidget::searchWidgetFlagsChanged );
47 l->addWidget( mSearchWidgetToolButton, 0 );
49 mStack =
new QStackedWidget();
61 l =
new QHBoxLayout();
62 l->setContentsMargins( 0, 0, 0, 0 );
64 l->addWidget( mStack );
66 if ( !mWidget || !mForm )
69 mEditPage->layout()->addWidget( mWidget->
widget() );
72 setSizePolicy( mWidget->
widget()->sizePolicy() );
84 mSearchPage =
nullptr;
105 mSearchWidgets.clear();
106 mSearchWidgets << wrapper;
107 mSearchFrame->layout()->addWidget( wrapper->widget() );
108 mSearchWidgetToolButton->setAvailableFlags( wrapper->supportedFlags() );
110 mSearchWidgetToolButton->setDefaultFlags( wrapper->defaultFlags() );
117 mSearchWidgets << wrapper;
119 mSearchFrame->layout()->addWidget( wrapper->
widget() );
120 wrapper->
widget()->hide();
125 return mSearchWidgets;
130 if ( mSearchWidgets.isEmpty() )
133 if ( !mSearchWidgetToolButton->
isActive() )
141 return QStringLiteral(
"%1 AND %2" ).arg( filter1, filter2 );
148 return QStringLiteral(
"%1 OR %2" ).arg( filter1, filter2 );
151 return mSearchWidgets.at( 0 )->createExpression( mSearchWidgetToolButton->
activeFlags() );
157 const auto constMSearchWidgets = mSearchWidgets;
160 widget->clearWidget();
166 return mWidget->
layer();
171 const auto constMSearchWidgets = mSearchWidgets;
176 if ( !mSearchWidgetToolButton->
isActive() )
178 widget->clearWidget();
182 if ( mSearchWidgets.count() >= 2 )
189void QgsAttributeFormWidget::updateWidgets()
196 QWidget *currentVisibleWidget = mStack->currentWidget();
198 QWidget *newVisibleWidget =
nullptr;
203 newVisibleWidget = mEditPage;
209 newVisibleWidget = mSearchPage;
214 if ( newVisibleWidget != currentVisibleWidget )
216 if ( currentVisibleWidget )
219 mStack->removeWidget( currentVisibleWidget );
222 mStack->addWidget( newVisibleWidget );
223 mStack->setCurrentWidget( newVisibleWidget );
229 return mSearchWidgetToolButton->isVisible();
Represents a vector layer which manages a vector based data sets.