FlightGear next
QmlPropertyModel.hxx
Go to the documentation of this file.
1// Copyright (C) 2020 James Turner <james@flightgear.org>
2//
3// This program is free software; you can redistribute it and/or
4// modify it under the terms of the GNU General Public License as
5// published by the Free Software Foundation; either version 2 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful, but
9// WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17#ifndef QmlPropertyModel_hpp
18#define QmlPropertyModel_hpp
19
20#include <QAbstractListModel>
21#include <memory>
22
23class FGQmlPropertyModel : public QAbstractListModel
24{
25 Q_OBJECT
26
27 Q_PROPERTY(QString rootPath READ rootPath WRITE setRootPath NOTIFY rootPathChanged);
28 Q_PROPERTY(QString childName READ childName WRITE setChildName NOTIFY childNameChanged);
29
30public:
31 FGQmlPropertyModel(QObject* parent = nullptr);
32 ~FGQmlPropertyModel() override;
33 QString rootPath() const;
34
35 QString childName() const;
36
37 QHash<int, QByteArray> roleNames() const override;
38
39 QVariant data(const QModelIndex& m, int role) const override;
40public slots:
41 void setRootPath(QString rootPath);
42
43 void setChildName(QString childName);
44
45signals:
47
49
50private:
52 std::unique_ptr<PropertyModelPrivate> d;
53};
54
55#endif /* QmlPropertyModel_hpp */
FGQmlPropertyModel(QObject *parent=nullptr)
void setRootPath(QString rootPath)
QVariant data(const QModelIndex &m, int role) const override
void setChildName(QString childName)
void rootPathChanged(QString rootPath)
void childNameChanged(QString childName)
QHash< int, QByteArray > roleNames() const override