diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp
index 046a7a12..4d5ed17c 100644
--- a/sources/awdebug.cpp
+++ b/sources/awdebug.cpp
@@ -56,15 +56,15 @@ QString AWDebug::getAboutText(const QString &_type)
translator = QString("
%1").arg(translator);
text = i18n("Translators:") + "" + translatorList.join("") + "
";
} else if (_type == "3rdparty") {
- QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(';', Qt::SkipEmptyParts);
- for (int i = 0; i < trdPartyList.count(); i++)
+ auto trdPartyList = QString(TRDPARTY_LICENSE).split(';', Qt::SkipEmptyParts);
+ for (auto i = 0; i < trdPartyList.count(); ++i)
trdPartyList[i] = QString("%1 (%2 license)")
.arg(trdPartyList.at(i).split(',')[0], trdPartyList.at(i).split(',')[1],
trdPartyList.at(i).split(',')[2]);
text = i18n("This software uses:") + "" + trdPartyList.join("") + "
";
} else if (_type == "thanks") {
- QStringList thanks = QString(SPECIAL_THANKS).split(';', Qt::SkipEmptyParts);
- for (int i = 0; i < thanks.count(); i++)
+ auto thanks = QString(SPECIAL_THANKS).split(';', Qt::SkipEmptyParts);
+ for (auto i = 0; i < thanks.count(); ++i)
thanks[i]
= QString("%1").arg(thanks.at(i).split(',')[0], thanks.at(i).split(',')[1]);
text = i18n("Special thanks to:") + "";
diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.cpp b/sources/awesome-widget/plugin/awabstractpairconfig.cpp
index 07c1a7d4..61ef7293 100644
--- a/sources/awesome-widget/plugin/awabstractpairconfig.cpp
+++ b/sources/awesome-widget/plugin/awabstractpairconfig.cpp
@@ -119,7 +119,7 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringLi
void AWAbstractPairConfig::clearSelectors()
{
- for (auto &selector : m_selectors) {
+ for (auto selector : m_selectors) {
disconnect(selector, &AWAbstractSelector::selectionChanged, this, &AWAbstractPairConfig::updateUi);
ui->verticalLayout->removeWidget(selector);
selector->deleteLater();
@@ -130,9 +130,9 @@ void AWAbstractPairConfig::clearSelectors()
void AWAbstractPairConfig::execDialog()
{
- int ret = exec();
+ auto ret = exec();
QHash data;
- for (auto &selector : m_selectors) {
+ for (auto selector : m_selectors) {
QPair select = selector->current();
if (select.first.isEmpty())
continue;
@@ -160,6 +160,7 @@ QPair AWAbstractPairConfig::initKeys() const
QStringList left = {""};
left.append(m_helper->leftKeys().isEmpty() ? m_keys : m_helper->leftKeys());
left.sort();
+
QStringList right = {""};
right.append(m_helper->rightKeys().isEmpty() ? m_keys : m_helper->rightKeys());
right.sort();
@@ -175,7 +176,7 @@ void AWAbstractPairConfig::updateDialog()
auto keys = initKeys();
for (auto &key : m_helper->keys())
- addSelector(keys.first, keys.second, QPair(key, pairs[key]));
+ addSelector(keys.first, keys.second, {key, pairs[key]});
// empty one
- addSelector(keys.first, keys.second, QPair());
+ addSelector(keys.first, keys.second, {});
}
diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.h b/sources/awesome-widget/plugin/awabstractpairconfig.h
index 67ce85e7..9a027ac1 100644
--- a/sources/awesome-widget/plugin/awabstractpairconfig.h
+++ b/sources/awesome-widget/plugin/awabstractpairconfig.h
@@ -33,7 +33,7 @@ class AWAbstractPairConfig : public QDialog
Q_OBJECT
public:
- explicit AWAbstractPairConfig(QWidget *_parent = nullptr, bool _hasEdit = false, QStringList _keys = QStringList());
+ explicit AWAbstractPairConfig(QWidget *_parent = nullptr, bool _hasEdit = false, QStringList _keys = {});
~AWAbstractPairConfig() override;
template void initHelper()
{
diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.cpp b/sources/awesome-widget/plugin/awabstractpairhelper.cpp
index 26be8f41..7d2c5b5e 100644
--- a/sources/awesome-widget/plugin/awabstractpairhelper.cpp
+++ b/sources/awesome-widget/plugin/awabstractpairhelper.cpp
@@ -34,12 +34,6 @@ AWAbstractPairHelper::AWAbstractPairHelper(QString _filePath, QString _section)
}
-AWAbstractPairHelper::~AWAbstractPairHelper()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
QStringList AWAbstractPairHelper::keys() const
{
return m_pairs.keys();
@@ -69,16 +63,16 @@ void AWAbstractPairHelper::initItems()
{
m_pairs.clear();
- QStringList configs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, m_filePath);
+ auto configs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, m_filePath);
for (auto &fileName : configs) {
QSettings settings(fileName, QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
settings.beginGroup(m_section);
- QStringList keys = settings.childKeys();
+ auto keys = settings.childKeys();
for (auto &key : keys) {
- QString value = settings.value(key).toString();
+ auto value = settings.value(key).toString();
qCInfo(LOG_AW) << "Found key" << key << "for value" << value << "in" << settings.fileName();
if (value.isEmpty()) {
qCInfo(LOG_AW) << "Skip empty value for" << key;
@@ -95,8 +89,8 @@ bool AWAbstractPairHelper::writeItems(const QHash &_configurat
{
qCDebug(LOG_AW) << "Write configuration" << _configuration;
- QString fileName
- = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).arg(m_filePath);
+ auto fileName
+ = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), m_filePath);
QSettings settings(fileName, QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << fileName;
@@ -107,7 +101,7 @@ bool AWAbstractPairHelper::writeItems(const QHash &_configurat
settings.sync();
- return (settings.status() == QSettings::NoError);
+ return settings.status() == QSettings::NoError;
}
@@ -115,14 +109,13 @@ bool AWAbstractPairHelper::removeUnusedKeys(const QStringList &_keys) const
{
qCDebug(LOG_AW) << "Remove keys" << _keys;
- QString fileName
- = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).arg(m_filePath);
+ auto fileName
+ = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), m_filePath);
QSettings settings(fileName, QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << fileName;
settings.beginGroup(m_section);
- QStringList foundKeys = settings.childKeys();
- for (auto &key : foundKeys) {
+ for (auto &key : settings.childKeys()) {
if (_keys.contains(key))
continue;
settings.remove(key);
@@ -131,5 +124,5 @@ bool AWAbstractPairHelper::removeUnusedKeys(const QStringList &_keys) const
settings.sync();
- return (settings.status() == QSettings::NoError);
+ return settings.status() == QSettings::NoError;
}
\ No newline at end of file
diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.h b/sources/awesome-widget/plugin/awabstractpairhelper.h
index 3f180526..fbc4c7d5 100644
--- a/sources/awesome-widget/plugin/awabstractpairhelper.h
+++ b/sources/awesome-widget/plugin/awabstractpairhelper.h
@@ -24,7 +24,7 @@ class AWAbstractPairHelper
{
public:
explicit AWAbstractPairHelper(QString _filePath = "", QString _section = "");
- virtual ~AWAbstractPairHelper();
+ virtual ~AWAbstractPairHelper() = default;
[[nodiscard]] QStringList keys() const;
[[nodiscard]] QHash pairs() const;
[[nodiscard]] QStringList values() const;
diff --git a/sources/awesome-widget/plugin/awabstractselector.cpp b/sources/awesome-widget/plugin/awabstractselector.cpp
index 463fb8e6..4c5c378f 100644
--- a/sources/awesome-widget/plugin/awabstractselector.cpp
+++ b/sources/awesome-widget/plugin/awabstractselector.cpp
@@ -31,8 +31,8 @@ AWAbstractSelector::AWAbstractSelector(QWidget *_parent, const QPair
ui->comboBox_key->setEditable(_editable.first);
ui->comboBox_value->setEditable(_editable.second);
- connect(ui->comboBox_key, SIGNAL(currentIndexChanged(int)), this, SIGNAL(selectionChanged()));
- connect(ui->comboBox_value, SIGNAL(currentIndexChanged(int)), this, SIGNAL(selectionChanged()));
+ connect(ui->comboBox_key, &QComboBox::currentIndexChanged, this, &AWAbstractSelector::selectionChanged);
+ connect(ui->comboBox_value, &QComboBox::currentIndexChanged, this, &AWAbstractSelector::selectionChanged);
}
@@ -46,10 +46,10 @@ AWAbstractSelector::~AWAbstractSelector()
QPair AWAbstractSelector::current() const
{
- QString key = ui->comboBox_key->currentText();
- QString value = ui->comboBox_value->currentText();
+ auto key = ui->comboBox_key->currentText();
+ auto value = ui->comboBox_value->currentText();
- return QPair(key, value);
+ return {key, value};
}
diff --git a/sources/awesome-widget/plugin/awactions.cpp b/sources/awesome-widget/plugin/awactions.cpp
index e79d2115..ba7c1c74 100644
--- a/sources/awesome-widget/plugin/awactions.cpp
+++ b/sources/awesome-widget/plugin/awactions.cpp
@@ -40,12 +40,6 @@ AWActions::AWActions(QObject *_parent)
}
-AWActions::~AWActions()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
void AWActions::checkUpdates(const bool _showAnyway)
{
qCDebug(LOG_AW) << "Show anyway" << _showAnyway;
@@ -65,7 +59,7 @@ QString AWActions::getFileContent(const QString &_path)
return "";
}
- QString output = inputFile.readAll();
+ auto output = inputFile.readAll();
inputFile.close();
return output;
}
@@ -102,10 +96,10 @@ QVariantMap AWActions::getFont(const QVariantMap &_defaultFont)
qCDebug(LOG_AW) << "Default font is" << _defaultFont;
QVariantMap fontMap;
- int ret = 0;
- CFont defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400, false,
- _defaultFont["color"].toString());
- CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false, &ret);
+ auto ret = 0;
+ auto defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400, false,
+ _defaultFont["color"].toString());
+ auto font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false, &ret);
fontMap["applied"] = ret;
fontMap["color"] = font.color().name();
diff --git a/sources/awesome-widget/plugin/awactions.h b/sources/awesome-widget/plugin/awactions.h
index d0f091d5..b3ee4586 100644
--- a/sources/awesome-widget/plugin/awactions.h
+++ b/sources/awesome-widget/plugin/awactions.h
@@ -29,7 +29,7 @@ class AWActions : public QObject
public:
explicit AWActions(QObject *_parent = nullptr);
- ~AWActions() override;
+ ~AWActions() override = default;
Q_INVOKABLE void checkUpdates(bool _showAnyway = false);
Q_INVOKABLE static QString getFileContent(const QString &_path);
Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args);
diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h
index 474bf295..5ff845be 100644
--- a/sources/awesome-widget/plugin/awbugreporter.h
+++ b/sources/awesome-widget/plugin/awbugreporter.h
@@ -20,7 +20,6 @@
#include
-class QAbstractButton;
class QNetworkReply;
class AWBugReporter : public QObject
diff --git a/sources/awesome-widget/plugin/awconfighelper.cpp b/sources/awesome-widget/plugin/awconfighelper.cpp
index 52cc9896..3498454c 100644
--- a/sources/awesome-widget/plugin/awconfighelper.cpp
+++ b/sources/awesome-widget/plugin/awconfighelper.cpp
@@ -34,17 +34,11 @@ AWConfigHelper::AWConfigHelper(QObject *_parent)
}
-AWConfigHelper::~AWConfigHelper()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
QString AWConfigHelper::configurationDirectory()
{
// get readable directory
- QString localDir = QString("%1/awesomewidgets/configs")
- .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
+ auto localDir = QString("%1/awesomewidgets/configs")
+ .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
// create directory and copy files from default settings
QDir localDirectory;
@@ -59,7 +53,7 @@ QString AWConfigHelper::configurationDirectory()
bool AWConfigHelper::dropCache()
{
- QString fileName
+ auto fileName
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
return QFile(fileName).remove();
@@ -75,7 +69,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
auto configuration = dynamic_cast(_nativeConfig);
settings.beginGroup("plasmoid");
for (auto &key : configuration->keys()) {
- QVariant value = configuration->value(key);
+ auto value = configuration->value(key);
if (!value.isValid())
continue;
settings.setValue(key, value);
@@ -84,7 +78,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
// extensions
for (auto &item : m_dirs) {
- QStringList items = QDir(QString("%1/%2").arg(m_baseDir, item)).entryList({"*.desktop"}, QDir::Files);
+ auto items = QDir(QString("%1/%2").arg(m_baseDir, item)).entryList({"*.desktop"}, QDir::Files);
settings.beginGroup(item);
for (auto &it : items)
copyExtensions(it, item, settings, false);
@@ -162,7 +156,7 @@ QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName, const
QVariantMap AWConfigHelper::readDataEngineConfiguration()
{
- QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, "plasma-dataengine-extsysmon.conf");
+ auto fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, "plasma-dataengine-extsysmon.conf");
qCInfo(LOG_AW) << "Configuration file" << fileName;
QSettings settings(fileName, QSettings::IniFormat);
QVariantMap configuration;
@@ -186,8 +180,8 @@ bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configurat
{
qCDebug(LOG_AW) << "Configuration" << _configuration;
- QString fileName = QString("%1/plasma-dataengine-extsysmon.conf")
- .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
+ auto fileName = QString("%1/plasma-dataengine-extsysmon.conf")
+ .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
QSettings settings(fileName, QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
@@ -210,15 +204,15 @@ void AWConfigHelper::copyConfigs(const QString &_localDir)
{
qCDebug(LOG_AW) << "Local directory" << _localDir;
- QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "awesomewidgets/configs",
- QStandardPaths::LocateDirectory);
+ auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "awesomewidgets/configs",
+ QStandardPaths::LocateDirectory);
for (auto &dir : dirs) {
if (dir == _localDir)
continue;
- QStringList files = QDir(dir).entryList(QDir::Files);
+ auto files = QDir(dir).entryList(QDir::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);
+ auto destination = QString("%1/%2").arg(_localDir, source);
+ auto status = QFile::copy(QString("%1/%2").arg(dir, source), destination);
qCInfo(LOG_AW) << "File" << source << "has been copied to" << destination << "with status" << status;
}
}
@@ -231,7 +225,7 @@ void AWConfigHelper::copyExtensions(const QString &_item, const QString &_type,
qCDebug(LOG_AW) << "Extension" << _item << "has type" << _type << "inverse copying" << _inverse;
_settings.beginGroup(_item);
- QSettings itemSettings(QString("%1/%2/%3").arg(m_baseDir).arg(_type).arg(_item), QSettings::IniFormat);
+ QSettings itemSettings(QString("%1/%2/%3").arg(m_baseDir, _type, _item), QSettings::IniFormat);
itemSettings.beginGroup("Desktop Entry");
if (_inverse)
copySettings(_settings, itemSettings);
@@ -258,7 +252,7 @@ void AWConfigHelper::readFile(QSettings &_settings, const QString &_key, const Q
QFile file(_fileName);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QString text = QString::fromUtf8(file.readAll());
+ auto text = QString::fromUtf8(file.readAll());
file.close();
_settings.setValue(_key, text);
} else {
diff --git a/sources/awesome-widget/plugin/awconfighelper.h b/sources/awesome-widget/plugin/awconfighelper.h
index dfbcf665..a4f16a52 100644
--- a/sources/awesome-widget/plugin/awconfighelper.h
+++ b/sources/awesome-widget/plugin/awconfighelper.h
@@ -29,7 +29,7 @@ class AWConfigHelper : public QObject
public:
explicit AWConfigHelper(QObject *_parent = nullptr);
- ~AWConfigHelper() override;
+ ~AWConfigHelper() override = default;
Q_INVOKABLE [[nodiscard]] static QString configurationDirectory();
Q_INVOKABLE static bool dropCache();
Q_INVOKABLE bool exportConfiguration(QObject *_nativeConfig, const QString &_fileName) const;
diff --git a/sources/awesome-widget/plugin/awcustomkeysconfig.cpp b/sources/awesome-widget/plugin/awcustomkeysconfig.cpp
index 5435b86f..4871b668 100644
--- a/sources/awesome-widget/plugin/awcustomkeysconfig.cpp
+++ b/sources/awesome-widget/plugin/awcustomkeysconfig.cpp
@@ -29,9 +29,3 @@ AWCustomKeysConfig::AWCustomKeysConfig(QWidget *_parent, const QStringList &_key
setEditable(true, false);
initHelper();
}
-
-
-AWCustomKeysConfig::~AWCustomKeysConfig()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
diff --git a/sources/awesome-widget/plugin/awcustomkeysconfig.h b/sources/awesome-widget/plugin/awcustomkeysconfig.h
index 52e35e86..38025363 100644
--- a/sources/awesome-widget/plugin/awcustomkeysconfig.h
+++ b/sources/awesome-widget/plugin/awcustomkeysconfig.h
@@ -26,5 +26,5 @@ class AWCustomKeysConfig : public AWAbstractPairConfig
public:
explicit AWCustomKeysConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList());
- ~AWCustomKeysConfig() override;
+ ~AWCustomKeysConfig() override = default;
};
diff --git a/sources/awesome-widget/plugin/awcustomkeyshelper.cpp b/sources/awesome-widget/plugin/awcustomkeyshelper.cpp
index 04ed21f6..7b639ada 100644
--- a/sources/awesome-widget/plugin/awcustomkeyshelper.cpp
+++ b/sources/awesome-widget/plugin/awcustomkeyshelper.cpp
@@ -30,12 +30,6 @@ AWCustomKeysHelper::AWCustomKeysHelper(QObject *_parent)
}
-AWCustomKeysHelper::~AWCustomKeysHelper()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
QString AWCustomKeysHelper::source(const QString &_key) const
{
qCDebug(LOG_AW) << "Get source by key" << _key;
diff --git a/sources/awesome-widget/plugin/awcustomkeyshelper.h b/sources/awesome-widget/plugin/awcustomkeyshelper.h
index 0012310c..b5556052 100644
--- a/sources/awesome-widget/plugin/awcustomkeyshelper.h
+++ b/sources/awesome-widget/plugin/awcustomkeyshelper.h
@@ -28,7 +28,7 @@ class AWCustomKeysHelper : public QObject, public AWAbstractPairHelper
public:
explicit AWCustomKeysHelper(QObject *_parent = nullptr);
- ~AWCustomKeysHelper() override;
+ ~AWCustomKeysHelper() override = default;
// get
[[nodiscard]] QString source(const QString &_key) const;
[[nodiscard]] QStringList sources() const;
@@ -37,6 +37,4 @@ class AWCustomKeysHelper : public QObject, public AWAbstractPairHelper
void editPairs() override{};
QStringList leftKeys() override;
QStringList rightKeys() override;
-
-private:
};
diff --git a/sources/awesome-widget/plugin/awdataaggregator.cpp b/sources/awesome-widget/plugin/awdataaggregator.cpp
index 6c8267e1..74e7d2b1 100644
--- a/sources/awesome-widget/plugin/awdataaggregator.cpp
+++ b/sources/awesome-widget/plugin/awdataaggregator.cpp
@@ -84,26 +84,26 @@ void AWDataAggregator::setParameters(const QVariantMap &_settings)
// resize tooltip image
m_toolTipView->resize(100 * m_counts, 105);
- requiredKeys.clear();
+ m_requiredKeys.clear();
if (m_configuration["cpuTooltip"].toBool())
- requiredKeys.append("cpuTooltip");
+ m_requiredKeys.append("cpuTooltip");
if (m_configuration["cpuclTooltip"].toBool())
- requiredKeys.append("cpuclTooltip");
+ m_requiredKeys.append("cpuclTooltip");
if (m_configuration["memTooltip"].toBool())
- requiredKeys.append("memTooltip");
+ m_requiredKeys.append("memTooltip");
if (m_configuration["swapTooltip"].toBool())
- requiredKeys.append("swapTooltip");
+ m_requiredKeys.append("swapTooltip");
if (m_configuration["downkbTooltip"].toBool())
- requiredKeys.append("downkbTooltip");
+ m_requiredKeys.append("downkbTooltip");
if (m_configuration["upkbTooltip"].toBool())
- requiredKeys.append("upkbTooltip");
+ m_requiredKeys.append("upkbTooltip");
if (m_configuration["batTooltip"].toBool())
- requiredKeys.append("batTooltip");
+ m_requiredKeys.append("batTooltip");
// background
m_toolTipScene->setBackgroundBrush(m_configuration["useTooltipBackground"].toBool()
- ? QBrush(QColor(m_configuration["tooltipBackground"].toString()))
- : QBrush(Qt::NoBrush));
+ ? QColor(m_configuration["tooltipBackground"].toString())
+ : Qt::NoBrush);
}
@@ -112,34 +112,42 @@ QPixmap AWDataAggregator::tooltipImage()
// create image
m_toolTipScene->clear();
QPen pen;
- bool down = false;
- for (auto &key : requiredKeys) {
+ auto shift = 0.0;
+
+ for (auto i = 0; i < m_requiredKeys.count(); ++i) {
+ auto key = m_requiredKeys[i];
+
// create frame
- float normX = 100.0f / static_cast(m_values[key].count());
- float normY = 100.0f / (1.5f * m_boundaries[key]);
- float shift = static_cast(requiredKeys.indexOf(key)) * 100.0f;
- if (down)
- shift -= 100.0;
+ auto normX = 100.0 / static_cast(m_values[key].count());
+ auto normY = 100.0 / (1.5 * m_boundaries[key]);
+
// apply pen color
if (key != "batTooltip")
- pen.setColor(QColor(m_configuration[QString("%1Color").arg(key)].toString()));
+ pen.setColor(m_configuration[QString("%1Color").arg(key)].toString());
+
// paint data inside frame
for (int j = 0; j < m_values[key].count() - 1; j++) {
// some magic here
- float x1 = j * normX + shift;
- float y1 = -std::fabs(m_values[key].at(j)) * normY + 5.0f;
- float x2 = (j + 1) * normX + shift;
- float y2 = -std::fabs(m_values[key].at(j + 1)) * normY + 5.0f;
+ auto x1 = j * normX + shift;
+ auto y1 = -std::fabs(m_values[key].at(j)) * normY + 5.0;
+ auto x2 = (j + 1) * normX + shift;
+ auto y2 = -std::fabs(m_values[key].at(j + 1)) * normY + 5.0;
+ // apply color for the battery tooltip based on charge/discharge
if (key == "batTooltip") {
if (m_values[key].at(j + 1) > 0)
pen.setColor(QColor(m_configuration["batTooltipColor"].toString()));
else
pen.setColor(QColor(m_configuration["batInTooltipColor"].toString()));
}
+
m_toolTipScene->addLine(x1, y1, x2, y2, pen);
}
- if (key == "downkbTooltip")
- down = true;
+
+ // increase frame shift if not downkbtooltip
+ // Additional workaround is required because there is frame (uokb and downkb) which contains two charts
+ // with the same shift
+ if (key != "downkbTooltip")
+ shift += 100.0;
}
return m_toolTipView->grab();
@@ -154,7 +162,7 @@ void AWDataAggregator::dataUpdate(const QVariantHash &_values)
}
-void AWDataAggregator::checkValue(const QString &_source, const float _value, const float _extremum) const
+void AWDataAggregator::checkValue(const QString &_source, const double _value, const double _extremum) const
{
qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value << "called with extremum"
<< _extremum;
@@ -227,25 +235,27 @@ void AWDataAggregator::setData(const QVariantHash &_values)
{
// do not log these arguments
// battery update requires info is AC online or not
- setData(_values["ac"].toString() == m_configuration["acOnline"], "batTooltip", _values["bat"].toFloat());
+ setData(_values["ac"].toString() == m_configuration["acOnline"], "batTooltip", _values["bat"].toDouble());
+
// usual case
- setData("cpuTooltip", _values["cpu"].toFloat(), 90.0);
- setData("cpuclTooltip", _values["cpucl"].toFloat());
- setData("memTooltip", _values["mem"].toFloat(), 80.0);
- setData("swapTooltip", _values["swap"].toFloat(), 0.0);
- setData("downkbTooltip", _values["downkb"].toFloat());
- setData("upkbTooltip", _values["upkb"].toFloat());
+ setData("cpuTooltip", _values["cpu"].toDouble(), 90.0);
+ setData("cpuclTooltip", _values["cpucl"].toDouble());
+ setData("memTooltip", _values["mem"].toDouble(), 80.0);
+ setData("swapTooltip", _values["swap"].toDouble(), 0.0);
+ setData("downkbTooltip", _values["downkb"].toDouble());
+ setData("upkbTooltip", _values["upkb"].toDouble());
+
// additional check for network device
- [this](const QString &value) {
- checkValue("netdev", m_currentNetworkDevice, value);
- m_currentNetworkDevice = value;
- }(_values["netdev"].toString());
+ auto currentNetworkDevice = _values["netdev"].toString();
+ checkValue("netdev", m_currentNetworkDevice, currentNetworkDevice);
+ m_currentNetworkDevice = currentNetworkDevice;
+
// additional check for GPU load
- [this](const float value) { checkValue("gpu", value, 90.0); }(_values["gpu"].toFloat());
+ checkValue("gpu", _values["gpu"].toDouble(), 90.0);
}
-void AWDataAggregator::setData(const QString &_source, float _value, const float _extremum)
+void AWDataAggregator::setData(const QString &_source, double _value, const double _extremum)
{
qCDebug(LOG_AW) << "Source" << _source << "to value" << _value << "with extremum" << _extremum;
@@ -261,16 +271,20 @@ void AWDataAggregator::setData(const QString &_source, float _value, const float
m_values[_source].append(_value);
if (_source == "downkbTooltip") {
- QList netValues = m_values["downkbTooltip"] + m_values["upkbTooltip"];
- // to avoid inf value of normY
- netValues << 1.0;
- m_boundaries["downkbTooltip"] = 1.2f * *std::max_element(netValues.cbegin(), netValues.cend());
- m_boundaries["upkbTooltip"] = m_boundaries["downkbTooltip"];
+ // to avoid copying of objects to another list we find max elements in each sequence and compare them
+ auto downMax = m_values["downkbTooltip"].empty()
+ ? 1.0
+ : *std::max_element(m_values["downkbTooltip"].cbegin(), m_values["downkbTooltip"].cend());
+ auto upMax = m_values["upkbTooltip"].empty()
+ ? 1.0
+ : *std::max_element(m_values["upkbTooltip"].cbegin(), m_values["upkbTooltip"].cend());
+ // assign both
+ m_boundaries["upkbTooltip"] = m_boundaries["downkbTooltip"] = 1.2 * std::max(downMax, upMax);
}
}
-void AWDataAggregator::setData(const bool _dontInvert, const QString &_source, float _value)
+void AWDataAggregator::setData(const bool _dontInvert, const QString &_source, double _value)
{
qCDebug(LOG_AW) << "Do not invert" << _dontInvert << "value" << _value << "for source" << _source;
diff --git a/sources/awesome-widget/plugin/awdataaggregator.h b/sources/awesome-widget/plugin/awdataaggregator.h
index 8d39853d..a03605f9 100644
--- a/sources/awesome-widget/plugin/awdataaggregator.h
+++ b/sources/awesome-widget/plugin/awdataaggregator.h
@@ -47,22 +47,22 @@ public slots:
// ui
QGraphicsScene *m_toolTipScene = nullptr;
QGraphicsView *m_toolTipView = nullptr;
- void checkValue(const QString &_source, float _value, float _extremum) const;
+ void checkValue(const QString &_source, double _value, double _extremum) const;
void checkValue(const QString &_source, const QString &_current, const QString &_received) const;
void initScene();
static QString notificationText(const QString &_source, float _value);
static QString notificationText(const QString &_source, const QString &_value);
// main method
void setData(const QVariantHash &_values);
- void setData(const QString &_source, float _value, float _extremum = -1.0f);
+ void setData(const QString &_source, double _value, double _extremum = -1.0);
// different signature for battery device
- void setData(bool _dontInvert, const QString &_source, float _value);
+ void setData(bool _dontInvert, const QString &_source, double _value);
// variables
int m_counts = 0;
QVariantHash m_configuration;
QString m_currentNetworkDevice = "lo";
- QHash m_boundaries;
- QHash> m_values;
+ QHash m_boundaries;
+ QHash> m_values;
bool m_enablePopup = false;
- QStringList requiredKeys;
+ QStringList m_requiredKeys;
};
diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp
index aaa9df91..fa2b3710 100644
--- a/sources/awesome-widget/plugin/awdataenginemapper.cpp
+++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp
@@ -52,12 +52,6 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus
}
-AWDataEngineMapper::~AWDataEngineMapper()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
AWKeysAggregator::FormatterType AWDataEngineMapper::formatter(const QString &_key) const
{
qCDebug(LOG_AW) << "Get formatter for key" << _key;
@@ -82,18 +76,18 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
// regular expressions
- auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$");
- auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$");
- auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
- auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
- auto gpuTempRegExp = QRegularExpression("^gpu/gpu.*/temperature$");
- auto hddrRegExp = QRegularExpression("^disk/.*/read$");
- auto hddwRegExp = QRegularExpression("^disk/.*/write$");
- auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$");
- auto mountFreeRegExp = QRegularExpression("^disk/.*/free$");
- auto mountUsedRegExp = QRegularExpression("^disk/.*/used$");
- auto netRegExp = QRegularExpression("^network/.*/(download|upload)$");
- auto netTotalRegExp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$");
+ static auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$");
+ static auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$");
+ static auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
+ static auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
+ static auto gpuTempRegExp = QRegularExpression("^gpu/gpu.*/temperature$");
+ static auto hddrRegExp = QRegularExpression("^disk/.*/read$");
+ static auto hddwRegExp = QRegularExpression("^disk/.*/write$");
+ static auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$");
+ static auto mountFreeRegExp = QRegularExpression("^disk/.*/free$");
+ static auto mountUsedRegExp = QRegularExpression("^disk/.*/used$");
+ static auto netRegExp = QRegularExpression("^network/.*/(download|upload)$");
+ static auto netTotalRegExp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$");
if (_source == "extsysmon/battery/ac") {
// AC
@@ -209,7 +203,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
auto index = m_devices["mount"].indexOf(device);
if (index > -1) {
// mb
- QString key = QString("hddfreemb%1").arg(index);
+ auto key = QString("hddfreemb%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat;
// gb
@@ -224,7 +218,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
auto index = m_devices["mount"].indexOf(device);
if (index > -1) {
// mb
- QString key = QString("hddmb%1").arg(index);
+ auto key = QString("hddmb%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat;
// gb
@@ -435,7 +429,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
// drop key from dictionary if no one user requested key required it
qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << _keys;
- auto required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](const QString &key) {
+ auto required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](auto &key) {
return _keys.contains(key);
});
if (!required) {
diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h
index 6903d4f6..39af6a72 100644
--- a/sources/awesome-widget/plugin/awdataenginemapper.h
+++ b/sources/awesome-widget/plugin/awdataenginemapper.h
@@ -33,7 +33,7 @@ class AWDataEngineMapper : public QObject
public:
explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr);
- ~AWDataEngineMapper() override;
+ ~AWDataEngineMapper() override = default;
// get methods
[[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const;
[[nodiscard]] QStringList keysFromSource(const QString &_source) const;
diff --git a/sources/awesome-widget/plugin/awdbusadaptor.cpp b/sources/awesome-widget/plugin/awdbusadaptor.cpp
index 0e294af4..02835f5b 100644
--- a/sources/awesome-widget/plugin/awdbusadaptor.cpp
+++ b/sources/awesome-widget/plugin/awdbusadaptor.cpp
@@ -32,27 +32,20 @@ AWDBusAdaptor::AWDBusAdaptor(AWKeys *_parent)
}
-AWDBusAdaptor::~AWDBusAdaptor()
-{
- qCDebug(LOG_DBUS) << __PRETTY_FUNCTION__;
-}
-
-
QStringList AWDBusAdaptor::ActiveServices()
{
- QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, "ListNames");
+ auto listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, "ListNames");
if (listServices.arguments().isEmpty()) {
qCWarning(LOG_DBUS) << "Could not find any DBus service";
return {};
}
- QStringList arguments = listServices.arguments().first().toStringList();
-
- return std::accumulate(arguments.cbegin(), arguments.cend(), QStringList(),
- [](QStringList source, const QString &service) {
- if (service.startsWith(AWDBUS_SERVICE))
- source.append(service);
- return source;
- });
+ auto arguments = listServices.arguments().first().toStringList();
+
+ return std::accumulate(arguments.cbegin(), arguments.cend(), QStringList(), [](auto source, auto &service) {
+ if (service.startsWith(AWDBUS_SERVICE))
+ source.append(service);
+ return source;
+ });
}
@@ -103,6 +96,6 @@ void AWDBusAdaptor::SetLogLevel(const QString &what, const QString &level, const
return;
}
- QString state = enabled ? "true" : "false";
- QLoggingCategory::setFilterRules(QString("%1.%2=%3").arg(what).arg(level).arg(state));
+ auto state = enabled ? "true" : "false";
+ QLoggingCategory::setFilterRules(QString("%1.%2=%3").arg(what, level, state));
}
diff --git a/sources/awesome-widget/plugin/awdbusadaptor.h b/sources/awesome-widget/plugin/awdbusadaptor.h
index dc75fd62..2594869a 100644
--- a/sources/awesome-widget/plugin/awdbusadaptor.h
+++ b/sources/awesome-widget/plugin/awdbusadaptor.h
@@ -31,7 +31,7 @@ class AWDBusAdaptor : public QDBusAbstractAdaptor
public:
explicit AWDBusAdaptor(AWKeys *_parent = nullptr);
- ~AWDBusAdaptor() override;
+ ~AWDBusAdaptor() override = default;
public slots:
// get methods
diff --git a/sources/awesome-widget/plugin/awformatterconfig.cpp b/sources/awesome-widget/plugin/awformatterconfig.cpp
index f12e6174..d4eedda6 100644
--- a/sources/awesome-widget/plugin/awformatterconfig.cpp
+++ b/sources/awesome-widget/plugin/awformatterconfig.cpp
@@ -29,9 +29,3 @@ AWFormatterConfig::AWFormatterConfig(QWidget *_parent, const QStringList &_keys)
setEditable(false, false);
initHelper();
}
-
-
-AWFormatterConfig::~AWFormatterConfig()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
diff --git a/sources/awesome-widget/plugin/awformatterconfig.h b/sources/awesome-widget/plugin/awformatterconfig.h
index cdbe75e8..20e14764 100644
--- a/sources/awesome-widget/plugin/awformatterconfig.h
+++ b/sources/awesome-widget/plugin/awformatterconfig.h
@@ -26,5 +26,5 @@ class AWFormatterConfig : public AWAbstractPairConfig
public:
explicit AWFormatterConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList());
- ~AWFormatterConfig() override;
+ ~AWFormatterConfig() override = default;
};
diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp
index a880ad74..cfe628a3 100644
--- a/sources/awesome-widget/plugin/awformatterhelper.cpp
+++ b/sources/awesome-widget/plugin/awformatterhelper.cpp
@@ -58,8 +58,7 @@ void AWFormatterHelper::initItems()
// assign internal storage
m_formatters.clear();
- for (auto &key : pairs().keys()) {
- auto name = pairs()[key];
+ for (auto [key, name] : pairs().asKeyValueRange()) {
if (!m_formattersClasses.contains(name)) {
qCWarning(LOG_AW) << "Invalid formatter" << name << "found in" << key;
continue;
@@ -87,7 +86,7 @@ QStringList AWFormatterHelper::definedFormatters() const
QList AWFormatterHelper::items() const
{
QList converted;
- for (auto &item : m_formattersClasses.values())
+ for (auto item : m_formattersClasses.values())
converted.append(item);
return converted;
@@ -123,7 +122,7 @@ AWAbstractFormatter::FormatterClass AWFormatterHelper::defineFormatterClass(cons
{
qCDebug(LOG_AW) << "Define formatter class for" << _stringType;
- AWAbstractFormatter::FormatterClass formatter = AWAbstractFormatter::FormatterClass::NoFormat;
+ auto formatter = AWAbstractFormatter::FormatterClass::NoFormat;
if (_stringType == "DateTime")
formatter = AWAbstractFormatter::FormatterClass::DateTime;
else if (_stringType == "Float")
@@ -151,17 +150,17 @@ void AWFormatterHelper::initFormatters()
auto dirs = directories();
for (auto &dir : dirs) {
- QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
+ auto files = QDir(dir).entryList(QDir::Files, QDir::Name);
for (auto &file : files) {
// check filename
if (!file.endsWith(".desktop"))
continue;
qCInfo(LOG_AW) << "Found file" << file << "in" << dir;
- QString filePath = QString("%1/%2").arg(dir).arg(file);
+ auto filePath = QString("%1/%2").arg(dir, file);
// check if already exists
auto values = m_formattersClasses.values();
if (std::any_of(values.cbegin(), values.cend(),
- [&filePath](const AWAbstractFormatter *item) { return (item->filePath() == filePath); }))
+ [&filePath](auto item) { return (item->filePath() == filePath); }))
continue;
auto metadata = readMetadata(filePath);
@@ -198,13 +197,14 @@ QPair AWFormatterHelper::readMetad
qCDebug(LOG_AW) << "Read initial parameters from" << _filePath;
QSettings settings(_filePath, QSettings::IniFormat);
+
settings.beginGroup("Desktop Entry");
auto name = settings.value("Name", _filePath).toString();
auto type = settings.value("X-AW-Type", "NoFormat").toString();
auto formatter = defineFormatterClass(type);
settings.endGroup();
- return QPair(name, formatter);
+ return {name, formatter};
}
@@ -219,7 +219,7 @@ void AWFormatterHelper::doCreateItem(QListWidget *_widget)
}
qCInfo(LOG_AW) << "Selected type" << select;
- AWAbstractFormatter::FormatterClass formatter = defineFormatterClass(select);
+ auto formatter = defineFormatterClass(select);
switch (formatter) {
case AWAbstractFormatter::FormatterClass::DateTime:
return createItem(_widget);
diff --git a/sources/awesome-widget/plugin/awkeycache.cpp b/sources/awesome-widget/plugin/awkeycache.cpp
index f22c26f7..0ac191c5 100644
--- a/sources/awesome-widget/plugin/awkeycache.cpp
+++ b/sources/awesome-widget/plugin/awkeycache.cpp
@@ -44,7 +44,7 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
if (_type == "net") {
auto rawInterfaceList = QNetworkInterface::allInterfaces();
for (auto &interface : rawInterfaceList) {
- QString device = interface.name();
+ auto device = interface.name();
if (cachedValues.contains(device))
continue;
qCInfo(LOG_AW) << "Found new key" << device << "for type" << _type;
@@ -74,10 +74,11 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
used.unite(QSet(_bars.cbegin(), _bars.cend()));
used.unite(QSet(_userKeys.cbegin(), _userKeys.cend()));
// insert keys from tooltip
- for (auto &key : _tooltip.keys()) {
- if ((key.endsWith("Tooltip")) && (_tooltip[key].toBool())) {
- key.remove("Tooltip");
- used << key;
+ for (auto [key, value] : _tooltip.asKeyValueRange()) {
+ if ((key.endsWith("Tooltip")) && value.toBool()) {
+ auto local = key;
+ local.remove("Tooltip");
+ used << local;
}
}
@@ -133,7 +134,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
used << filtered;
}
// netdev key
- if (std::any_of(netKeys.cbegin(), netKeys.cend(), [&used](const QString &key) { return used.contains(key); }))
+ if (std::any_of(netKeys.cbegin(), netKeys.cend(), [&used](auto &key) { return used.contains(key); }))
used << "netdev";
// HACK append dummy if there are no other keys. This hack is required
diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp
index e0f07c2a..5d78e070 100644
--- a/sources/awesome-widget/plugin/awkeyoperations.cpp
+++ b/sources/awesome-widget/plugin/awkeyoperations.cpp
@@ -49,12 +49,6 @@ AWKeyOperations::AWKeyOperations(QObject *_parent)
}
-AWKeyOperations::~AWKeyOperations()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
QStringList AWKeyOperations::devices(const QString &_type) const
{
qCDebug(LOG_AW) << "Looking for type" << _type;
@@ -89,20 +83,20 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(item->tag("timestamp"));
}
// cpuclock & cpu
- for (auto i = 0; i < QThread::idealThreadCount(); i++) {
+ for (auto i = 0; i < QThread::idealThreadCount(); ++i) {
allKeys.append(QString("cpucl%1").arg(i));
allKeys.append(QString("cpu%1").arg(i));
}
// temperature
- for (auto i = 0; i < m_devices["temp"].count(); i++)
+ for (auto i = 0; i < m_devices["temp"].count(); ++i)
allKeys.append(QString("temp%1").arg(i));
// gpu
- for (auto i = 0; i < m_devices["gpu"].count(); i++) {
+ for (auto i = 0; i < m_devices["gpu"].count(); ++i) {
allKeys.append(QString("gpu%1").arg(i));
allKeys.append(QString("gputemp%1").arg(i));
}
// hdd
- for (auto i = 0; i < m_devices["mount"].count(); i++) {
+ for (auto i = 0; i < m_devices["mount"].count(); ++i) {
allKeys.append(QString("hddmb%1").arg(i));
allKeys.append(QString("hddgb%1").arg(i));
allKeys.append(QString("hddfreemb%1").arg(i));
@@ -112,12 +106,12 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(QString("hdd%1").arg(i));
}
// hdd speed
- for (auto i = 0; i < m_devices["disk"].count(); i++) {
+ for (auto i = 0; i < m_devices["disk"].count(); ++i) {
allKeys.append(QString("hddr%1").arg(i));
allKeys.append(QString("hddw%1").arg(i));
}
// network
- for (auto i = 0; i < m_devices["net"].count(); i++) {
+ for (auto i = 0; i < m_devices["net"].count(); ++i) {
allKeys.append(QString("downunits%1").arg(i));
allKeys.append(QString("upunits%1").arg(i));
allKeys.append(QString("downtotkb%1").arg(i));
@@ -132,7 +126,7 @@ QStringList AWKeyOperations::dictKeys() const
// battery
auto allBatteryDevices = QDir("/sys/class/power_supply")
.entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
- for (int i = 0; i < allBatteryDevices.count(); i++) {
+ for (int i = 0; i < allBatteryDevices.count(); ++i) {
allKeys.append(QString("bat%1").arg(i));
allKeys.append(QString("batleft%1").arg(i));
allKeys.append(QString("batnow%1").arg(i));
@@ -205,10 +199,20 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
{
qCDebug(LOG_AW) << "Requested key" << _key;
+ static auto numberRegExp = QRegularExpression("\\d+");
+
auto stripped = _key;
- stripped.remove(QRegularExpression("\\d+"));
+ stripped.remove(numberRegExp);
QString output;
+ static auto hddRegExp = QRegularExpression("^hdd(|mb|gb|freemb|freegb|totmb|totgb)");
+ static auto hddrwRegExp = QRegularExpression("^hdd[rw]");
+ static auto hddMatchRegExp = QRegularExpression("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)");
+ static auto netRegExp = QRegularExpression("^(down|up)");
+ static auto netMatchRegExp = QRegularExpression("^(down|up)[0-9]");
+ static auto quotesRegExp = QRegularExpression("^(|perc)(ask|bid|price)(chg|)");
+ static auto weatherRegExp = QRegularExpression("^(weather|weatherId|humidity|pressure|temperature)");
+
if (_key.startsWith("bar")) {
auto item = m_graphicalItems->itemByTag(_key, stripped);
if (item)
@@ -217,27 +221,27 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
auto item = m_extScripts->itemByTag(_key, stripped);
if (item)
output = item->uniq();
- } else if (_key.contains(QRegularExpression("^hdd[rw]"))) {
+ } else if (_key.contains(hddrwRegExp)) {
auto index = _key;
- index.remove(QRegularExpression("hdd[rw]"));
+ index.remove(hddrwRegExp);
output = m_devices["disk"][index.toInt()];
- } else if (_key.contains(QRegularExpression("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) {
+ } else if (_key.contains(hddMatchRegExp)) {
auto index = _key;
- index.remove(QRegularExpression("^hdd(|mb|gb|freemb|freegb|totmb|totgb)"));
+ index.remove(hddRegExp);
output = m_devices["mount"][index.toInt()];
- } else if (_key.contains(QRegularExpression("^(down|up)[0-9]"))) {
+ } else if (_key.contains(netMatchRegExp)) {
auto index = _key;
- index.remove(QRegularExpression("^(down|up)"));
+ index.remove(netRegExp);
output = m_devices["net"][index.toInt()];
} else if (_key.startsWith("pkgcount")) {
auto item = m_extUpgrade->itemByTag(_key, stripped);
if (item)
output = item->uniq();
- } else if (_key.contains(QRegularExpression("(^|perc)(ask|bid|price)(chg|)"))) {
+ } else if (_key.contains(quotesRegExp)) {
auto item = m_extQuotes->itemByTag(_key, stripped);
if (item)
output = item->uniq();
- } else if (_key.contains(QRegularExpression("(weather|weatherId|humidity|pressure|temperature)"))) {
+ } else if (_key.contains(weatherRegExp)) {
auto item = m_extWeather->itemByTag(_key, stripped);
if (item)
output = item->uniq();
@@ -275,8 +279,10 @@ void AWKeyOperations::editItem(const QString &_type)
{
qCDebug(LOG_AW) << "Item type" << _type;
+ static auto supportsGraphicalRegExp = QRegularExpression("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)");
+
if (_type == "graphicalitem") {
- QStringList keys = dictKeys().filter(QRegularExpression("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)"));
+ auto keys = dictKeys().filter(supportsGraphicalRegExp);
keys.sort();
m_graphicalItems->setConfigArgs(keys);
return m_graphicalItems->editItems();
@@ -298,10 +304,10 @@ void AWKeyOperations::addDevice(const QString &_source)
{
qCDebug(LOG_AW) << "Source" << _source;
- auto diskRegexp = QRegularExpression("^disk/.*/read$");
- auto mountRegexp = QRegularExpression("^disk/.*/usedPercent$");
- auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
- auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
+ static auto diskRegexp = QRegularExpression("^disk/.*/read$");
+ static auto mountRegexp = QRegularExpression("^disk/.*/usedPercent$");
+ static auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
+ static auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
if (_source.contains(diskRegexp)) {
auto device = _source;
@@ -344,7 +350,7 @@ void AWKeyOperations::reinitKeys()
m_extWeather->initItems();
// init
- QStringList allKeys = dictKeys();
+ auto allKeys = dictKeys();
// apply aw_* functions
m_pattern = AWPatternFunctions::insertAllKeys(m_pattern, allKeys);
diff --git a/sources/awesome-widget/plugin/awkeyoperations.h b/sources/awesome-widget/plugin/awkeyoperations.h
index eb0a40d7..c9b028ca 100644
--- a/sources/awesome-widget/plugin/awkeyoperations.h
+++ b/sources/awesome-widget/plugin/awkeyoperations.h
@@ -37,7 +37,7 @@ class AWKeyOperations : public QObject
public:
explicit AWKeyOperations(QObject *_parent = nullptr);
- ~AWKeyOperations() override;
+ ~AWKeyOperations() override = default;
[[nodiscard]] QStringList devices(const QString &_type) const;
[[nodiscard]] QHash devices() const;
void updateCache();
diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp
index 49dacea3..34422de8 100644
--- a/sources/awesome-widget/plugin/awkeysaggregator.cpp
+++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp
@@ -43,12 +43,6 @@ AWKeysAggregator::AWKeysAggregator(QObject *_parent)
}
-AWKeysAggregator::~AWKeysAggregator()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
void AWKeysAggregator::initFormatters()
{
m_customFormatters->initItems();
@@ -140,17 +134,19 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
case FormatterType::Uptime:
case FormatterType::UptimeCustom:
output =
- [](QString source, const int uptime) {
- int seconds = uptime - uptime % 60;
- int minutes = seconds / 60 % 60;
- int hours = ((seconds / 60) - minutes) / 60 % 24;
- int days = (((seconds / 60) - minutes) / 60 - hours) / 24;
+ [](auto source, auto uptime) {
+ auto seconds = uptime - uptime % 60;
+ auto minutes = seconds / 60 % 60;
+ auto hours = ((seconds / 60) - minutes) / 60 % 24;
+ auto days = (((seconds / 60) - minutes) / 60 - hours) / 24;
+
source.replace("$dd", QString("%1").arg(days, 3, 10, QChar('0')));
source.replace("$d", QString("%1").arg(days));
source.replace("$hh", QString("%1").arg(hours, 2, 10, QChar('0')));
source.replace("$h", QString("%1").arg(hours));
source.replace("$mm", QString("%1").arg(minutes, 2, 10, QChar('0')));
source.replace("$m", QString("%1").arg(minutes));
+
return source;
}(m_mapper->formatter(_key) == FormatterType::Uptime ? "$ddd$hhh$mmm" : m_customUptime,
static_cast(_data.toDouble()));
diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h
index bd7fc7da..e88f1f78 100644
--- a/sources/awesome-widget/plugin/awkeysaggregator.h
+++ b/sources/awesome-widget/plugin/awkeysaggregator.h
@@ -71,7 +71,7 @@ class AWKeysAggregator : public QObject
static constexpr double GBinBytes = 1024.0 * MBinBytes;
explicit AWKeysAggregator(QObject *_parent = nullptr);
- ~AWKeysAggregator() override;
+ ~AWKeysAggregator() override = default;
void initFormatters();
// get methods
[[nodiscard]] QString formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const;
diff --git a/sources/awesome-widget/plugin/awpairconfigfactory.cpp b/sources/awesome-widget/plugin/awpairconfigfactory.cpp
index 83082542..d345c29f 100644
--- a/sources/awesome-widget/plugin/awpairconfigfactory.cpp
+++ b/sources/awesome-widget/plugin/awpairconfigfactory.cpp
@@ -29,12 +29,6 @@ AWPairConfigFactory::AWPairConfigFactory(QObject *_parent)
}
-AWPairConfigFactory::~AWPairConfigFactory()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys)
{
auto config = new AWFormatterConfig(nullptr, _keys);
diff --git a/sources/awesome-widget/plugin/awpairconfigfactory.h b/sources/awesome-widget/plugin/awpairconfigfactory.h
index 0969d686..8df7e391 100644
--- a/sources/awesome-widget/plugin/awpairconfigfactory.h
+++ b/sources/awesome-widget/plugin/awpairconfigfactory.h
@@ -26,7 +26,7 @@ class AWPairConfigFactory : public QObject
public:
explicit AWPairConfigFactory(QObject *_parent = nullptr);
- ~AWPairConfigFactory() override;
+ ~AWPairConfigFactory() override = default;
Q_INVOKABLE static void showFormatterDialog(const QStringList &_keys);
Q_INVOKABLE static void showKeysDialog(const QStringList &_keys);
diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp
index 9a56da39..36c9680e 100644
--- a/sources/awesome-widget/plugin/awpatternfunctions.cpp
+++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp
@@ -36,7 +36,7 @@ QString AWPatternFunctions::expandLambdas(QString _code, AWKeysAggregator *_aggr
for (auto &lambdaKey : _usedKeys)
_code.replace(QString("$%1").arg(lambdaKey), _aggregator->formatter(_metadata[lambdaKey], lambdaKey, false));
qCInfo(LOG_AW) << "Expression" << _code;
- QJSValue result = engine.evaluate(_code);
+ auto result = engine.evaluate(_code);
if (result.isError()) {
qCWarning(LOG_AW) << "Uncaught exception at line" << result.property("lineNumber").toInt() << ":"
<< result.toString();
@@ -52,17 +52,17 @@ QString AWPatternFunctions::expandTemplates(QString _code)
qCDebug(LOG_AW) << "Expand templates in" << _code;
// match the following construction $template{{some code here}}
- QRegularExpression templatesRegexp(R"(\$template\{\{(?.*?)\}\})");
+ static QRegularExpression templatesRegexp(R"(\$template\{\{(?.*?)\}\})");
templatesRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
- QRegularExpressionMatchIterator it = templatesRegexp.globalMatch(_code);
+ auto it = templatesRegexp.globalMatch(_code);
while (it.hasNext()) {
- QRegularExpressionMatch match = it.next();
- QString body = match.captured("body");
+ auto match = it.next();
+ auto body = match.captured("body");
QJSEngine engine;
qCInfo(LOG_AW) << "Expression" << body;
- QJSValue result = engine.evaluate(body);
+ auto result = engine.evaluate(body);
QString templateResult = "";
if (result.isError()) {
qCWarning(LOG_AW) << "Uncaught exception at line" << result.property("lineNumber").toInt() << ":"
@@ -94,20 +94,20 @@ QList AWPatternFunctions::findFunctionCalls(cons
regex.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
QList foundFunctions;
- QRegularExpressionMatchIterator it = regex.globalMatch(_code);
+ auto it = regex.globalMatch(_code);
while (it.hasNext()) {
- QRegularExpressionMatch match = it.next();
+ auto match = it.next();
AWPatternFunctions::AWFunction metadata;
// work with args
- QString argsString = match.captured("args");
+ auto argsString = match.captured("args");
if (argsString.isEmpty()) {
metadata.args = QStringList();
} else {
// replace '$,' to 0x1d
argsString.replace("$,", QChar(0x1d));
- QStringList args = argsString.split(',');
- std::for_each(args.begin(), args.end(), [](QString &arg) { arg.replace(QChar(0x1d), ","); });
+ auto args = argsString.split(',');
+ std::for_each(args.begin(), args.end(), [](auto &arg) { arg.replace(QChar(0x1d), ","); });
metadata.args = args;
}
// other variables
@@ -127,11 +127,11 @@ QString AWPatternFunctions::insertAllKeys(QString _code, const QStringList &_key
{
qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" << _keys;
- QList found = AWPatternFunctions::findFunctionCalls("aw_all", _code);
+ auto found = AWPatternFunctions::findFunctionCalls("aw_all", _code);
for (auto &function : found) {
- QString separator = function.args.isEmpty() ? "," : function.args.at(0);
- QStringList required = _keys.filter(QRegularExpression(function.body));
- std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("%1: $%1").arg(value); });
+ auto separator = function.args.isEmpty() ? "," : function.args.at(0);
+ auto required = _keys.filter(QRegularExpression(function.body));
+ std::for_each(required.begin(), required.end(), [](auto &value) { value = QString("%1: $%1").arg(value); });
_code.replace(function.what, required.join(separator));
}
@@ -144,9 +144,9 @@ QString AWPatternFunctions::insertKeyCount(QString _code, const QStringList &_ke
{
qCDebug(LOG_AW) << "Looking for count in code" << _code << "using list" << _keys;
- QList found = AWPatternFunctions::findFunctionCalls("aw_count", _code);
+ auto found = AWPatternFunctions::findFunctionCalls("aw_count", _code);
for (auto &function : found) {
- int count = _keys.filter(QRegularExpression(function.body)).count();
+ auto count = _keys.filter(QRegularExpression(function.body)).count();
_code.replace(function.what, QString::number(count));
}
@@ -159,10 +159,10 @@ QString AWPatternFunctions::insertKeyNames(QString _code, const QStringList &_ke
{
qCDebug(LOG_AW) << "Looking for key names in code" << _code << "using list" << _keys;
- QList found = AWPatternFunctions::findFunctionCalls("aw_names", _code);
+ auto found = AWPatternFunctions::findFunctionCalls("aw_names", _code);
for (auto &function : found) {
- QString separator = function.args.isEmpty() ? "," : function.args.at(0);
- QStringList required = _keys.filter(QRegularExpression(function.body));
+ auto separator = function.args.isEmpty() ? "," : function.args.at(0);
+ auto required = _keys.filter(QRegularExpression(function.body));
_code.replace(function.what, required.join(separator));
}
@@ -175,11 +175,11 @@ QString AWPatternFunctions::insertKeys(QString _code, const QStringList &_keys)
{
qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" << _keys;
- QList found = AWPatternFunctions::findFunctionCalls("aw_keys", _code);
+ auto found = AWPatternFunctions::findFunctionCalls("aw_keys", _code);
for (auto &function : found) {
- QString separator = function.args.isEmpty() ? "," : function.args.at(0);
- QStringList required = _keys.filter(QRegularExpression(function.body));
- std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("$%1").arg(value); });
+ auto separator = function.args.isEmpty() ? "," : function.args.at(0);
+ auto required = _keys.filter(QRegularExpression(function.body));
+ std::for_each(required.begin(), required.end(), [](auto &value) { value = QString("$%1").arg(value); });
_code.replace(function.what, required.join(separator));
}
@@ -192,26 +192,25 @@ QString AWPatternFunctions::insertMacros(QString _code)
{
qCDebug(LOG_AW) << "Looking for macros in code" << _code;
- QList found = AWPatternFunctions::findFunctionCalls("aw_macro", _code);
+ auto found = AWPatternFunctions::findFunctionCalls("aw_macro", _code);
for (auto ¯o : found) {
// get macro params
if (macro.args.isEmpty()) {
qCWarning(LOG_AW) << "No macro name found for" << macro.what;
continue;
}
- QString name = macro.args.takeFirst();
+ auto name = macro.args.takeFirst();
// find macro usage
- QList macroUsage
- = AWPatternFunctions::findFunctionCalls(QString("aw_macro_%1").arg(name), _code);
+ auto macroUsage = AWPatternFunctions::findFunctionCalls(QString("aw_macro_%1").arg(name), _code);
for (auto &function : macroUsage) {
if (function.args.count() != macro.args.count()) {
qCWarning(LOG_AW) << "Invalid args count found for call" << function.what << "with macro" << macro.what;
continue;
}
// generate body to replace
- QString result = macro.body;
- std::for_each(macro.args.cbegin(), macro.args.cend(), [&result, macro, function](const QString &arg) {
- int index = macro.args.indexOf(arg);
+ auto result = macro.body;
+ std::for_each(macro.args.cbegin(), macro.args.cend(), [&result, macro, function](auto &arg) {
+ auto index = macro.args.indexOf(arg);
result.replace(QString("$%1").arg(arg), function.args.at(index));
});
// do replace
@@ -231,7 +230,7 @@ QStringList AWPatternFunctions::findKeys(const QString &_code, const QStringList
qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" << _keys;
QStringList selectedKeys;
- QString replacedCode = _code;
+ auto replacedCode = _code;
for (auto &key : _keys)
if ((key.startsWith("bar") == _isBars) && (replacedCode.contains(QString("$%1").arg(key)))) {
qCInfo(LOG_AW) << "Found key" << key << "with bar enabled" << _isBars;
@@ -251,13 +250,13 @@ QStringList AWPatternFunctions::findLambdas(const QString &_code)
QStringList selectedKeys;
// match the following construction ${{some code here}}
- QRegularExpression lambdaRegexp(R"(\$\{\{(?.*?)\}\})");
+ static QRegularExpression lambdaRegexp(R"(\$\{\{(?.*?)\}\})");
lambdaRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
- QRegularExpressionMatchIterator it = lambdaRegexp.globalMatch(_code);
+ auto it = lambdaRegexp.globalMatch(_code);
while (it.hasNext()) {
- QRegularExpressionMatch match = it.next();
- QString lambda = match.captured("body");
+ auto match = it.next();
+ auto lambda = match.captured("body");
// append
qCInfo(LOG_AW) << "Found lambda" << lambda;
diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.cpp b/sources/awesome-widget/plugin/awtelemetryhandler.cpp
index b4738ec0..a98cf2be 100644
--- a/sources/awesome-widget/plugin/awtelemetryhandler.cpp
+++ b/sources/awesome-widget/plugin/awtelemetryhandler.cpp
@@ -41,12 +41,6 @@ AWTelemetryHandler::AWTelemetryHandler(QObject *_parent, const QString &_clientI
}
-AWTelemetryHandler::~AWTelemetryHandler()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
QStringList AWTelemetryHandler::get(const QString &_group) const
{
qCDebug(LOG_AW) << "Get stored data for group" << _group;
@@ -106,7 +100,7 @@ bool AWTelemetryHandler::put(const QString &_group, const QString &_value) const
settings.remove("");
// and save now
for (auto &val : saved) {
- QString key = getKey(settings.childKeys().count());
+ auto key = getKey(settings.childKeys().count());
settings.setValue(key, val);
}
diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.h b/sources/awesome-widget/plugin/awtelemetryhandler.h
index 329110af..5f3253f1 100644
--- a/sources/awesome-widget/plugin/awtelemetryhandler.h
+++ b/sources/awesome-widget/plugin/awtelemetryhandler.h
@@ -30,7 +30,7 @@ class AWTelemetryHandler : public QObject
const char *REMOTE_TELEMETRY_URL = "https://arcanis.me/telemetry";
explicit AWTelemetryHandler(QObject *_parent = nullptr, const QString &_clientId = "");
- ~AWTelemetryHandler() override;
+ ~AWTelemetryHandler() override = default;
Q_INVOKABLE [[nodiscard]] QStringList get(const QString &_group) const;
Q_INVOKABLE [[nodiscard]] QString getLast(const QString &_group) const;
Q_INVOKABLE void init(int _count, bool _enableRemote, const QString &_clientId);
diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp
index ba1fb8fc..622f8d25 100644
--- a/sources/awesome-widget/plugin/awupdatehelper.cpp
+++ b/sources/awesome-widget/plugin/awupdatehelper.cpp
@@ -41,12 +41,6 @@ AWUpdateHelper::AWUpdateHelper(QObject *_parent)
}
-AWUpdateHelper::~AWUpdateHelper()
-{
- qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
-}
-
-
void AWUpdateHelper::checkUpdates(const bool _showAnyway)
{
qCDebug(LOG_AW) << "Show anyway" << _showAnyway;
diff --git a/sources/awesome-widget/plugin/awupdatehelper.h b/sources/awesome-widget/plugin/awupdatehelper.h
index 00d78671..0ddeb28b 100644
--- a/sources/awesome-widget/plugin/awupdatehelper.h
+++ b/sources/awesome-widget/plugin/awupdatehelper.h
@@ -30,7 +30,7 @@ class AWUpdateHelper : public QObject
public:
explicit AWUpdateHelper(QObject *_parent = nullptr);
- ~AWUpdateHelper() override;
+ ~AWUpdateHelper() override = default;
void checkUpdates(bool _showAnyway = false);
bool checkVersion();
diff --git a/sources/extsysmonsources/batterysource.cpp b/sources/extsysmonsources/batterysource.cpp
index a5cda540..52ffd64d 100644
--- a/sources/extsysmonsources/batterysource.cpp
+++ b/sources/extsysmonsources/batterysource.cpp
@@ -55,8 +55,8 @@ void BatterySource::run()
acFile.close();
// batteries
- float currentLevel = 0.0, fullLevel = 0.0;
- for (int i = 0; i < m_batteriesCount; i++) {
+ auto currentLevel = 0.0, fullLevel = 0.0;
+ for (auto i = 0; i < m_batteriesCount; ++i) {
// current level
QFile currentLevelFile(QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i));
if (currentLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -101,7 +101,7 @@ QHash BatterySource::sources() const
result.insert("battotal", makeSensorInfo("Full battery capacity", QVariant::Int));
// generators
- for (auto i = 0; i < m_batteriesCount; i++) {
+ for (auto i = 0; i < m_batteriesCount; ++i) {
result.insert(QString("bat%1").arg(i), makeSensorInfo(QString("Battery %1 usage").arg(i), QVariant::Int,
KSysGuard::UnitPercent, 0, 100));
result.insert(QString("batleft%1").arg(i), makeSensorInfo(QString("Battery %1 discharge time").arg(i),
@@ -124,7 +124,7 @@ double BatterySource::approximate(const QList &_trend)
auto count = _trend.count();
auto sumxy = 0;
- for (int i = 0; i < count; i++)
+ for (auto i = 0; i < count; ++i)
sumxy += _trend.at(i) * (i + 1);
auto sumx = count * (count + 1) / 2;
@@ -149,7 +149,7 @@ void BatterySource::calculateRates()
qCDebug(LOG_AW) << interval;
m_timestamp.swap(now);
- for (int i = 0; i < m_batteriesCount; i++) {
+ for (auto i = 0; i < m_batteriesCount; ++i) {
auto approx = approximate(m_trend[i + 1]);
m_values[QString("batrate%1").arg(i)] = approx / interval;
m_values[QString("batleft%1").arg(i)] = interval * m_values[QString("batnow%1").arg(i)].toFloat() / approx;
diff --git a/sources/extsysmonsources/loadsource.cpp b/sources/extsysmonsources/loadsource.cpp
index acb6198e..d9ec5e3b 100644
--- a/sources/extsysmonsources/loadsource.cpp
+++ b/sources/extsysmonsources/loadsource.cpp
@@ -41,7 +41,7 @@ QHash LoadSource::sources() const
{
auto result = QHash();
- for (auto i = 0; i < 1000; i++)
+ for (auto i = 0; i < 1000; ++i)
result.insert(QString("load%1").arg(i), makeSensorInfo("Simple sources for load tests", QVariant::Int));
return result;
diff --git a/sources/test/awtestlibrary.cpp b/sources/test/awtestlibrary.cpp
index 78de05a5..f2805113 100644
--- a/sources/test/awtestlibrary.cpp
+++ b/sources/test/awtestlibrary.cpp
@@ -73,7 +73,7 @@ QString AWTestLibrary::randomString(const int _min, const int _max)
QString output;
auto count = _min + randomInt(_max - _min);
- for (auto i = 0; i < count; i++)
+ for (auto i = 0; i < count; ++i)
output += randomChar();
return output;
@@ -85,7 +85,7 @@ QStringList AWTestLibrary::randomStringList(const int _max)
QStringList output;
auto count = 1 + randomInt(_max);
- for (auto i = 0; i < count; i++)
+ for (auto i = 0; i < count; ++i)
output.append(randomString());
return output;
@@ -97,7 +97,7 @@ QStringList AWTestLibrary::randomSelect(const QStringList &_available)
QSet output;
auto count = 1 + randomInt(_available.count());
- for (auto i = 0; i < count; i++) {
+ for (auto i = 0; i < count; ++i) {
auto index = randomInt(_available.count());
output << _available.at(index);
}
diff --git a/sources/test/testawpatternfunctions.cpp b/sources/test/testawpatternfunctions.cpp
index c4446a76..7de20305 100644
--- a/sources/test/testawpatternfunctions.cpp
+++ b/sources/test/testawpatternfunctions.cpp
@@ -55,7 +55,7 @@ void TestAWPatternFunctions::test_findKeys()
{
auto count = AWTestLibrary::randomInt(200);
QStringList allKeys;
- for (auto i = 0; i < count; i++) {
+ for (auto i = 0; i < count; ++i) {
auto key = AWTestLibrary::randomString(1, 20);
while (allKeys.indexOf(QRegularExpression(QString("^%1.*").arg(key))) != -1)
key = AWTestLibrary::randomString(1, 20);
diff --git a/sources/test/testjsonformatter.cpp b/sources/test/testjsonformatter.cpp
index 31f50fb5..5ceffc22 100644
--- a/sources/test/testjsonformatter.cpp
+++ b/sources/test/testjsonformatter.cpp
@@ -73,7 +73,7 @@ void TestAWJsonFormatter::generate()
auto listCount = AWTestLibrary::randomInt(5) + 1;
auto validCount = AWTestLibrary::randomInt(listCount);
QVariantList second;
- for (auto i = 0; i < listCount; i++) {
+ for (auto i = 0; i < listCount; ++i) {
if (i == validCount) {
second.append(first);
} else {