libosmscout  1.1.1
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 <QAbstractListModel>
24 
26 #include <osmscout/DBThread.h>
27 #include <osmscout/OSMScoutQt.h>
28 
29 namespace osmscout {
30 
81 class OSMSCOUT_CLIENT_QT_API OnlineTileProviderModel : public QAbstractListModel {
82  Q_OBJECT
83 
84 public:
86  {
87  auto settings=OSMScoutQt::GetInstance().GetSettings();
88  onlineProviders=settings->GetOnlineProviders();
89  };
90 
91  virtual inline ~OnlineTileProviderModel(){};
92 
93  enum Roles {
94  NameRole = Qt::UserRole,
95  IdRole = Qt::UserRole+1,
96  };
97 
98  Q_INVOKABLE virtual int inline rowCount(const QModelIndex &/*parent = QModelIndex()*/) const
99  {
100  return onlineProviders.size();
101  };
102 
103  Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role) const;
104  virtual QHash<int, QByteArray> roleNames() const;
105  Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
106 
107  Q_INVOKABLE int count() const;
108  Q_INVOKABLE QString getId(int row) const;
109  Q_INVOKABLE QString getName(int row) const;
110 
111 private:
112  QList<OnlineTileProvider> onlineProviders;
113 };
114 
115 }
116 
117 #endif /* OSMSCOUT_CLIENT_QT_ONLINETILEPROVIDERMODEL_H */
118 
Roles
Definition: OnlineTileProviderModel.h:93
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
Definition: OnlineTileProviderModel.h:81
Definition: Area.h:38
static OSMScoutQt & GetInstance()
virtual Q_INVOKABLE int rowCount(const QModelIndex &) const
Definition: OnlineTileProviderModel.h:98
OnlineTileProviderModel()
Definition: OnlineTileProviderModel.h:85
SettingsRef GetSettings() const
virtual ~OnlineTileProviderModel()
Definition: OnlineTileProviderModel.h:91