Commit 4c7e4782 authored by Volker Krause's avatar Volker Krause
Browse files

Rename ProductSchemaEntry to SchemaEntry

parent 7e9e893b
set(analyzer_lib_srcs
core/product.cpp
core/productschemaentry.cpp
core/schemaentry.cpp
rest/restapi.cpp
rest/restclient.cpp
......
......@@ -31,7 +31,7 @@ class ProductData : public QSharedData
{
public:
QString name;
QVector<ProductSchemaEntry> schema;
QVector<SchemaEntry> schema;
};
}
......@@ -57,12 +57,12 @@ void Product::setName(const QString& name)
d->name = name;
}
QVector<ProductSchemaEntry> Product::schema() const
QVector<SchemaEntry> Product::schema() const
{
return d->schema;
}
void Product::setSchema(const QVector<ProductSchemaEntry> &schema)
void Product::setSchema(const QVector<SchemaEntry> &schema)
{
d->schema = schema;
}
......@@ -87,7 +87,7 @@ QVector<Product> Product::fromJson(const QByteArray &data)
const auto obj = value.toObject();
Product product;
product.setName(obj.value(QStringLiteral("name")).toString());
product.setSchema(ProductSchemaEntry::fromJson(obj.value(QStringLiteral("schema")).toArray()));
product.setSchema(SchemaEntry::fromJson(obj.value(QStringLiteral("schema")).toArray()));
products.push_back(product);
}
return products;
......
......@@ -18,7 +18,7 @@
#ifndef USERFEEDBACK_ANALYZER_PRODUCT_H
#define USERFEEDBACK_ANALYZER_PRODUCT_H
#include "productschemaentry.h"
#include "schemaentry.h"
#include <QMetaType>
#include <QSharedDataPointer>
......@@ -45,8 +45,8 @@ public:
QString name() const;
void setName(const QString &name);
QVector<ProductSchemaEntry> schema() const;
void setSchema(const QVector<ProductSchemaEntry>& schema);
QVector<SchemaEntry> schema() const;
void setSchema(const QVector<SchemaEntry>& schema);
QByteArray toJson() const;
static QVector<Product> fromJson(const QByteArray &data);
......
......@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "productschemaentry.h"
#include "schemaentry.h"
#include <QJsonArray>
#include <QJsonObject>
......@@ -27,54 +27,54 @@ using namespace UserFeedback::Analyzer;
namespace UserFeedback {
namespace Analyzer {
class ProductSchemaEntryData : public QSharedData
class SchemaEntryData : public QSharedData
{
public:
QString name;
int internalId = -1;
ProductSchemaEntry::Type type = ProductSchemaEntry::StringType;
SchemaEntry::Type type = SchemaEntry::StringType;
};
}
}
ProductSchemaEntry::ProductSchemaEntry() : d(new ProductSchemaEntryData) {}
ProductSchemaEntry::ProductSchemaEntry(const ProductSchemaEntry&) = default;
ProductSchemaEntry::~ProductSchemaEntry() = default;
ProductSchemaEntry& ProductSchemaEntry::operator=(const ProductSchemaEntry&) = default;
SchemaEntry::SchemaEntry() : d(new SchemaEntryData) {}
SchemaEntry::SchemaEntry(const SchemaEntry&) = default;
SchemaEntry::~SchemaEntry() = default;
SchemaEntry& SchemaEntry::operator=(const SchemaEntry&) = default;
int ProductSchemaEntry::internalId() const
int SchemaEntry::internalId() const
{
return d->internalId;
}
void ProductSchemaEntry::setInternalId(int internalId)
void SchemaEntry::setInternalId(int internalId)
{
d->internalId = internalId;
}
QString ProductSchemaEntry::name() const
QString SchemaEntry::name() const
{
return d->name;
}
void ProductSchemaEntry::setName(const QString& name)
void SchemaEntry::setName(const QString& name)
{
d->name = name;
}
ProductSchemaEntry::Type ProductSchemaEntry::type() const
SchemaEntry::Type SchemaEntry::type() const
{
return d->type;
}
void ProductSchemaEntry::setType(ProductSchemaEntry::Type type)
void SchemaEntry::setType(SchemaEntry::Type type)
{
d->type = type;
}
QString ProductSchemaEntry::displayString(ProductSchemaEntry::Type type)
QString SchemaEntry::displayString(SchemaEntry::Type type)
{
switch (type) {
case InvalidType: return QObject::tr("Invalid");
......@@ -87,7 +87,7 @@ QString ProductSchemaEntry::displayString(ProductSchemaEntry::Type type)
Q_UNREACHABLE();
}
QJsonObject ProductSchemaEntry::toJsonObject() const
QJsonObject SchemaEntry::toJsonObject() const
{
QJsonObject obj;
if (d->internalId >= 0)
......@@ -106,14 +106,14 @@ QJsonObject ProductSchemaEntry::toJsonObject() const
return obj;
}
QVector<ProductSchemaEntry> ProductSchemaEntry::fromJson(const QJsonArray &array)
QVector<SchemaEntry> SchemaEntry::fromJson(const QJsonArray &array)
{
QVector<ProductSchemaEntry> res;
QVector<SchemaEntry> res;
res.reserve(array.size());
foreach (const auto &v, array) {
const auto obj = v.toObject();
ProductSchemaEntry entry;
SchemaEntry entry;
entry.setName(obj.value(QStringLiteral("name")).toString());
const auto t = obj.value(QStringLiteral("type")).toString();
if (t == QStringLiteral("string"))
......
......@@ -15,8 +15,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERFEEDBACK_ANALYZER_PRODUCTSCHEMAENTRY_H
#define USERFEEDBACK_ANALYZER_PRODUCTSCHEMAENTRY_H
#ifndef USERFEEDBACK_ANALYZER_SCHEMAENTRY_H
#define USERFEEDBACK_ANALYZER_SCHEMAENTRY_H
#include <QObject>
#include <QSharedDataPointer>
......@@ -28,9 +28,33 @@ class QJsonObject;
namespace UserFeedback {
namespace Analyzer {
class ProductSchemaEntryData;
class ProductSchemaEntry
class SchemaEntryData;
/** Represents one schema entry.
* A schema entry can be a scalar, a list or a map, and consists of one or
* more named entries. A schema entry can also have higher-level aggregation
* hints, used for visualizing the recorded data. The following examples
* list common configurations.
*
* \li Product version, Qt version, framework version:
* scalar, one string element containing the version, category aggregation
* \li Usage time, start count:
* scalar, one integer element containing the data, numeric aggregation
* \li Platform type/version:
* scalar, two string elements containing platform type/sub-type, hierarchical category aggregation
* \li View usage/feature usage ratios:
* Option 1 (fixed set): scalar, multiple numeric elements per feature, ratio set aggregation
* Option 2 (variable set): map for feature to single numeric element, ratio set aggregation
* \li Screen size:
* list (one entry per screen), two numeric elements for height/width, x/y aggregation
* \li Screen resolution, screen count:
* scalar of single numeric element, numeric aggregation
* \li event counts:
* scalar, multiple numeric elements, numeric aggregation
* \li language settings:
* scalar, one string element, category aggregation
*/
class SchemaEntry
{
Q_GADGET
public:
......@@ -43,10 +67,10 @@ public:
};
Q_ENUM(Type)
ProductSchemaEntry();
ProductSchemaEntry(const ProductSchemaEntry &entry);
~ProductSchemaEntry();
ProductSchemaEntry& operator=(const ProductSchemaEntry &entry);
SchemaEntry();
SchemaEntry(const SchemaEntry &entry);
~SchemaEntry();
SchemaEntry& operator=(const SchemaEntry &entry);
int internalId() const;
void setInternalId(int internalId);
......@@ -60,17 +84,17 @@ public:
static QString displayString(Type type);
QJsonObject toJsonObject() const;
static QVector<ProductSchemaEntry> fromJson(const QJsonArray &array);
static QVector<SchemaEntry> fromJson(const QJsonArray &array);
private:
QSharedDataPointer<ProductSchemaEntryData> d;
QSharedDataPointer<SchemaEntryData> d;
};
}
}
Q_DECLARE_METATYPE(UserFeedback::Analyzer::ProductSchemaEntry)
Q_DECLARE_METATYPE(UserFeedback::Analyzer::ProductSchemaEntry::Type)
Q_DECLARE_TYPEINFO(UserFeedback::Analyzer::ProductSchemaEntry, Q_MOVABLE_TYPE);
Q_DECLARE_METATYPE(UserFeedback::Analyzer::SchemaEntry)
Q_DECLARE_METATYPE(UserFeedback::Analyzer::SchemaEntry::Type)
Q_DECLARE_TYPEINFO(UserFeedback::Analyzer::SchemaEntry, Q_MOVABLE_TYPE);
#endif // USERFEEDBACK_ANALYZER_PRODUCTSCHEMAENTRY_H
......@@ -214,15 +214,15 @@ void MainWindow::createProduct()
Product product;
product.setName(name);
QVector<ProductSchemaEntry> schema;
ProductSchemaEntry entry;
QVector<SchemaEntry> schema;
SchemaEntry entry;
entry.setName(QStringLiteral("version"));
entry.setType(ProductSchemaEntry::StringType);
entry.setType(SchemaEntry::StringType);
schema.push_back(entry);
entry.setName(QStringLiteral("platform"));
schema.push_back(entry);
entry.setName(QStringLiteral("startCount"));
entry.setType(ProductSchemaEntry::IntegerType);
entry.setType(SchemaEntry::IntegerType);
schema.push_back(entry);
entry.setName(QStringLiteral("usageTime"));
schema.push_back(entry);
......@@ -274,10 +274,10 @@ void MainWindow::productSelected()
foreach (const auto &schemaEntry, product.schema()) {
switch (schemaEntry.type()) {
case ProductSchemaEntry::InvalidType:
case ProductSchemaEntry::StringListType:
case SchemaEntry::InvalidType:
case SchemaEntry::StringListType:
break;
case ProductSchemaEntry::StringType:
case SchemaEntry::StringType:
{
auto model = new CategoryAggregationModel(this);
model->setSourceModel(m_timeAggregationModel);
......@@ -287,7 +287,7 @@ void MainWindow::productSelected()
ui->chartType->addItem(schemaEntry.name(), QVariant::fromValue(model));
break;
}
case ProductSchemaEntry::IntegerType:
case SchemaEntry::IntegerType:
{
auto model = new NumericAggregationModel(this);
model->setSourceModel(m_timeAggregationModel);
......@@ -297,7 +297,7 @@ void MainWindow::productSelected()
ui->chartType->addItem(schemaEntry.name(), QVariant::fromValue(model));
break;
}
case ProductSchemaEntry::RatioSetType:
case SchemaEntry::RatioSetType:
{
auto model = new RatioSetAggregationModel(this);
model->setSourceModel(m_timeAggregationModel);
......
......@@ -17,7 +17,7 @@
#include "sample.h"
#include <core/product.h>
#include <core/productschemaentry.h>
#include <core/schemaentry.h>
#include "ratioset.h"
#include <QDateTime>
......@@ -66,15 +66,15 @@ QVector<Sample> Sample::fromJson(const QByteArray &json, const Product &product)
if (!obj.contains(entry.name()))
continue;
switch (entry.type()) {
case ProductSchemaEntry::InvalidType:
case SchemaEntry::InvalidType:
break;
case ProductSchemaEntry::StringType:
case SchemaEntry::StringType:
s.d->data.insert(entry.name(), obj.value(entry.name()).toString());
break;
case ProductSchemaEntry::IntegerType:
case SchemaEntry::IntegerType:
s.d->data.insert(entry.name(), obj.value(entry.name()).toInt());
break;
case ProductSchemaEntry::StringListType:
case SchemaEntry::StringListType:
{
QStringList l;
const auto a = obj.value(entry.name()).toArray();
......@@ -84,7 +84,7 @@ QVector<Sample> Sample::fromJson(const QByteArray &json, const Product &product)
s.d->data.insert(entry.name(), l);
break;
}
case ProductSchemaEntry::RatioSetType:
case SchemaEntry::RatioSetType:
{
const auto set = RatioSet::fromJson(obj.value(entry.name()).toObject());
s.d->data.insert(entry.name(), QVariant::fromValue(set));
......
......@@ -16,7 +16,7 @@
*/
#include "schemaentryitemeditorfactory.h"
#include <core/productschemaentry.h>
#include <core/schemaentry.h>
#include "schemaentrytypecombobox.h"
#include <QDebug>
......@@ -25,5 +25,5 @@ using namespace UserFeedback::Analyzer;
SchemaEntryItemEditorFactory::SchemaEntryItemEditorFactory()
{
registerEditor(qMetaTypeId<ProductSchemaEntry::Type>(), new QStandardItemEditorCreator<SchemaEntryTypeComboBox>());
registerEditor(qMetaTypeId<SchemaEntry::Type>(), new QStandardItemEditorCreator<SchemaEntryTypeComboBox>());
}
......@@ -24,25 +24,25 @@ using namespace UserFeedback::Analyzer;
SchemaEntryTypeComboBox::SchemaEntryTypeComboBox(QWidget* parent) :
QComboBox(parent)
{
addEntry(ProductSchemaEntry::IntegerType);
addEntry(ProductSchemaEntry::StringType);
addEntry(ProductSchemaEntry::StringListType);
addEntry(ProductSchemaEntry::RatioSetType);
addEntry(SchemaEntry::IntegerType);
addEntry(SchemaEntry::StringType);
addEntry(SchemaEntry::StringListType);
addEntry(SchemaEntry::RatioSetType);
}
SchemaEntryTypeComboBox::~SchemaEntryTypeComboBox() = default;
void SchemaEntryTypeComboBox::setType(ProductSchemaEntry::Type type)
void SchemaEntryTypeComboBox::setType(SchemaEntry::Type type)
{
setCurrentIndex(findData(QVariant::fromValue(type)));
}
ProductSchemaEntry::Type SchemaEntryTypeComboBox::type() const
SchemaEntry::Type SchemaEntryTypeComboBox::type() const
{
return currentData().value<ProductSchemaEntry::Type>();
return currentData().value<SchemaEntry::Type>();
}
void SchemaEntryTypeComboBox::addEntry(ProductSchemaEntry::Type type)
void SchemaEntryTypeComboBox::addEntry(SchemaEntry::Type type)
{
addItem(ProductSchemaEntry::displayString(type), QVariant::fromValue(type));
addItem(SchemaEntry::displayString(type), QVariant::fromValue(type));
}
......@@ -18,7 +18,7 @@
#ifndef USERFEEDBACK_ANALYZER_SCHEMAENTRYTYPECOMBOBOX_H
#define USERFEEDBACK_ANALYZER_SCHEMAENTRYTYPECOMBOBOX_H
#include <core/productschemaentry.h>
#include <core/schemaentry.h>
#include <QComboBox>
......@@ -28,16 +28,16 @@ namespace Analyzer {
class SchemaEntryTypeComboBox : public QComboBox
{
Q_OBJECT
Q_PROPERTY(UserFeedback::Analyzer::ProductSchemaEntry::Type type READ type WRITE setType USER true)
Q_PROPERTY(UserFeedback::Analyzer::SchemaEntry::Type type READ type WRITE setType USER true)
public:
explicit SchemaEntryTypeComboBox(QWidget *parent = nullptr);
~SchemaEntryTypeComboBox();
ProductSchemaEntry::Type type() const;
void setType(ProductSchemaEntry::Type type);
SchemaEntry::Type type() const;
void setType(SchemaEntry::Type type);
private:
void addEntry(ProductSchemaEntry::Type type);
void addEntry(SchemaEntry::Type type);
};
......
......@@ -42,7 +42,7 @@ void SchemaModel::addEntry(const QString &name)
{
auto schema = m_product.schema();
beginInsertRows(QModelIndex(), schema.size(), schema.size());
ProductSchemaEntry entry;
SchemaEntry entry;
entry.setName(name);
schema.push_back(entry);
m_product.setSchema(schema);
......@@ -83,7 +83,7 @@ QVariant SchemaModel::data(const QModelIndex& index, int role) const
break;
case 1:
if (role == Qt::DisplayRole)
return ProductSchemaEntry::displayString(m_product.schema().at(index.row()).type());
return SchemaEntry::displayString(m_product.schema().at(index.row()).type());
if (role == Qt::EditRole)
return QVariant::fromValue(m_product.schema().at(index.row()).type());
break;
......@@ -121,7 +121,7 @@ bool SchemaModel::setData(const QModelIndex &index, const QVariant &value, int r
entry.setName(value.toString());
break;
case 1:
entry.setType(value.value<ProductSchemaEntry::Type>());
entry.setType(value.value<SchemaEntry::Type>());
break;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment