Skip to content

Commit 83ccff2

Browse files
authoredMay 18, 2018
Merge pull request #7017 from 3nids/locator_subgroup
[QgsLocator] add the capability of adding group for elements within t…
2 parents 2a7c10e + ae389be commit 83ccff2

File tree

8 files changed

+191
-46
lines changed

8 files changed

+191
-46
lines changed
 

‎python/core/auto_generated/locator/qgslocatorfilter.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Constructor for QgsLocatorResult.
4545

4646
double score;
4747

48+
QString group;
49+
4850
};
4951

5052
class QgsLocatorFilter : QObject

‎python/core/auto_generated/locator/qgslocatormodel.sip.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ in order to ensure correct sorting of results by priority and match level.
2626
%End
2727
public:
2828

29+
static const int NoGroup;
30+
2931
enum Role
3032
{
3133
ResultDataRole,
3234
ResultTypeRole,
3335
ResultFilterPriorityRole,
3436
ResultScoreRole,
3537
ResultFilterNameRole,
38+
ResultFilterGroupSortingRole,
3639
};
3740

3841
QgsLocatorModel( QObject *parent /TransferThis/ = 0 );

‎scripts/sipify.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ sub detect_comment_block{
409409
}
410410

411411
# Detect if line is a non method member declaration
412-
# https://regex101.com/r/gUBZUk/13
412+
# https://regex101.com/r/gUBZUk/14
413413
sub detect_non_method_member{
414-
return 1 if $LINE =~ m/^\s*(?:template\s*<\w+>\s+)?(?:(const|mutable|static|friend|unsigned)\s+)*\w+(::\w+)?(<([\w<> *&,()]|::)+>)?(,?\s+\*?\w+( = (-?\d+(\.\d+)?|((QMap|QList)<[^()]+>\(\))|(\w+::)*\w+(\([^()]+\))?)|\[\d+\])?)+;/;
414+
return 1 if $LINE =~ m/^\s*(?:template\s*<\w+>\s+)?(?:(const|mutable|static|friend|unsigned)\s+)*\w+(::\w+)?(<([\w<> *&,()]|::)+>)?(,?\s+\*?\w+( = (-?\d+(\.\d+)?|((QMap|QList)<[^()]+>\(\))|(\w+::)*\w+(\([^()]?\))?)|\[\d+\])?)+;/;
415415
return 0;
416416
}
417417

@@ -899,7 +899,7 @@ sub detect_non_method_member{
899899
};
900900

901901
# remove struct member assignment
902-
if ( $SIP_RUN != 1 && $ACCESS[$#ACCESS] == PUBLIC && $LINE =~ m/^(\s*\w+[\w<> *&:,]* \*?\w+) = [\-\w\:\.]+(\([^()]+\))?\s*;/ ){
902+
if ( $SIP_RUN != 1 && $ACCESS[$#ACCESS] == PUBLIC && $LINE =~ m/^(\s*\w+[\w<> *&:,]* \*?\w+) = [\-\w\:\.]+(\([^()]*\))?\s*;/ ){
903903
dbg_info("remove struct member assignment");
904904
$LINE = "$1;";
905905
}

‎src/core/locator/qgslocatorfilter.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ class CORE_EXPORT QgsLocatorResult
8282
*/
8383
double score = 0.5;
8484

85+
/**
86+
* Group the results by categories
87+
* If left as empty string, this means that results are all shown without being grouped.
88+
* If a group is given, the results will be grouped by \a group under a header.
89+
* \note This should be translated.
90+
* \since 3.2
91+
*/
92+
QString group = QString();
93+
8594
};
8695

8796
/**

‎src/core/locator/qgslocatormodel.cpp

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
* *
1616
***************************************************************************/
1717

18+
#include <QFont>
1819

1920
#include "qgslocatormodel.h"
2021
#include "qgslocator.h"
2122
#include "qgsapplication.h"
2223
#include "qgslogger.h"
2324

25+
2426
//
2527
// QgsLocatorModel
2628
//
@@ -41,6 +43,7 @@ void QgsLocatorModel::clear()
4143
beginResetModel();
4244
mResults.clear();
4345
mFoundResultsFromFilterNames.clear();
46+
mFoundResultsFilterGroups.clear();
4447
endResetModel();
4548
}
4649

@@ -76,8 +79,14 @@ QVariant QgsLocatorModel::data( const QModelIndex &index, int role ) const
7679
case Name:
7780
if ( !mResults.at( index.row() ).filter )
7881
return mResults.at( index.row() ).result.displayString;
79-
else
82+
else if ( mResults.at( index.row() ).filter && mResults.at( index.row() ).groupSorting == 0 )
8083
return mResults.at( index.row() ).filterTitle;
84+
else
85+
{
86+
QString groupTitle = mResults.at( index.row() ).groupTitle;
87+
groupTitle.prepend( " " );
88+
return groupTitle;
89+
}
8190
case Description:
8291
if ( !mResults.at( index.row() ).filter )
8392
return mResults.at( index.row() ).result.description;
@@ -87,6 +96,19 @@ QVariant QgsLocatorModel::data( const QModelIndex &index, int role ) const
8796
break;
8897
}
8998

99+
case Qt::FontRole:
100+
if ( index.column() == Name && !mResults.at( index.row() ).groupTitle.isEmpty() )
101+
{
102+
QFont font;
103+
font.setItalic( true );
104+
return font;
105+
}
106+
else
107+
{
108+
return QVariant();
109+
}
110+
break;
111+
90112
case Qt::DecorationRole:
91113
switch ( index.column() )
92114
{
@@ -112,10 +134,8 @@ QVariant QgsLocatorModel::data( const QModelIndex &index, int role ) const
112134
return QVariant();
113135

114136
case ResultTypeRole:
115-
if ( mResults.at( index.row() ).filter )
116-
return 0;
117-
else
118-
return 1;
137+
// 0 for filter title, the group otherwise, 9999 if no group
138+
return mResults.at( index.row() ).groupSorting;
119139

120140
case ResultScoreRole:
121141
if ( mResults.at( index.row() ).filter )
@@ -134,6 +154,12 @@ QVariant QgsLocatorModel::data( const QModelIndex &index, int role ) const
134154
return mResults.at( index.row() ).result.filter->displayName();
135155
else
136156
return mResults.at( index.row() ).filterTitle;
157+
158+
case ResultFilterGroupSortingRole:
159+
if ( mResults.at( index.row() ).groupTitle.isEmpty() )
160+
return 1;
161+
else
162+
return 0;
137163
}
138164

139165
return QVariant();
@@ -146,7 +172,7 @@ Qt::ItemFlags QgsLocatorModel::flags( const QModelIndex &index ) const
146172
return QAbstractTableModel::flags( index );
147173

148174
Qt::ItemFlags flags = QAbstractTableModel::flags( index );
149-
if ( !mResults.at( index.row() ).filterTitle.isEmpty() )
175+
if ( mResults.at( index.row() ).filter )
150176
{
151177
flags = flags & ~( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
152178
}
@@ -159,20 +185,29 @@ void QgsLocatorModel::addResult( const QgsLocatorResult &result )
159185
if ( mDeferredClear )
160186
{
161187
mFoundResultsFromFilterNames.clear();
188+
mFoundResultsFilterGroups.clear();
162189
}
163190

164191
int pos = mResults.size();
165192
bool addingFilter = !result.filter->displayName().isEmpty() && !mFoundResultsFromFilterNames.contains( result.filter->name() );
166193
if ( addingFilter )
167194
mFoundResultsFromFilterNames << result.filter->name();
168195

196+
bool addingGroup = !result.group.isEmpty() && ( !mFoundResultsFilterGroups.contains( result.filter )
197+
|| !mFoundResultsFilterGroups.value( result.filter ).contains( result.group ) );
198+
if ( addingGroup )
199+
{
200+
if ( !mFoundResultsFilterGroups.contains( result.filter ) )
201+
mFoundResultsFilterGroups[result.filter] = QStringList();
202+
mFoundResultsFilterGroups[result.filter] << result.group ;
203+
}
169204
if ( mDeferredClear )
170205
{
171206
beginResetModel();
172207
mResults.clear();
173208
}
174209
else
175-
beginInsertRows( QModelIndex(), pos, pos + ( addingFilter ? 1 : 0 ) );
210+
beginInsertRows( QModelIndex(), pos, pos + ( static_cast<int>( addingFilter ) + static_cast<int>( addingGroup ) ) );
176211

177212
if ( addingFilter )
178213
{
@@ -181,8 +216,21 @@ void QgsLocatorModel::addResult( const QgsLocatorResult &result )
181216
entry.filter = result.filter;
182217
mResults << entry;
183218
}
219+
if ( addingGroup )
220+
{
221+
Entry entry;
222+
entry.filterTitle = result.filter->displayName();
223+
entry.groupTitle = result.group;
224+
// the sorting of groups will be achieved by order of adding groups
225+
// this could be customized by adding the extra info to QgsLocatorResult
226+
entry.groupSorting = mFoundResultsFilterGroups[result.filter].count();
227+
entry.filter = result.filter;
228+
mResults << entry;
229+
}
184230
Entry entry;
185231
entry.result = result;
232+
// keep the group title empty to allow differecing group title from results
233+
entry.groupSorting = result.group.isEmpty() ? NoGroup : mFoundResultsFilterGroups[result.filter].count();
186234
mResults << entry;
187235

188236
if ( mDeferredClear )
@@ -279,12 +327,18 @@ bool QgsLocatorProxyModel::lessThan( const QModelIndex &left, const QModelIndex
279327
if ( leftFilter != rightFilter )
280328
return QString::localeAwareCompare( leftFilter, rightFilter ) < 0;
281329

282-
// then make sure filter title appears before filter's results
330+
// then make sure filter title or group appears before filter's results
283331
int leftTypeRole = sourceModel()->data( left, QgsLocatorModel::ResultTypeRole ).toInt();
284332
int rightTypeRole = sourceModel()->data( right, QgsLocatorModel::ResultTypeRole ).toInt();
285333
if ( leftTypeRole != rightTypeRole )
286334
return leftTypeRole < rightTypeRole;
287335

336+
// make sure group title are above
337+
int leftGroupRole = sourceModel()->data( left, QgsLocatorModel::ResultFilterGroupSortingRole ).toInt();
338+
int rightGroupRole = sourceModel()->data( right, QgsLocatorModel::ResultFilterGroupSortingRole ).toInt();
339+
if ( leftGroupRole != rightGroupRole )
340+
return leftGroupRole < rightGroupRole;
341+
288342
// sort filter's results by score
289343
double leftScore = sourceModel()->data( left, QgsLocatorModel::ResultScoreRole ).toDouble();
290344
double rightScore = sourceModel()->data( right, QgsLocatorModel::ResultScoreRole ).toDouble();

‎src/core/locator/qgslocatormodel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class CORE_EXPORT QgsLocatorModel : public QAbstractTableModel
4545

4646
public:
4747

48+
static const int NoGroup = 9999;
49+
4850
//! Custom model roles
4951
enum Role
5052
{
@@ -53,6 +55,7 @@ class CORE_EXPORT QgsLocatorModel : public QAbstractTableModel
5355
ResultFilterPriorityRole, //!< Result priority, used by QgsLocatorProxyModel for sorting roles.
5456
ResultScoreRole, //!< Result match score, used by QgsLocatorProxyModel for sorting roles.
5557
ResultFilterNameRole, //!< Associated filter name which created the result
58+
ResultFilterGroupSortingRole, //!< Group results within the same filter results
5659
};
5760

5861
/**
@@ -99,10 +102,13 @@ class CORE_EXPORT QgsLocatorModel : public QAbstractTableModel
99102
QgsLocatorResult result;
100103
QString filterTitle;
101104
QgsLocatorFilter *filter = nullptr;
105+
QString groupTitle = QString();
106+
int groupSorting = 0;
102107
};
103108

104109
QList<Entry> mResults;
105110
QSet<QString> mFoundResultsFromFilterNames;
111+
QMap<QgsLocatorFilter *, QStringList> mFoundResultsFilterGroups;
106112
bool mDeferredClear = false;
107113
QTimer mDeferredClearTimer;
108114
};

‎src/gui/locator/qgslocatorwidget.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,15 @@ void QgsLocatorWidget::addResult( const QgsLocatorResult &result )
252252
mLocatorModel->addResult( result );
253253
if ( selectFirst )
254254
{
255-
int row = mProxyModel->flags( mProxyModel->index( 0, 0 ) ) & Qt::ItemIsSelectable ? 0 : 1;
256-
mResultsView->setCurrentIndex( mProxyModel->index( row, 0 ) );
255+
int row = -1;
256+
bool selectable = false;
257+
while ( !selectable && row < mProxyModel->rowCount() )
258+
{
259+
row++;
260+
selectable = mProxyModel->flags( mProxyModel->index( row, 0 ) ).testFlag( Qt::ItemIsSelectable );
261+
}
262+
if ( selectable )
263+
mResultsView->setCurrentIndex( mProxyModel->index( row, 0 ) );
257264
}
258265
}
259266

‎tests/src/python/test_qgslocator.py

Lines changed: 97 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
QgsLocatorContext,
2121
QgsLocatorResult,
2222
QgsLocatorModel,
23+
QgsLocatorProxyModel,
2324
QgsLocatorAutomaticModel,
2425
QgsSettings)
2526
from qgis.PyQt.QtCore import QVariant, pyqtSignal, QCoreApplication
@@ -31,35 +32,52 @@
3132

3233
class test_filter(QgsLocatorFilter):
3334

34-
def __init__(self, identifier, prefix=None, parent=None):
35+
def __init__(self, identifier, prefix=None, groupResult=False, parent=None):
3536
super().__init__(parent)
3637
self.identifier = identifier
3738
self._prefix = prefix
39+
self.groupResult = groupResult
3840

3941
def clone(self):
40-
return test_filter(self.identifier)
42+
return test_filter(self.identifier, self.prefix, self.groupResult)
4143

4244
def name(self):
4345
return 'test_' + self.identifier
4446

4547
def displayName(self):
46-
return 'test'
48+
return 'test_' + self.identifier
4749

4850
def prefix(self):
4951
return self._prefix
5052

5153
def fetchResults(self, string, context, feedback):
52-
for i in range(3):
54+
n = 3 if not self.groupResult else 9
55+
for i in range(n):
5356
if feedback.isCanceled():
5457
return
5558
sleep(0.001)
5659
result = QgsLocatorResult()
5760
result.displayString = self.identifier + str(i)
61+
if self.groupResult:
62+
if i < 6:
63+
result.group = 'first group'
64+
elif i < 8:
65+
result.group = 'second group'
5866
self.resultFetched.emit(result)
5967

6068
def triggerResult(self, result):
6169
pass
6270

71+
def priority(self):
72+
if self.identifier == 'a':
73+
return QgsLocatorFilter.High
74+
elif self.identifier == 'b':
75+
return QgsLocatorFilter.Medium
76+
elif self.identifier == 'c':
77+
return QgsLocatorFilter.Low
78+
else:
79+
return QgsLocatorFilter.Medium
80+
6381

6482
class TestQgsLocator(unittest.TestCase):
6583

@@ -268,6 +286,8 @@ def got_hit(result):
268286

269287
def testModel(self):
270288
m = QgsLocatorModel()
289+
p = QgsLocatorProxyModel(m)
290+
p.setSourceModel(m)
271291
l = QgsLocator()
272292

273293
filter_a = test_filter('a')
@@ -282,40 +302,84 @@ def testModel(self):
282302
QCoreApplication.processEvents()
283303

284304
# 4 results - one is locator name
285-
self.assertEqual(m.rowCount(), 4)
286-
self.assertEqual(m.data(m.index(0, 0)), 'test')
287-
self.assertEqual(m.data(m.index(0, 0), QgsLocatorModel.ResultTypeRole), 0)
288-
self.assertEqual(m.data(m.index(0, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
289-
self.assertEqual(m.data(m.index(1, 0)), 'a0')
290-
self.assertEqual(m.data(m.index(1, 0), QgsLocatorModel.ResultTypeRole), 1)
291-
self.assertEqual(m.data(m.index(1, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
292-
self.assertEqual(m.data(m.index(2, 0)), 'a1')
293-
self.assertEqual(m.data(m.index(2, 0), QgsLocatorModel.ResultTypeRole), 1)
294-
self.assertEqual(m.data(m.index(2, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
295-
self.assertEqual(m.data(m.index(3, 0)), 'a2')
296-
self.assertEqual(m.data(m.index(3, 0), QgsLocatorModel.ResultTypeRole), 1)
297-
self.assertEqual(m.data(m.index(3, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
305+
self.assertEqual(p.rowCount(), 4)
306+
self.assertEqual(p.data(p.index(0, 0)), 'test_a')
307+
self.assertEqual(p.data(p.index(0, 0), QgsLocatorModel.ResultTypeRole), 0)
308+
self.assertEqual(p.data(p.index(0, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
309+
self.assertEqual(p.data(p.index(1, 0)), 'a0')
310+
self.assertEqual(p.data(p.index(1, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
311+
self.assertEqual(p.data(p.index(1, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
312+
self.assertEqual(p.data(p.index(2, 0)), 'a1')
313+
self.assertEqual(p.data(p.index(2, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
314+
self.assertEqual(p.data(p.index(2, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
315+
self.assertEqual(p.data(p.index(3, 0)), 'a2')
316+
self.assertEqual(p.data(p.index(3, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
317+
self.assertEqual(p.data(p.index(3, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
298318

299319
m.clear()
300-
self.assertEqual(m.rowCount(), 0)
320+
self.assertEqual(p.rowCount(), 0)
301321
l.fetchResults('b', context)
302322

303323
for i in range(100):
304324
sleep(0.002)
305325
QCoreApplication.processEvents()
306326

307-
self.assertEqual(m.rowCount(), 4)
308-
self.assertEqual(m.data(m.index(1, 0)), 'a0')
309-
self.assertEqual(m.data(m.index(2, 0)), 'a1')
310-
self.assertEqual(m.data(m.index(3, 0)), 'a2')
327+
self.assertEqual(p.rowCount(), 4)
328+
self.assertEqual(p.data(p.index(1, 0)), 'a0')
329+
self.assertEqual(p.data(p.index(2, 0)), 'a1')
330+
self.assertEqual(p.data(p.index(3, 0)), 'a2')
311331

312332
m.deferredClear()
313333
# should not be immediately cleared!
314-
self.assertEqual(m.rowCount(), 4)
334+
self.assertEqual(p.rowCount(), 4)
315335
for i in range(100):
316336
sleep(0.002)
317337
QCoreApplication.processEvents()
318-
self.assertEqual(m.rowCount(), 0)
338+
self.assertEqual(p.rowCount(), 0)
339+
m.clear()
340+
341+
# test with groups
342+
self.assertEqual(p.rowCount(), 0)
343+
filter_b = test_filter('b', None, True)
344+
l.registerFilter(filter_b)
345+
l.fetchResults('c', context)
346+
for i in range(200):
347+
sleep(0.002)
348+
QCoreApplication.processEvents()
349+
self.assertEqual(p.rowCount(), 16) # 1 title a + 3 results + 1 title b + 2 groups + 9 results
350+
self.assertEqual(p.data(p.index(0, 0)), 'test_a')
351+
self.assertEqual(p.data(p.index(0, 0), QgsLocatorModel.ResultTypeRole), 0)
352+
self.assertEqual(p.data(p.index(1, 0)), 'a0')
353+
self.assertEqual(p.data(p.index(1, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
354+
self.assertEqual(p.data(p.index(2, 0)), 'a1')
355+
self.assertEqual(p.data(p.index(2, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
356+
self.assertEqual(p.data(p.index(3, 0)), 'a2')
357+
self.assertEqual(p.data(p.index(3, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
358+
self.assertEqual(p.data(p.index(4, 0)), 'test_b')
359+
self.assertEqual(p.data(p.index(4, 0), QgsLocatorModel.ResultTypeRole), 0)
360+
self.assertEqual(p.data(p.index(4, 0), QgsLocatorModel.ResultFilterNameRole), 'test_b')
361+
self.assertEqual(p.data(p.index(5, 0)).strip(), 'first group')
362+
self.assertEqual(p.data(p.index(5, 0), QgsLocatorModel.ResultTypeRole), 1)
363+
self.assertEqual(p.data(p.index(6, 0)), 'b0')
364+
self.assertEqual(p.data(p.index(6, 0), QgsLocatorModel.ResultTypeRole), 1)
365+
self.assertEqual(p.data(p.index(7, 0)), 'b1')
366+
self.assertEqual(p.data(p.index(7, 0), QgsLocatorModel.ResultTypeRole), 1)
367+
self.assertEqual(p.data(p.index(8, 0)), 'b2')
368+
self.assertEqual(p.data(p.index(8, 0), QgsLocatorModel.ResultTypeRole), 1)
369+
self.assertEqual(p.data(p.index(9, 0)), 'b3')
370+
self.assertEqual(p.data(p.index(9, 0), QgsLocatorModel.ResultTypeRole), 1)
371+
self.assertEqual(p.data(p.index(10, 0)), 'b4')
372+
self.assertEqual(p.data(p.index(10, 0), QgsLocatorModel.ResultTypeRole), 1)
373+
self.assertEqual(p.data(p.index(11, 0)), 'b5')
374+
self.assertEqual(p.data(p.index(11, 0), QgsLocatorModel.ResultTypeRole), 1)
375+
self.assertEqual(p.data(p.index(12, 0)).strip(), 'second group')
376+
self.assertEqual(p.data(p.index(12, 0), QgsLocatorModel.ResultTypeRole), 2)
377+
self.assertEqual(p.data(p.index(13, 0)), 'b6')
378+
self.assertEqual(p.data(p.index(13, 0), QgsLocatorModel.ResultTypeRole), 2)
379+
self.assertEqual(p.data(p.index(14, 0)), 'b7')
380+
self.assertEqual(p.data(p.index(14, 0), QgsLocatorModel.ResultTypeRole), 2)
381+
self.assertEqual(p.data(p.index(15, 0)), 'b8')
382+
self.assertEqual(p.data(p.index(15, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
319383

320384
def testAutoModel(self):
321385
"""
@@ -336,18 +400,18 @@ def testAutoModel(self):
336400

337401
# 4 results - one is locator name
338402
self.assertEqual(m.rowCount(), 4)
339-
self.assertEqual(m.data(m.index(0, 0)), 'test')
403+
self.assertEqual(m.data(m.index(0, 0)), 'test_a')
340404
self.assertEqual(m.data(m.index(0, 0), QgsLocatorModel.ResultTypeRole), 0)
341-
self.assertEqual(m.data(m.index(0, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
405+
self.assertEqual(m.data(m.index(0, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
342406
self.assertEqual(m.data(m.index(1, 0)), 'a0')
343-
self.assertEqual(m.data(m.index(1, 0), QgsLocatorModel.ResultTypeRole), 1)
344-
self.assertEqual(m.data(m.index(1, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
407+
self.assertEqual(m.data(m.index(1, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
408+
self.assertEqual(m.data(m.index(1, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
345409
self.assertEqual(m.data(m.index(2, 0)), 'a1')
346-
self.assertEqual(m.data(m.index(2, 0), QgsLocatorModel.ResultTypeRole), 1)
347-
self.assertEqual(m.data(m.index(2, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
410+
self.assertEqual(m.data(m.index(2, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
411+
self.assertEqual(m.data(m.index(2, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
348412
self.assertEqual(m.data(m.index(3, 0)), 'a2')
349-
self.assertEqual(m.data(m.index(3, 0), QgsLocatorModel.ResultTypeRole), 1)
350-
self.assertEqual(m.data(m.index(3, 0), QgsLocatorModel.ResultFilterNameRole), 'test')
413+
self.assertEqual(m.data(m.index(3, 0), QgsLocatorModel.ResultTypeRole), QgsLocatorModel.NoGroup)
414+
self.assertEqual(m.data(m.index(3, 0), QgsLocatorModel.ResultFilterNameRole), 'test_a')
351415

352416
m.search('a')
353417

@@ -357,7 +421,7 @@ def testAutoModel(self):
357421

358422
# 4 results - one is locator name
359423
self.assertEqual(m.rowCount(), 4)
360-
self.assertEqual(m.data(m.index(0, 0)), 'test')
424+
self.assertEqual(m.data(m.index(0, 0)), 'test_a')
361425
self.assertEqual(m.data(m.index(1, 0)), 'a0')
362426
self.assertEqual(m.data(m.index(2, 0)), 'a1')
363427
self.assertEqual(m.data(m.index(3, 0)), 'a2')

0 commit comments

Comments
 (0)
Please sign in to comment.