| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/qmlitem.h" |
| 7 | #include "icpuprofilepart.h" |
| 8 | #include <QObject> |
| 9 | |
| 10 | class QQuickItem; |
| 11 | |
| 12 | class CPUQMLItem |
| 13 | : public QMLItem |
| 14 | , public ICPUProfilePart::Importer |
| 15 | , public ICPUProfilePart::Exporter |
| 16 | { |
| 17 | Q_OBJECT |
| 18 | Q_PROPERTY(int physicalId READ providePhysicalId) |
| 19 | |
| 20 | public: |
| 21 | void activate(bool active) override; |
| 22 | |
| 23 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 24 | provideImporter(Item const &i) override; |
| 25 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 26 | provideExporter(Item const &i) override; |
| 27 | |
| 28 | bool provideActive() const override; |
| 29 | int providePhysicalId() const override; |
| 30 | |
| 31 | void takeActive(bool active) override; |
| 32 | void takePhysicalId(int id) override; |
| 33 | |
| 34 | std::unique_ptr<Exportable::Exporter> |
| 35 | initializer(IQMLComponentFactory const &qmlComponentFactory, |
| 36 | QQmlApplicationEngine &qmlEngine) override; |
| 37 | |
| 38 | signals: |
| 39 | void newGraphItem(QQuickItem *item); |
| 40 | |
| 41 | private: |
| 42 | class Initializer; |
| 43 | |
| 44 | bool active_; |
| 45 | int physicalId_; |
| 46 | |
| 47 | static bool register_(); |
| 48 | static bool const registered_; |
| 49 | }; |