Skip to content

Commit

Permalink
allow to reset prefixes in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 10, 2018
1 parent 0a0de2e commit 6459d24
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 33 deletions.
12 changes: 1 addition & 11 deletions python/core/locator/qgslocator.sip.in
Expand Up @@ -73,23 +73,13 @@ deregisterFilter() to deregister their filters upon plugin unload to avoid crash
.. seealso:: :py:func:`registerFilter`
%End

QList< QgsLocatorFilter *> filters( const QString &prefix = QString() );
QList< QgsLocatorFilter *> filters();
%Docstring
Returns the list of filters registered in the locator.

.. seealso:: :py:func:`prefixedFilters`
%End

QStringList prefixes();
%Docstring
Returns the list of prefixes in use.
A prefix can have several filters

.. seealso:: :py:func:`filter`

.. versionadded:: 3.2
%End


QMap<QString, QgsLocatorFilter *> prefixedFilters() const;
%Docstring
Expand Down
12 changes: 9 additions & 3 deletions src/app/locator/qgslocatoroptionswidget.cpp
Expand Up @@ -178,9 +178,15 @@ bool QgsLocatorFiltersModel::setData( const QModelIndex &index, const QVariant &
case Prefix:
{
QString prefix = value.toString();
if ( prefix.isEmpty() )
return false;
mPrefixes.insert( filterForIndex( index ), prefix );
if ( !prefix.isEmpty() )
{
mPrefixes.insert( filterForIndex( index ), prefix );
}
else
{
// reset to the native prefix
mPrefixes.insert( filterForIndex( index ), filterForIndex( index )->prefix() );
}
emit dataChanged( index, index );
return true;
}
Expand Down
12 changes: 2 additions & 10 deletions src/core/locator/qgslocator.cpp
Expand Up @@ -48,17 +48,9 @@ void QgsLocator::deregisterFilter( QgsLocatorFilter *filter )
delete filter;
}

QList<QgsLocatorFilter *> QgsLocator::filters( const QString &prefix )
QList<QgsLocatorFilter *> QgsLocator::filters()
{
if ( !prefix.isEmpty() )
return mPrefixedFilters.values( prefix );
else
return mFilters;
}

QStringList QgsLocator::prefixes()
{
return mPrefixedFilters.keys();
return mFilters;
}

QMultiMap<QString, QgsLocatorFilter *> QgsLocator::prefixedFilters() const
Expand Down
11 changes: 2 additions & 9 deletions src/core/locator/qgslocator.h
Expand Up @@ -60,6 +60,7 @@ class CORE_EXPORT QgsLocator : public QObject

public:

//! List of core filters (i.e. not plugin filters)
static const QList<QString> CORE_FILTERS;

/**
Expand Down Expand Up @@ -96,15 +97,7 @@ class CORE_EXPORT QgsLocator : public QObject
* Returns the list of filters registered in the locator.
* \see prefixedFilters()
*/
QList< QgsLocatorFilter *> filters( const QString &prefix = QString() );

/**
* Returns the list of prefixes in use.
* A prefix can have several filters
* \see filter()
* \since QGIS 3.2
*/
QStringList prefixes();
QList< QgsLocatorFilter *> filters();

#ifndef SIP_RUN

Expand Down

0 comments on commit 6459d24

Please sign in to comment.