mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 14:55:48 +00:00
massive changes inside
* use pass by ref instead of by value if possible * use reference in interation over collections * fix no tag inserting
This commit is contained in:
@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
AWAbstractSelector::AWAbstractSelector(QWidget *parent,
|
||||
const QPair<bool, bool> editable)
|
||||
const QPair<bool, bool> &editable)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::AWAbstractSelector)
|
||||
{
|
||||
@ -56,8 +56,9 @@ QPair<QString, QString> AWAbstractSelector::current() const
|
||||
}
|
||||
|
||||
|
||||
void AWAbstractSelector::init(const QStringList keys, const QStringList values,
|
||||
const QPair<QString, QString> current)
|
||||
void AWAbstractSelector::init(const QStringList &keys,
|
||||
const QStringList &values,
|
||||
const QPair<QString, QString> ¤t)
|
||||
{
|
||||
if ((!keys.contains(current.first)) || (!values.contains(current.second))) {
|
||||
qCWarning(LOG_AW) << "Invalid current value" << current
|
||||
|
@ -33,12 +33,12 @@ class AWAbstractSelector : public QWidget
|
||||
|
||||
public:
|
||||
explicit AWAbstractSelector(QWidget *parent = nullptr,
|
||||
const QPair<bool, bool> editable
|
||||
const QPair<bool, bool> &editable
|
||||
= {false, false});
|
||||
virtual ~AWAbstractSelector();
|
||||
QPair<QString, QString> current() const;
|
||||
void init(const QStringList keys, const QStringList values,
|
||||
const QPair<QString, QString> current);
|
||||
void init(const QStringList &keys, const QStringList &values,
|
||||
const QPair<QString, QString> ¤t);
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
|
@ -57,7 +57,7 @@ void AWActions::checkUpdates(const bool showAnyway)
|
||||
}
|
||||
|
||||
|
||||
QString AWActions::getFileContent(const QString path) const
|
||||
QString AWActions::getFileContent(const QString &path) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Get content from file" << path;
|
||||
|
||||
@ -81,7 +81,7 @@ bool AWActions::isDebugEnabled() const
|
||||
}
|
||||
|
||||
|
||||
bool AWActions::runCmd(const QString cmd) const
|
||||
bool AWActions::runCmd(const QString &cmd) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Cmd" << cmd;
|
||||
|
||||
@ -114,7 +114,7 @@ void AWActions::showLegacyInfo() const
|
||||
|
||||
|
||||
// HACK: this method uses variables from version.h
|
||||
QString AWActions::getAboutText(const QString type) const
|
||||
QString AWActions::getAboutText(const QString &type) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Type" << type;
|
||||
|
||||
@ -122,7 +122,7 @@ QString AWActions::getAboutText(const QString type) const
|
||||
}
|
||||
|
||||
|
||||
QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
|
||||
QVariantMap AWActions::getFont(const QVariantMap &defaultFont) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Default font is" << defaultFont;
|
||||
|
||||
@ -144,7 +144,7 @@ QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
|
||||
|
||||
|
||||
// to avoid additional object definition this method is static
|
||||
void AWActions::sendNotification(const QString eventId, const QString message)
|
||||
void AWActions::sendNotification(const QString &eventId, const QString &message)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Event" << eventId << "with message" << message;
|
||||
|
||||
|
@ -33,19 +33,20 @@ public:
|
||||
explicit AWActions(QObject *parent = nullptr);
|
||||
virtual ~AWActions();
|
||||
Q_INVOKABLE void checkUpdates(const bool showAnyway = false);
|
||||
Q_INVOKABLE QString getFileContent(const QString path) const;
|
||||
Q_INVOKABLE QString getFileContent(const QString &path) const;
|
||||
Q_INVOKABLE bool isDebugEnabled() const;
|
||||
Q_INVOKABLE bool runCmd(const QString cmd = QString("/usr/bin/true")) const;
|
||||
Q_INVOKABLE bool runCmd(const QString &cmd
|
||||
= QString("/usr/bin/true")) const;
|
||||
Q_INVOKABLE void showLegacyInfo() const;
|
||||
Q_INVOKABLE void showReadme() const;
|
||||
// configuration slots
|
||||
Q_INVOKABLE QString getAboutText(const QString type
|
||||
Q_INVOKABLE QString getAboutText(const QString &type
|
||||
= QString("header")) const;
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont) const;
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap &defaultFont) const;
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE static void sendNotification(const QString eventId,
|
||||
const QString message);
|
||||
Q_INVOKABLE static void sendNotification(const QString &eventId,
|
||||
const QString &message);
|
||||
|
||||
private:
|
||||
AWUpdateHelper *m_updateHelper = nullptr;
|
||||
|
@ -46,15 +46,15 @@ AWBugReporter::~AWBugReporter()
|
||||
void AWBugReporter::doConnect()
|
||||
{
|
||||
// additional method for testing needs
|
||||
connect(this, SIGNAL(replyReceived(const int, const QString)), this,
|
||||
SLOT(showInformation(const int, const QString)));
|
||||
connect(this, SIGNAL(replyReceived(const int, const QString &)), this,
|
||||
SLOT(showInformation(const int, const QString &)));
|
||||
}
|
||||
|
||||
|
||||
QString AWBugReporter::generateText(const QString description,
|
||||
const QString reproduce,
|
||||
const QString expected,
|
||||
const QString logs) const
|
||||
QString AWBugReporter::generateText(const QString &description,
|
||||
const QString &reproduce,
|
||||
const QString &expected,
|
||||
const QString &logs) const
|
||||
{
|
||||
// do not log logs here, it may have quite large size
|
||||
qCDebug(LOG_AW) << "Generate text with description" << description
|
||||
@ -74,7 +74,7 @@ QString AWBugReporter::generateText(const QString description,
|
||||
}
|
||||
|
||||
|
||||
void AWBugReporter::sendBugReport(const QString title, const QString body)
|
||||
void AWBugReporter::sendBugReport(const QString &title, const QString &body)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Send bug report with title" << title << "and body"
|
||||
<< body;
|
||||
@ -126,7 +126,7 @@ void AWBugReporter::issueReplyRecieved(QNetworkReply *reply)
|
||||
}
|
||||
|
||||
|
||||
void AWBugReporter::showInformation(const int number, const QString url)
|
||||
void AWBugReporter::showInformation(const int number, const QString &url)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Created issue with number" << number << "and url"
|
||||
<< url;
|
||||
|
@ -33,18 +33,18 @@ public:
|
||||
explicit AWBugReporter(QObject *parent = nullptr);
|
||||
virtual ~AWBugReporter();
|
||||
Q_INVOKABLE void doConnect();
|
||||
Q_INVOKABLE QString generateText(const QString description,
|
||||
const QString reproduce,
|
||||
const QString expected,
|
||||
const QString logs) const;
|
||||
Q_INVOKABLE void sendBugReport(const QString title, const QString body);
|
||||
Q_INVOKABLE QString generateText(const QString &description,
|
||||
const QString &reproduce,
|
||||
const QString &expected,
|
||||
const QString &logs) const;
|
||||
Q_INVOKABLE void sendBugReport(const QString &title, const QString &body);
|
||||
|
||||
signals:
|
||||
void replyReceived(const int number, const QString url);
|
||||
void replyReceived(const int number, const QString &url);
|
||||
|
||||
private slots:
|
||||
void issueReplyRecieved(QNetworkReply *reply);
|
||||
void showInformation(const int number, const QString url);
|
||||
void showInformation(const int number, const QString &url);
|
||||
void userReplyOnBugReport(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
|
@ -70,7 +70,7 @@ bool AWConfigHelper::dropCache() const
|
||||
|
||||
|
||||
bool AWConfigHelper::exportConfiguration(QObject *nativeConfig,
|
||||
const QString fileName) const
|
||||
const QString &fileName) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Selected filename" << fileName;
|
||||
|
||||
@ -79,7 +79,7 @@ bool AWConfigHelper::exportConfiguration(QObject *nativeConfig,
|
||||
const QQmlPropertyMap *configuration
|
||||
= static_cast<const QQmlPropertyMap *>(nativeConfig);
|
||||
settings.beginGroup(QString("plasmoid"));
|
||||
for (auto key : configuration->keys()) {
|
||||
for (auto &key : configuration->keys()) {
|
||||
QVariant value = configuration->value(key);
|
||||
if (!value.isValid())
|
||||
continue;
|
||||
@ -88,13 +88,13 @@ bool AWConfigHelper::exportConfiguration(QObject *nativeConfig,
|
||||
settings.endGroup();
|
||||
|
||||
// extensions
|
||||
for (auto item : m_dirs) {
|
||||
for (auto &item : m_dirs) {
|
||||
QStringList items
|
||||
= QDir(QString("%1/%2").arg(m_baseDir).arg(item))
|
||||
.entryList(QStringList() << QString("*.desktop"),
|
||||
QDir::Files);
|
||||
settings.beginGroup(item);
|
||||
for (auto it : items)
|
||||
for (auto &it : items)
|
||||
copyExtensions(it, item, settings, false);
|
||||
settings.endGroup();
|
||||
}
|
||||
@ -121,7 +121,7 @@ bool AWConfigHelper::exportConfiguration(QObject *nativeConfig,
|
||||
}
|
||||
|
||||
|
||||
QVariantMap AWConfigHelper::importConfiguration(const QString fileName,
|
||||
QVariantMap AWConfigHelper::importConfiguration(const QString &fileName,
|
||||
const bool importPlasmoid,
|
||||
const bool importExtensions,
|
||||
const bool importAdds) const
|
||||
@ -133,9 +133,9 @@ QVariantMap AWConfigHelper::importConfiguration(const QString fileName,
|
||||
|
||||
// extensions
|
||||
if (importExtensions) {
|
||||
for (auto item : m_dirs) {
|
||||
for (auto &item : m_dirs) {
|
||||
settings.beginGroup(item);
|
||||
for (auto it : settings.childGroups())
|
||||
for (auto &it : settings.childGroups())
|
||||
copyExtensions(it, item, settings, true);
|
||||
settings.endGroup();
|
||||
}
|
||||
@ -161,7 +161,7 @@ QVariantMap AWConfigHelper::importConfiguration(const QString fileName,
|
||||
// plasmoid configuration
|
||||
if (importPlasmoid) {
|
||||
settings.beginGroup(QString("plasmoid"));
|
||||
for (auto key : settings.childKeys())
|
||||
for (auto &key : settings.childKeys())
|
||||
configuration[key] = settings.value(key);
|
||||
settings.endGroup();
|
||||
}
|
||||
@ -207,7 +207,7 @@ QVariantMap AWConfigHelper::readDataEngineConfiguration() const
|
||||
|
||||
|
||||
bool AWConfigHelper::writeDataEngineConfiguration(
|
||||
const QVariantMap configuration) const
|
||||
const QVariantMap &configuration) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Configuration" << configuration;
|
||||
|
||||
@ -238,18 +238,18 @@ bool AWConfigHelper::writeDataEngineConfiguration(
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::copyConfigs(const QString localDir) const
|
||||
void AWConfigHelper::copyConfigs(const QString &localDir) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Local directory" << localDir;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(
|
||||
QStandardPaths::GenericDataLocation, QString("awesomewidgets/configs"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
for (auto dir : dirs) {
|
||||
for (auto &dir : dirs) {
|
||||
if (dir == localDir)
|
||||
continue;
|
||||
QStringList files = QDir(dir).entryList(QDir::Files);
|
||||
for (auto source : files) {
|
||||
for (auto &source : files) {
|
||||
QString destination = QString("%1/%2").arg(localDir).arg(source);
|
||||
bool status = QFile::copy(QString("%1/%2").arg(dir).arg(source),
|
||||
destination);
|
||||
@ -260,7 +260,7 @@ void AWConfigHelper::copyConfigs(const QString localDir) const
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::copyExtensions(const QString item, const QString type,
|
||||
void AWConfigHelper::copyExtensions(const QString &item, const QString &type,
|
||||
QSettings &settings,
|
||||
const bool inverse) const
|
||||
{
|
||||
@ -286,13 +286,13 @@ void AWConfigHelper::copyExtensions(const QString item, const QString type,
|
||||
|
||||
void AWConfigHelper::copySettings(QSettings &from, QSettings &to) const
|
||||
{
|
||||
for (auto key : from.childKeys())
|
||||
for (auto &key : from.childKeys())
|
||||
to.setValue(key, from.value(key));
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::readFile(QSettings &settings, const QString key,
|
||||
const QString fileName) const
|
||||
void AWConfigHelper::readFile(QSettings &settings, const QString &key,
|
||||
const QString &fileName) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << key << "from file" << fileName;
|
||||
|
||||
@ -307,8 +307,8 @@ void AWConfigHelper::readFile(QSettings &settings, const QString key,
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::writeFile(QSettings &settings, const QString key,
|
||||
const QString fileName) const
|
||||
void AWConfigHelper::writeFile(QSettings &settings, const QString &key,
|
||||
const QString &fileName) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << key << "to file" << fileName;
|
||||
|
||||
|
@ -36,26 +36,26 @@ public:
|
||||
Q_INVOKABLE QString configurationDirectory() const;
|
||||
Q_INVOKABLE bool dropCache() const;
|
||||
Q_INVOKABLE bool exportConfiguration(QObject *nativeConfig,
|
||||
const QString fileName) const;
|
||||
Q_INVOKABLE QVariantMap importConfiguration(const QString fileName,
|
||||
const QString &fileName) const;
|
||||
Q_INVOKABLE QVariantMap importConfiguration(const QString &fileName,
|
||||
const bool importPlasmoid,
|
||||
const bool importExtensions,
|
||||
const bool importAdds) const;
|
||||
// dataengine
|
||||
Q_INVOKABLE QVariantMap readDataEngineConfiguration() const;
|
||||
Q_INVOKABLE bool
|
||||
writeDataEngineConfiguration(const QVariantMap configuration) const;
|
||||
writeDataEngineConfiguration(const QVariantMap &configuration) const;
|
||||
|
||||
private:
|
||||
// methods
|
||||
void copyConfigs(const QString localDir) const;
|
||||
void copyExtensions(const QString item, const QString type,
|
||||
void copyConfigs(const QString &localDir) const;
|
||||
void copyExtensions(const QString &item, const QString &type,
|
||||
QSettings &settings, const bool inverse) const;
|
||||
void copySettings(QSettings &from, QSettings &to) const;
|
||||
void readFile(QSettings &settings, const QString key,
|
||||
const QString fileName) const;
|
||||
void writeFile(QSettings &settings, const QString key,
|
||||
const QString fileName) const;
|
||||
void readFile(QSettings &settings, const QString &key,
|
||||
const QString &fileName) const;
|
||||
void writeFile(QSettings &settings, const QString &key,
|
||||
const QString &fileName) const;
|
||||
// properties
|
||||
QString m_baseDir = QString("%1/awesomewidgets")
|
||||
.arg(QStandardPaths::writableLocation(
|
||||
|
@ -57,7 +57,7 @@ AWDataAggregator::~AWDataAggregator()
|
||||
}
|
||||
|
||||
|
||||
QList<float> AWDataAggregator::getData(const QString key) const
|
||||
QList<float> AWDataAggregator::getData(const QString &key) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << key;
|
||||
|
||||
@ -78,7 +78,7 @@ QString AWDataAggregator::htmlImage(const QPixmap &source) const
|
||||
}
|
||||
|
||||
|
||||
void AWDataAggregator::setParameters(QVariantMap settings)
|
||||
void AWDataAggregator::setParameters(const QVariantMap &settings)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Settings" << settings;
|
||||
|
||||
@ -128,7 +128,7 @@ QPixmap AWDataAggregator::tooltipImage()
|
||||
m_toolTipScene->clear();
|
||||
QPen pen;
|
||||
bool down = false;
|
||||
for (auto key : requiredKeys) {
|
||||
for (auto &key : requiredKeys) {
|
||||
// create frame
|
||||
float normX = 100.0f / static_cast<float>(m_values[key].count());
|
||||
float normY = 100.0f / (1.5f * m_boundaries[key]);
|
||||
@ -174,7 +174,7 @@ void AWDataAggregator::dataUpdate(const QVariantHash &values)
|
||||
}
|
||||
|
||||
|
||||
void AWDataAggregator::checkValue(const QString source, const float value,
|
||||
void AWDataAggregator::checkValue(const QString &source, const float value,
|
||||
const float extremum) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Notification source" << source << "with value" << value
|
||||
@ -194,8 +194,8 @@ void AWDataAggregator::checkValue(const QString source, const float value,
|
||||
}
|
||||
|
||||
|
||||
void AWDataAggregator::checkValue(const QString source, const QString current,
|
||||
const QString received) const
|
||||
void AWDataAggregator::checkValue(const QString &source, const QString ¤t,
|
||||
const QString &received) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Notification source" << source << "with current value"
|
||||
<< current << "and received one" << received;
|
||||
@ -218,7 +218,7 @@ void AWDataAggregator::initScene()
|
||||
}
|
||||
|
||||
|
||||
QString AWDataAggregator::notificationText(const QString source,
|
||||
QString AWDataAggregator::notificationText(const QString &source,
|
||||
const float value) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Notification source" << source << "with value" << value;
|
||||
@ -239,8 +239,8 @@ QString AWDataAggregator::notificationText(const QString source,
|
||||
}
|
||||
|
||||
|
||||
QString AWDataAggregator::notificationText(const QString source,
|
||||
const QString value) const
|
||||
QString AWDataAggregator::notificationText(const QString &source,
|
||||
const QString &value) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Notification source" << source << "with value" << value;
|
||||
|
||||
|
@ -35,14 +35,14 @@ class AWDataAggregator : public QObject
|
||||
public:
|
||||
explicit AWDataAggregator(QObject *parent = nullptr);
|
||||
virtual ~AWDataAggregator();
|
||||
QList<float> getData(const QString key) const;
|
||||
QList<float> getData(const QString &key) const;
|
||||
QString htmlImage(const QPixmap &source) const;
|
||||
void setParameters(QVariantMap settings);
|
||||
void setParameters(const QVariantMap &settings);
|
||||
QPixmap tooltipImage();
|
||||
|
||||
signals:
|
||||
void updateData(const QVariantHash &values);
|
||||
void toolTipPainted(const QString image) const;
|
||||
void toolTipPainted(const QString &image) const;
|
||||
|
||||
private slots:
|
||||
void dataUpdate(const QVariantHash &values);
|
||||
@ -51,13 +51,13 @@ private:
|
||||
// ui
|
||||
QGraphicsScene *m_toolTipScene = nullptr;
|
||||
QGraphicsView *m_toolTipView = nullptr;
|
||||
void checkValue(const QString source, const float value,
|
||||
void checkValue(const QString &source, const float value,
|
||||
const float extremum) const;
|
||||
void checkValue(const QString source, const QString current,
|
||||
const QString received) const;
|
||||
void checkValue(const QString &source, const QString ¤t,
|
||||
const QString &received) const;
|
||||
void initScene();
|
||||
QString notificationText(const QString source, const float value) const;
|
||||
QString notificationText(const QString source, const QString value) const;
|
||||
QString notificationText(const QString &source, const float value) const;
|
||||
QString notificationText(const QString &source, const QString &value) const;
|
||||
// main method
|
||||
void setData(const QVariantHash &values);
|
||||
void setData(const QString &source, float value,
|
||||
|
@ -52,8 +52,8 @@ void AWDataEngineAggregator::clear()
|
||||
|
||||
void AWDataEngineAggregator::disconnectSources()
|
||||
{
|
||||
for (auto dataengine : m_dataEngines.values())
|
||||
for (auto source : dataengine->sources())
|
||||
for (auto &dataengine : m_dataEngines.values())
|
||||
for (auto &source : dataengine->sources())
|
||||
dataengine->disconnectSource(source, parent());
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ void AWDataEngineAggregator::initDataEngines(const int interval)
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::dropSource(const QString source)
|
||||
void AWDataEngineAggregator::dropSource(const QString &source)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Source" << source;
|
||||
|
||||
@ -114,7 +114,7 @@ void AWDataEngineAggregator::createQueuedConnection()
|
||||
{
|
||||
// HACK additional method which forces QueuedConnection instead of Auto one
|
||||
// for more details refer to plasma-framework source code
|
||||
for (auto dataEngine : m_dataEngines.keys()) {
|
||||
for (auto &dataEngine : m_dataEngines.keys()) {
|
||||
// different source set for different engines
|
||||
QStringList sources;
|
||||
if (dataEngine == QString("time"))
|
||||
@ -122,7 +122,7 @@ void AWDataEngineAggregator::createQueuedConnection()
|
||||
else
|
||||
sources = m_dataEngines[dataEngine]->sources();
|
||||
// reconnect sources
|
||||
for (auto source : sources) {
|
||||
for (auto &source : sources) {
|
||||
Plasma::DataContainer *container
|
||||
= m_dataEngines[dataEngine]->containerForSource(source);
|
||||
// disconnect old connections first
|
||||
|
@ -40,7 +40,7 @@ signals:
|
||||
void deviceAdded(const QString &source);
|
||||
|
||||
public slots:
|
||||
void dropSource(const QString source);
|
||||
void dropSource(const QString &source);
|
||||
void reconnectSources(const int interval);
|
||||
|
||||
private:
|
||||
|
@ -35,19 +35,19 @@ AWDBusAdaptor::~AWDBusAdaptor()
|
||||
}
|
||||
|
||||
|
||||
QString AWDBusAdaptor::Info(const QString key) const
|
||||
QString AWDBusAdaptor::Info(const QString &key) const
|
||||
{
|
||||
return m_plugin->infoByKey(key);
|
||||
}
|
||||
|
||||
|
||||
QStringList AWDBusAdaptor::Keys(const QString regexp) const
|
||||
QStringList AWDBusAdaptor::Keys(const QString ®exp) const
|
||||
{
|
||||
return m_plugin->dictKeys(true, regexp);
|
||||
}
|
||||
|
||||
|
||||
QString AWDBusAdaptor::Value(const QString key) const
|
||||
QString AWDBusAdaptor::Value(const QString &key) const
|
||||
{
|
||||
return m_plugin->valueByKey(key);
|
||||
}
|
||||
@ -59,7 +59,7 @@ qlonglong AWDBusAdaptor::WhoAmI() const
|
||||
}
|
||||
|
||||
|
||||
void AWDBusAdaptor::SetLogLevel(const QString what, const int level)
|
||||
void AWDBusAdaptor::SetLogLevel(const QString &what, const int level)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Set log level" << level << "for" << what;
|
||||
|
||||
@ -69,12 +69,12 @@ void AWDBusAdaptor::SetLogLevel(const QString what, const int level)
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto lev : m_logLevels)
|
||||
for (auto &lev : m_logLevels)
|
||||
SetLogLevel(what, lev, m_logLevels.indexOf(lev) >= level);
|
||||
}
|
||||
|
||||
|
||||
void AWDBusAdaptor::SetLogLevel(const QString what, const QString level,
|
||||
void AWDBusAdaptor::SetLogLevel(const QString &what, const QString &level,
|
||||
const bool enabled)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Set log level" << level << "enabled" << enabled
|
||||
|
@ -37,13 +37,13 @@ public:
|
||||
|
||||
public slots:
|
||||
// get methods
|
||||
QString Info(const QString key) const;
|
||||
QStringList Keys(const QString regexp) const;
|
||||
QString Value(const QString key) const;
|
||||
QString Info(const QString &key) const;
|
||||
QStringList Keys(const QString ®exp) const;
|
||||
QString Value(const QString &key) const;
|
||||
qlonglong WhoAmI() const;
|
||||
// set methods
|
||||
void SetLogLevel(const QString what, const int level);
|
||||
void SetLogLevel(const QString what, const QString level,
|
||||
void SetLogLevel(const QString &what, const int level);
|
||||
void SetLogLevel(const QString &what, const QString &level,
|
||||
const bool enabled);
|
||||
|
||||
private:
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "awformatterhelper.h"
|
||||
|
||||
|
||||
AWFormatterConfig::AWFormatterConfig(QWidget *parent, const QStringList keys)
|
||||
AWFormatterConfig::AWFormatterConfig(QWidget *parent, const QStringList &keys)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AWFormatterConfig)
|
||||
, m_keys(keys)
|
||||
@ -114,7 +114,7 @@ void AWFormatterConfig::addSelector(const QStringList &keys,
|
||||
|
||||
void AWFormatterConfig::clearSelectors()
|
||||
{
|
||||
for (auto selector : m_selectors) {
|
||||
for (auto &selector : m_selectors) {
|
||||
disconnect(selector, SIGNAL(selectionChanged()), this,
|
||||
SLOT(updateUi()));
|
||||
ui->verticalLayout->removeWidget(selector);
|
||||
@ -128,7 +128,7 @@ void AWFormatterConfig::execDialog()
|
||||
{
|
||||
int ret = exec();
|
||||
QHash<QString, QString> data;
|
||||
for (auto selector : m_selectors) {
|
||||
for (auto &selector : m_selectors) {
|
||||
QPair<QString, QString> select = selector->current();
|
||||
if (select.first.isEmpty())
|
||||
continue;
|
||||
@ -175,7 +175,7 @@ void AWFormatterConfig::updateDialog()
|
||||
QHash<QString, QString> appliedFormatters = m_helper->getFormatters();
|
||||
auto keys = initKeys();
|
||||
|
||||
for (auto key : appliedFormatters.keys())
|
||||
for (auto &key : appliedFormatters.keys())
|
||||
addSelector(keys.first, keys.second,
|
||||
QPair<QString, QString>(key, appliedFormatters[key]));
|
||||
// empty one
|
||||
|
@ -35,7 +35,7 @@ class AWFormatterConfig : public QDialog
|
||||
|
||||
public:
|
||||
explicit AWFormatterConfig(QWidget *parent = nullptr,
|
||||
const QStringList keys = QStringList());
|
||||
const QStringList &keys = QStringList());
|
||||
virtual ~AWFormatterConfig();
|
||||
Q_INVOKABLE void showDialog();
|
||||
|
||||
|
@ -34,7 +34,7 @@ AWFormatterConfigFactory::~AWFormatterConfigFactory()
|
||||
}
|
||||
|
||||
|
||||
void AWFormatterConfigFactory::showDialog(const QStringList keys)
|
||||
void AWFormatterConfigFactory::showDialog(const QStringList &keys)
|
||||
{
|
||||
AWFormatterConfig *config = new AWFormatterConfig(nullptr, keys);
|
||||
config->showDialog();
|
||||
|
@ -29,7 +29,7 @@ class AWFormatterConfigFactory : public QObject
|
||||
public:
|
||||
explicit AWFormatterConfigFactory(QObject *parent = nullptr);
|
||||
virtual ~AWFormatterConfigFactory();
|
||||
Q_INVOKABLE void showDialog(const QStringList keys);
|
||||
Q_INVOKABLE void showDialog(const QStringList &keys);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ QStringList AWFormatterHelper::definedFormatters() const
|
||||
QHash<QString, QString> AWFormatterHelper::getFormatters() const
|
||||
{
|
||||
QHash<QString, QString> map;
|
||||
for (auto tag : m_formatters.keys())
|
||||
for (auto &tag : m_formatters.keys())
|
||||
map[tag] = m_formatters[tag]->name();
|
||||
|
||||
return map;
|
||||
@ -81,7 +81,7 @@ QHash<QString, QString> AWFormatterHelper::getFormatters() const
|
||||
QList<AbstractExtItem *> AWFormatterHelper::items() const
|
||||
{
|
||||
QList<AbstractExtItem *> converted;
|
||||
for (auto item : m_formattersClasses.values())
|
||||
for (auto &item : m_formattersClasses.values())
|
||||
converted.append(item);
|
||||
|
||||
return converted;
|
||||
@ -94,7 +94,7 @@ QStringList AWFormatterHelper::knownFormatters() const
|
||||
}
|
||||
|
||||
|
||||
bool AWFormatterHelper::removeUnusedFormatters(const QStringList keys) const
|
||||
bool AWFormatterHelper::removeUnusedFormatters(const QStringList &keys) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Remove formatters" << keys;
|
||||
|
||||
@ -107,7 +107,7 @@ bool AWFormatterHelper::removeUnusedFormatters(const QStringList keys) const
|
||||
|
||||
settings.beginGroup(QString("Formatters"));
|
||||
QStringList foundKeys = settings.childKeys();
|
||||
for (auto key : foundKeys) {
|
||||
for (auto &key : foundKeys) {
|
||||
if (keys.contains(key))
|
||||
continue;
|
||||
settings.remove(key);
|
||||
@ -121,7 +121,7 @@ bool AWFormatterHelper::removeUnusedFormatters(const QStringList keys) const
|
||||
|
||||
|
||||
bool AWFormatterHelper::writeFormatters(
|
||||
const QHash<QString, QString> configuration) const
|
||||
const QHash<QString, QString> &configuration) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Write configuration" << configuration;
|
||||
|
||||
@ -133,7 +133,7 @@ bool AWFormatterHelper::writeFormatters(
|
||||
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||
|
||||
settings.beginGroup(QString("Formatters"));
|
||||
for (auto key : configuration.keys())
|
||||
for (auto &key : configuration.keys())
|
||||
settings.setValue(key, configuration[key]);
|
||||
settings.endGroup();
|
||||
|
||||
@ -152,7 +152,7 @@ void AWFormatterHelper::editItems()
|
||||
|
||||
|
||||
AWAbstractFormatter::FormatterClass
|
||||
AWFormatterHelper::defineFormatterClass(const QString stringType) const
|
||||
AWFormatterHelper::defineFormatterClass(const QString &stringType) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Define formatter class for" << stringType;
|
||||
|
||||
@ -186,7 +186,7 @@ void AWFormatterHelper::initFormatters()
|
||||
for (int i = m_directories.count() - 1; i >= 0; i--) {
|
||||
QStringList files
|
||||
= QDir(m_directories.at(i)).entryList(QDir::Files, QDir::Name);
|
||||
for (auto file : files) {
|
||||
for (auto &file : files) {
|
||||
if (!file.endsWith(QString(".desktop")))
|
||||
continue;
|
||||
qCInfo(LOG_AW) << "Found file" << file << "in"
|
||||
@ -238,13 +238,13 @@ void AWFormatterHelper::initKeys()
|
||||
QStringList configs = QStandardPaths::locateAll(
|
||||
QStandardPaths::GenericDataLocation, m_filePath);
|
||||
|
||||
for (auto fileName : configs) {
|
||||
for (auto &fileName : configs) {
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Formatters"));
|
||||
QStringList keys = settings.childKeys();
|
||||
for (auto key : keys) {
|
||||
for (auto &key : keys) {
|
||||
QString name = settings.value(key).toString();
|
||||
qCInfo(LOG_AW) << "Found formatter" << name << "for key" << key
|
||||
<< "in" << settings.fileName();
|
||||
@ -281,7 +281,7 @@ void AWFormatterHelper::installDirectories()
|
||||
|
||||
|
||||
QPair<QString, AWAbstractFormatter::FormatterClass>
|
||||
AWFormatterHelper::readMetadata(const QString filePath) const
|
||||
AWFormatterHelper::readMetadata(const QString &filePath) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Read initial parameters from" << filePath;
|
||||
|
||||
|
@ -38,8 +38,8 @@ public:
|
||||
QHash<QString, QString> getFormatters() const;
|
||||
QList<AbstractExtItem *> items() const;
|
||||
QStringList knownFormatters() const;
|
||||
bool removeUnusedFormatters(const QStringList keys) const;
|
||||
bool writeFormatters(const QHash<QString, QString> configuration) const;
|
||||
bool removeUnusedFormatters(const QStringList &keys) const;
|
||||
bool writeFormatters(const QHash<QString, QString> &configuration) const;
|
||||
|
||||
public slots:
|
||||
void editItems();
|
||||
@ -47,12 +47,12 @@ public slots:
|
||||
private:
|
||||
// methods
|
||||
AWAbstractFormatter::FormatterClass
|
||||
defineFormatterClass(const QString stringType) const;
|
||||
defineFormatterClass(const QString &stringType) const;
|
||||
void initFormatters();
|
||||
void initKeys();
|
||||
void installDirectories();
|
||||
QPair<QString, AWAbstractFormatter::FormatterClass>
|
||||
readMetadata(const QString filePath) const;
|
||||
readMetadata(const QString &filePath) const;
|
||||
// parent methods
|
||||
void doCreateItem();
|
||||
void initItems();
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "awdebug.h"
|
||||
|
||||
|
||||
bool AWKeyCache::addKeyToCache(const QString type, const QString key)
|
||||
bool AWKeyCache::addKeyToCache(const QString &type, const QString &key)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << key << "with type" << type;
|
||||
|
||||
@ -38,7 +38,7 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key)
|
||||
|
||||
cache.beginGroup(type);
|
||||
QStringList cachedValues;
|
||||
for (auto number : cache.allKeys())
|
||||
for (auto &number : cache.allKeys())
|
||||
cachedValues.append(cache.value(number).toString());
|
||||
|
||||
if (type == QString("hdd")) {
|
||||
@ -46,7 +46,7 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key)
|
||||
= QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
|
||||
QStringList devices
|
||||
= allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
||||
for (auto dev : devices) {
|
||||
for (auto &dev : devices) {
|
||||
QString device = QString("/dev/%1").arg(dev);
|
||||
if (cachedValues.contains(device))
|
||||
continue;
|
||||
@ -59,7 +59,7 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key)
|
||||
} else if (type == QString("net")) {
|
||||
QList<QNetworkInterface> rawInterfaceList
|
||||
= QNetworkInterface::allInterfaces();
|
||||
for (auto interface : rawInterfaceList) {
|
||||
for (auto &interface : rawInterfaceList) {
|
||||
QString device = interface.name();
|
||||
if (cachedValues.contains(device))
|
||||
continue;
|
||||
@ -95,7 +95,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &keys,
|
||||
QSet<QString> used = QSet<QString>::fromList(keys);
|
||||
used.unite(QSet<QString>::fromList(bars));
|
||||
// insert keys from tooltip
|
||||
for (auto key : tooltip.keys()) {
|
||||
for (auto &key : tooltip.keys()) {
|
||||
if ((key.endsWith(QString("Tooltip"))) && (tooltip[key].toBool())) {
|
||||
key.remove(QString("Tooltip"));
|
||||
used << key;
|
||||
@ -104,7 +104,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &keys,
|
||||
|
||||
// insert depending keys, refer to AWKeys::calculateValues()
|
||||
// hddtotmb*
|
||||
for (auto key : allKeys.filter(QRegExp(QString("^hddtotmb")))) {
|
||||
for (auto &key : allKeys.filter(QRegExp(QString("^hddtotmb")))) {
|
||||
if (!used.contains(key))
|
||||
continue;
|
||||
key.remove(QString("hddtotmb"));
|
||||
@ -113,7 +113,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &keys,
|
||||
<< QString("hddmb%1").arg(index);
|
||||
}
|
||||
// hddtotgb*
|
||||
for (auto key : allKeys.filter(QRegExp(QString("^hddtotgb")))) {
|
||||
for (auto &key : allKeys.filter(QRegExp(QString("^hddtotgb")))) {
|
||||
if (!used.contains(key))
|
||||
continue;
|
||||
key.remove(QString("hddtotgb"));
|
||||
@ -146,12 +146,12 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &keys,
|
||||
<< QString("upunits") << QString("down")
|
||||
<< QString("downkb") << QString("downtotal")
|
||||
<< QString("downtotalkb") << QString("downunits"));
|
||||
for (auto key : netKeys) {
|
||||
for (auto &key : netKeys) {
|
||||
if (!used.contains(key))
|
||||
continue;
|
||||
QStringList filt
|
||||
= allKeys.filter(QRegExp(QString("^%1[0-9]{1,}").arg(key)));
|
||||
for (auto filtered : filt)
|
||||
for (auto &filtered : filt)
|
||||
used << filtered;
|
||||
}
|
||||
// netdev key
|
||||
@ -177,9 +177,9 @@ QHash<QString, QStringList> AWKeyCache::loadKeysFromCache()
|
||||
QSettings cache(fileName, QSettings::IniFormat);
|
||||
|
||||
QHash<QString, QStringList> devices;
|
||||
for (auto group : cache.childGroups()) {
|
||||
for (auto &group : cache.childGroups()) {
|
||||
cache.beginGroup(group);
|
||||
for (auto key : cache.allKeys())
|
||||
for (auto &key : cache.allKeys())
|
||||
devices[group].append(cache.value(key).toString());
|
||||
cache.endGroup();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
namespace AWKeyCache
|
||||
{
|
||||
bool addKeyToCache(const QString type, const QString key = QString(""));
|
||||
bool addKeyToCache(const QString &type, const QString &key = QString(""));
|
||||
QStringList getRequiredKeys(const QStringList &keys, const QStringList &bars,
|
||||
const QVariantMap &tooltip,
|
||||
const QStringList &allKeys);
|
||||
|
@ -55,7 +55,7 @@ AWKeyOperations::~AWKeyOperations()
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeyOperations::devices(const QString type) const
|
||||
QStringList AWKeyOperations::devices(const QString &type) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for type" << type;
|
||||
|
||||
@ -81,7 +81,7 @@ QStringList AWKeyOperations::dictKeys() const
|
||||
{
|
||||
QStringList allKeys;
|
||||
// weather
|
||||
for (auto item : m_extWeather->activeItems()) {
|
||||
for (auto &item : m_extWeather->activeItems()) {
|
||||
allKeys.append(item->tag(QString("weatherId")));
|
||||
allKeys.append(item->tag(QString("weather")));
|
||||
allKeys.append(item->tag(QString("humidity")));
|
||||
@ -136,10 +136,10 @@ QStringList AWKeyOperations::dictKeys() const
|
||||
for (int i = 0; i < allBatteryDevices.count(); i++)
|
||||
allKeys.append(QString("bat%1").arg(i));
|
||||
// package manager
|
||||
for (auto item : m_extUpgrade->activeItems())
|
||||
for (auto &item : m_extUpgrade->activeItems())
|
||||
allKeys.append(item->tag(QString("pkgcount")));
|
||||
// quotes
|
||||
for (auto item : m_extQuotes->activeItems()) {
|
||||
for (auto &item : m_extQuotes->activeItems()) {
|
||||
allKeys.append(item->tag(QString("ask")));
|
||||
allKeys.append(item->tag(QString("askchg")));
|
||||
allKeys.append(item->tag(QString("percaskchg")));
|
||||
@ -151,13 +151,13 @@ QStringList AWKeyOperations::dictKeys() const
|
||||
allKeys.append(item->tag(QString("percpricechg")));
|
||||
}
|
||||
// custom
|
||||
for (auto item : m_extScripts->activeItems())
|
||||
for (auto &item : m_extScripts->activeItems())
|
||||
allKeys.append(item->tag(QString("custom")));
|
||||
// network requests
|
||||
for (auto item : m_extNetRequest->activeItems())
|
||||
for (auto &item : m_extNetRequest->activeItems())
|
||||
allKeys.append(item->tag(QString("response")));
|
||||
// bars
|
||||
for (auto item : m_graphicalItems->activeItems())
|
||||
for (auto &item : m_graphicalItems->activeItems())
|
||||
allKeys.append(item->tag(QString("bar")));
|
||||
// static keys
|
||||
allKeys.append(QString(STATIC_KEYS).split(QChar(',')));
|
||||
@ -172,7 +172,7 @@ QStringList AWKeyOperations::dictKeys() const
|
||||
|
||||
// this method is required to provide GraphicalItem functions (e.g. paint()) to
|
||||
// parent classes
|
||||
GraphicalItem *AWKeyOperations::giByKey(const QString key) const
|
||||
GraphicalItem *AWKeyOperations::giByKey(const QString &key) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for item" << key;
|
||||
|
||||
@ -180,7 +180,7 @@ GraphicalItem *AWKeyOperations::giByKey(const QString key) const
|
||||
}
|
||||
|
||||
|
||||
QString AWKeyOperations::infoByKey(QString key) const
|
||||
QString AWKeyOperations::infoByKey(const QString &key) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Requested key" << key;
|
||||
|
||||
@ -197,22 +197,22 @@ QString AWKeyOperations::infoByKey(QString key) const
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else if (key.contains(QRegExp(QString("^hdd[rw]")))) {
|
||||
output = m_devices[QString("disk")]
|
||||
[key.remove(QRegExp(QString("hdd[rw]"))).toInt()];
|
||||
QString index = key;
|
||||
index.remove(QRegExp("hdd[rw]"));
|
||||
output = m_devices["disk"][index.toInt()];
|
||||
} else if (key.contains(QRegExp(
|
||||
QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))) {
|
||||
output
|
||||
= m_devices[QString("mount")]
|
||||
[key
|
||||
.remove(QRegExp(QString(
|
||||
"^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))
|
||||
.toInt()];
|
||||
QString index = key;
|
||||
index.remove(QRegExp("^hdd(|mb|gb|freemb|freegb|totmb|totgb)"));
|
||||
output = m_devices[QString("mount")][index.toInt()];
|
||||
} else if (key.startsWith(QString("hddtemp"))) {
|
||||
output
|
||||
= m_devices[QString("hdd")][key.remove(QString("hddtemp")).toInt()];
|
||||
QString index = key;
|
||||
index.remove("hddtemp");
|
||||
output = m_devices[QString("hdd")][index.toInt()];
|
||||
} else if (key.contains(QRegExp(QString("^(down|up)[0-9]")))) {
|
||||
output = m_devices[QString("net")]
|
||||
[key.remove(QRegExp(QString("^(down|up)"))).toInt()];
|
||||
QString index = key;
|
||||
index.remove(QRegExp("^(down|up)"));
|
||||
output = m_devices[QString("net")][index.toInt()];
|
||||
} else if (key.startsWith(QString("pkgcount"))) {
|
||||
AbstractExtItem *item = m_extUpgrade->itemByTag(key, stripped);
|
||||
if (item)
|
||||
@ -228,8 +228,9 @@ QString AWKeyOperations::infoByKey(QString key) const
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else if (key.startsWith(QString("temp"))) {
|
||||
output
|
||||
= m_devices[QString("temp")][key.remove(QString("temp")).toInt()];
|
||||
QString index = key;
|
||||
index.remove("temp");
|
||||
output = m_devices[QString("temp")][index.toInt()];
|
||||
} else if (key.startsWith(QString("response"))) {
|
||||
AbstractExtItem *item = m_extNetRequest->itemByTag(key, stripped);
|
||||
if (item)
|
||||
@ -248,7 +249,7 @@ QString AWKeyOperations::pattern() const
|
||||
}
|
||||
|
||||
|
||||
void AWKeyOperations::setPattern(const QString currentPattern)
|
||||
void AWKeyOperations::setPattern(const QString ¤tPattern)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Set pattern" << currentPattern;
|
||||
|
||||
@ -256,7 +257,7 @@ void AWKeyOperations::setPattern(const QString currentPattern)
|
||||
}
|
||||
|
||||
|
||||
void AWKeyOperations::editItem(const QString type)
|
||||
void AWKeyOperations::editItem(const QString &type)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Item type" << type;
|
||||
|
||||
@ -302,7 +303,7 @@ void AWKeyOperations::addDevice(const QString &source)
|
||||
}
|
||||
|
||||
|
||||
void AWKeyOperations::addKeyToCache(const QString type, const QString key)
|
||||
void AWKeyOperations::addKeyToCache(const QString &type, const QString &key)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << key << "with type" << type;
|
||||
|
||||
|
@ -46,28 +46,28 @@ class AWKeyOperations : public QObject
|
||||
public:
|
||||
explicit AWKeyOperations(QObject *parent = nullptr);
|
||||
virtual ~AWKeyOperations();
|
||||
QStringList devices(const QString type) const;
|
||||
QStringList devices(const QString &type) const;
|
||||
QHash<QString, QStringList> devices() const;
|
||||
void updateCache();
|
||||
// keys
|
||||
QStringList dictKeys() const;
|
||||
GraphicalItem *giByKey(const QString key) const;
|
||||
GraphicalItem *giByKey(const QString &key) const;
|
||||
// values
|
||||
QString infoByKey(QString key) const;
|
||||
QString infoByKey(const QString &key) const;
|
||||
QString pattern() const;
|
||||
void setPattern(const QString currentPattern);
|
||||
void setPattern(const QString ¤tPattern);
|
||||
// configuration
|
||||
void editItem(const QString type);
|
||||
void editItem(const QString &type);
|
||||
|
||||
signals:
|
||||
void updateKeys(const QStringList currentKeys);
|
||||
void updateKeys(const QStringList ¤tKeys);
|
||||
|
||||
public slots:
|
||||
void addDevice(const QString &source);
|
||||
|
||||
private:
|
||||
// methods
|
||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||
void addKeyToCache(const QString &type, const QString &key = QString(""));
|
||||
void reinitKeys();
|
||||
// objects
|
||||
ExtItemAggregator<GraphicalItem> *m_graphicalItems = nullptr;
|
||||
|
@ -97,7 +97,7 @@ bool AWKeys::isDBusActive() const
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initDataAggregator(const QVariantMap tooltipParams)
|
||||
void AWKeys::initDataAggregator(const QVariantMap &tooltipParams)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Tooltip parameters" << tooltipParams;
|
||||
|
||||
@ -107,7 +107,7 @@ void AWKeys::initDataAggregator(const QVariantMap tooltipParams)
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString currentPattern, const int interval,
|
||||
void AWKeys::initKeys(const QString ¤tPattern, const int interval,
|
||||
const int limit, const bool optimize)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Pattern" << currentPattern << "with interval"
|
||||
@ -131,7 +131,7 @@ void AWKeys::initKeys(const QString currentPattern, const int interval,
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setAggregatorProperty(const QString key, const QVariant value)
|
||||
void AWKeys::setAggregatorProperty(const QString &key, const QVariant &value)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << key << "with value" << value;
|
||||
|
||||
@ -153,7 +153,7 @@ void AWKeys::updateCache()
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
||||
QStringList AWKeys::dictKeys(const bool sorted, const QString ®exp) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Should be sorted" << sorted << "and filter applied"
|
||||
<< regexp;
|
||||
@ -180,7 +180,7 @@ QVariantList AWKeys::getHddDevices() const
|
||||
|
||||
// build model
|
||||
QVariantList devices;
|
||||
for (auto device : hddDevices) {
|
||||
for (auto &device : hddDevices) {
|
||||
QVariantMap model;
|
||||
model[QString("label")] = device;
|
||||
model[QString("name")] = device;
|
||||
@ -191,7 +191,7 @@ QVariantList AWKeys::getHddDevices() const
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::infoByKey(QString key) const
|
||||
QString AWKeys::infoByKey(const QString &key) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Requested info for key" << key;
|
||||
|
||||
@ -200,7 +200,7 @@ QString AWKeys::infoByKey(QString key) const
|
||||
|
||||
|
||||
// HACK this method requires to define tag value from bar from UI interface
|
||||
QString AWKeys::valueByKey(QString key) const
|
||||
QString AWKeys::valueByKey(const QString &key) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Requested value for key" << key;
|
||||
|
||||
@ -211,7 +211,7 @@ QString AWKeys::valueByKey(QString key) const
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::editItem(const QString type)
|
||||
void AWKeys::editItem(const QString &type)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Item type" << type;
|
||||
|
||||
@ -228,7 +228,7 @@ void AWKeys::dataUpdated(const QString &sourceName,
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::reinitKeys(const QStringList currentKeys)
|
||||
void AWKeys::reinitKeys(const QStringList ¤tKeys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Update found keys by using list" << currentKeys;
|
||||
|
||||
@ -240,7 +240,7 @@ void AWKeys::reinitKeys(const QStringList currentKeys)
|
||||
m_foundLambdas = AWPatternFunctions::findLambdas(m_keyOperator->pattern());
|
||||
// generate list of required keys for bars
|
||||
QStringList barKeys;
|
||||
for (auto bar : m_foundBars) {
|
||||
for (auto &bar : m_foundBars) {
|
||||
GraphicalItem *item = m_keyOperator->giByKey(bar);
|
||||
if (item->isCustom())
|
||||
item->setUsedKeys(
|
||||
@ -279,7 +279,7 @@ void AWKeys::calculateValues()
|
||||
{
|
||||
// hddtot*
|
||||
QStringList mountDevices = m_keyOperator->devices(QString("mount"));
|
||||
for (auto device : mountDevices) {
|
||||
for (auto &device : mountDevices) {
|
||||
int index = mountDevices.indexOf(device);
|
||||
m_values[QString("hddtotmb%1").arg(index)]
|
||||
= m_values[QString("hddfreemb%1").arg(index)].toFloat()
|
||||
@ -327,7 +327,7 @@ void AWKeys::calculateValues()
|
||||
/ m_values[QString("swaptotmb")].toFloat();
|
||||
|
||||
// lambdas
|
||||
for (auto key : m_foundLambdas)
|
||||
for (auto &key : m_foundLambdas)
|
||||
m_values[key] = AWPatternFunctions::expandLambdas(
|
||||
key, m_aggregator, m_values, m_foundKeys);
|
||||
}
|
||||
@ -360,11 +360,11 @@ QString AWKeys::parsePattern(QString pattern) const
|
||||
pattern.replace(QString("$$"), QString(0x1d));
|
||||
|
||||
// lambdas
|
||||
for (auto key : m_foundLambdas)
|
||||
for (auto &key : m_foundLambdas)
|
||||
pattern.replace(QString("${{%1}}").arg(key), m_values[key].toString());
|
||||
|
||||
// main keys
|
||||
for (auto key : m_foundKeys)
|
||||
for (auto &key : m_foundKeys)
|
||||
pattern.replace(QString("$%1").arg(key), [this](const QString &tag,
|
||||
const QVariant &value) {
|
||||
QString strValue = m_aggregator->formatter(value, tag);
|
||||
@ -375,7 +375,7 @@ QString AWKeys::parsePattern(QString pattern) const
|
||||
}(key, m_values[key]));
|
||||
|
||||
// bars
|
||||
for (auto bar : m_foundBars) {
|
||||
for (auto &bar : m_foundBars) {
|
||||
GraphicalItem *item = m_keyOperator->giByKey(bar);
|
||||
QString image
|
||||
= item->isCustom()
|
||||
|
@ -40,24 +40,24 @@ public:
|
||||
explicit AWKeys(QObject *parent = nullptr);
|
||||
virtual ~AWKeys();
|
||||
bool isDBusActive() const;
|
||||
Q_INVOKABLE void initDataAggregator(const QVariantMap tooltipParams);
|
||||
Q_INVOKABLE void initKeys(const QString currentPattern, const int interval,
|
||||
Q_INVOKABLE void initDataAggregator(const QVariantMap &tooltipParams);
|
||||
Q_INVOKABLE void initKeys(const QString ¤tPattern, const int interval,
|
||||
const int limit, const bool optimize);
|
||||
Q_INVOKABLE void setAggregatorProperty(const QString key,
|
||||
const QVariant value);
|
||||
Q_INVOKABLE void setAggregatorProperty(const QString &key,
|
||||
const QVariant &value);
|
||||
Q_INVOKABLE void setWrapNewLines(const bool wrap = false);
|
||||
// additional method to force load keys from Qml UI. Used in some
|
||||
// configuration pages
|
||||
Q_INVOKABLE void updateCache();
|
||||
// keys
|
||||
Q_INVOKABLE QStringList dictKeys(const bool sorted = false,
|
||||
const QString regexp = QString()) const;
|
||||
const QString ®exp = QString()) const;
|
||||
Q_INVOKABLE QVariantList getHddDevices() const;
|
||||
// values
|
||||
Q_INVOKABLE QString infoByKey(QString key) const;
|
||||
Q_INVOKABLE QString valueByKey(QString key) const;
|
||||
Q_INVOKABLE QString infoByKey(const QString &key) const;
|
||||
Q_INVOKABLE QString valueByKey(const QString &key) const;
|
||||
// configuration
|
||||
Q_INVOKABLE void editItem(const QString type);
|
||||
Q_INVOKABLE void editItem(const QString &type);
|
||||
|
||||
public slots:
|
||||
void dataUpdated(const QString &sourceName,
|
||||
@ -66,12 +66,12 @@ public slots:
|
||||
void modelChanged(QString, QAbstractItemModel *){};
|
||||
|
||||
signals:
|
||||
void dropSourceFromDataengine(const QString source);
|
||||
void needTextToBeUpdated(const QString newText) const;
|
||||
void needToolTipToBeUpdated(const QString newText) const;
|
||||
void dropSourceFromDataengine(const QString &source);
|
||||
void needTextToBeUpdated(const QString &newText) const;
|
||||
void needToolTipToBeUpdated(const QString &newText) const;
|
||||
|
||||
private slots:
|
||||
void reinitKeys(const QStringList currentKeys);
|
||||
void reinitKeys(const QStringList ¤tKeys);
|
||||
void updateTextData();
|
||||
|
||||
private:
|
||||
|
@ -136,7 +136,7 @@ QString AWKeysAggregator::formatter(const QVariant &data,
|
||||
case FormatterType::TimeCustom:
|
||||
output = m_customTime;
|
||||
[&output, loc, this](const QDateTime dt) {
|
||||
for (auto key : m_timeKeys)
|
||||
for (auto &key : m_timeKeys)
|
||||
output.replace(QString("$%1").arg(key), loc.toString(dt, key));
|
||||
}(data.toDateTime());
|
||||
break;
|
||||
@ -197,7 +197,7 @@ QStringList AWKeysAggregator::keysFromSource(const QString &source) const
|
||||
}
|
||||
|
||||
|
||||
void AWKeysAggregator::setAcOffline(const QString inactive)
|
||||
void AWKeysAggregator::setAcOffline(const QString &inactive)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Inactive AC string" << inactive;
|
||||
|
||||
@ -205,7 +205,7 @@ void AWKeysAggregator::setAcOffline(const QString inactive)
|
||||
}
|
||||
|
||||
|
||||
void AWKeysAggregator::setAcOnline(const QString active)
|
||||
void AWKeysAggregator::setAcOnline(const QString &active)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Active AC string" << active;
|
||||
|
||||
@ -213,7 +213,7 @@ void AWKeysAggregator::setAcOnline(const QString active)
|
||||
}
|
||||
|
||||
|
||||
void AWKeysAggregator::setCustomTime(const QString customTime)
|
||||
void AWKeysAggregator::setCustomTime(const QString &customTime)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Format" << customTime;
|
||||
|
||||
@ -221,7 +221,7 @@ void AWKeysAggregator::setCustomTime(const QString customTime)
|
||||
}
|
||||
|
||||
|
||||
void AWKeysAggregator::setCustomUptime(const QString customUptime)
|
||||
void AWKeysAggregator::setCustomUptime(const QString &customUptime)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Format" << customUptime;
|
||||
|
||||
@ -229,7 +229,7 @@ void AWKeysAggregator::setCustomUptime(const QString customUptime)
|
||||
}
|
||||
|
||||
|
||||
void AWKeysAggregator::setDevices(const QHash<QString, QStringList> devices)
|
||||
void AWKeysAggregator::setDevices(const QHash<QString, QStringList> &devices)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Devices" << devices;
|
||||
|
||||
@ -237,7 +237,7 @@ void AWKeysAggregator::setDevices(const QHash<QString, QStringList> devices)
|
||||
}
|
||||
|
||||
|
||||
void AWKeysAggregator::setTempUnits(const QString units)
|
||||
void AWKeysAggregator::setTempUnits(const QString &units)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Units" << units;
|
||||
|
||||
@ -596,7 +596,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source,
|
||||
customFormattersKeys = m_customFormatters->definedFormatters();
|
||||
qCInfo(LOG_AW) << "Looking for fprmatters" << foundKeys << "in"
|
||||
<< customFormattersKeys;
|
||||
for (auto key : foundKeys) {
|
||||
for (auto &key : foundKeys) {
|
||||
if (!customFormattersKeys.contains(key))
|
||||
continue;
|
||||
m_formatter[key] = FormatterType::Custom;
|
||||
@ -611,7 +611,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source,
|
||||
});
|
||||
if (!required) {
|
||||
m_map.remove(source);
|
||||
for (auto key : foundKeys)
|
||||
for (auto &key : foundKeys)
|
||||
m_formatter.remove(key);
|
||||
}
|
||||
|
||||
|
@ -74,12 +74,12 @@ public:
|
||||
QString formatter(const QVariant &data, const QString &key) const;
|
||||
QStringList keysFromSource(const QString &source) const;
|
||||
// set methods
|
||||
void setAcOffline(const QString inactive);
|
||||
void setAcOnline(const QString active);
|
||||
void setCustomTime(const QString customTime);
|
||||
void setCustomUptime(const QString customUptime);
|
||||
void setDevices(const QHash<QString, QStringList> devices);
|
||||
void setTempUnits(const QString units);
|
||||
void setAcOffline(const QString &inactive);
|
||||
void setAcOnline(const QString &active);
|
||||
void setCustomTime(const QString &customTime);
|
||||
void setCustomUptime(const QString &customUptime);
|
||||
void setDevices(const QHash<QString, QStringList> &devices);
|
||||
void setTempUnits(const QString &units);
|
||||
void setTranslate(const bool translate);
|
||||
|
||||
public slots:
|
||||
|
@ -35,7 +35,7 @@ QString AWPatternFunctions::expandLambdas(QString code,
|
||||
// apply $this values
|
||||
code.replace(QString("$this"), metadata[code].toString());
|
||||
// parsed values
|
||||
for (auto lambdaKey : usedKeys)
|
||||
for (auto &lambdaKey : usedKeys)
|
||||
code.replace(QString("$%1").arg(lambdaKey),
|
||||
aggregator->formatter(metadata[lambdaKey], lambdaKey));
|
||||
qCInfo(LOG_AW) << "Expression" << code;
|
||||
@ -87,8 +87,8 @@ QString AWPatternFunctions::expandTemplates(QString code)
|
||||
|
||||
|
||||
QList<AWPatternFunctions::AWFunction>
|
||||
AWPatternFunctions::findFunctionCalls(const QString function,
|
||||
const QString code)
|
||||
AWPatternFunctions::findFunctionCalls(const QString &function,
|
||||
const QString &code)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for function" << function << "in" << code;
|
||||
|
||||
@ -135,14 +135,14 @@ AWPatternFunctions::findFunctionCalls(const QString function,
|
||||
}
|
||||
|
||||
|
||||
QString AWPatternFunctions::insertAllKeys(QString code, const QStringList keys)
|
||||
QString AWPatternFunctions::insertAllKeys(QString code, const QStringList &keys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list"
|
||||
<< keys;
|
||||
|
||||
QList<AWPatternFunctions::AWFunction> found
|
||||
= AWPatternFunctions::findFunctionCalls(QString("aw_all"), code);
|
||||
for (auto function : found) {
|
||||
for (auto &function : found) {
|
||||
QString separator
|
||||
= function.args.isEmpty() ? QString(",") : function.args.at(0);
|
||||
QStringList required = keys.filter(QRegExp(function.body));
|
||||
@ -157,14 +157,15 @@ QString AWPatternFunctions::insertAllKeys(QString code, const QStringList keys)
|
||||
}
|
||||
|
||||
|
||||
QString AWPatternFunctions::insertKeyCount(QString code, const QStringList keys)
|
||||
QString AWPatternFunctions::insertKeyCount(QString code,
|
||||
const QStringList &keys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for count in code" << code << "using list"
|
||||
<< keys;
|
||||
|
||||
QList<AWPatternFunctions::AWFunction> found
|
||||
= AWPatternFunctions::findFunctionCalls(QString("aw_count"), code);
|
||||
for (auto function : found) {
|
||||
for (auto &function : found) {
|
||||
int count = keys.filter(QRegExp(function.body)).count();
|
||||
|
||||
code.replace(function.what, QString::number(count));
|
||||
@ -174,14 +175,15 @@ QString AWPatternFunctions::insertKeyCount(QString code, const QStringList keys)
|
||||
}
|
||||
|
||||
|
||||
QString AWPatternFunctions::insertKeyNames(QString code, const QStringList keys)
|
||||
QString AWPatternFunctions::insertKeyNames(QString code,
|
||||
const QStringList &keys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for key names in code" << code << "using list"
|
||||
<< keys;
|
||||
|
||||
QList<AWPatternFunctions::AWFunction> found
|
||||
= AWPatternFunctions::findFunctionCalls(QString("aw_names"), code);
|
||||
for (auto function : found) {
|
||||
for (auto &function : found) {
|
||||
QString separator
|
||||
= function.args.isEmpty() ? QString(",") : function.args.at(0);
|
||||
QStringList required = keys.filter(QRegExp(function.body));
|
||||
@ -193,14 +195,14 @@ QString AWPatternFunctions::insertKeyNames(QString code, const QStringList keys)
|
||||
}
|
||||
|
||||
|
||||
QString AWPatternFunctions::insertKeys(QString code, const QStringList keys)
|
||||
QString AWPatternFunctions::insertKeys(QString code, const QStringList &keys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list"
|
||||
<< keys;
|
||||
|
||||
QList<AWPatternFunctions::AWFunction> found
|
||||
= AWPatternFunctions::findFunctionCalls(QString("aw_keys"), code);
|
||||
for (auto function : found) {
|
||||
for (auto &function : found) {
|
||||
QString separator
|
||||
= function.args.isEmpty() ? QString(",") : function.args.at(0);
|
||||
QStringList required = keys.filter(QRegExp(function.body));
|
||||
@ -221,7 +223,7 @@ QString AWPatternFunctions::insertMacros(QString code)
|
||||
|
||||
QList<AWPatternFunctions::AWFunction> found
|
||||
= AWPatternFunctions::findFunctionCalls(QString("aw_macro"), code);
|
||||
for (auto macro : found) {
|
||||
for (auto ¯o : found) {
|
||||
// get macro params
|
||||
if (macro.args.isEmpty()) {
|
||||
qCWarning(LOG_AW) << "No macro name found for" << macro.what;
|
||||
@ -232,7 +234,7 @@ QString AWPatternFunctions::insertMacros(QString code)
|
||||
QList<AWPatternFunctions::AWFunction> macroUsage
|
||||
= AWPatternFunctions::findFunctionCalls(
|
||||
QString("aw_macro_%1").arg(name), code);
|
||||
for (auto function : macroUsage) {
|
||||
for (auto &function : macroUsage) {
|
||||
if (function.args.count() != macro.args.count()) {
|
||||
qCWarning(LOG_AW)
|
||||
<< "Invalid args count found for call" << function.what
|
||||
@ -259,8 +261,8 @@ QString AWPatternFunctions::insertMacros(QString code)
|
||||
}
|
||||
|
||||
|
||||
QStringList AWPatternFunctions::findKeys(const QString code,
|
||||
const QStringList keys,
|
||||
QStringList AWPatternFunctions::findKeys(const QString &code,
|
||||
const QStringList &keys,
|
||||
const bool isBars)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list"
|
||||
@ -268,7 +270,7 @@ QStringList AWPatternFunctions::findKeys(const QString code,
|
||||
|
||||
QStringList selectedKeys;
|
||||
QString replacedCode = code;
|
||||
for (auto key : keys)
|
||||
for (auto &key : keys)
|
||||
if ((key.startsWith(QString("bar")) == isBars)
|
||||
&& (replacedCode.contains(QString("$%1").arg(key)))) {
|
||||
qCInfo(LOG_AW) << "Found key" << key << "with bar enabled"
|
||||
@ -283,7 +285,7 @@ QStringList AWPatternFunctions::findKeys(const QString code,
|
||||
}
|
||||
|
||||
|
||||
QStringList AWPatternFunctions::findLambdas(const QString code)
|
||||
QStringList AWPatternFunctions::findLambdas(const QString &code)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Looking for lambdas in code" << code;
|
||||
|
||||
|
@ -38,16 +38,17 @@ QString expandLambdas(QString code, AWKeysAggregator *aggregator,
|
||||
const QVariantHash &metadata,
|
||||
const QStringList &usedKeys);
|
||||
QString expandTemplates(QString code);
|
||||
QList<AWFunction> findFunctionCalls(const QString function, const QString code);
|
||||
QString insertAllKeys(QString code, const QStringList keys);
|
||||
QString insertKeyCount(QString code, const QStringList keys);
|
||||
QString insertKeyNames(QString code, const QStringList keys);
|
||||
QString insertKeys(QString code, const QStringList keys);
|
||||
QList<AWFunction> findFunctionCalls(const QString &function,
|
||||
const QString &code);
|
||||
QString insertAllKeys(QString code, const QStringList &keys);
|
||||
QString insertKeyCount(QString code, const QStringList &keys);
|
||||
QString insertKeyNames(QString code, const QStringList &keys);
|
||||
QString insertKeys(QString code, const QStringList &keys);
|
||||
QString insertMacros(QString code);
|
||||
// find methods
|
||||
QStringList findKeys(const QString code, const QStringList keys,
|
||||
QStringList findKeys(const QString &code, const QStringList &keys,
|
||||
const bool isBars);
|
||||
QStringList findLambdas(const QString code);
|
||||
QStringList findLambdas(const QString &code);
|
||||
};
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "awdebug.h"
|
||||
|
||||
|
||||
AWTelemetryHandler::AWTelemetryHandler(QObject *parent, const QString clientId)
|
||||
AWTelemetryHandler::AWTelemetryHandler(QObject *parent, const QString &clientId)
|
||||
: QObject(parent)
|
||||
{
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
@ -50,7 +50,7 @@ AWTelemetryHandler::~AWTelemetryHandler()
|
||||
}
|
||||
|
||||
|
||||
QStringList AWTelemetryHandler::get(const QString group) const
|
||||
QStringList AWTelemetryHandler::get(const QString &group) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Get stored data for group" << group;
|
||||
|
||||
@ -58,7 +58,7 @@ QStringList AWTelemetryHandler::get(const QString group) const
|
||||
|
||||
QSettings settings(m_localFile, QSettings::IniFormat);
|
||||
settings.beginGroup(group);
|
||||
for (auto key : settings.childKeys())
|
||||
for (auto &key : settings.childKeys())
|
||||
values.append(settings.value(key).toString());
|
||||
settings.endGroup();
|
||||
|
||||
@ -66,7 +66,7 @@ QStringList AWTelemetryHandler::get(const QString group) const
|
||||
}
|
||||
|
||||
|
||||
QString AWTelemetryHandler::getLast(const QString group) const
|
||||
QString AWTelemetryHandler::getLast(const QString &group) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Get last stored data for group" << group;
|
||||
|
||||
@ -75,7 +75,7 @@ QString AWTelemetryHandler::getLast(const QString group) const
|
||||
|
||||
|
||||
void AWTelemetryHandler::init(const int count, const bool enableRemote,
|
||||
const QString clientId)
|
||||
const QString &clientId)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Init telemetry with count" << count << "enable remote"
|
||||
<< enableRemote << "client ID" << clientId;
|
||||
@ -86,7 +86,7 @@ void AWTelemetryHandler::init(const int count, const bool enableRemote,
|
||||
}
|
||||
|
||||
|
||||
bool AWTelemetryHandler::put(const QString group, const QString value) const
|
||||
bool AWTelemetryHandler::put(const QString &group, const QString &value) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Store data with group" << group << "and value" << value;
|
||||
|
||||
@ -95,7 +95,7 @@ bool AWTelemetryHandler::put(const QString group, const QString value) const
|
||||
// values will be stored as num=value inside specified group
|
||||
// load all values to memory
|
||||
QStringList saved;
|
||||
for (auto key : settings.childKeys())
|
||||
for (auto &key : settings.childKeys())
|
||||
saved.append(settings.value(key).toString());
|
||||
// check if this value is already saved
|
||||
if (saved.contains(value)) {
|
||||
@ -110,7 +110,7 @@ bool AWTelemetryHandler::put(const QString group, const QString value) const
|
||||
// clear group
|
||||
settings.remove(QString(""));
|
||||
// and save now
|
||||
for (auto value : saved) {
|
||||
for (auto &value : saved) {
|
||||
QString key = getKey(settings.childKeys().count());
|
||||
settings.setValue(key, value);
|
||||
}
|
||||
@ -123,8 +123,8 @@ bool AWTelemetryHandler::put(const QString group, const QString value) const
|
||||
}
|
||||
|
||||
|
||||
void AWTelemetryHandler::uploadTelemetry(const QString group,
|
||||
const QString value)
|
||||
void AWTelemetryHandler::uploadTelemetry(const QString &group,
|
||||
const QString &value)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Upload data with group" << group << "and value"
|
||||
<< value;
|
||||
|
@ -34,17 +34,18 @@ public:
|
||||
const char *REMOTE_TELEMETRY_URL = "https://arcanis.me/telemetry";
|
||||
|
||||
explicit AWTelemetryHandler(QObject *parent = nullptr,
|
||||
const QString clientId = QString());
|
||||
const QString &clientId = QString());
|
||||
virtual ~AWTelemetryHandler();
|
||||
Q_INVOKABLE QStringList get(const QString group) const;
|
||||
Q_INVOKABLE QString getLast(const QString group) const;
|
||||
Q_INVOKABLE QStringList get(const QString &group) const;
|
||||
Q_INVOKABLE QString getLast(const QString &group) const;
|
||||
Q_INVOKABLE void init(const int count, const bool enableRemote,
|
||||
const QString clientId);
|
||||
Q_INVOKABLE bool put(const QString group, const QString value) const;
|
||||
Q_INVOKABLE void uploadTelemetry(const QString group, const QString value);
|
||||
const QString &clientId);
|
||||
Q_INVOKABLE bool put(const QString &group, const QString &value) const;
|
||||
Q_INVOKABLE void uploadTelemetry(const QString &group,
|
||||
const QString &value);
|
||||
|
||||
signals:
|
||||
void replyReceived(QString message);
|
||||
void replyReceived(const QString &message);
|
||||
|
||||
private slots:
|
||||
void telemetryReplyRecieved(QNetworkReply *reply);
|
||||
|
@ -92,7 +92,7 @@ bool AWUpdateHelper::checkVersion()
|
||||
}
|
||||
|
||||
|
||||
void AWUpdateHelper::showInfo(const QVersionNumber version)
|
||||
void AWUpdateHelper::showInfo(const QVersionNumber &version)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Version" << version;
|
||||
|
||||
@ -105,7 +105,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber version)
|
||||
}
|
||||
|
||||
|
||||
void AWUpdateHelper::showUpdates(const QVersionNumber version)
|
||||
void AWUpdateHelper::showUpdates(const QVersionNumber &version)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Version" << version;
|
||||
|
||||
@ -176,7 +176,7 @@ void AWUpdateHelper::versionReplyRecieved(QNetworkReply *reply,
|
||||
|
||||
// additional method which is used to show message box which does not block UI
|
||||
QMessageBox *
|
||||
AWUpdateHelper::genMessageBox(const QString title, const QString body,
|
||||
AWUpdateHelper::genMessageBox(const QString &title, const QString &body,
|
||||
const QMessageBox::StandardButtons buttons)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Construct message box with title" << title << "and body"
|
||||
|
@ -37,13 +37,13 @@ public:
|
||||
bool checkVersion();
|
||||
|
||||
private slots:
|
||||
void showInfo(const QVersionNumber version);
|
||||
void showUpdates(const QVersionNumber version);
|
||||
void showInfo(const QVersionNumber &version);
|
||||
void showUpdates(const QVersionNumber &version);
|
||||
void userReplyOnUpdates(QAbstractButton *button);
|
||||
void versionReplyRecieved(QNetworkReply *reply, const bool showAnyway);
|
||||
|
||||
private:
|
||||
QMessageBox *genMessageBox(const QString title, const QString body,
|
||||
QMessageBox *genMessageBox(const QString &title, const QString &body,
|
||||
const QMessageBox::StandardButtons buttons);
|
||||
QVersionNumber m_foundVersion;
|
||||
QString m_genericConfig;
|
||||
|
Reference in New Issue
Block a user