libosmscout 1.1.1
Loading...
Searching...
No Matches
StyleFlagsModel.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_STYLEFLAGSMODEL_H
2#define OSMSCOUT_CLIENT_QT_STYLEFLAGSMODEL_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 <unordered_map>
24
25#include <QObject>
26#include <QAbstractListModel>
27#include <QSet>
28
31
32namespace osmscout {
33
37class OSMSCOUT_CLIENT_QT_API StyleFlagsModel: public QAbstractListModel
38{
39 Q_OBJECT
40
41private:
42 StyleModule *styleModule;
43 QMap<QString,bool> mapFlags;
44 QSet<QString> inProgressFlags;
45
46signals:
48 void setFlagRequest(QString key, bool value);
49
50private slots:
51 void onStyleFlagsChanged(QMap<QString,bool>);
52 void onFlagSet(QString key, bool value);
53
54public:
55 enum Roles {
56 KeyRole = Qt::UserRole,
57 ValueRole = Qt::UserRole+1,
58 InProgressRole = Qt::UserRole+2,
59 };
60 Q_ENUM(Roles)
61
63 ~StyleFlagsModel() override;
64
65 Q_INVOKABLE int inline rowCount(const QModelIndex &parent = QModelIndex()) const override
66 {
67 Q_UNUSED(parent);
68 return mapFlags.size();
69 };
70
71 Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override;
72 QHash<int, QByteArray> roleNames() const override;
73 Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override;
74
75 Q_INVOKABLE void setFlag(const QString &key, bool value);
76};
77
78}
79
80#endif /* OSMSCOUT_CLIENT_QT_STYLEFLAGSMODEL_H */
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override
QHash< int, QByteArray > roleNames() const override
Q_INVOKABLE void setFlag(const QString &key, bool value)
Roles
Definition StyleFlagsModel.h:55
@ ValueRole
Definition StyleFlagsModel.h:57
@ InProgressRole
Definition StyleFlagsModel.h:58
@ KeyRole
Definition StyleFlagsModel.h:56
void setFlagRequest(QString key, bool value)
Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition StyleFlagsModel.h:65
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override
Definition StyleModule.h:37
Definition Area.h:39