libosmscout  1.1.1
MapStyleModel.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_MAPSTYLEMODEL_H
2 #define OSMSCOUT_CLIENT_QT_MAPSTYLEMODEL_H
3 
4 /*
5  OSMScout - a Qt backend for libosmscout and libosmscout-map
6  Copyright (C) 2017 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 <QAbstractListModel>
25 #include <QFileInfo>
26 
27 #include <osmscout/StyleModule.h>
29 
30 namespace osmscout {
31 
35 class OSMSCOUT_CLIENT_QT_API MapStyleModel: public QAbstractListModel
36 {
37  Q_OBJECT
38  Q_PROPERTY(QString style READ getStyle WRITE setStyle NOTIFY styleChanged)
39 
40 private:
41  StyleModule *styleModule;
42 
43 signals:
44  void styleChanged();
45  void loadStyleRequested(QString,std::unordered_map<std::string,bool>);
46 
47 public:
48  enum Roles {
49  NameRole = Qt::UserRole,
50  FileRole = Qt::UserRole+1,
51  PathRole = Qt::UserRole+2,
52  };
53  Q_ENUM(Roles)
54 
55  MapStyleModel();
56  virtual ~MapStyleModel();
57 
58  QString getStyle() const;
59  void setStyle(const QString &style);
60 
61  Q_INVOKABLE virtual int inline rowCount(const QModelIndex &/*parent = QModelIndex()*/) const
62  {
63  return stylesheets.size();
64  };
65 
66  Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role) const;
67  virtual QHash<int, QByteArray> roleNames() const;
68  Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
69 
70  Q_INVOKABLE int indexOf(const QString &style) const;
71  Q_INVOKABLE QString file(int i) const;
72 
73 private:
74  QList<QFileInfo> stylesheets;
75 };
76 
77 }
78 
79 #endif /* OSMSCOUT_CLIENT_QT_MAPSTYLEHELPER_H */
80 
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
Definition: MapStyleModel.h:35
Definition: Area.h:38
virtual Q_INVOKABLE int rowCount(const QModelIndex &) const
Definition: MapStyleModel.h:61
Definition: StyleModule.h:34
Roles
Definition: MapStyleModel.h:48