libosmscout 1.1.1
Loading...
Searching...
No Matches
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
29
30namespace osmscout {
31
35class OSMSCOUT_CLIENT_QT_API MapStyleModel: public QAbstractListModel
36{
37 Q_OBJECT
38 Q_PROPERTY(QString style READ getStyle WRITE setStyle NOTIFY styleChanged)
39
40private:
41 StyleModule *styleModule;
42
43signals:
45 void loadStyleRequested(QString,std::unordered_map<std::string,bool>);
46
47public:
48 enum Roles {
49 NameRole = Qt::UserRole,
50 FileRole = Qt::UserRole+1,
51 PathRole = Qt::UserRole+2,
52 };
53 Q_ENUM(Roles)
54
56 ~MapStyleModel() override;
57
58 QString getStyle() const;
59 void setStyle(const QString &style);
60
61 Q_INVOKABLE int inline rowCount(const QModelIndex &parent = QModelIndex()) const override
62 {
63 Q_UNUSED(parent);
64 return stylesheets.size();
65 };
66
67 Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override;
68 QHash<int, QByteArray> roleNames() const override;
69 Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override;
70
71 Q_INVOKABLE int indexOf(const QString &style) const;
72 Q_INVOKABLE QString file(int i) const;
73
74private:
75 QList<QFileInfo> stylesheets;
76};
77
78}
79
80#endif /* OSMSCOUT_CLIENT_QT_MAPSTYLEHELPER_H */
81
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
void setStyle(const QString &style)
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override
Q_INVOKABLE QString file(int i) const
Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition MapStyleModel.h:61
void loadStyleRequested(QString, std::unordered_map< std::string, bool >)
QHash< int, QByteArray > roleNames() const override
Q_INVOKABLE int indexOf(const QString &style) const
QString style
Definition MapStyleModel.h:38
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override
QString getStyle() const
Roles
Definition MapStyleModel.h:48
@ FileRole
Definition MapStyleModel.h:50
@ PathRole
Definition MapStyleModel.h:51
@ NameRole
Definition MapStyleModel.h:49
Definition StyleModule.h:37
Definition Area.h:39