File indexing completed on 2024-12-15 03:45:00

0001 /*
0002     SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef KUSERFEEDBACK_CONSOLE_SCHEMAENTRY_H
0008 #define KUSERFEEDBACK_CONSOLE_SCHEMAENTRY_H
0009 
0010 #include <QObject>
0011 #include <QSharedDataPointer>
0012 #include <QVector>
0013 
0014 class QJsonArray;
0015 class QJsonObject;
0016 
0017 namespace KUserFeedback {
0018 namespace Console {
0019 
0020 class SchemaEntryData;
0021 class SchemaEntryElement;
0022 
0023 /** Represents one schema entry.
0024  *  A schema entry can be a scalar, a list or a map, and consists of one or
0025  *  more named entries. A schema entry can also have higher-level aggregation
0026  *  hints, used for visualizing the recorded data. The following examples
0027  *  list common configurations.
0028  *
0029  *  \li Product version, Qt version, framework version:
0030  *  scalar, one string element containing the version, category aggregation
0031  *  \li Usage time, start count:
0032  *  scalar, one integer element containing the data, numeric aggregation
0033  *  \li Platform type/version:
0034  *  scalar, two string elements containing platform type/sub-type, hierarchical category aggregation
0035  *  \li View usage/feature usage ratios:
0036  *  Option 1 (fixed set): scalar, multiple numeric elements per feature, ratio set aggregation
0037  *  Option 2 (variable set): map for feature to single numeric element, ratio set aggregation
0038  *  \li Screen size:
0039  *  list (one entry per screen), two numeric elements for height/width, x/y aggregation
0040  *  \li Screen resolution, screen count:
0041  *  scalar of single numeric element, numeric aggregation
0042  *  \li event counts:
0043  *  scalar, multiple numeric elements, numeric aggregation
0044  *  \li language settings:
0045  *  scalar, one string element, category aggregation
0046  */
0047 class SchemaEntry
0048 {
0049     Q_GADGET
0050 public:
0051     enum DataType {
0052         Scalar,
0053         List,
0054         Map
0055     };
0056     Q_ENUM(DataType)
0057 
0058     SchemaEntry();
0059     SchemaEntry(const SchemaEntry &entry);
0060     ~SchemaEntry();
0061     SchemaEntry& operator=(const SchemaEntry &entry);
0062 
0063     bool operator==(const SchemaEntry &other) const;
0064 
0065     int internalId() const;
0066     void setInternalId(int internalId);
0067 
0068     QString name() const;
0069     void setName(const QString& name);
0070 
0071     DataType dataType() const;
0072     void setDataType(DataType type);
0073 
0074     QVector<SchemaEntryElement> elements() const;
0075     void setElements(const QVector<SchemaEntryElement> &elements);
0076     SchemaEntryElement element(const QString &name) const;
0077 
0078     QJsonObject toJsonObject() const;
0079     static QVector<SchemaEntry> fromJson(const QJsonArray &array);
0080 
0081 private:
0082     QSharedDataPointer<SchemaEntryData> d;
0083 };
0084 
0085 }
0086 }
0087 
0088 Q_DECLARE_METATYPE(KUserFeedback::Console::SchemaEntry)
0089 Q_DECLARE_TYPEINFO(KUserFeedback::Console::SchemaEntry, Q_MOVABLE_TYPE);
0090 
0091 #endif // KUSERFEEDBACK_CONSOLE_PRODUCTSCHEMAENTRY_H