// Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #pragma once #include #include #include #include #include #include #include namespace QmlDesigner { template class BasicAuxiliaryDataKey { public: constexpr BasicAuxiliaryDataKey() = default; constexpr BasicAuxiliaryDataKey(AuxiliaryDataType type, NameType name) : type{type} , name{std::move(name)} {} template>> constexpr explicit BasicAuxiliaryDataKey(const BasicAuxiliaryDataKey &other) : type{other.type} , name{NameType{other.name}} {} public: AuxiliaryDataType type = AuxiliaryDataType::None; NameType name; }; template bool operator<(const BasicAuxiliaryDataKey &first, const BasicAuxiliaryDataKey &second) { return std::tie(first.type, first.name) < std::tie(second.type, second.name); } template bool operator==(const BasicAuxiliaryDataKey &first, const BasicAuxiliaryDataKey &second) { return first.type == second.type && first.name == second.name; } template bool operator!=(const BasicAuxiliaryDataKey &first, const BasicAuxiliaryDataKey &second) { return !(first == second); } using AuxiliaryDataKey = BasicAuxiliaryDataKey; using AuxiliaryDataKeyView = BasicAuxiliaryDataKey; using AuxiliaryDatas = std::vector>; using AuxiliaryDatasView = Utils::span>; using AuxiliaryDatasForType = std::vector>; using PropertyValue = std::variant; inline QVariant toQVariant(const PropertyValue &variant) { return std::visit([](const auto &value) { return QVariant::fromValue(value); }, variant); } class AuxiliaryDataKeyDefaultValue : public AuxiliaryDataKeyView { public: constexpr AuxiliaryDataKeyDefaultValue() = default; constexpr AuxiliaryDataKeyDefaultValue(AuxiliaryDataType type, Utils::SmallStringView name, PropertyValue defaultValue) : AuxiliaryDataKeyView{type, name} , defaultValue{std::move(defaultValue)} {} public: PropertyValue defaultValue; }; template QVariant getDefaultValueAsQVariant(const Type &key) { if constexpr (std::is_same_v) return toQVariant(key.defaultvalue); return {}; } } // namespace QmlDesigner