#pragma once #include #include #include #include #include #include // extremely inefficient map template class AwfulMap { public: [[nodiscard]] bool contains(const K& key) const; void insert(K key, V value); // assumes no duplicates bool remove(const K& key); // returns true if anything was removed QList> values; }; class Variants: public QObject, public QQmlParserStatus { Q_OBJECT; Q_PROPERTY(QQmlComponent* component MEMBER mComponent); Q_PROPERTY(QVariantList variants MEMBER mVariants WRITE setVariants); Q_CLASSINFO("DefaultProperty", "component"); QML_ELEMENT; public: explicit Variants(QObject* parent = nullptr): QObject(parent) {} void classBegin() override {}; void componentComplete() override; private: void setVariants(QVariantList variants); void updateVariants(); QQmlComponent* mComponent = nullptr; QVariantList mVariants; AwfulMap instances; };