libosmscout  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
osmscout::AvailableMapsModel Class Reference

Tree model with maps available by configured providers (see Settings::GetMapProviders). More...

#include <AvailableMapsModel.h>

+ Inheritance diagram for osmscout::AvailableMapsModel:

Public Types

enum  Roles {
  NameRole = Qt::UserRole, PathRole = Qt::UserRole+1, DirRole = Qt::UserRole+2, ServerDirectoryRole = Qt::UserRole+3,
  TimeRole = Qt::UserRole+4, VersionRole = Qt::UserRole+5, ByteSizeRole = Qt::UserRole+6, ProviderUriRole = Qt::UserRole+7,
  DescriptionRole = Qt::UserRole+8, SizeRole = Qt::UserRole+9, MapRole = Qt::UserRole+10
}
 

Public Slots

void listDownloaded (const MapProvider &provider, QNetworkReply *)
 
void reload ()
 

Signals

void loadingChanged ()
 

Public Member Functions

 AvailableMapsModel ()
 
Q_INVOKABLE int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
Q_INVOKABLE QVariant data (const QModelIndex &index, int role) const override
 
Q_INVOKABLE Qt::ItemFlags flags (const QModelIndex &index) const override
 
QString getFetchError () const
 
Q_INVOKABLE QModelIndex index (int row, int column=0, const QModelIndex &parent=QModelIndex()) const override
 
bool isLoading () const
 
Q_INVOKABLE QVariant map (const QModelIndex &index) const
 
Q_INVOKABLE QObject * mapByPath (QStringList path)
 
Q_INVOKABLE QModelIndex parent (const QModelIndex &index) const override
 
QHash< int, QByteArray > roleNames () const override
 
Q_INVOKABLE int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
Q_INVOKABLE QVariant timeOfMap (QStringList path)
 Generation time of map with given path. More...
 
 ~AvailableMapsModel () override
 

Properties

QString fetchError
 
bool loading
 

Detailed Description

Tree model with maps available by configured providers (see Settings::GetMapProviders).

Every map provider have to expose list of maps by json. Json format example:

[
 {
   "version" : 10,
   "timestamp" : 1480801927,
   "name" : "Czech Republic",
   "directory" : "europe/czech-republic-10-20161203",
   "size" : 622036876,
   "map" : "europe/czech-republic"
 },
 {
   "dir" : "europe",
   "name" : "Europe"
 }
]

Member Enumeration Documentation

◆ Roles

Enumerator
NameRole 
PathRole 
DirRole 
ServerDirectoryRole 
TimeRole 
VersionRole 
ByteSizeRole 
ProviderUriRole 
DescriptionRole 
SizeRole 
MapRole 

Constructor & Destructor Documentation

◆ AvailableMapsModel()

osmscout::AvailableMapsModel::AvailableMapsModel ( )

◆ ~AvailableMapsModel()

osmscout::AvailableMapsModel::~AvailableMapsModel ( )
override

Member Function Documentation

◆ columnCount()

int osmscout::AvailableMapsModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

References parent().

◆ data()

◆ flags()

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

References index().

◆ getFetchError()

QString osmscout::AvailableMapsModel::getFetchError ( ) const
inline

◆ index()

QModelIndex osmscout::AvailableMapsModel::index ( int  row,
int  column = 0,
const QModelIndex &  parent = QModelIndex() 
) const
override

◆ isLoading()

bool osmscout::AvailableMapsModel::isLoading ( ) const
inline

◆ listDownloaded

void osmscout::AvailableMapsModel::listDownloaded ( const MapProvider &  provider,
QNetworkReply *  reply 
)
slot

◆ loadingChanged

void osmscout::AvailableMapsModel::loadingChanged ( )
signal

Referenced by listDownloaded(), and reload().

◆ map()

QVariant osmscout::AvailableMapsModel::map ( const QModelIndex &  index) const

References data(), index(), and MapRole.

Referenced by data(), listDownloaded(), mapByPath(), and timeOfMap().

◆ mapByPath()

QObject * osmscout::AvailableMapsModel::mapByPath ( QStringList  path)

◆ parent()

QModelIndex osmscout::AvailableMapsModel::parent ( const QModelIndex &  index) const
override

◆ reload

◆ roleNames()

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

◆ rowCount()

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

References parent().

◆ timeOfMap()

QVariant osmscout::AvailableMapsModel::timeOfMap ( QStringList  path)

Generation time of map with given path.

Null if don't exists in available maps. It may be used for detection if there is some update available.

Parameters
path
Returns

References osmscout::AvailableMapsModelItem::getPath(), osmscout::AvailableMapsModelItem::isDirectory(), osmscout::AvailableMapsModelItem::isValid(), and map().

Property Documentation

◆ fetchError

QString osmscout::AvailableMapsModel::fetchError
read

Referenced by listDownloaded(), and reload().

◆ loading

bool osmscout::AvailableMapsModel::loading
read

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