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;
60 if ( !( mAvailableFilterFlags & flag ) )
74 if ( !( mAvailableFilterFlags & flag ) )
84 mFilterFlags = newFlags;
91 if ( !( flag & mAvailableFilterFlags ) )
96 if ( flag & mFilterFlags )
97 mFilterFlags &= ~flag;
107 mFilterFlags &= ~exclusiveFlag;
110 mFilterFlags |= flag;
121 if ( mFilterFlags & flag )
127 void QgsSearchWidgetToolButton::aboutToShowMenu()
130 bool fieldActive =
false;
134 if ( !( mAvailableFilterFlags & flag ) )
141 connect( action, &QAction::triggered,
this, &QgsSearchWidgetToolButton::actionSelected );
142 action->setData( flag );
143 action->setCheckable(
true );
144 if ( mFilterFlags & flag )
147 action->setChecked(
true );
151 QAction *clearAction = mMenu->addAction( tr(
"Exclude Field" ) );
153 clearAction->setCheckable(
true );
154 clearAction->setChecked( !fieldActive );
155 if ( mMenu->actions().count() > 0 )
157 mMenu->insertAction( mMenu->actions().at( 0 ), clearAction );
158 mMenu->insertSeparator( mMenu->actions().at( 1 ) );
161 mMenu->addAction( clearAction );
163 mMenu->addSeparator();
168 if ( !( mAvailableFilterFlags & flag ) )
175 connect( action, &QAction::triggered,
this, &QgsSearchWidgetToolButton::actionSelected );
176 action->setData( flag );
177 action->setCheckable(
true );
178 if ( mFilterFlags & flag )
179 action->setChecked(
true );
183 void QgsSearchWidgetToolButton::actionSelected()
189 void QgsSearchWidgetToolButton::searchWidgetValueChanged()
199 QgsSearchWidgetWrapper::FilterFlags newFlags;
203 if ( !( mAvailableFilterFlags & flag ) || !( mFilterFlags & flag ) )
207 mFilterFlags = newFlags;
219 if ( mDefaultFilterFlags & flag )
227 void QgsSearchWidgetToolButton::updateState()
230 QStringList toolTips;
234 if ( mFilterFlags & flag )
243 if ( mFilterFlags & flag )
251 QString text = toolTips.join( QLatin1String(
", " ) );
257 setText( tr(
"Exclude Field" ) );
258 setToolTip( QString() );