| 1 | // Copyright (C) 2020 James Turner <[email protected]> |
| 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 | |
| 23 | class 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 | |
| 30 | public: |
| 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; |
| 40 | public slots: |
| 41 | void setRootPath(QString rootPath); |
| 42 | |
| 43 | void setChildName(QString childName); |
| 44 | |
| 45 | signals: |
| 46 | void rootPathChanged(QString rootPath); |
| 47 | |
| 48 | void childNameChanged(QString childName); |
| 49 | |
| 50 | private: |
| 51 | class PropertyModelPrivate; |
| 52 | std::unique_ptr<PropertyModelPrivate> d; |
| 53 | }; |
| 54 | |
| 55 | #endif /* QmlPropertyModel_hpp */ |