libosmscout  1.1.1
Public Types | Public Slots | Signals | Public Member Functions | Properties | List of all members
osmscout::LocationListModel Class Reference

#include <libosmscout-client-qt/include/osmscout/SearchLocationModel.h>

Inheritance diagram for osmscout::LocationListModel:
Inheritance graph
[legend]
Collaboration diagram for osmscout::LocationListModel:
Collaboration graph
[legend]

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
}
 

Public Slots

void setPattern (const QString &pattern)
 
void onSearchResult (const QString searchPattern, const QList< LocationEntry >)
 
void onSearchFinished (const QString searchPattern, bool error)
 
void onLocationAdminRegions (const osmscout::GeoCoord, QList< AdminRegionInfoRef >)
 
void onLocationAdminRegionFinished (const osmscout::GeoCoord)
 

Signals

void SearchRequested (const QString searchPattern, int limit, osmscout::GeoCoord searchCenter, AdminRegionInfoRef defaultRegion, osmscout::BreakerRef breaker)
 
void SearchingChanged (bool)
 
void countChanged (int)
 
void regionLookupRequested (osmscout::GeoCoord)
 

Public Member Functions

 LocationListModel (QObject *parent=nullptr)
 
 ~LocationListModel () override
 
QJSValue getCompare () const
 
void setCompare (const QJSValue &fn)
 
QJSValue getEquals () const
 
void setEquals (const QJSValue &fn)
 
Q_INVOKABLE QVariant data (const QModelIndex &index, int role) const override
 
Q_INVOKABLE int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
Q_INVOKABLE Qt::ItemFlags flags (const QModelIndex &index) const override
 
QHash< int, QByteArray > roleNames () const override
 
Q_INVOKABLE QObject * get (int row) const
 
bool isSearching () const
 
double GetLat () const
 
double GetLon () const
 
void SetLat (double lat)
 
void SetLon (double lon)
 
int GetResultLimit () const
 
void SetResultLimit (int limit)
 
QString getPattern () const
 

Properties

int count
 
bool searching
 
double lat
 
double lon
 
int resultLimit
 
QString pattern
 
QJSValue compare
 
QJSValue equals
 

Detailed Description

Model for searching objects in osmscout databases by pattern written by human.

Member Enumeration Documentation

◆ Roles

Enumerator
LabelRole 
TypeRole 
RegionRole 
LatRole 
LonRole 
DistanceRole 
BearingRole 
LocationObjectRole 

Constructor & Destructor Documentation

◆ LocationListModel()

osmscout::LocationListModel::LocationListModel ( QObject *  parent = nullptr)
explicit

◆ ~LocationListModel()

osmscout::LocationListModel::~LocationListModel ( )
override

Member Function Documentation

◆ countChanged

void osmscout::LocationListModel::countChanged ( int  )
signal

◆ data()

Q_INVOKABLE QVariant osmscout::LocationListModel::data ( const QModelIndex &  index,
int  role 
) const
override

◆ flags()

Q_INVOKABLE Qt::ItemFlags osmscout::LocationListModel::flags ( const QModelIndex &  index) const
override

◆ get()

Q_INVOKABLE QObject* osmscout::LocationListModel::get ( int  row) const

◆ getCompare()

QJSValue osmscout::LocationListModel::getCompare ( ) const
inline

◆ getEquals()

QJSValue osmscout::LocationListModel::getEquals ( ) const
inline

◆ GetLat()

double osmscout::LocationListModel::GetLat ( ) const
inline

◆ GetLon()

double osmscout::LocationListModel::GetLon ( ) const
inline

◆ getPattern()

QString osmscout::LocationListModel::getPattern ( ) const
inline

◆ GetResultLimit()

int osmscout::LocationListModel::GetResultLimit ( ) const
inline

◆ isSearching()

bool osmscout::LocationListModel::isSearching ( ) const
inline

◆ onLocationAdminRegionFinished

void osmscout::LocationListModel::onLocationAdminRegionFinished ( const osmscout::GeoCoord  )
slot

◆ onLocationAdminRegions

void osmscout::LocationListModel::onLocationAdminRegions ( const osmscout::GeoCoord  ,
QList< AdminRegionInfoRef  
)
slot

◆ onSearchFinished

void osmscout::LocationListModel::onSearchFinished ( const QString  searchPattern,
bool  error 
)
slot

◆ onSearchResult

void osmscout::LocationListModel::onSearchResult ( const QString  searchPattern,
const QList< LocationEntry  
)
slot

◆ regionLookupRequested

void osmscout::LocationListModel::regionLookupRequested ( osmscout::GeoCoord  )
signal

◆ roleNames()

QHash<int, QByteArray> osmscout::LocationListModel::roleNames ( ) const
override

◆ rowCount()

Q_INVOKABLE int osmscout::LocationListModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

◆ SearchingChanged

void osmscout::LocationListModel::SearchingChanged ( bool  )
signal

◆ SearchRequested

void osmscout::LocationListModel::SearchRequested ( const QString  searchPattern,
int  limit,
osmscout::GeoCoord  searchCenter,
AdminRegionInfoRef  defaultRegion,
osmscout::BreakerRef  breaker 
)
signal

◆ setCompare()

void osmscout::LocationListModel::setCompare ( const QJSValue &  fn)
inline

◆ setEquals()

void osmscout::LocationListModel::setEquals ( const QJSValue &  fn)
inline

◆ SetLat()

void osmscout::LocationListModel::SetLat ( double  lat)
inline

◆ SetLon()

void osmscout::LocationListModel::SetLon ( double  lon)
inline

◆ setPattern

void osmscout::LocationListModel::setPattern ( const QString &  pattern)
slot

◆ SetResultLimit()

void osmscout::LocationListModel::SetResultLimit ( int  limit)
inline

Property Documentation

◆ compare

QJSValue osmscout::LocationListModel::compare
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:

compare: function(a, b){
if (a.label < b.label){
return -1;
}
return +1;
}
}

◆ count

int osmscout::LocationListModel::count
read

Count of rows in model - count of search results

◆ equals

QJSValue osmscout::LocationListModel::equals
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 database 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:

equals: function(a, b){
if (a.objectType == b.objectType &&
a.distanceTo(b.lat, b.lon) < 300 &&
a.distanceTo(searchCenterLat, searchCenterLon) > 3000 ){
return true;
}
return false;
}
}

◆ lat

double osmscout::LocationListModel::lat
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).

◆ lon

double osmscout::LocationListModel::lon
readwrite
See also
lat property

◆ pattern

QString osmscout::LocationListModel::pattern
readwrite

Searched pattern

◆ resultLimit

int osmscout::LocationListModel::resultLimit
readwrite

Limit of results for each database.

◆ searching

bool osmscout::LocationListModel::searching
read

True if searching is in progress


The documentation for this class was generated from the following file: