|
libosmscout 0.1
|
Model for searching objects in osmscout databases by pattern written by human. More...
#include <SearchLocationModel.h>
Public Types | |
| enum | Roles { LabelRole = Qt::UserRole , TypeRole = Qt::UserRole +1 , RegionRole = Qt::UserRole +2 , LatRole = Qt::UserRole +3 , LonRole = Qt::UserRole +4 , DistanceRole = Qt::UserRole +5 , BearingRole = Qt::UserRole +6 , LocationObjectRole = Qt::UserRole +7 , IndexedAdminRegionRole = Qt::UserRole +8 , AltLangName = Qt::UserRole +9 } |
Public Slots | |
| void | onLocationAdminRegionFinished (const osmscout::GeoCoord) |
| void | onLocationAdminRegions (const osmscout::GeoCoord, QList< AdminRegionInfoRef >) |
| void | onSearchFinished (const QString searchPattern, bool error) |
| void | onSearchResult (const QString searchPattern, const QList< LocationEntry >) |
| void | setPattern (const QString &pattern) |
Signals | |
| void | countChanged (int) |
| void | regionLookupRequested (osmscout::GeoCoord) |
| void | SearchingChanged (bool) |
| void | SearchRequested (const QString searchPattern, int limit, osmscout::GeoCoord searchCenter, AdminRegionInfoRef defaultRegion, osmscout::BreakerRef breaker) |
Public Member Functions | |
| Q_INVOKABLE QVariant | data (const QModelIndex &index, int role) const override |
| Q_INVOKABLE Qt::ItemFlags | flags (const QModelIndex &index) const override |
| Q_INVOKABLE QObject * | get (int row) const |
| QJSValue | getCompare () const |
| int | GetDisplayLimit () const |
| QJSValue | getEquals () const |
| double | GetLat () const |
| double | GetLon () const |
| QString | getPattern () const |
| int | GetResultLimit () const |
| bool | isSearching () const |
| LocationListModel (const LocationListModel &)=delete | |
| LocationListModel (LocationListModel &&)=delete | |
| LocationListModel (QObject *parent=nullptr) | |
| LocationListModel & | operator= (const LocationListModel &)=delete |
| LocationListModel & | operator= (LocationListModel &&)=delete |
| QHash< int, QByteArray > | roleNames () const override |
| Q_INVOKABLE int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| void | setCompare (const QJSValue &fn) |
| void | SetDisplayLimit (int limit) |
| void | setEquals (const QJSValue &fn) |
| void | SetLat (double lat) |
| void | SetLon (double lon) |
| void | SetResultLimit (int limit) |
| ~LocationListModel () override | |
Properties | |
| QJSValue | compare |
| JavaScript function used for sorting search results. | |
| int | count |
| Count of rows in model - count of search results. | |
| int | displayLimit =100 |
| Limit of model rows. | |
| QJSValue | equals |
| JavaScript function used for check location equality. | |
| double | lat |
| Lat and lon properties control where is logical search center. | |
| double | lon |
| QString | pattern |
| Searched pattern. | |
| int | resultLimit =2000 |
| Limit of results for each db. | |
| bool | searching =false |
| True if searching is in progress. | |
Model for searching objects in osmscout databases by pattern written by human.
|
explicit |
References osmscout::OSMScoutQt::GetInstance(), osmscout::OSMScoutQt::GetSettings(), INVALID_COORD, osmscout::LookupModule::locationAdminRegionFinished(), osmscout::LookupModule::locationAdminRegions(), osmscout::OSMScoutQt::MakeLookupModule(), osmscout::OSMScoutQt::MakeSearchModule(), onLocationAdminRegionFinished(), onLocationAdminRegions(), onSearchFinished(), onSearchResult(), regionLookupRequested(), osmscout::LookupModule::requestRegionLookup(), osmscout::SearchModule::searchFinished(), osmscout::SearchModule::SearchForLocations(), SearchRequested(), and osmscout::SearchModule::searchResult().
Referenced by LocationListModel(), LocationListModel(), operator=(), and operator=().
|
delete |
References LocationListModel().
|
delete |
References LocationListModel().
|
override |
|
signal |
References countChanged().
Referenced by countChanged(), and setPattern().
|
override |
References osmscout::LookupModule::AdminRegionNames(), AltLangName, osmscout::Distance::AsMeter(), BearingRole, DistanceRole, osmscout::GetSphericalBearingInitial(), osmscout::GetSphericalDistance(), osmscout::LookupModule::IndexedAdminRegionNames(), IndexedAdminRegionRole, INVALID_COORD, LabelRole, LatRole, LocationObjectRole, LonRole, RegionRole, and TypeRole.
|
override |
| QObject * osmscout::LocationListModel::get | ( | int | row | ) | const |
|
inline |
|
inline |
References displayLimit.
|
inline |
|
inline |
|
inline |
|
inline |
References pattern.
|
inline |
References resultLimit.
|
inline |
References searching.
Referenced by onSearchFinished(), and setPattern().
|
slot |
References osmscout::log, pattern, and setPattern().
Referenced by LocationListModel(), and regionLookupRequested().
|
slot |
References osmscout::LookupModule::Town.
Referenced by LocationListModel(), and regionLookupRequested().
|
slot |
References isSearching(), pattern, resultLimit, searching, SearchingChanged(), and SearchRequested().
Referenced by LocationListModel(), and regionLookupRequested().
|
slot |
Adding huge batch of entries to model (more that 100) may take longer than ~16 ms and UI may become choppy. So, we enqueue all found entries to postponedEntries and start postponeTimer that adds entries by small chunks. Whole operation is splitted to multiple animation frames.
References pattern.
Referenced by LocationListModel(), and regionLookupRequested().
|
delete |
References LocationListModel().
|
delete |
References LocationListModel().
|
signal |
References displayLimit, onLocationAdminRegionFinished(), onLocationAdminRegions(), onSearchFinished(), onSearchResult(), pattern, regionLookupRequested(), resultLimit, searching, and setPattern().
Referenced by LocationListModel(), and regionLookupRequested().
|
override |
References AltLangName, BearingRole, DistanceRole, IndexedAdminRegionRole, LabelRole, LatRole, LocationObjectRole, LonRole, RegionRole, and TypeRole.
|
override |
|
signal |
References SearchingChanged().
Referenced by onSearchFinished(), SearchingChanged(), and setPattern().
|
signal |
References SearchRequested().
Referenced by LocationListModel(), onSearchFinished(), SearchRequested(), and setPattern().
|
inline |
|
inline |
References displayLimit.
|
inline |
|
inline |
References lat.
|
inline |
References lon.
|
slot |
References countChanged(), osmscout::GeoCoord::GetDisplayText(), isSearching(), osmscout::GeoCoord::Parse(), pattern, resultLimit, searching, SearchingChanged(), and SearchRequested().
Referenced by onLocationAdminRegionFinished(), and regionLookupRequested().
|
inline |
References resultLimit.
|
readwrite |
JavaScript function used for sorting search results.
Compare function will receive two locations arguments, A and B, where A < B (A should be shown before B), compare function should return number < 0.
For sorting results alphabetically:
|
read |
Count of rows in model - count of search results.
|
readwrite |
Limit of model rows.
Referenced by GetDisplayLimit(), regionLookupRequested(), and SetDisplayLimit().
|
readwrite |
JavaScript function used for check location equality.
It is possible that model will returns one physical location multiple times, for example one from location index and second from fulltext search, or two db segments for one real street...
Such results may be merged in model. Function will receive two locations (only locations with same label will be checked) and should return boolean result.
For example, merge near objects with same label and type:
|
readwrite |
Lat and lon properties control where is logical search center.
Local admin region is used as default region, databases used for search are sorted by distance from this point (local results should be available faster).
Referenced by SetLat().
|
readwrite |
Searched pattern.
Referenced by getPattern(), onLocationAdminRegionFinished(), onSearchFinished(), onSearchResult(), regionLookupRequested(), and setPattern().
|
readwrite |
Limit of results for each db.
Referenced by GetResultLimit(), onSearchFinished(), regionLookupRequested(), setPattern(), and SetResultLimit().
|
read |
True if searching is in progress.
Referenced by isSearching(), onSearchFinished(), regionLookupRequested(), and setPattern().