libosmscout 1.1.1
Loading...
Searching...
No Matches
OnlineTileProviderModel.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_ONLINETILEPROVIDERMODEL_H
2#define OSMSCOUT_CLIENT_QT_ONLINETILEPROVIDERMODEL_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6 Copyright (C) 2016 Lukas Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
23#include <osmscoutclient/OnlineTileProvider.h>
24#include <osmscoutclient/DBThread.h>
25
27
28#include <QAbstractListModel>
29
30namespace osmscout {
31
82class OSMSCOUT_CLIENT_QT_API OnlineTileProviderModel : public QAbstractListModel {
83 Q_OBJECT
84
85public:
87 {
88 auto settings=OSMScoutQt::GetInstance().GetSettings();
89 auto providers=settings->GetOnlineProviders();
90 for (const auto &provider: providers) {
91 onlineProviders << provider;
92 }
93 };
94
95 virtual inline ~OnlineTileProviderModel(){};
96
97 enum Roles {
98 NameRole = Qt::UserRole,
99 IdRole = Qt::UserRole+1,
100 };
101
102 Q_INVOKABLE virtual int inline rowCount(const QModelIndex &parent = QModelIndex()) const
103 {
104 Q_UNUSED(parent);
105 return onlineProviders.size();
106 };
107
108 Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role) const;
109 virtual QHash<int, QByteArray> roleNames() const;
110 Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
111
112 Q_INVOKABLE int count() const;
113 Q_INVOKABLE QString getId(int row) const;
114 Q_INVOKABLE QString getName(int row) const;
115
116private:
117 QList<OnlineTileProvider> onlineProviders;
118};
119
120}
121
122#endif /* OSMSCOUT_CLIENT_QT_ONLINETILEPROVIDERMODEL_H */
123
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
static OSMScoutQt & GetInstance()
Q_INVOKABLE QString getName(int row) const
Q_INVOKABLE QString getId(int row) const
virtual QHash< int, QByteArray > roleNames() const
Roles
Definition OnlineTileProviderModel.h:97
@ IdRole
Definition OnlineTileProviderModel.h:99
@ NameRole
Definition OnlineTileProviderModel.h:98
virtual Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const
virtual Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition OnlineTileProviderModel.h:102
OnlineTileProviderModel()
Definition OnlineTileProviderModel.h:86
Q_INVOKABLE int count() const
virtual ~OnlineTileProviderModel()
Definition OnlineTileProviderModel.h:95
Definition Area.h:39