Skip to content

Commit 30cf2d3

Browse files
authoredNov 9, 2018
Merge pull request #8404 from 3nids/locator_core
Move parts of QgsLocatorFilter to core
2 parents 9e78b82 + fe6f99a commit 30cf2d3

File tree

12 files changed

+530
-107
lines changed

12 files changed

+530
-107
lines changed
 

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ which may occur if the model is being updated quickly multiple times as a result
6767

6868
virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
6969

70+
virtual QHash<int, QByteArray> roleNames() const;
71+
7072

7173
public slots:
7274

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/locator/qgslocatormodelbridge.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
15+
class QgsLocatorModelBridge : QObject
16+
{
17+
%Docstring
18+
The QgsLocatorModelBridge class provides the core functionality
19+
to be used in a locator widget.
20+
21+
.. versionadded:: 3.6
22+
%End
23+
24+
%TypeHeaderCode
25+
#include "qgslocatormodelbridge.h"
26+
%End
27+
public:
28+
explicit QgsLocatorModelBridge( QObject *parent = 0 );
29+
%Docstring
30+
Constructor of QgsLocatorModelBridge
31+
%End
32+
virtual ~QgsLocatorModelBridge();
33+
34+
void performSearch( const QString &text );
35+
%Docstring
36+
Perform a search
37+
%End
38+
39+
QgsLocator *locator() const;
40+
%Docstring
41+
Returns the locator
42+
%End
43+
44+
QgsLocatorProxyModel *proxyModel() const;
45+
%Docstring
46+
Returns the proxy model
47+
%End
48+
49+
bool hasQueueRequested() const;
50+
%Docstring
51+
Returns true if some text to be search is pending in the queue
52+
%End
53+
54+
bool isRunning() const;
55+
%Docstring
56+
Returns true if the a search is currently running
57+
%End
58+
59+
void triggerResult( const QModelIndex &index );
60+
%Docstring
61+
Triggers the result at given index
62+
%End
63+
64+
signals:
65+
void resultAdded();
66+
%Docstring
67+
Emitted when a result is added
68+
%End
69+
70+
void isRunningChanged();
71+
%Docstring
72+
Emitted when the running status changes
73+
%End
74+
75+
void resultsCleared();
76+
%Docstring
77+
Emitted when the results are cleared
78+
%End
79+
80+
public slots:
81+
void invalidateResults();
82+
%Docstring
83+
This will invalidate current search results
84+
%End
85+
86+
void updateCanvasExtent( const QgsRectangle &extent );
87+
%Docstring
88+
Update the canvas extent used to create search context
89+
%End
90+
91+
void updateCanvasCrs( const QgsCoordinateReferenceSystem &crs );
92+
%Docstring
93+
Update the canvas CRS used to create search context
94+
%End
95+
96+
};
97+
98+
/************************************************************************
99+
* This file has been generated automatically from *
100+
* *
101+
* src/core/locator/qgslocatormodelbridge.h *
102+
* *
103+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
104+
************************************************************************/
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/locator/qgslocatormodelbridge.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
15+
class QgsLocatorModelBridge : QObject
16+
{
17+
%Docstring
18+
The QgsLocatorModelBridge class provides the core functionality
19+
to be used in a locator widget.
20+
21+
.. versionadded:: 3.6
22+
%End
23+
24+
%TypeHeaderCode
25+
#include "qgslocatormodelbridge.h"
26+
%End
27+
public:
28+
explicit QgsLocatorModelBridge( QObject *parent = 0 );
29+
%Docstring
30+
Constructor of QgsLocatorModelBridge
31+
%End
32+
33+
void performSearch( const QString &text );
34+
%Docstring
35+
Perform a search
36+
%End
37+
38+
QgsLocator *locator() const;
39+
%Docstring
40+
Returns the locator
41+
%End
42+
43+
QgsLocatorProxyModel *proxyModel() const;
44+
%Docstring
45+
Returns the proxy model
46+
%End
47+
48+
bool hasQueueRequested() const;
49+
%Docstring
50+
Returns true if some text to be search is pending in the queue
51+
%End
52+
53+
bool isRunning() const;
54+
%Docstring
55+
Returns true if the a search is currently running
56+
%End
57+
58+
signals:
59+
void resultAdded();
60+
%Docstring
61+
Emitted when a result is added
62+
%End
63+
64+
void isRunningChanged();
65+
%Docstring
66+
Emitted when the running status changes
67+
%End
68+
69+
void resultsCleared();
70+
%Docstring
71+
Emitted when the results are cleared
72+
%End
73+
74+
public slots:
75+
void invalidateResults();
76+
%Docstring
77+
This will invalidate current search results
78+
%End
79+
80+
void updateCanvasExtent( const QgsRectangle &extent );
81+
%Docstring
82+
Update the canvas extent used to create search context
83+
%End
84+
85+
void updateCanvasCrs( const QgsCoordinateReferenceSystem &crs );
86+
%Docstring
87+
Update the canvas CRS used to create search context
88+
%End
89+
90+
};
91+
92+
/************************************************************************
93+
* This file has been generated automatically from *
94+
* *
95+
* src/core/locator/qgslocatormodelbridge.h *
96+
* *
97+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
98+
************************************************************************/

‎python/core/core_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@
382382
%Include auto_generated/locator/qgslocator.sip
383383
%Include auto_generated/locator/qgslocatorfilter.sip
384384
%Include auto_generated/locator/qgslocatormodel.sip
385+
%Include auto_generated/locator/qgslocatormodelbridge.sip
385386
%Include auto_generated/processing/qgsprocessingalgrunnertask.sip
386387
%Include auto_generated/processing/qgsprocessingfeedback.sip
387388
%Include auto_generated/processing/qgsprocessingprovider.sip

‎python/gui/auto_generated/locator/qgslocatorwidget.sip.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Emitted when the configure option is triggered in the widget.
6464
%End
6565

6666
protected:
67-
6867
virtual bool eventFilter( QObject *obj, QEvent *event );
6968

7069

‎src/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ SET(QGIS_CORE_SRCS
109109
locator/qgslocator.cpp
110110
locator/qgslocatorfilter.cpp
111111
locator/qgslocatormodel.cpp
112+
locator/qgslocatormodelbridge.cpp
112113

113114
processing/qgsprocessingalgorithm.cpp
114115
processing/qgsprocessingalgrunnertask.cpp
@@ -681,6 +682,7 @@ SET(QGIS_CORE_MOC_HDRS
681682
locator/qgslocator.h
682683
locator/qgslocatorfilter.h
683684
locator/qgslocatormodel.h
685+
locator/qgslocatormodelbridge.h
684686

685687
processing/qgsprocessingalgrunnertask.h
686688
processing/qgsprocessingfeedback.h

‎src/core/locator/qgslocatormodel.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ Qt::ItemFlags QgsLocatorModel::flags( const QModelIndex &index ) const
179179
return flags;
180180
}
181181

182+
QHash<int, QByteArray> QgsLocatorModel::roleNames() const
183+
{
184+
QHash<int, QByteArray> roles;
185+
roles[ResultDataRole] = "ResultData";
186+
roles[ResultTypeRole] = "ResultType";
187+
roles[ResultFilterPriorityRole] = "ResultFilterPriority";
188+
roles[ResultScoreRole] = "ResultScore";
189+
roles[ResultFilterNameRole] = "ResultFilterName";
190+
roles[ResultFilterGroupSortingRole] = "ResultFilterGroupSorting";
191+
roles[Qt::DisplayRole] = "Text";
192+
return roles;
193+
}
194+
182195
void QgsLocatorModel::addResult( const QgsLocatorResult &result )
183196
{
184197
mDeferredClearTimer.stop();

‎src/core/locator/qgslocatormodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class CORE_EXPORT QgsLocatorModel : public QAbstractTableModel
8181
int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
8282
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
8383
Qt::ItemFlags flags( const QModelIndex &index ) const override;
84+
QHash<int, QByteArray> roleNames() const override;
8485

8586
public slots:
8687

0 commit comments

Comments
 (0)
Please sign in to comment.