Commit a13f3034 authored by Volker Krause's avatar Volker Krause
Browse files

Port application version handling to data source infrastructure

parent 8ebe4686
......@@ -28,6 +28,7 @@
#include <rest/serverinfo.h>
#include <provider/widgets/feedbackconfigdialog.h>
#include <provider/core/applicationversionsource.h>
#include <provider/core/propertyratiosource.h>
#include <provider/core/provider.h>
......@@ -131,6 +132,7 @@ MainWindow::MainWindow() :
viewModeSource->addValueMapping(1, QStringLiteral("surveyEditor"));
viewModeSource->addValueMapping(2, QStringLiteral("schemaEditor"));
m_feedbackProvider->addDataSource(viewModeSource, Provider::AllStatistics);
m_feedbackProvider->addDataSource(new ApplicationVersionSource, Provider::BasicStatistics);
}
MainWindow::~MainWindow()
......
[
{
"name": "productVersion",
"name": "applicationVersion",
"type": "scalar",
"aggregation": "category",
"elements": [
{
"name": "productVersion",
"name": "value",
"type": "string"
}
]
......
......@@ -2,7 +2,7 @@
<RCC version="1.0">
<qresource prefix="/org.kde.user-feedback/schemaentrytemplates">
<file>platform.json</file>
<file>productVersion.json</file>
<file>applicationVersion.json</file>
<file>qtVersion.json</file>
<file>screens.json</file>
<file>usageCount.json</file>
......
set(userfeedback_core_srcs
abstractdatasource.cpp
applicationversionsource.cpp
platforminfosource.cpp
propertyratiosource.cpp
provider.cpp
......
/*
Copyright (C) 2016 Volker Krause <vkrause@kde.org>
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 "applicationversionsource.h"
#include <QCoreApplication>
#include <QVariant>
using namespace UserFeedback;
ApplicationVersionSource::ApplicationVersionSource() :
AbstractDataSource(QStringLiteral("applicationVersion"))
{
}
QVariant ApplicationVersionSource::data()
{
if (QCoreApplication::applicationVersion().isEmpty())
return QVariant();
QVariantMap m;
m.insert(QStringLiteral("value"), QCoreApplication::applicationVersion());
return m;
}
/*
Copyright (C) 2016 Volker Krause <vkrause@kde.org>
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_APPLICATIONVERSIONSOURCE_H
#define USERFEEDBACK_APPLICATIONVERSIONSOURCE_H
#include "userfeedbackcore_export.h"
#include "abstractdatasource.h"
namespace UserFeedback {
class USERFEEDBACKCORE_EXPORT ApplicationVersionSource : public AbstractDataSource
{
public:
ApplicationVersionSource();
QVariant data() Q_DECL_OVERRIDE;
};
}
#endif // USERFEEDBACK_APPLICATIONVERSIONSOURCE_H
......@@ -181,7 +181,6 @@ QByteArray ProviderPrivate::jsonData() const
if (statisticsMode != Provider::NoStatistics) {
obj.insert(QStringLiteral("startCount"), startCount);
obj.insert(QStringLiteral("usageTime"), currentApplicationTime());
obj.insert(QStringLiteral("version"), QCoreApplication::applicationVersion());
foreach (auto source, dataSources) {
if (statisticsMode < source->collectionMode())
continue;
......
......@@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <provider/core/applicationversionsource.h>
#include <provider/core/platforminfosource.h>
#include <provider/core/propertyratiosource.h>
#include <provider/core/screeninfosource.h>
......@@ -109,6 +110,18 @@ private slots:
v = o.value(QLatin1String("value2"));
QCOMPARE(v.type(), QVariant::Double);
}
void testApplicationVersionSource()
{
ApplicationVersionSource src;
auto v = src.data();
QVERIFY(v.isNull());
QCoreApplication::setApplicationVersion(QStringLiteral("1.9.84"));
auto m = src.data().toMap();
QVERIFY(m.contains(QLatin1String("value")));
QCOMPARE(m.value(QLatin1String("value")).toString(), QLatin1String("1.9.84"));
}
};
QTEST_MAIN(DataSourceTest)
......
......@@ -19,6 +19,7 @@
#include "ui_orwell.h"
#include <provider/widgets/feedbackconfigdialog.h>
#include <provider/core/applicationversionsource.h>
#include <provider/core/platforminfosource.h>
#include <provider/core/propertyratiosource.h>
#include <provider/core/provider.h>
......@@ -104,6 +105,7 @@ int main(int argc, char** argv)
provider->setSubmissionInterval(1);
provider->setApplicationStartsUntilEncouragement(5);
provider->setEncouragementDelay(10);
provider->addDataSource(new UserFeedback::ApplicationVersionSource, UserFeedback::Provider::BasicStatistics);
provider->addDataSource(new UserFeedback::PlatformInfoSource, UserFeedback::Provider::AllStatistics);
provider->addDataSource(new UserFeedback::ScreenInfoSource, UserFeedback::Provider::AllStatistics);
......
Markdown is supported
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