Commit ef010f9b authored by Vitaly Fanaskov's avatar Vitaly Fanaskov Committed by Volker Krause

Add method name() to the *DataSource classes

Summary:
This method provides human-readable name that supposed to be used in
UI elements. One of the usage cases is to give the user an ability to
work with individual data sources (e.g., check data, activate/
deactivate, check description, and so on).
This method is not pure virtual because there are might be some data
sources that are not good for individual processing by the user. For
example, trackers of individual QML properties.

Reviewers: vkrause

Reviewed By: vkrause

Differential Revision: https://phabricator.kde.org/D19756
parent bdb5bf53
......@@ -47,6 +47,11 @@ QString AbstractDataSource::id() const
return d_ptr->id;
}
QString AbstractDataSource::name() const
{
return {};
}
void AbstractDataSource::setId(const QString& id)
{
d_ptr->id = id;
......
......@@ -45,6 +45,12 @@ public:
*/
QString id() const;
/*! Returns a short name of this data source.
* Can be empty if short name is meaningless for this data source.
* @returns A translated, human-readable string.
*/
virtual QString name() const;
/*! Returns a human-readable, translated description of what
* this source provides.
* @see id()
......
......@@ -41,3 +41,8 @@ QVariant ApplicationVersionSource::data()
m.insert(QStringLiteral("value"), QCoreApplication::applicationVersion());
return m;
}
QString ApplicationVersionSource::name() const
{
return tr("Application version");
}
......@@ -34,7 +34,10 @@ class KUSERFEEDBACKCORE_EXPORT ApplicationVersionSource : public AbstractDataSou
public:
/*! Create a new application version source. */
ApplicationVersionSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -59,5 +59,10 @@ QVariant CompilerInfoSource::data()
return m;
}
QString CompilerInfoSource::name() const
{
return tr("Compiler information");
}
#undef STRINGIFY
#undef INT2STR
......@@ -37,7 +37,10 @@ public:
Q_DECLARE_TR_FUNCTIONS(KUserFeedback::CompilerInfoSource)
public:
CompilerInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -40,3 +40,8 @@ QVariant CpuInfoSource::data()
m.insert(QStringLiteral("count"), QThread::idealThreadCount());
return m;
}
QString CpuInfoSource::name() const
{
return tr("CPU information");
}
......@@ -32,7 +32,10 @@ class KUSERFEEDBACKCORE_EXPORT CpuInfoSource : public AbstractDataSource
Q_DECLARE_TR_FUNCTIONS(KUserFeedback::CpuInfoSource)
public:
CpuInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -40,3 +40,8 @@ QVariant LocaleInfoSource::data()
m.insert(QStringLiteral("language"), QLocale::languageToString(l.language()));
return m;
}
QString LocaleInfoSource::name() const
{
return tr("Locale information");
}
......@@ -32,7 +32,10 @@ class KUSERFEEDBACKCORE_EXPORT LocaleInfoSource : public AbstractDataSource
Q_DECLARE_TR_FUNCTIONS(KUserFeedback::LocaleInfoSource)
public:
LocaleInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -94,3 +94,8 @@ QVariant OpenGLInfoSource::data()
m.insert(QStringLiteral("type"), QStringLiteral("none"));
return m;
}
QString OpenGLInfoSource::name() const
{
return tr("OpenGL information");
}
......@@ -32,7 +32,10 @@ public:
Q_DECLARE_TR_FUNCTIONS(KUserFeedback::OpenGLInfoSource)
public:
OpenGLInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -63,3 +63,8 @@ QVariant PlatformInfoSource::data()
#endif
return m;
}
QString PlatformInfoSource::name() const
{
return tr("Platform information");
}
......@@ -35,7 +35,10 @@ class KUSERFEEDBACKCORE_EXPORT PlatformInfoSource : public AbstractDataSource
public:
/*! Create a new platform information source. */
PlatformInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -38,3 +38,8 @@ QVariant QPAInfoSource::data()
m.insert(QStringLiteral("name"), QGuiApplication::platformName());
return m;
}
QString QPAInfoSource::name() const
{
return tr("QPA information");
}
......@@ -33,7 +33,10 @@ class KUSERFEEDBACKCORE_EXPORT QPAInfoSource : public AbstractDataSource
Q_DECLARE_TR_FUNCTIONS(KUserFeedback::QPAInfoSource)
public:
QPAInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -37,3 +37,8 @@ QVariant QtVersionSource::data()
m.insert(QStringLiteral("value"), QString::fromLatin1(qVersion()));
return m;
}
QString QtVersionSource::name() const
{
return tr("Qt version information");
}
......@@ -32,7 +32,10 @@ class KUSERFEEDBACKCORE_EXPORT QtVersionSource : public AbstractDataSource
Q_DECLARE_TR_FUNCTIONS(KUserFeedback::QtVersionSource)
public:
QtVersionSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
}
......
......@@ -45,3 +45,8 @@ QVariant ScreenInfoSource::data()
}
return l;
}
QString ScreenInfoSource::name() const
{
return tr("Screen parameters");
}
......@@ -37,7 +37,10 @@ class KUSERFEEDBACKCORE_EXPORT ScreenInfoSource : public AbstractDataSource
public:
/*! Create a new screen information source. */
ScreenInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
......@@ -52,6 +52,11 @@ QVariant StartCountSource::data()
return m;
}
QString StartCountSource::name() const
{
return tr("Launches count");
}
void StartCountSource::setProvider(ProviderPrivate *p)
{
Q_D(StartCountSource);
......
......@@ -37,7 +37,10 @@ class KUSERFEEDBACKCORE_EXPORT StartCountSource : public AbstractDataSource
public:
/*! Create a new start count data source. */
StartCountSource();
QString name() const override;
QString description() const override;
QVariant data() override;
private:
......
......@@ -52,6 +52,11 @@ QVariant UsageTimeSource::data()
return m;
}
QString UsageTimeSource::name() const
{
return tr("Usage time");
}
void UsageTimeSource::setProvider(ProviderPrivate* p)
{
Q_D(UsageTimeSource);
......
......@@ -38,7 +38,10 @@ public:
public:
/*! Create a new usage time data source. */
UsageTimeSource();
QString name() const override;
QString description() const override;
QVariant data() override;
private:
......
......@@ -42,3 +42,8 @@ QVariant StyleInfoSource::data()
m.insert(QStringLiteral("dark"), qApp->palette().color(QPalette::Background).lightness() < 128);
return m;
}
QString StyleInfoSource::name() const
{
return tr("Application style");
}
......@@ -31,7 +31,10 @@ public:
Q_DECLARE_TR_FUNCTIONS(KUserFeedback::StyleInfoSource)
public:
StyleInfoSource();
QString name() const override;
QString description() const override;
QVariant data() override;
};
......
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