libosmscout  1.1.1
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 
28 #include <osmscout/StyleModule.h>
30 
31 namespace osmscout {
32 
36 class OSMSCOUT_CLIENT_QT_API StyleFlagsModel: public QAbstractListModel
37 {
38  Q_OBJECT
39 
40 private:
41  StyleModule *styleModule;
42  QMap<QString,bool> mapFlags;
43  QSet<QString> inProgressFlags;
44 
45 signals:
46  void styleFlagsRequested();
47  void setFlagRequest(QString key, bool value);
48 
49 private slots:
50  void onStyleFlagsChanged(QMap<QString,bool>);
51  void onFlagSet(QString key, bool value);
52 
53 public:
54  enum Roles {
55  KeyRole = Qt::UserRole,
56  ValueRole = Qt::UserRole+1,
57  InProgressRole = Qt::UserRole+2,
58  };
59  Q_ENUM(Roles)
60 
62  virtual ~StyleFlagsModel();
63 
64  Q_INVOKABLE virtual int inline rowCount(const QModelIndex &/*parent = QModelIndex()*/) const
65  {
66  return mapFlags.size();
67  };
68 
69  Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role) const;
70  virtual QHash<int, QByteArray> roleNames() const;
71  Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
72 
73  Q_INVOKABLE void setFlag(const QString &key, bool value);
74 };
75 
76 }
77 
78 #endif /* OSMSCOUT_CLIENT_QT_STYLEFLAGSMODEL_H */
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
Definition: StyleFlagsModel.h:36
virtual Q_INVOKABLE int rowCount(const QModelIndex &) const
Definition: StyleFlagsModel.h:64
Definition: Area.h:38
Definition: StyleModule.h:34
Roles
Definition: StyleFlagsModel.h:54