QGIS API Documentation
3.0.2-Girona (307d082)
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
49
enum
Role
50
{
51
ResultDataRole = Qt::UserRole + 1,
52
ResultTypeRole
,
53
ResultFilterPriorityRole
,
54
ResultScoreRole
,
55
ResultFilterNameRole
,
56
};
57
61
QgsLocatorModel
( QObject *parent
SIP_TRANSFERTHIS
=
nullptr
);
62
67
void
clear();
68
75
void
deferredClear();
76
77
int
rowCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
78
int
columnCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
79
QVariant data(
const
QModelIndex &index,
int
role = Qt::DisplayRole )
const override
;
80
Qt::ItemFlags flags(
const
QModelIndex &index )
const override
;
81
82
public
slots:
83
87
void
addResult(
const
QgsLocatorResult
&result );
88
89
private
:
90
91
enum
ColumnCount
92
{
93
Name = 0,
94
Description
95
};
96
97
struct
Entry
98
{
99
QgsLocatorResult
result;
100
QString filterTitle;
101
QgsLocatorFilter
*filter =
nullptr
;
102
};
103
104
QList<Entry> mResults;
105
QSet<QString> mFoundResultsFromFilterNames;
106
bool
mDeferredClear =
false
;
107
QTimer mDeferredClearTimer;
108
};
109
128
class
CORE_EXPORT
QgsLocatorAutomaticModel
:
public
QgsLocatorModel
129
{
130
Q_OBJECT
131
132
public
:
133
139
explicit
QgsLocatorAutomaticModel
(
QgsLocator
*locator
SIP_TRANSFERTHIS
);
140
144
QgsLocator
*locator();
145
155
void
search(
const
QString &
string
);
156
162
virtual
QgsLocatorContext
createContext();
163
164
private
slots:
165
166
void
searchFinished();
167
168
private
:
169
170
QgsLocator
*mLocator =
nullptr
;
171
172
QString mNextRequestedString;
173
bool
mHasQueuedRequest =
false
;
174
};
175
183
class
CORE_EXPORT
QgsLocatorProxyModel
:
public
QSortFilterProxyModel
184
{
185
Q_OBJECT
186
187
public
:
188
192
explicit
QgsLocatorProxyModel
( QObject *parent
SIP_TRANSFERTHIS
=
nullptr
);
193
bool
lessThan(
const
QModelIndex &left,
const
QModelIndex &right )
const override
;
194
};
195
196
#endif // QGSLOCATORMODEL_H
197
198
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition:
qgis_sip.h:46
QgsLocatorProxyModel
A sort proxy model for QgsLocatorModel, which automatically sorts results by precedence.
Definition:
qgslocatormodel.h:183
QgsLocatorAutomaticModel
A QgsLocatorModel which has is associated directly with a QgsLocator, and is automatically populated ...
Definition:
qgslocatormodel.h:128
QgsLocatorContext
Encapsulates the properties relating to the context of a locator search.
Definition:
qgslocatorcontext.h:31
QgsLocatorResult
Encapsulates properties of an individual matching result found by a QgsLocatorFilter.
Definition:
qgslocatorfilter.h:37
QgsLocatorFilter
Abstract base class for filters which collect locator results.
Definition:
qgslocatorfilter.h:93
QgsLocator
Handles the management of QgsLocatorFilter objects and async collection of search results from them...
Definition:
qgslocator.h:54
QgsLocatorModel
An abstract list model for displaying the results of locator searches.
Definition:
qgslocatormodel.h:42
QgsLocatorModel::ResultFilterPriorityRole
Result priority, used by QgsLocatorProxyModel for sorting roles.
Definition:
qgslocatormodel.h:53
QgsLocatorModel::ResultScoreRole
Result match score, used by QgsLocatorProxyModel for sorting roles.
Definition:
qgslocatormodel.h:54
QgsLocatorModel::Role
Role
Custom model roles.
Definition:
qgslocatormodel.h:49
QgsLocatorModel::ResultTypeRole
Result type.
Definition:
qgslocatormodel.h:52
qgslocatorfilter.h
QgsLocatorModel::ResultFilterNameRole
Associated filter name which created the result.
Definition:
qgslocatormodel.h:55
Generated on Sat Apr 21 2018 11:45:00 for QGIS API Documentation by
1.8.13