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 );
48 mStack =
new QStackedWidget();
60 l =
new QHBoxLayout();
61 l->setContentsMargins( 0, 0, 0, 0 );
63 l->addWidget( mStack );
65 if ( !mWidget || !mForm )
68 mEditPage->layout()->addWidget( mWidget->
widget() );
71 setSizePolicy( mWidget->
widget()->sizePolicy() );
83 mSearchPage =
nullptr;
104 mSearchWidgets.clear();
105 mSearchWidgets << wrapper;
106 mSearchFrame->layout()->addWidget( wrapper->widget() );
107 mSearchWidgetToolButton->setAvailableFlags( wrapper->supportedFlags() );
109 mSearchWidgetToolButton->setDefaultFlags( wrapper->defaultFlags() );
116 mSearchWidgets << wrapper;
118 mSearchFrame->layout()->addWidget( wrapper->
widget() );
119 wrapper->
widget()->hide();
124 return mSearchWidgets;
129 if ( mSearchWidgets.isEmpty() )
132 if ( !mSearchWidgetToolButton->
isActive() )
140 return QStringLiteral(
"%1 AND %2" ).arg( filter1, filter2 );
147 return QStringLiteral(
"%1 OR %2" ).arg( filter1, filter2 );
150 return mSearchWidgets.at( 0 )->createExpression( mSearchWidgetToolButton->
activeFlags() );
156 const auto constMSearchWidgets = mSearchWidgets;
159 widget->clearWidget();
165 return mWidget->
layer();
170 const auto constMSearchWidgets = mSearchWidgets;
175 if ( !mSearchWidgetToolButton->
isActive() )
177 widget->clearWidget();
181 if ( mSearchWidgets.count() >= 2 )
188void QgsAttributeFormWidget::updateWidgets()
195 QWidget *currentVisibleWidget = mStack->currentWidget();
197 QWidget *newVisibleWidget =
nullptr;
202 newVisibleWidget = mEditPage;
208 newVisibleWidget = mSearchPage;
213 if ( newVisibleWidget != currentVisibleWidget )
215 if ( currentVisibleWidget )
218 mStack->removeWidget( currentVisibleWidget );
221 mStack->addWidget( newVisibleWidget );
222 mStack->setCurrentWidget( newVisibleWidget );
228 return mSearchWidgetToolButton->isVisible();
Represents a vector layer which manages a vector based data sets.