File indexing completed on 2024-12-15 03:44:59
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KUSERFEEDBACK_CONSOLE_AGGREGATION_H 0008 #define KUSERFEEDBACK_CONSOLE_AGGREGATION_H 0009 0010 #include <core/aggregationelement.h> 0011 0012 #include <QTypeInfo> 0013 0014 class QJsonArray; 0015 class QJsonObject; 0016 0017 namespace KUserFeedback { 0018 namespace Console { 0019 0020 class Product; 0021 0022 class Aggregation 0023 { 0024 Q_GADGET 0025 public: 0026 enum Type { 0027 None, 0028 Category, 0029 RatioSet, 0030 Numeric 0031 }; 0032 Q_ENUM(Type) 0033 0034 Aggregation(); 0035 ~Aggregation(); 0036 0037 bool isValid() const; 0038 0039 Type type() const; 0040 void setType(Type t); 0041 0042 QString name() const; 0043 void setName(const QString &name); 0044 0045 QVector<AggregationElement> elements() const; 0046 void setElements(const QVector<AggregationElement> &elements); 0047 0048 QJsonObject toJsonObject() const; 0049 static QVector<Aggregation> fromJson(const Product &product, const QJsonArray &a); 0050 0051 private: 0052 Type m_type = None; 0053 QString m_name; 0054 QVector<AggregationElement> m_elements; 0055 }; 0056 0057 } 0058 } 0059 0060 Q_DECLARE_TYPEINFO(KUserFeedback::Console::Aggregation, Q_MOVABLE_TYPE); 0061 Q_DECLARE_METATYPE(KUserFeedback::Console::Aggregation::Type) 0062 0063 #endif // KUSERFEEDBACK_CONSOLE_AGGREGATION_H