Commit 433f2fe2 authored by Volker Krause's avatar Volker Krause
Browse files

Remove the last uses of SchemaEntry::type

This is now superseded by more fine-grained control about data and
aggregation types.
parent 2361372d
......@@ -38,7 +38,6 @@ set(analyzer_srcs
schemaeditor/schemaeditwidget.cpp
schemaeditor/schemaentryitemeditorfactory.cpp
schemaeditor/schemaentrytypecombobox.cpp
surveyeditor/surveydialog.cpp
surveyeditor/surveyeditor.cpp
......
......@@ -122,11 +122,10 @@ void AnalyticsView::setProduct(const Product& product)
ui->chartType->addItem(tr("Samples"), QVariant::fromValue(m_timeAggregationModel));
foreach (const auto &schemaEntry, product.schema()) {
switch (schemaEntry.type()) {
case SchemaEntry::InvalidType:
case SchemaEntry::StringListType:
switch (schemaEntry.aggregationType()) {
case SchemaEntry::None:
break;
case SchemaEntry::StringType:
case SchemaEntry::Category:
{
auto model = new CategoryAggregationModel(this);
model->setSourceModel(m_timeAggregationModel);
......@@ -136,7 +135,7 @@ void AnalyticsView::setProduct(const Product& product)
ui->chartType->addItem(schemaEntry.name(), QVariant::fromValue(model));
break;
}
case SchemaEntry::IntegerType:
case SchemaEntry::Numeric:
{
auto model = new NumericAggregationModel(this);
model->setSourceModel(m_timeAggregationModel);
......@@ -146,7 +145,7 @@ void AnalyticsView::setProduct(const Product& product)
ui->chartType->addItem(schemaEntry.name(), QVariant::fromValue(model));
break;
}
case SchemaEntry::RatioSetType:
case SchemaEntry::RatioSet:
{
auto model = new RatioSetAggregationModel(this);
model->setSourceModel(m_timeAggregationModel);
......@@ -156,6 +155,9 @@ void AnalyticsView::setProduct(const Product& product)
ui->chartType->addItem(schemaEntry.name(), QVariant::fromValue(model));
break;
}
case SchemaEntry::XY:
// TODO
break;
}
}
}
......
......@@ -35,7 +35,6 @@ class SchemaEntryData : public QSharedData
public:
QString name;
int internalId = -1;
SchemaEntry::Type type = SchemaEntry::StringType;
SchemaEntry::DataType dataType = SchemaEntry::Scalar;
SchemaEntry::AggregationType aggregation = SchemaEntry::None;
QVector<SchemaEntryElement> elements;
......@@ -73,7 +72,6 @@ bool SchemaEntry::operator==(const SchemaEntry &other) const
{
return d->name == other.d->name
&& d->internalId == other.d->internalId
&& d->type == other.d->type
&& d->dataType == other.d->dataType
&& d->aggregation == other.d->aggregation
&& d->elements == other.d->elements;
......@@ -99,16 +97,6 @@ void SchemaEntry::setName(const QString& name)
d->name = name;
}
SchemaEntry::Type SchemaEntry::type() const
{
return d->type;
}
void SchemaEntry::setType(SchemaEntry::Type type)
{
d->type = type;
}
SchemaEntry::DataType SchemaEntry::dataType() const
{
return d->dataType;
......@@ -139,19 +127,6 @@ void SchemaEntry::setElements(const QVector<SchemaEntryElement> &elements)
d->elements = elements;
}
QString SchemaEntry::displayString(SchemaEntry::Type type)
{
switch (type) {
case InvalidType: return QObject::tr("Invalid");
case IntegerType: return QObject::tr("Integer");
case StringType: return QObject::tr("String");
case StringListType: return QObject::tr("String List");
case RatioSetType: return QObject::tr("Ratio Set");
}
Q_UNREACHABLE();
}
QJsonObject SchemaEntry::toJsonObject() const
{
QJsonObject obj;
......@@ -160,13 +135,6 @@ QJsonObject SchemaEntry::toJsonObject() const
obj.insert(QStringLiteral("name"), d->name);
QString t;
switch (d->type) {
case InvalidType: break;
case StringType: t = QStringLiteral("string"); break;
case IntegerType: t = QStringLiteral("int"); break;
case StringListType: t = QStringLiteral("string_list"); break;
case RatioSetType: t = QStringLiteral("ratio_set"); break;
}
obj.insert(QStringLiteral("type"), QLatin1String(data_types_table[d->dataType].name));
obj.insert(QStringLiteral("aggregationType"), QLatin1String(aggregation_types_table[d->aggregation].name));
......
......@@ -75,15 +75,6 @@ public:
};
Q_ENUM(AggregationType)
enum Type {
InvalidType,
IntegerType,
StringType,
StringListType,
RatioSetType
};
Q_ENUM(Type)
SchemaEntry();
SchemaEntry(const SchemaEntry &entry);
~SchemaEntry();
......@@ -97,9 +88,6 @@ public:
QString name() const;
void setName(const QString& name);
Type type() const;
void setType(Type type);
AggregationType aggregationType() const;
void setAggregationType(AggregationType type);
......@@ -109,8 +97,6 @@ public:
QVector<SchemaEntryElement> elements() const;
void setElements(const QVector<SchemaEntryElement> &elements);
static QString displayString(Type type);
QJsonObject toJsonObject() const;
static QVector<SchemaEntry> fromJson(const QJsonArray &array);
......@@ -122,7 +108,6 @@ private:
}
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
......@@ -182,21 +182,6 @@ void MainWindow::createProduct()
Product product;
product.setName(name);
QVector<SchemaEntry> schema;
SchemaEntry entry;
entry.setName(QStringLiteral("version"));
entry.setType(SchemaEntry::StringType);
schema.push_back(entry);
entry.setName(QStringLiteral("platform"));
schema.push_back(entry);
entry.setName(QStringLiteral("startCount"));
entry.setType(SchemaEntry::IntegerType);
schema.push_back(entry);
entry.setName(QStringLiteral("usageTime"));
schema.push_back(entry);
product.setSchema(schema);
auto reply = RESTApi::createProduct(m_restClient, product);
connect(reply, &QNetworkReply::finished, this, [this, reply, name]() {
if (reply->error() == QNetworkReply::NoError) {
......
......@@ -106,12 +106,6 @@ QVariant SchemaModel::data(const QModelIndex& index, int role) const
if (role == Qt::DisplayRole || role == Qt::EditRole)
return m_product.schema().at(index.row()).name();
break;
case 1:
if (role == Qt::DisplayRole)
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;
case 2:
if (role == Qt::DisplayRole)
return Util::enumToString(m_product.schema().at(index.row()).aggregationType());
......@@ -153,7 +147,7 @@ Qt::ItemFlags SchemaModel::flags(const QModelIndex &index) const
const auto baseFlags = QAbstractItemModel::flags(index);
if (!index.isValid())
return baseFlags;
if (index.internalId() == TOPLEVEL || index.column() < 2)
if ((index.internalId() == TOPLEVEL && index.column() != 1) || (index.internalId() != TOPLEVEL && index.column() < 2))
return baseFlags | Qt::ItemIsEditable;
return baseFlags;
}
......@@ -171,9 +165,6 @@ bool SchemaModel::setData(const QModelIndex &index, const QVariant &value, int r
case 0:
entry.setName(value.toString());
break;
case 1:
entry.setType(value.value<SchemaEntry::Type>());
break;
case 2:
entry.setAggregationType(value.value<SchemaEntry::AggregationType>());
break;
......
......@@ -18,7 +18,6 @@
#include "schemaentryitemeditorfactory.h"
#include <core/schemaentry.h>
#include <core/schemaentryelement.h>
#include "schemaentrytypecombobox.h"
#include <widgets/metaenumcombobox.h>
#include <QDebug>
......@@ -27,7 +26,6 @@ using namespace UserFeedback::Analyzer;
SchemaEntryItemEditorFactory::SchemaEntryItemEditorFactory()
{
registerEditor(qMetaTypeId<SchemaEntry::Type>(), new QStandardItemEditorCreator<SchemaEntryTypeComboBox>());
registerEditor(qMetaTypeId<SchemaEntry::AggregationType>(), new QStandardItemEditorCreator<MetaEnumComboBox>());
registerEditor(qMetaTypeId<SchemaEntryElement::Type>(), new QStandardItemEditorCreator<MetaEnumComboBox>());
}
/*
Copyright (C) 2016 Volker Krause <volker.krause@kdab.com>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "schemaentrytypecombobox.h"
#include <QDebug>
using namespace UserFeedback::Analyzer;
SchemaEntryTypeComboBox::SchemaEntryTypeComboBox(QWidget* parent) :
QComboBox(parent)
{
addEntry(SchemaEntry::IntegerType);
addEntry(SchemaEntry::StringType);
addEntry(SchemaEntry::StringListType);
addEntry(SchemaEntry::RatioSetType);
}
SchemaEntryTypeComboBox::~SchemaEntryTypeComboBox() = default;
void SchemaEntryTypeComboBox::setType(SchemaEntry::Type type)
{
setCurrentIndex(findData(QVariant::fromValue(type)));
}
SchemaEntry::Type SchemaEntryTypeComboBox::type() const
{
return currentData().value<SchemaEntry::Type>();
}
void SchemaEntryTypeComboBox::addEntry(SchemaEntry::Type type)
{
addItem(SchemaEntry::displayString(type), QVariant::fromValue(type));
}
/*
Copyright (C) 2016 Volker Krause <volker.krause@kdab.com>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERFEEDBACK_ANALYZER_SCHEMAENTRYTYPECOMBOBOX_H
#define USERFEEDBACK_ANALYZER_SCHEMAENTRYTYPECOMBOBOX_H
#include <core/schemaentry.h>
#include <QComboBox>
namespace UserFeedback {
namespace Analyzer {
class SchemaEntryTypeComboBox : public QComboBox
{
Q_OBJECT
Q_PROPERTY(UserFeedback::Analyzer::SchemaEntry::Type type READ type WRITE setType USER true)
public:
explicit SchemaEntryTypeComboBox(QWidget *parent = nullptr);
~SchemaEntryTypeComboBox();
SchemaEntry::Type type() const;
void setType(SchemaEntry::Type type);
private:
void addEntry(SchemaEntry::Type type);
};
}
}
#endif // USERFEEDBACK_ANALYZER_SCHEMAENTRYTYPECOMBOBOX_H
......@@ -107,11 +107,9 @@ private slots:
// add new product
SchemaEntry entry;
entry.setName(QStringLiteral("entry1"));
entry.setType(SchemaEntry::StringType);
entry.setAggregationType(SchemaEntry::Category);
SchemaEntryElement elem1;
elem1.setName(QStringLiteral("elem11"));
elem1.setType(SchemaEntryElement::Integer);
entry.setElements({elem1});
newProduct.setSchema({entry});
QVERIFY(newProduct.isValid());
......
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