Skip to content

Commit 6459d24

Browse files
committedMay 10, 2018
allow to reset prefixes in settings
1 parent 0a0de2e commit 6459d24

File tree

4 files changed

+14
-33
lines changed

4 files changed

+14
-33
lines changed
 

‎python/core/locator/qgslocator.sip.in

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,13 @@ deregisterFilter() to deregister their filters upon plugin unload to avoid crash
7373
.. seealso:: :py:func:`registerFilter`
7474
%End
7575

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

8080
.. seealso:: :py:func:`prefixedFilters`
8181
%End
8282

83-
QStringList prefixes();
84-
%Docstring
85-
Returns the list of prefixes in use.
86-
A prefix can have several filters
87-
88-
.. seealso:: :py:func:`filter`
89-
90-
.. versionadded:: 3.2
91-
%End
92-
9383

9484
QMap<QString, QgsLocatorFilter *> prefixedFilters() const;
9585
%Docstring

‎src/app/locator/qgslocatoroptionswidget.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,15 @@ bool QgsLocatorFiltersModel::setData( const QModelIndex &index, const QVariant &
178178
case Prefix:
179179
{
180180
QString prefix = value.toString();
181-
if ( prefix.isEmpty() )
182-
return false;
183-
mPrefixes.insert( filterForIndex( index ), prefix );
181+
if ( !prefix.isEmpty() )
182+
{
183+
mPrefixes.insert( filterForIndex( index ), prefix );
184+
}
185+
else
186+
{
187+
// reset to the native prefix
188+
mPrefixes.insert( filterForIndex( index ), filterForIndex( index )->prefix() );
189+
}
184190
emit dataChanged( index, index );
185191
return true;
186192
}

‎src/core/locator/qgslocator.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,9 @@ void QgsLocator::deregisterFilter( QgsLocatorFilter *filter )
4848
delete filter;
4949
}
5050

51-
QList<QgsLocatorFilter *> QgsLocator::filters( const QString &prefix )
51+
QList<QgsLocatorFilter *> QgsLocator::filters()
5252
{
53-
if ( !prefix.isEmpty() )
54-
return mPrefixedFilters.values( prefix );
55-
else
56-
return mFilters;
57-
}
58-
59-
QStringList QgsLocator::prefixes()
60-
{
61-
return mPrefixedFilters.keys();
53+
return mFilters;
6254
}
6355

6456
QMultiMap<QString, QgsLocatorFilter *> QgsLocator::prefixedFilters() const

‎src/core/locator/qgslocator.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class CORE_EXPORT QgsLocator : public QObject
6060

6161
public:
6262

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

6566
/**
@@ -96,15 +97,7 @@ class CORE_EXPORT QgsLocator : public QObject
9697
* Returns the list of filters registered in the locator.
9798
* \see prefixedFilters()
9899
*/
99-
QList< QgsLocatorFilter *> filters( const QString &prefix = QString() );
100-
101-
/**
102-
* Returns the list of prefixes in use.
103-
* A prefix can have several filters
104-
* \see filter()
105-
* \since QGIS 3.2
106-
*/
107-
QStringList prefixes();
100+
QList< QgsLocatorFilter *> filters();
108101

109102
#ifndef SIP_RUN
110103

0 commit comments

Comments
 (0)
Please sign in to comment.