QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
src
core
locator
qgslocatormodel.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgslocatormodel.h
3
------------------
4
begin : May 2017
5
copyright : (C) 2017 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef QGSLOCATORMODEL_H
19
#define QGSLOCATORMODEL_H
20
21
#include "qgis_core.h"
22
#include "
qgslocatorfilter.h
"
23
#include <QAbstractListModel>
24
#include <QTimer>
25
#include <QSet>
26
#include <QSortFilterProxyModel>
27
28
class
QgsLocator
;
29
class
QgsLocatorModel
;
30
class
QgsLocatorProxyModel
;
31
42
class
CORE_EXPORT
QgsLocatorModel
:
public
QAbstractTableModel
43
{
44
Q_OBJECT
45
46
public
:
47
48
static
const
int
NoGroup = 9999;
49
51
enum
Role
52
{
53
ResultDataRole = Qt::UserRole + 1,
54
ResultTypeRole
,
55
ResultFilterPriorityRole
,
56
ResultScoreRole
,
57
ResultFilterNameRole
,
58
ResultFilterGroupSortingRole
,
59
ResultActionsRole
,
60
};
61
65
QgsLocatorModel
( QObject *parent
SIP_TRANSFERTHIS
=
nullptr
);
66
71
void
clear();
72
79
void
deferredClear();
80
81
int
rowCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
82
int
columnCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
83
QVariant data(
const
QModelIndex &index,
int
role = Qt::DisplayRole )
const override
;
84
Qt::ItemFlags flags(
const
QModelIndex &index )
const override
;
85
QHash<int, QByteArray> roleNames()
const override
;
86
87
public
slots:
88
92
void
addResult(
const
QgsLocatorResult
&result );
93
94
private
:
95
96
enum
ColumnCount
97
{
98
Name = 0,
99
Description
100
};
101
102
struct
Entry
103
{
104
QgsLocatorResult
result;
105
QString filterTitle;
106
QgsLocatorFilter
*filter =
nullptr
;
107
QString groupTitle = QString();
108
int
groupSorting = 0;
109
};
110
111
QList<Entry> mResults;
112
QSet<QString> mFoundResultsFromFilterNames;
113
QMap<QgsLocatorFilter *, QStringList> mFoundResultsFilterGroups;
114
bool
mDeferredClear =
false
;
115
QTimer mDeferredClearTimer;
116
};
117
136
class
CORE_EXPORT
QgsLocatorAutomaticModel
:
public
QgsLocatorModel
137
{
138
Q_OBJECT
139
140
public
:
141
147
explicit
QgsLocatorAutomaticModel
(
QgsLocator
*locator
SIP_TRANSFERTHIS
);
148
152
QgsLocator
*locator();
153
163
void
search(
const
QString &
string
);
164
170
virtual
QgsLocatorContext
createContext();
171
172
private
slots:
173
174
void
searchFinished();
175
176
private
:
177
178
QgsLocator
*mLocator =
nullptr
;
179
180
QString mNextRequestedString;
181
bool
mHasQueuedRequest =
false
;
182
};
183
191
class
CORE_EXPORT
QgsLocatorProxyModel
:
public
QSortFilterProxyModel
192
{
193
Q_OBJECT
194
195
public
:
196
200
explicit
QgsLocatorProxyModel
( QObject *parent
SIP_TRANSFERTHIS
=
nullptr
);
201
bool
lessThan(
const
QModelIndex &left,
const
QModelIndex &right )
const override
;
202
};
203
204
#endif // QGSLOCATORMODEL_H
205
206
QgsLocatorFilter
Abstract base class for filters which collect locator results.
Definition:
qgslocatorfilter.h:152
QgsLocator
Handles the management of QgsLocatorFilter objects and async collection of search results from them.
Definition:
qgslocator.h:58
QgsLocatorModel::Role
Role
Custom model roles.
Definition:
qgslocatormodel.h:51
QgsLocatorModel::ResultFilterNameRole
@ ResultFilterNameRole
Associated filter name which created the result.
Definition:
qgslocatormodel.h:57
QgsLocatorResult
Encapsulates properties of an individual matching result found by a QgsLocatorFilter.
Definition:
qgslocatorfilter.h:38
QgsLocatorAutomaticModel
A QgsLocatorModel which has is associated directly with a QgsLocator, and is automatically populated ...
Definition:
qgslocatormodel.h:136
QgsLocatorModel::ResultTypeRole
@ ResultTypeRole
Result type.
Definition:
qgslocatormodel.h:54
QgsLocatorModel
An abstract list model for displaying the results of locator searches.
Definition:
qgslocatormodel.h:42
QgsLocatorContext
Encapsulates the properties relating to the context of a locator search.
Definition:
qgslocatorcontext.h:32
QgsLocatorModel::ResultActionsRole
@ ResultActionsRole
The actions to be shown for the given result in a context menu.
Definition:
qgslocatormodel.h:59
QgsLocatorProxyModel
A sort proxy model for QgsLocatorModel, which automatically sorts results by precedence.
Definition:
qgslocatormodel.h:191
QgsLocatorModel::ResultScoreRole
@ ResultScoreRole
Result match score, used by QgsLocatorProxyModel for sorting roles.
Definition:
qgslocatormodel.h:56
QgsLocatorModel::ResultFilterPriorityRole
@ ResultFilterPriorityRole
Result priority, used by QgsLocatorProxyModel for sorting roles.
Definition:
qgslocatormodel.h:55
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition:
qgis_sip.h:53
QgsLocatorModel::ResultFilterGroupSortingRole
@ ResultFilterGroupSortingRole
Group results within the same filter results.
Definition:
qgslocatormodel.h:58
qgslocatorfilter.h
Generated on Sun Sep 11 2022 00:03:17 for QGIS API Documentation by
1.8.17