Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Telemetry
KUserFeedback
Commits
4c7e4782
Commit
4c7e4782
authored
Oct 01, 2016
by
Volker Krause
Browse files
Rename ProductSchemaEntry to SchemaEntry
parent
7e9e893b
Changes
11
Hide whitespace changes
Inline
Side-by-side
analyzer/CMakeLists.txt
View file @
4c7e4782
set
(
analyzer_lib_srcs
core/product.cpp
core/
product
schemaentry.cpp
core/schemaentry.cpp
rest/restapi.cpp
rest/restclient.cpp
...
...
analyzer/core/product.cpp
View file @
4c7e4782
...
...
@@ -31,7 +31,7 @@ class ProductData : public QSharedData
{
public:
QString
name
;
QVector
<
Product
SchemaEntry
>
schema
;
QVector
<
SchemaEntry
>
schema
;
};
}
...
...
@@ -57,12 +57,12 @@ void Product::setName(const QString& name)
d
->
name
=
name
;
}
QVector
<
Product
SchemaEntry
>
Product
::
schema
()
const
QVector
<
SchemaEntry
>
Product
::
schema
()
const
{
return
d
->
schema
;
}
void
Product
::
setSchema
(
const
QVector
<
Product
SchemaEntry
>
&
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
(
Product
SchemaEntry
::
fromJson
(
obj
.
value
(
QStringLiteral
(
"schema"
)).
toArray
()));
product
.
setSchema
(
SchemaEntry
::
fromJson
(
obj
.
value
(
QStringLiteral
(
"schema"
)).
toArray
()));
products
.
push_back
(
product
);
}
return
products
;
...
...
analyzer/core/product.h
View file @
4c7e4782
...
...
@@ -18,7 +18,7 @@
#ifndef USERFEEDBACK_ANALYZER_PRODUCT_H
#define USERFEEDBACK_ANALYZER_PRODUCT_H
#include "
product
schemaentry.h"
#include "schemaentry.h"
#include <QMetaType>
#include <QSharedDataPointer>
...
...
@@ -45,8 +45,8 @@ public:
QString
name
()
const
;
void
setName
(
const
QString
&
name
);
QVector
<
Product
SchemaEntry
>
schema
()
const
;
void
setSchema
(
const
QVector
<
Product
SchemaEntry
>&
schema
);
QVector
<
SchemaEntry
>
schema
()
const
;
void
setSchema
(
const
QVector
<
SchemaEntry
>&
schema
);
QByteArray
toJson
()
const
;
static
QVector
<
Product
>
fromJson
(
const
QByteArray
&
data
);
...
...
analyzer/core/
product
schemaentry.cpp
→
analyzer/core/schemaentry.cpp
View file @
4c7e4782
...
...
@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "
product
schemaentry.h"
#include "schemaentry.h"
#include <QJsonArray>
#include <QJsonObject>
...
...
@@ -27,54 +27,54 @@ using namespace UserFeedback::Analyzer;
namespace
UserFeedback
{
namespace
Analyzer
{
class
Product
SchemaEntryData
:
public
QSharedData
class
SchemaEntryData
:
public
QSharedData
{
public:
QString
name
;
int
internalId
=
-
1
;
Product
SchemaEntry
::
Type
type
=
Product
SchemaEntry
::
StringType
;
SchemaEntry
::
Type
type
=
SchemaEntry
::
StringType
;
};
}
}
Product
SchemaEntry
::
Product
SchemaEntry
()
:
d
(
new
Product
SchemaEntryData
)
{}
Product
SchemaEntry
::
Product
SchemaEntry
(
const
Product
SchemaEntry
&
)
=
default
;
Product
SchemaEntry
::~
Product
SchemaEntry
()
=
default
;
Product
SchemaEntry
&
Product
SchemaEntry
::
operator
=
(
const
Product
SchemaEntry
&
)
=
default
;
SchemaEntry
::
SchemaEntry
()
:
d
(
new
SchemaEntryData
)
{}
SchemaEntry
::
SchemaEntry
(
const
SchemaEntry
&
)
=
default
;
SchemaEntry
::~
SchemaEntry
()
=
default
;
SchemaEntry
&
SchemaEntry
::
operator
=
(
const
SchemaEntry
&
)
=
default
;
int
Product
SchemaEntry
::
internalId
()
const
int
SchemaEntry
::
internalId
()
const
{
return
d
->
internalId
;
}
void
Product
SchemaEntry
::
setInternalId
(
int
internalId
)
void
SchemaEntry
::
setInternalId
(
int
internalId
)
{
d
->
internalId
=
internalId
;
}
QString
Product
SchemaEntry
::
name
()
const
QString
SchemaEntry
::
name
()
const
{
return
d
->
name
;
}
void
Product
SchemaEntry
::
setName
(
const
QString
&
name
)
void
SchemaEntry
::
setName
(
const
QString
&
name
)
{
d
->
name
=
name
;
}
Product
SchemaEntry
::
Type
Product
SchemaEntry
::
type
()
const
SchemaEntry
::
Type
SchemaEntry
::
type
()
const
{
return
d
->
type
;
}
void
Product
SchemaEntry
::
setType
(
Product
SchemaEntry
::
Type
type
)
void
SchemaEntry
::
setType
(
SchemaEntry
::
Type
type
)
{
d
->
type
=
type
;
}
QString
Product
SchemaEntry
::
displayString
(
Product
SchemaEntry
::
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
Product
SchemaEntry
::
toJsonObject
()
const
QJsonObject
SchemaEntry
::
toJsonObject
()
const
{
QJsonObject
obj
;
if
(
d
->
internalId
>=
0
)
...
...
@@ -106,14 +106,14 @@ QJsonObject ProductSchemaEntry::toJsonObject() const
return
obj
;
}
QVector
<
Product
SchemaEntry
>
Product
SchemaEntry
::
fromJson
(
const
QJsonArray
&
array
)
QVector
<
SchemaEntry
>
SchemaEntry
::
fromJson
(
const
QJsonArray
&
array
)
{
QVector
<
Product
SchemaEntry
>
res
;
QVector
<
SchemaEntry
>
res
;
res
.
reserve
(
array
.
size
());
foreach
(
const
auto
&
v
,
array
)
{
const
auto
obj
=
v
.
toObject
();
Product
SchemaEntry
entry
;
SchemaEntry
entry
;
entry
.
setName
(
obj
.
value
(
QStringLiteral
(
"name"
)).
toString
());
const
auto
t
=
obj
.
value
(
QStringLiteral
(
"type"
)).
toString
();
if
(
t
==
QStringLiteral
(
"string"
))
...
...
analyzer/core/
product
schemaentry.h
→
analyzer/core/schemaentry.h
View file @
4c7e4782
...
...
@@ -15,8 +15,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERFEEDBACK_ANALYZER_
PRODUCT
SCHEMAENTRY_H
#define USERFEEDBACK_ANALYZER_
PRODUCT
SCHEMAENTRY_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
)
Product
SchemaEntry
();
Product
SchemaEntry
(
const
Product
SchemaEntry
&
entry
);
~
Product
SchemaEntry
();
Product
SchemaEntry
&
operator
=
(
const
Product
SchemaEntry
&
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
<
Product
SchemaEntry
>
fromJson
(
const
QJsonArray
&
array
);
static
QVector
<
SchemaEntry
>
fromJson
(
const
QJsonArray
&
array
);
private:
QSharedDataPointer
<
Product
SchemaEntryData
>
d
;
QSharedDataPointer
<
SchemaEntryData
>
d
;
};
}
}
Q_DECLARE_METATYPE
(
UserFeedback
::
Analyzer
::
Product
SchemaEntry
)
Q_DECLARE_METATYPE
(
UserFeedback
::
Analyzer
::
Product
SchemaEntry
::
Type
)
Q_DECLARE_TYPEINFO
(
UserFeedback
::
Analyzer
::
Product
SchemaEntry
,
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
analyzer/mainwindow.cpp
View file @
4c7e4782
...
...
@@ -214,15 +214,15 @@ void MainWindow::createProduct()
Product
product
;
product
.
setName
(
name
);
QVector
<
Product
SchemaEntry
>
schema
;
Product
SchemaEntry
entry
;
QVector
<
SchemaEntry
>
schema
;
SchemaEntry
entry
;
entry
.
setName
(
QStringLiteral
(
"version"
));
entry
.
setType
(
Product
SchemaEntry
::
StringType
);
entry
.
setType
(
SchemaEntry
::
StringType
);
schema
.
push_back
(
entry
);
entry
.
setName
(
QStringLiteral
(
"platform"
));
schema
.
push_back
(
entry
);
entry
.
setName
(
QStringLiteral
(
"startCount"
));
entry
.
setType
(
Product
SchemaEntry
::
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
Product
SchemaEntry
::
InvalidType
:
case
Product
SchemaEntry
::
StringListType
:
case
SchemaEntry
::
InvalidType
:
case
SchemaEntry
::
StringListType
:
break
;
case
Product
SchemaEntry
::
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
Product
SchemaEntry
::
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
Product
SchemaEntry
::
RatioSetType
:
case
SchemaEntry
::
RatioSetType
:
{
auto
model
=
new
RatioSetAggregationModel
(
this
);
model
->
setSourceModel
(
m_timeAggregationModel
);
...
...
analyzer/sample.cpp
View file @
4c7e4782
...
...
@@ -17,7 +17,7 @@
#include "sample.h"
#include <core/product.h>
#include <core/
product
schemaentry.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
Product
SchemaEntry
::
InvalidType
:
case
SchemaEntry
::
InvalidType
:
break
;
case
Product
SchemaEntry
::
StringType
:
case
SchemaEntry
::
StringType
:
s
.
d
->
data
.
insert
(
entry
.
name
(),
obj
.
value
(
entry
.
name
()).
toString
());
break
;
case
Product
SchemaEntry
::
IntegerType
:
case
SchemaEntry
::
IntegerType
:
s
.
d
->
data
.
insert
(
entry
.
name
(),
obj
.
value
(
entry
.
name
()).
toInt
());
break
;
case
Product
SchemaEntry
::
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
Product
SchemaEntry
::
RatioSetType
:
case
SchemaEntry
::
RatioSetType
:
{
const
auto
set
=
RatioSet
::
fromJson
(
obj
.
value
(
entry
.
name
()).
toObject
());
s
.
d
->
data
.
insert
(
entry
.
name
(),
QVariant
::
fromValue
(
set
));
...
...
analyzer/schemaentryitemeditorfactory.cpp
View file @
4c7e4782
...
...
@@ -16,7 +16,7 @@
*/
#include "schemaentryitemeditorfactory.h"
#include <core/
product
schemaentry.h>
#include <core/schemaentry.h>
#include "schemaentrytypecombobox.h"
#include <QDebug>
...
...
@@ -25,5 +25,5 @@ using namespace UserFeedback::Analyzer;
SchemaEntryItemEditorFactory
::
SchemaEntryItemEditorFactory
()
{
registerEditor
(
qMetaTypeId
<
Product
SchemaEntry
::
Type
>
(),
new
QStandardItemEditorCreator
<
SchemaEntryTypeComboBox
>
());
registerEditor
(
qMetaTypeId
<
SchemaEntry
::
Type
>
(),
new
QStandardItemEditorCreator
<
SchemaEntryTypeComboBox
>
());
}
analyzer/schemaentrytypecombobox.cpp
View file @
4c7e4782
...
...
@@ -24,25 +24,25 @@ using namespace UserFeedback::Analyzer;
SchemaEntryTypeComboBox
::
SchemaEntryTypeComboBox
(
QWidget
*
parent
)
:
QComboBox
(
parent
)
{
addEntry
(
Product
SchemaEntry
::
IntegerType
);
addEntry
(
Product
SchemaEntry
::
StringType
);
addEntry
(
Product
SchemaEntry
::
StringListType
);
addEntry
(
Product
SchemaEntry
::
RatioSetType
);
addEntry
(
SchemaEntry
::
IntegerType
);
addEntry
(
SchemaEntry
::
StringType
);
addEntry
(
SchemaEntry
::
StringListType
);
addEntry
(
SchemaEntry
::
RatioSetType
);
}
SchemaEntryTypeComboBox
::~
SchemaEntryTypeComboBox
()
=
default
;
void
SchemaEntryTypeComboBox
::
setType
(
Product
SchemaEntry
::
Type
type
)
void
SchemaEntryTypeComboBox
::
setType
(
SchemaEntry
::
Type
type
)
{
setCurrentIndex
(
findData
(
QVariant
::
fromValue
(
type
)));
}
Product
SchemaEntry
::
Type
SchemaEntryTypeComboBox
::
type
()
const
SchemaEntry
::
Type
SchemaEntryTypeComboBox
::
type
()
const
{
return
currentData
().
value
<
Product
SchemaEntry
::
Type
>
();
return
currentData
().
value
<
SchemaEntry
::
Type
>
();
}
void
SchemaEntryTypeComboBox
::
addEntry
(
Product
SchemaEntry
::
Type
type
)
void
SchemaEntryTypeComboBox
::
addEntry
(
SchemaEntry
::
Type
type
)
{
addItem
(
Product
SchemaEntry
::
displayString
(
type
),
QVariant
::
fromValue
(
type
));
addItem
(
SchemaEntry
::
displayString
(
type
),
QVariant
::
fromValue
(
type
));
}
analyzer/schemaentrytypecombobox.h
View file @
4c7e4782
...
...
@@ -18,7 +18,7 @@
#ifndef USERFEEDBACK_ANALYZER_SCHEMAENTRYTYPECOMBOBOX_H
#define USERFEEDBACK_ANALYZER_SCHEMAENTRYTYPECOMBOBOX_H
#include <core/
product
schemaentry.h>
#include <core/schemaentry.h>
#include <QComboBox>
...
...
@@ -28,16 +28,16 @@ namespace Analyzer {
class
SchemaEntryTypeComboBox
:
public
QComboBox
{
Q_OBJECT
Q_PROPERTY
(
UserFeedback
::
Analyzer
::
Product
SchemaEntry
::
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
();
Product
SchemaEntry
::
Type
type
()
const
;
void
setType
(
Product
SchemaEntry
::
Type
type
);
SchemaEntry
::
Type
type
()
const
;
void
setType
(
SchemaEntry
::
Type
type
);
private:
void
addEntry
(
Product
SchemaEntry
::
Type
type
);
void
addEntry
(
SchemaEntry
::
Type
type
);
};
...
...
analyzer/schemamodel.cpp
View file @
4c7e4782
...
...
@@ -42,7 +42,7 @@ void SchemaModel::addEntry(const QString &name)
{
auto
schema
=
m_product
.
schema
();
beginInsertRows
(
QModelIndex
(),
schema
.
size
(),
schema
.
size
());
Product
SchemaEntry
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
Product
SchemaEntry
::
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
<
Product
SchemaEntry
::
Type
>
());
entry
.
setType
(
value
.
value
<
SchemaEntry
::
Type
>
());
break
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment