mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Only show action results when . prefix is used
This commit is contained in:
parent
102a46662b
commit
a53516d71d
@ -139,6 +139,21 @@ class QgsLocatorFilter : QObject
|
||||
result.
|
||||
%End
|
||||
|
||||
bool useWithoutPrefix() const;
|
||||
%Docstring
|
||||
Returns true if the filter should be used when no prefix
|
||||
is entered.
|
||||
.. seealso:: setUseWithoutPrefix()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
void setUseWithoutPrefix( bool useWithoutPrefix );
|
||||
%Docstring
|
||||
Sets whether the filter should be used when no prefix
|
||||
is entered.
|
||||
.. seealso:: useWithoutPrefix()
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void resultFetched( const QgsLocatorResult &result );
|
||||
|
@ -103,7 +103,7 @@ QgsActionLocatorFilter::QgsActionLocatorFilter( const QList<QWidget *> &parentOb
|
||||
: QgsLocatorFilter( parent )
|
||||
, mActionParents( parentObjectsForActions )
|
||||
{
|
||||
|
||||
setUseWithoutPrefix( false );
|
||||
}
|
||||
|
||||
void QgsActionLocatorFilter::fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback )
|
||||
|
@ -89,18 +89,25 @@ void QgsLocator::fetchResults( const QString &string, const QgsLocatorContext &c
|
||||
}
|
||||
mFeedback = feedback;
|
||||
|
||||
mActiveFilters = mFilters;
|
||||
mActiveFilters.clear();
|
||||
QString searchString = string;
|
||||
if ( searchString.indexOf( ' ' ) > 0 )
|
||||
{
|
||||
QString prefix = searchString.left( searchString.indexOf( ' ' ) );
|
||||
if ( mPrefixedFilters.contains( prefix ) )
|
||||
{
|
||||
mActiveFilters.clear();
|
||||
mActiveFilters << mPrefixedFilters.value( prefix );
|
||||
searchString = searchString.mid( prefix.length() + 1 );
|
||||
}
|
||||
}
|
||||
if ( mActiveFilters.isEmpty() )
|
||||
{
|
||||
Q_FOREACH ( QgsLocatorFilter *filter, mFilters )
|
||||
{
|
||||
if ( filter->useWithoutPrefix() )
|
||||
mActiveFilters << filter;
|
||||
}
|
||||
}
|
||||
|
||||
auto gatherFilterResults = [searchString, context, feedback]( QgsLocatorFilter * filter )
|
||||
{
|
||||
|
@ -23,3 +23,18 @@ QgsLocatorFilter::QgsLocatorFilter( QObject *parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool QgsLocatorFilter::stringMatches( const QString &test, const QString &match )
|
||||
{
|
||||
return QgsStringUtils::containsFuzzy( match, test );
|
||||
}
|
||||
|
||||
bool QgsLocatorFilter::useWithoutPrefix() const
|
||||
{
|
||||
return mUseWithoutPrefix;
|
||||
}
|
||||
|
||||
void QgsLocatorFilter::setUseWithoutPrefix( bool useWithoutPrefix )
|
||||
{
|
||||
mUseWithoutPrefix = useWithoutPrefix;
|
||||
}
|
||||
|
@ -154,6 +154,20 @@ class GUI_EXPORT QgsLocatorFilter : public QObject
|
||||
*/
|
||||
virtual void triggerResult( const QgsLocatorResult &result ) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if the filter should be used when no prefix
|
||||
* is entered.
|
||||
* \see setUseWithoutPrefix()
|
||||
*/
|
||||
bool useWithoutPrefix() const;
|
||||
|
||||
/**
|
||||
* Sets whether the filter should be used when no prefix
|
||||
* is entered.
|
||||
* \see useWithoutPrefix()
|
||||
*/
|
||||
void setUseWithoutPrefix( bool useWithoutPrefix );
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
@ -162,6 +176,10 @@ class GUI_EXPORT QgsLocatorFilter : public QObject
|
||||
*/
|
||||
void resultFetched( const QgsLocatorResult &result );
|
||||
|
||||
private:
|
||||
|
||||
bool mUseWithoutPrefix = true;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( QgsLocatorResult )
|
||||
|
Loading…
x
Reference in New Issue
Block a user