21 : QToolButton( parent )
27 setFocusPolicy( Qt::StrongFocus );
28 setPopupMode( QToolButton::InstantPopup );
30 mMenu =
new QMenu(
this );
31 connect( mMenu, &QMenu::aboutToShow,
this, &QgsSearchWidgetToolButton::aboutToShowMenu );
40 mFilterFlags &= flags;
41 mAvailableFilterFlags = flags;
42 mDefaultFilterFlags = mDefaultFilterFlags & flags;
48 mDefaultFilterFlags = flags & mAvailableFilterFlags;
54 QgsSearchWidgetWrapper::FilterFlags newFlags;
59 if ( !( mAvailableFilterFlags & flag ) )
73 if ( !( mAvailableFilterFlags & flag ) )
83 mFilterFlags = newFlags;
90 if ( !( flag & mAvailableFilterFlags ) )
95 if ( flag & mFilterFlags )
96 mFilterFlags &= ~flag;
105 mFilterFlags &= ~exclusiveFlag;
108 mFilterFlags |= flag;
118 if ( mFilterFlags & flag )
124 void QgsSearchWidgetToolButton::aboutToShowMenu()
127 bool fieldActive =
false;
130 if ( !( mAvailableFilterFlags & flag ) )
137 connect( action, &QAction::triggered,
this, &QgsSearchWidgetToolButton::actionSelected );
138 action->setData( flag );
139 action->setCheckable(
true );
140 if ( mFilterFlags & flag )
143 action->setChecked(
true );
147 QAction *clearAction = mMenu->addAction( tr(
"Exclude Field" ) );
149 clearAction->setCheckable(
true );
150 clearAction->setChecked( !fieldActive );
151 if ( mMenu->actions().count() > 0 )
153 mMenu->insertAction( mMenu->actions().at( 0 ), clearAction );
154 mMenu->insertSeparator( mMenu->actions().at( 1 ) );
157 mMenu->addAction( clearAction );
159 mMenu->addSeparator();
163 if ( !( mAvailableFilterFlags & flag ) )
170 connect( action, &QAction::triggered,
this, &QgsSearchWidgetToolButton::actionSelected );
171 action->setData( flag );
172 action->setCheckable(
true );
173 if ( mFilterFlags & flag )
174 action->setChecked(
true );
178 void QgsSearchWidgetToolButton::actionSelected()
184 void QgsSearchWidgetToolButton::searchWidgetValueChanged()
194 QgsSearchWidgetWrapper::FilterFlags newFlags;
197 if ( !( mAvailableFilterFlags & flag ) || !( mFilterFlags & flag ) )
201 mFilterFlags = newFlags;
212 if ( mDefaultFilterFlags & flag )
220 void QgsSearchWidgetToolButton::updateState()
223 QStringList toolTips;
226 if ( mFilterFlags & flag )
234 if ( mFilterFlags & flag )
242 QString text = toolTips.join( QStringLiteral(
", " ) );
248 setText( tr(
"Exclude field" ) );
249 setToolTip( QString() );