libosmscout  1.1.1
MapProvider.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_MAPPROVIDER_H
2 #define OSMSCOUT_CLIENT_QT_MAPPROVIDER_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 <QObject>
24 #include <QString>
25 #include <QUrl>
26 
27 #include <QJsonDocument>
28 #include <QJsonArray>
29 #include <QJsonObject>
30 
32 
33 namespace osmscout {
34 
38 class OSMSCOUT_CLIENT_QT_API MapProvider: public QObject
39 {
40  Q_OBJECT
41 
42 private:
43  bool valid=false;
44  QString uri;
45  QString listUri;
46  QString name;
47 
48 public:
49  MapProvider() = default;
50 
51  inline MapProvider(const MapProvider &o):
52  QObject(o.parent()),
53  valid(o.valid), uri(o.uri), listUri(o.listUri), name(o.name){};
54 
55  inline MapProvider(QString name, QString uri, QString listUri):
56  valid(true), uri(uri), listUri(listUri), name(name) {}
57 
58  ~MapProvider() override = default;
59 
60  inline MapProvider& operator=(const MapProvider &o)
61  {
62  valid = o.valid;
63  uri = o.uri;
64  listUri = o.listUri;
65  name = o.name;
66 
67  return *this;
68  }
69 
70  inline QString getName() const
71  {
72  return name;
73  }
74 
75  inline QString getUri() const
76  {
77  return uri;
78  }
79 
80  inline QUrl getListUri(int fromVersion, int toVersion, QString locale="en") const
81  {
82  return listUri.arg(fromVersion).arg(toVersion).arg(locale);
83  }
84 
85  inline bool isValid() const
86  {
87  return valid;
88  }
89 
90  static MapProvider fromJson(QJsonValue obj);
91 };
92 
93 }
94 
95 Q_DECLARE_METATYPE(osmscout::MapProvider)
96 
97 #endif // OSMSCOUT_CLIENT_QT_MAPPROVIDER_H
bool isValid() const
Definition: MapProvider.h:85
Definition: MapProvider.h:38
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
QString getUri() const
Definition: MapProvider.h:75
QUrl getListUri(int fromVersion, int toVersion, QString locale="en") const
Definition: MapProvider.h:80
Definition: Area.h:38
QString getName() const
Definition: MapProvider.h:70
MapProvider(QString name, QString uri, QString listUri)
Definition: MapProvider.h:55
MapProvider & operator=(const MapProvider &o)
Definition: MapProvider.h:60
MapProvider(const MapProvider &o)
Definition: MapProvider.h:51