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

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