diff --git a/sources/awesome-widget/plugin/awbugreporter.cpp b/sources/awesome-widget/plugin/awbugreporter.cpp index 4f8ce5b..a3aa12f 100644 --- a/sources/awesome-widget/plugin/awbugreporter.cpp +++ b/sources/awesome-widget/plugin/awbugreporter.cpp @@ -47,7 +47,7 @@ AWBugReporter::~AWBugReporter() } -void AWBugReporter::doConnect() +void AWBugReporter::doConnect() const { // additional method for testing needs connect(this, &AWBugReporter::replyReceived, this, &AWBugReporter::showInformation); diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h index 14b1dca..7f79321 100644 --- a/sources/awesome-widget/plugin/awbugreporter.h +++ b/sources/awesome-widget/plugin/awbugreporter.h @@ -30,7 +30,7 @@ class AWBugReporter : public QObject public: explicit AWBugReporter(QObject *_parent = nullptr); ~AWBugReporter() override; - Q_INVOKABLE void doConnect(); + Q_INVOKABLE void doConnect() const; Q_INVOKABLE static QString generateText(const QString &_description, const QString &_reproduce, const QString &_expected, const QString &_logs); Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body); diff --git a/sources/awesome-widget/plugin/awdataaggregator.h b/sources/awesome-widget/plugin/awdataaggregator.h index a03605f..5b126ff 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.h +++ b/sources/awesome-widget/plugin/awdataaggregator.h @@ -24,7 +24,6 @@ class QGraphicsScene; class QGraphicsView; class QPixmap; -class QThreadPool; class AWDataAggregator : public QObject { diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h index 39af6a7..6f88af3 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.h +++ b/sources/awesome-widget/plugin/awdataenginemapper.h @@ -38,7 +38,7 @@ public: [[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const; [[nodiscard]] QStringList keysFromSource(const QString &_source) const; // set methods - QStringList registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys); + QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys); void setDevices(const QHash &_devices); private: diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index e88f1f7..e6fbca1 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -86,7 +86,7 @@ public: void setTranslate(bool _translate); public slots: - QStringList registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys); + QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys); private: [[nodiscard]] double temperature(double temp) const; diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp index 3ac092f..c3579dd 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.cpp +++ b/sources/awesome-widget/plugin/awupdatehelper.cpp @@ -95,7 +95,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version) } -void AWUpdateHelper::showUpdates(const QVersionNumber &_version) +void AWUpdateHelper::showUpdates(const QVersionNumber &_version) const { qCDebug(LOG_AW) << "Version" << _version; diff --git a/sources/awesome-widget/plugin/awupdatehelper.h b/sources/awesome-widget/plugin/awupdatehelper.h index 0ddeb28..e5dba9d 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.h +++ b/sources/awesome-widget/plugin/awupdatehelper.h @@ -37,7 +37,7 @@ public: private slots: void openReleasesPage(); static void showInfo(const QVersionNumber &_version); - void showUpdates(const QVersionNumber &_version); + void showUpdates(const QVersionNumber &_version) const; void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway); private: diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index 7c046c8..cba81fd 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -245,7 +245,7 @@ void AbstractExtItem::setNumber(int _number) if (generateNumber) { _number = []() { qCWarning(LOG_LIB) << "Number is empty, generate new one"; - auto n = QRandomGenerator::global()->generate() % 1000; + auto n = QRandomGenerator::global()->bounded(1000); qCInfo(LOG_LIB) << "Generated number is" << n; return n; }(); diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index bf2ce82..5a5814f 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -184,8 +184,9 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply) _reply->deleteLater(); auto data = m_providerObject->parse(text); - for (auto [key, value] : data.asKeyValueRange()) + for (auto [key, value] : data.asKeyValueRange()) { m_values[tag(key)] = value; + } emit(dataReceived(m_values)); } diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 4f1081d..a648c48 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -94,7 +94,7 @@ QString GraphicalItem::image(const QVariant &value) m_scene->clear(); auto scaleX = 1, scaleY = 1; - auto converted = GraphicalItemHelper::getPercents(value.toFloat(), minValue(), maxValue()); + auto converted = GraphicalItemHelper::getPercents(value.toDouble(), minValue(), maxValue()); // paint switch (m_type) { @@ -182,13 +182,13 @@ int GraphicalItem::itemWidth() const } -float GraphicalItem::maxValue() const +double GraphicalItem::maxValue() const { return m_maxValue; } -float GraphicalItem::minValue() const +double GraphicalItem::minValue() const { return m_minValue; } @@ -321,7 +321,7 @@ void GraphicalItem::setItemWidth(const int _width) } -void GraphicalItem::setMaxValue(const float _value) +void GraphicalItem::setMaxValue(const double _value) { qCDebug(LOG_LIB) << "Max value" << _value; @@ -329,7 +329,7 @@ void GraphicalItem::setMaxValue(const float _value) } -void GraphicalItem::setMinValue(const float _value) +void GraphicalItem::setMinValue(const double _value) { qCDebug(LOG_LIB) << "Min value" << _value; @@ -406,8 +406,8 @@ void GraphicalItem::readConfiguration() setCount(settings.value("X-AW-Count", count()).toInt()); setCustom(settings.value("X-AW-Custom", isCustom()).toBool()); setBar(settings.value("X-AW-Value", bar()).toString()); - setMaxValue(settings.value("X-AW-Max", maxValue()).toFloat()); - setMinValue(settings.value("X-AW-Min", minValue()).toFloat()); + setMaxValue(settings.value("X-AW-Max", maxValue()).toDouble()); + setMinValue(settings.value("X-AW-Min", minValue()).toDouble()); setActiveColor(settings.value("X-AW-ActiveColor", activeColor()).toString()); setInactiveColor(settings.value("X-AW-InactiveColor", inactiveColor()).toString()); setStrType(settings.value("X-AW-Type", strType()).toString()); @@ -439,9 +439,8 @@ int GraphicalItem::showConfiguration(QWidget *_parent, const QVariant &_args) ui->setupUi(dialog); translate(ui); - connect(ui->checkBox_custom, &QCheckBox::stateChanged, [this, ui](const int state) { changeValue(ui, state); }); - connect(ui->comboBox_type, &QComboBox::currentIndexChanged, - [this, ui](const int state) { changeCountState(ui, state); }); + connect(ui->checkBox_custom, &QCheckBox::stateChanged, [ui](const int state) { changeValue(ui, state); }); + connect(ui->comboBox_type, &QComboBox::currentIndexChanged, [ui](const int state) { changeCountState(ui, state); }); connect(ui->toolButton_activeColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); }); connect(ui->toolButton_inactiveColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); }); diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index 93890af..fef495f 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -64,8 +64,8 @@ public: [[nodiscard]] bool isCustom() const; [[nodiscard]] int itemHeight() const; [[nodiscard]] int itemWidth() const; - [[nodiscard]] float minValue() const; - [[nodiscard]] float maxValue() const; + [[nodiscard]] double minValue() const; + [[nodiscard]] double maxValue() const; [[nodiscard]] Type type() const; [[nodiscard]] QString strType() const; [[nodiscard]] Direction direction() const; @@ -80,8 +80,8 @@ public: void setInactiveColor(const QString &_color); void setItemHeight(int _height); void setItemWidth(int _width); - void setMinValue(float _value); - void setMaxValue(float _value); + void setMinValue(double _value); + void setMaxValue(double _value); void setType(Type _type); void setStrType(const QString &_type); void setDirection(Direction _direction); @@ -110,8 +110,8 @@ private: bool m_custom = false; QString m_activeColor = "color://0,0,0,130"; QString m_inactiveColor = "color://255,255,255,130"; - float m_minValue = 0.0f; - float m_maxValue = 100.0f; + double m_minValue = 0.0; + double m_maxValue = 100.0; Type m_type = Type::Horizontal; Direction m_direction = Direction::LeftToRight; int m_height = 100; diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index dfe174b..ccd9d67 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -155,7 +155,7 @@ void GraphicalItemHelper::paintVertical(const float _percent) } -float GraphicalItemHelper::getPercents(const float _value, const float _min, const float _max) +double GraphicalItemHelper::getPercents(const double _value, const double _min, const double _max) { qCDebug(LOG_LIB) << "Get percent value from" << _value; // newest Qt crashes here if value is nan diff --git a/sources/awesomewidgets/graphicalitemhelper.h b/sources/awesomewidgets/graphicalitemhelper.h index 506c107..62f8eb6 100644 --- a/sources/awesomewidgets/graphicalitemhelper.h +++ b/sources/awesomewidgets/graphicalitemhelper.h @@ -40,12 +40,12 @@ public: void paintHorizontal(float _percent); void paintVertical(float _percent); // additional conversion methods - static float getPercents(float _value, float _min, float _max); + static double getPercents(double _value, double _min, double _max); static bool isColor(const QString &_input); static QColor stringToColor(const QString &_color); private: - static QBrush parseBrush(const QString &_input, const int _width, const int _height, const QColor &_default); + static QBrush parseBrush(const QString &_input, int _width, int _height, const QColor &_default); void storeValue(float _value); QGraphicsScene *m_scene = nullptr; int m_count = 100; diff --git a/sources/compiler.cmake b/sources/compiler.cmake index 2526ea2..6fef039 100644 --- a/sources/compiler.cmake +++ b/sources/compiler.cmake @@ -1,25 +1,22 @@ # flags -if (CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "-Wall") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") - set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") - # avoid newer gcc warnings - add_definitions(-D_DEFAULT_SOURCE) -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") - set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") - # linker flags -else () - message(FATAL_ERROR "Unknown compiler") -endif () +set(CMAKE_CXX_FLAGS "-Wall") +set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") +set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") +set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") -# some flags -set(CMAKE_CXX_STANDARD 20) +# standard force +set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # enable clang-tidy + set(CMAKE_CXX_CLANG_TIDY + clang-tidy; + -format-style='file'; + -header-filter=${CMAKE_CURRENT_SOURCE_DIR}; + ) +endif () + # verbose output for debug builds if (CMAKE_BUILD_TYPE MATCHES Debug) set(CMAKE_VERBOSE_MAKEFILE ON) diff --git a/sources/extsysmonsources/abstractextsysmonsource.cpp b/sources/extsysmonsources/abstractextsysmonsource.cpp new file mode 100644 index 0000000..2b5a07e --- /dev/null +++ b/sources/extsysmonsources/abstractextsysmonsource.cpp @@ -0,0 +1,52 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "abstractextsysmonsource.h" + +#include "awdebug.h" + + +AbstractExtSysMonSource::AbstractExtSysMonSource(QObject *_parent) + : QObject(_parent) +{ + qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; +} + + +// This method returns -1 in case of invalid source name (like if there is no number) +int AbstractExtSysMonSource::index(const QString &_source) +{ + auto match = NUMBER_REGEX.match(_source); + return match.hasMatch() ? match.captured().toInt() : -1; +} + + +KSysGuard::SensorInfo *AbstractExtSysMonSource::makeSensorInfo(const QString &_name, const QMetaType::Type _type, + const KSysGuard::Unit _unit, const double _min, + const double _max) +{ + auto info = new KSysGuard::SensorInfo(); + info->name = _name; + info->variantType = static_cast(_type); + + info->unit = _unit; + + info->min = _min; + info->max = _max; + + return info; +} diff --git a/sources/extsysmonsources/abstractextsysmonsource.h b/sources/extsysmonsources/abstractextsysmonsource.h index e7bf1e4..69895f6 100644 --- a/sources/extsysmonsources/abstractextsysmonsource.h +++ b/sources/extsysmonsources/abstractextsysmonsource.h @@ -30,20 +30,11 @@ class AbstractExtSysMonSource : public QObject public: inline static QRegularExpression NUMBER_REGEX = QRegularExpression("\\d+$"); - explicit AbstractExtSysMonSource(QObject *_parent) - : QObject(_parent){}; + explicit AbstractExtSysMonSource(QObject *_parent); ~AbstractExtSysMonSource() override = default; virtual QVariant data(const QString &_source) = 0; [[nodiscard]] virtual QHash sources() const = 0; - - // used by extensions - // This method returns -1 in case of invalid source name (like if there is no number) - static int index(const QString &_source) - { - auto match = NUMBER_REGEX.match(_source); - return match.hasMatch() ? match.captured().toInt() : -1; - } - + static int index(const QString &_source); // safe value extractor template static QVariantHash dataByItem(T *_extension, const QString &_source) { @@ -54,22 +45,9 @@ public: auto item = _extension->itemByTagNumber(idx); return item ? item->run() : QVariantHash(); } - - static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, const QVariant::Type _type, - const KSysGuard::Unit _unit = KSysGuard::UnitNone, - const double _min = 0, const double _max = 0) - { - auto info = new KSysGuard::SensorInfo(); - info->name = _name; - info->variantType = _type; - - info->unit = _unit; - - info->min = _min; - info->max = _max; - - return info; - } + static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, QMetaType::Type _type, + KSysGuard::Unit _unit = KSysGuard::UnitNone, + double _min = 0, double _max = 0); signals: void dataReceived(const QVariantHash &); diff --git a/sources/extsysmonsources/batterysource.cpp b/sources/extsysmonsources/batterysource.cpp index 52ffd64..18986d0 100644 --- a/sources/extsysmonsources/batterysource.cpp +++ b/sources/extsysmonsources/batterysource.cpp @@ -71,11 +71,11 @@ void BatterySource::run() m_values[QString("battotal%1").arg(i)] = QString(fullLevelFile.readLine()).toInt(); fullLevelFile.close(); - m_values[QString("bat%1").arg(i)] = static_cast(100 * m_values[QString("batnow%1").arg(i)].toFloat() - / m_values[QString("battotal%1").arg(i)].toFloat()); + m_values[QString("bat%1").arg(i)] = static_cast(100 * m_values[QString("batnow%1").arg(i)].toDouble() + / m_values[QString("battotal%1").arg(i)].toDouble()); // accumulate - currentLevel += m_values[QString("batnow%1").arg(i)].toFloat(); - fullLevel += m_values[QString("battotal%1").arg(i)].toFloat(); + currentLevel += m_values[QString("batnow%1").arg(i)].toDouble(); + fullLevel += m_values[QString("battotal%1").arg(i)].toDouble(); } // total @@ -93,24 +93,25 @@ QHash BatterySource::sources() const auto result = QHash(); // fixed fields - result.insert("ac", makeSensorInfo("Is AC online or not", QVariant::Bool)); - result.insert("bat", makeSensorInfo("Average battery usage", QVariant::Int, KSysGuard::UnitPercent, 0, 100)); - result.insert("batleft", makeSensorInfo("Battery discharge time", QVariant::Int, KSysGuard::UnitSecond)); - result.insert("batnow", makeSensorInfo("Current battery capacity", QVariant::Int)); - result.insert("batrate", makeSensorInfo("Average battery discharge rate", QVariant::Double, KSysGuard::UnitRate)); - result.insert("battotal", makeSensorInfo("Full battery capacity", QVariant::Int)); + result.insert("ac", makeSensorInfo("Is AC online or not", QMetaType::Bool)); + result.insert("bat", makeSensorInfo("Average battery usage", QMetaType::Int, KSysGuard::UnitPercent, 0, 100)); + result.insert("batleft", makeSensorInfo("Battery discharge time", QMetaType::Int, KSysGuard::UnitSecond)); + result.insert("batnow", makeSensorInfo("Current battery capacity", QMetaType::Int)); + result.insert("batrate", makeSensorInfo("Average battery discharge rate", QMetaType::Double, KSysGuard::UnitRate)); + result.insert("battotal", makeSensorInfo("Full battery capacity", QMetaType::Int)); // generators for (auto i = 0; i < m_batteriesCount; ++i) { - result.insert(QString("bat%1").arg(i), makeSensorInfo(QString("Battery %1 usage").arg(i), QVariant::Int, + result.insert(QString("bat%1").arg(i), makeSensorInfo(QString("Battery %1 usage").arg(i), QMetaType::Int, KSysGuard::UnitPercent, 0, 100)); result.insert(QString("batleft%1").arg(i), makeSensorInfo(QString("Battery %1 discharge time").arg(i), - QVariant::Int, KSysGuard::UnitSecond)); - result.insert(QString("batnow%1").arg(i), makeSensorInfo(QString("Battery %1 capacity").arg(i), QVariant::Int)); + QMetaType::Int, KSysGuard::UnitSecond)); + result.insert(QString("batnow%1").arg(i), + makeSensorInfo(QString("Battery %1 capacity").arg(i), QMetaType::Int)); result.insert(QString("batrate%1").arg(i), makeSensorInfo(QString("Battery %1 discharge rate").arg(i), - QVariant::Double, KSysGuard::UnitRate)); + QMetaType::Double, KSysGuard::UnitRate)); result.insert(QString("battotal%1").arg(i), - makeSensorInfo(QString("Battery %1 full capacity").arg(i), QVariant::Int)); + makeSensorInfo(QString("Battery %1 full capacity").arg(i), QMetaType::Int)); } return result; @@ -145,20 +146,19 @@ void BatterySource::calculateRates() // check time interval auto now = QDateTime::currentDateTimeUtc(); - auto interval = m_timestamp.secsTo(now); - qCDebug(LOG_AW) << interval; + auto interval = static_cast(m_timestamp.secsTo(now)); m_timestamp.swap(now); 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; + m_values[QString("batleft%1").arg(i)] = interval * m_values[QString("batnow%1").arg(i)].toDouble() / approx; } // total auto approx = approximate(m_trend[0]); m_values["batrate"] = approx / interval; - m_values["batleft"] = interval * m_values["batnow"].toFloat() / approx; + m_values["batleft"] = interval * m_values["batnow"].toDouble() / approx; // old data cleanup for (auto &trend : m_trend.keys()) { diff --git a/sources/extsysmonsources/customsource.cpp b/sources/extsysmonsources/customsource.cpp index a9dff45..9168873 100644 --- a/sources/extsysmonsources/customsource.cpp +++ b/sources/extsysmonsources/customsource.cpp @@ -46,7 +46,7 @@ QHash CustomSource::sources() const for (auto item : m_extScripts->activeItems()) result.insert(item->tag("custom"), - makeSensorInfo(QString("Custom command '%1' output").arg(item->uniq()), QVariant::String)); + makeSensorInfo(QString("Custom command '%1' output").arg(item->uniq()), QMetaType::QString)); return result; } diff --git a/sources/extsysmonsources/desktopsource.cpp b/sources/extsysmonsources/desktopsource.cpp index c880e71..843b974 100644 --- a/sources/extsysmonsources/desktopsource.cpp +++ b/sources/extsysmonsources/desktopsource.cpp @@ -55,9 +55,9 @@ QHash DesktopSource::sources() const { auto result = QHash(); - result.insert("name", makeSensorInfo("Current desktop name", QVariant::String)); - result.insert("number", makeSensorInfo("Current desktop number", QVariant::Int)); - result.insert("count", makeSensorInfo("Desktops count", QVariant::Int)); + result.insert("name", makeSensorInfo("Current desktop name", QMetaType::QString)); + result.insert("number", makeSensorInfo("Current desktop number", QMetaType::Int)); + result.insert("count", makeSensorInfo("Desktops count", QMetaType::Int)); return result; } diff --git a/sources/extsysmonsources/loadsource.cpp b/sources/extsysmonsources/loadsource.cpp index d9ec5e3..a9fd7e6 100644 --- a/sources/extsysmonsources/loadsource.cpp +++ b/sources/extsysmonsources/loadsource.cpp @@ -42,7 +42,7 @@ QHash LoadSource::sources() const auto result = QHash(); for (auto i = 0; i < 1000; ++i) - result.insert(QString("load%1").arg(i), makeSensorInfo("Simple sources for load tests", QVariant::Int)); + result.insert(QString("load%1").arg(i), makeSensorInfo("Simple sources for load tests", QMetaType::Int)); return result; } diff --git a/sources/extsysmonsources/networksource.cpp b/sources/extsysmonsources/networksource.cpp index 0366bbe..a60e8ce 100644 --- a/sources/extsysmonsources/networksource.cpp +++ b/sources/extsysmonsources/networksource.cpp @@ -65,8 +65,8 @@ QHash NetworkSource::sources() const { auto result = QHash(); - result.insert("device", makeSensorInfo("Current network device name", QVariant::String)); - result.insert("ssid", makeSensorInfo("Current SSID name", QVariant::String)); + result.insert("device", makeSensorInfo("Current network device name", QMetaType::QString)); + result.insert("ssid", makeSensorInfo("Current SSID name", QMetaType::QString)); return result; } diff --git a/sources/extsysmonsources/networksource.h b/sources/extsysmonsources/networksource.h index aba2c18..43da6ed 100644 --- a/sources/extsysmonsources/networksource.h +++ b/sources/extsysmonsources/networksource.h @@ -32,7 +32,6 @@ public: explicit NetworkSource(QObject *_parent); ~NetworkSource() override; QVariant data(const QString &_source) override; - void run(); [[nodiscard]] QHash sources() const override; private slots: diff --git a/sources/extsysmonsources/playersource.cpp b/sources/extsysmonsources/playersource.cpp index c41b563..3a210fc 100644 --- a/sources/extsysmonsources/playersource.cpp +++ b/sources/extsysmonsources/playersource.cpp @@ -115,23 +115,23 @@ QHash PlayerSource::sources() const { auto result = QHash(); - result.insert("album", makeSensorInfo("Current song album", QVariant::String)); + result.insert("album", makeSensorInfo("Current song album", QMetaType::QString)); result.insert("salbum", - makeSensorInfo(QString("Current song album (%1 symbols)").arg(m_symbols), QVariant::String)); - result.insert("dalbum", - makeSensorInfo(QString("Current song album (%1 symbols, dynamic)").arg(m_symbols), QVariant::String)); - result.insert("artist", makeSensorInfo("Current song artist", QVariant::String)); + makeSensorInfo(QString("Current song album (%1 symbols)").arg(m_symbols), QMetaType::QString)); + result.insert("dalbum", makeSensorInfo(QString("Current song album (%1 symbols, dynamic)").arg(m_symbols), + QMetaType::QString)); + result.insert("artist", makeSensorInfo("Current song artist", QMetaType::QString)); result.insert("sartist", - makeSensorInfo(QString("Current song artist (%1 symbols)").arg(m_symbols), QVariant::String)); + makeSensorInfo(QString("Current song artist (%1 symbols)").arg(m_symbols), QMetaType::QString)); result.insert("dartist", makeSensorInfo(QString("Current song artist (%1 symbols, dynamic)").arg(m_symbols), - QVariant::String)); - result.insert("duration", makeSensorInfo("Current song duration", QVariant::Int, KSysGuard::UnitSecond)); - result.insert("progress", makeSensorInfo("Current song progress", QVariant::Int, KSysGuard::UnitSecond)); - result.insert("title", makeSensorInfo("Current song title", QVariant::String)); + QMetaType::QString)); + result.insert("duration", makeSensorInfo("Current song duration", QMetaType::Int, KSysGuard::UnitSecond)); + result.insert("progress", makeSensorInfo("Current song progress", QMetaType::Int, KSysGuard::UnitSecond)); + result.insert("title", makeSensorInfo("Current song title", QMetaType::QString)); result.insert("stitle", - makeSensorInfo(QString("Current song title (%1 symbols)").arg(m_symbols), QVariant::String)); - result.insert("dtitle", - makeSensorInfo(QString("Current song title (%1 symbols, dynamic)").arg(m_symbols), QVariant::String)); + makeSensorInfo(QString("Current song title (%1 symbols)").arg(m_symbols), QMetaType::QString)); + result.insert("dtitle", makeSensorInfo(QString("Current song title (%1 symbols, dynamic)").arg(m_symbols), + QMetaType::QString)); return result; } diff --git a/sources/extsysmonsources/processessource.cpp b/sources/extsysmonsources/processessource.cpp index b97db5e..d85e02a 100644 --- a/sources/extsysmonsources/processessource.cpp +++ b/sources/extsysmonsources/processessource.cpp @@ -71,9 +71,9 @@ QHash ProcessesSource::sources() const { auto result = QHash(); - result.insert("running", makeSensorInfo("Count of running processes", QVariant::Int)); - result.insert("list", makeSensorInfo("All running processes list", QVariant::StringList)); - result.insert("count", makeSensorInfo("Total count of processes", QVariant::Int)); + result.insert("running", makeSensorInfo("Count of running processes", QMetaType::Int)); + result.insert("list", makeSensorInfo("All running processes list", QMetaType::QStringList)); + result.insert("count", makeSensorInfo("Total count of processes", QMetaType::Int)); return result; } diff --git a/sources/extsysmonsources/quotessource.cpp b/sources/extsysmonsources/quotessource.cpp index 41b4ca1..38c5927 100644 --- a/sources/extsysmonsources/quotessource.cpp +++ b/sources/extsysmonsources/quotessource.cpp @@ -48,17 +48,17 @@ QHash QuotesSource::sources() const for (auto item : m_extQuotes->activeItems()) { result.insert(item->tag("pricechg"), - makeSensorInfo(QString("Absolute price changes for '%1'").arg(item->uniq()), QVariant::Double)); + makeSensorInfo(QString("Absolute price changes for '%1'").arg(item->uniq()), QMetaType::Double)); result.insert(item->tag("price"), - makeSensorInfo(QString("Price for '%1'").arg(item->uniq()), QVariant::Double)); + makeSensorInfo(QString("Price for '%1'").arg(item->uniq()), QMetaType::Double)); result.insert(item->tag("percpricechg"), makeSensorInfo(QString("Price changes for '%1'").arg(item->uniq()), - QVariant::Double, KSysGuard::UnitPercent, 0, 100)); + QMetaType::Double, KSysGuard::UnitPercent, 0, 100)); result.insert(item->tag("volumechg"), - makeSensorInfo(QString("Absolute volume changes for '%1'").arg(item->uniq()), QVariant::Double)); + makeSensorInfo(QString("Absolute volume changes for '%1'").arg(item->uniq()), QMetaType::Double)); result.insert(item->tag("volume"), - makeSensorInfo(QString("Volume for '%1'").arg(item->uniq()), QVariant::Double)); + makeSensorInfo(QString("Volume for '%1'").arg(item->uniq()), QMetaType::Double)); result.insert(item->tag("percvolumechg"), makeSensorInfo(QString("Volume changes for '%1'").arg(item->uniq()), - QVariant::Double, KSysGuard::UnitPercent, 0, 100)); + QMetaType::Double, KSysGuard::UnitPercent, 0, 100)); } return result; diff --git a/sources/extsysmonsources/requestsource.cpp b/sources/extsysmonsources/requestsource.cpp index 29b3cf3..f2f010e 100644 --- a/sources/extsysmonsources/requestsource.cpp +++ b/sources/extsysmonsources/requestsource.cpp @@ -46,7 +46,7 @@ QHash RequestSource::sources() const for (auto item : m_extNetRequest->activeItems()) result.insert(item->tag("response"), - makeSensorInfo(QString("Network response for %1").arg(item->uniq()), QVariant::String)); + makeSensorInfo(QString("Network response for %1").arg(item->uniq()), QMetaType::QString)); return result; } diff --git a/sources/extsysmonsources/systeminfosource.cpp b/sources/extsysmonsources/systeminfosource.cpp index a77b8a8..7642b85 100644 --- a/sources/extsysmonsources/systeminfosource.cpp +++ b/sources/extsysmonsources/systeminfosource.cpp @@ -54,8 +54,8 @@ QHash SystemInfoSource::sources() const { auto result = QHash(); - result.insert("brightness", makeSensorInfo("Screen brightness", QVariant::Double, KSysGuard::UnitPercent, 0, 100)); - result.insert("volume", makeSensorInfo("Master volume", QVariant::Double, KSysGuard::UnitNone)); + result.insert("brightness", makeSensorInfo("Screen brightness", QMetaType::Double, KSysGuard::UnitPercent, 0, 100)); + result.insert("volume", makeSensorInfo("Master volume", QMetaType::Double, KSysGuard::UnitNone)); return result; } diff --git a/sources/extsysmonsources/timesource.cpp b/sources/extsysmonsources/timesource.cpp index 4a7bdd6..a8fe2bb 100644 --- a/sources/extsysmonsources/timesource.cpp +++ b/sources/extsysmonsources/timesource.cpp @@ -43,7 +43,7 @@ QHash TimeSource::sources() const { auto result = QHash(); - result.insert("now", makeSensorInfo("Current time", QVariant::LongLong, KSysGuard::UnitSecond)); + result.insert("now", makeSensorInfo("Current time", QMetaType::LongLong, KSysGuard::UnitSecond)); return result; } diff --git a/sources/extsysmonsources/upgradesource.cpp b/sources/extsysmonsources/upgradesource.cpp index 7c2b3e1..011d7f9 100644 --- a/sources/extsysmonsources/upgradesource.cpp +++ b/sources/extsysmonsources/upgradesource.cpp @@ -46,7 +46,7 @@ QHash UpgradeSource::sources() const for (auto item : m_extUpgrade->activeItems()) result.insert(item->tag("pkgcount"), - makeSensorInfo(QString("Package manager '%1' metadata").arg(item->uniq()), QVariant::Int)); + makeSensorInfo(QString("Package manager '%1' metadata").arg(item->uniq()), QMetaType::Int)); return result; } diff --git a/sources/extsysmonsources/weathersource.cpp b/sources/extsysmonsources/weathersource.cpp index 709d36e..c013a2a 100644 --- a/sources/extsysmonsources/weathersource.cpp +++ b/sources/extsysmonsources/weathersource.cpp @@ -48,17 +48,17 @@ QHash WeatherSource::sources() const for (auto item : m_extWeather->activeItems()) { result.insert(item->tag("weatherId"), makeSensorInfo(QString("Numeric weather ID for '%1'").arg(item->uniq()), - QVariant::Int, KSysGuard::UnitNone, 0, 1000)); + QMetaType::Int, KSysGuard::UnitNone, 0, 1000)); result.insert(item->tag("weather"), - makeSensorInfo(QString("ID string map for '%1'").arg(item->uniq()), QVariant::String)); + makeSensorInfo(QString("ID string map for '%1'").arg(item->uniq()), QMetaType::QString)); result.insert(item->tag("humidity"), makeSensorInfo(QString("Humidity for '%1'").arg(item->uniq()), - QVariant::Int, KSysGuard::UnitPercent, 0, 100)); + QMetaType::Int, KSysGuard::UnitPercent, 0, 100)); result.insert(item->tag("pressure"), - makeSensorInfo(QString("Atmospheric pressure for '%1'").arg(item->uniq()), QVariant::Int)); + makeSensorInfo(QString("Atmospheric pressure for '%1'").arg(item->uniq()), QMetaType::Int)); result.insert(item->tag("temperature"), makeSensorInfo(QString("Temperature for '%1'").arg(item->uniq()), - QVariant::Double, KSysGuard::UnitCelsius)); + QMetaType::Double, KSysGuard::UnitCelsius)); result.insert(item->tag("timestamp"), makeSensorInfo(QString("Timestamp for '%1'").arg(item->uniq()), - QVariant::DateTime, KSysGuard::UnitNone)); + QMetaType::QDateTime, KSysGuard::UnitNone)); } return result; diff --git a/sources/test/testabstractextitem.cpp b/sources/test/testabstractextitem.cpp index e523fa1..75368ad 100644 --- a/sources/test/testabstractextitem.cpp +++ b/sources/test/testabstractextitem.cpp @@ -34,7 +34,7 @@ void TestAbstractExtItem::initTestCase() comment = AWTestLibrary::randomString(); socket = AWTestLibrary::randomString(); - extItem = new ExtUpgrade(nullptr, filePath); + extItem = new ExtUpgrade(this, filePath); extItem->setActive(false); extItem->setApiVersion(1); extItem->setComment(comment); @@ -48,7 +48,6 @@ void TestAbstractExtItem::initTestCase() void TestAbstractExtItem::cleanupTestCase() { QFile::remove(filePath); - delete extItem; } @@ -83,7 +82,7 @@ void TestAbstractExtItem::test_configuration() QCOMPARE(newExtItem->socket(), extItem->socket()); QCOMPARE(newExtItem->cron(), extItem->cron()); - delete newExtItem; + newExtItem->deleteLater(); } @@ -102,7 +101,7 @@ void TestAbstractExtItem::test_delete() QVERIFY(newExtItem->tryDelete()); QVERIFY(!QFile::exists(writeFilePath)); - delete newExtItem; + newExtItem->deleteLater(); } @@ -117,7 +116,7 @@ void TestAbstractExtItem::test_copy() QCOMPARE(newExtItem->socket(), extItem->socket()); QCOMPARE(newExtItem->cron(), extItem->cron()); - delete newExtItem; + newExtItem->deleteLater(); } diff --git a/sources/test/testabstractformatter.cpp b/sources/test/testabstractformatter.cpp index ccd3fcb..1e27620 100644 --- a/sources/test/testabstractformatter.cpp +++ b/sources/test/testabstractformatter.cpp @@ -26,14 +26,11 @@ void TestAbstractFormatter::initTestCase() { AWTestLibrary::init(); - formatter = new AWNoFormatter(nullptr); + formatter = new AWNoFormatter(this); } -void TestAbstractFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAbstractFormatter::cleanupTestCase() {} void TestAbstractFormatter::test_values() {} @@ -58,7 +55,7 @@ void TestAbstractFormatter::test_copy() QCOMPARE(newFormatter->type(), formatter->type()); QCOMPARE(newFormatter->name(), formatter->name()); - delete newFormatter; + newFormatter->deleteLater(); } diff --git a/sources/test/testawbugreporter.cpp b/sources/test/testawbugreporter.cpp index 8cf26ee..4dc19f7 100644 --- a/sources/test/testawbugreporter.cpp +++ b/sources/test/testawbugreporter.cpp @@ -31,10 +31,7 @@ void TestAWBugReporter::initTestCase() } -void TestAWBugReporter::cleanupTestCase() -{ - delete plugin; -} +void TestAWBugReporter::cleanupTestCase() {} void TestAWBugReporter::test_generateText() @@ -54,7 +51,7 @@ void TestAWBugReporter::test_sendBugReport() plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3))); QVERIFY(spy.wait(5000)); - QVariantList arguments = spy.takeFirst(); + auto arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toInt() > 0); QVERIFY(!arguments.at(1).toString().isEmpty()); diff --git a/sources/test/testawconfighelper.cpp b/sources/test/testawconfighelper.cpp index c10ab4c..64f0de7 100644 --- a/sources/test/testawconfighelper.cpp +++ b/sources/test/testawconfighelper.cpp @@ -30,10 +30,7 @@ void TestAWConfigHelper::initTestCase() } -void TestAWConfigHelper::cleanupTestCase() -{ - delete plugin; -} +void TestAWConfigHelper::cleanupTestCase() {} void TestAWConfigHelper::test_configurationDirectory() diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index 0c9c0a7..00799c0 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -67,10 +67,7 @@ void TestAWKeys::initTestCase() } -void TestAWKeys::cleanupTestCase() -{ - delete plugin; -} +void TestAWKeys::cleanupTestCase() {} void TestAWKeys::test_dictKeys() diff --git a/sources/test/testawpatternfunctions.cpp b/sources/test/testawpatternfunctions.cpp index 7de2030..a7f4abc 100644 --- a/sources/test/testawpatternfunctions.cpp +++ b/sources/test/testawpatternfunctions.cpp @@ -42,7 +42,7 @@ void TestAWPatternFunctions::test_findFunctionCalls() auto pattern = AWTestLibrary::randomString() + function + AWTestLibrary::randomString(); - QList found = AWPatternFunctions::findFunctionCalls(name, pattern); + auto found = AWPatternFunctions::findFunctionCalls(name, pattern); QCOMPARE(found.count(), 1); QCOMPARE(found.at(0).args, args); diff --git a/sources/test/testawtelemetryhandler.cpp b/sources/test/testawtelemetryhandler.cpp index a9a15cb..7bd4e7e 100644 --- a/sources/test/testawtelemetryhandler.cpp +++ b/sources/test/testawtelemetryhandler.cpp @@ -33,10 +33,7 @@ void TestAWTelemetryHandler::initTestCase() } -void TestAWTelemetryHandler::cleanupTestCase() -{ - delete plugin; -} +void TestAWTelemetryHandler::cleanupTestCase() {} void TestAWTelemetryHandler::test_put() diff --git a/sources/test/testawupdatehelper.cpp b/sources/test/testawupdatehelper.cpp index 0825da4..b8750a0 100644 --- a/sources/test/testawupdatehelper.cpp +++ b/sources/test/testawupdatehelper.cpp @@ -30,10 +30,7 @@ void TestAWUpdateHelper::initTestCase() } -void TestAWUpdateHelper::cleanupTestCase() -{ - delete plugin; -} +void TestAWUpdateHelper::cleanupTestCase() {} void TestAWUpdateHelper::test_checkVersion() diff --git a/sources/test/testbatterysource.cpp b/sources/test/testbatterysource.cpp index 693cb8b..82a2368 100644 --- a/sources/test/testbatterysource.cpp +++ b/sources/test/testbatterysource.cpp @@ -32,10 +32,7 @@ void TestBatterySource::initTestCase() } -void TestBatterySource::cleanupTestCase() -{ - delete source; -} +void TestBatterySource::cleanupTestCase() {} void TestBatterySource::test_sources() @@ -53,11 +50,11 @@ void TestBatterySource::test_battery() std::for_each(batteries.cbegin(), batteries.cend(), [this](auto bat) { auto value = source->data(bat); if (bat == "ac") - QCOMPARE(value.type(), QVariant::Bool); + QCOMPARE(value.typeId(), QMetaType::Bool); else if (bat.startsWith("batrate") || bat.startsWith("batleft")) ; else - QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat()))); + QVERIFY((value.toDouble() >= battery.first) || (std::isnan(value.toDouble()))); }); } diff --git a/sources/test/testdatetimeformatter.cpp b/sources/test/testdatetimeformatter.cpp index fd51fd6..11aff2e 100644 --- a/sources/test/testdatetimeformatter.cpp +++ b/sources/test/testdatetimeformatter.cpp @@ -29,15 +29,12 @@ void TestAWDateTimeFormatter::initTestCase() AWTestLibrary::init(); format = AWTestLibrary::randomSelect(QString(TIME_KEYS).split(',')).join(' '); - formatter = new AWDateTimeFormatter(nullptr); + formatter = new AWDateTimeFormatter(this); formatter->setFormat(format); } -void TestAWDateTimeFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAWDateTimeFormatter::cleanupTestCase() {} void TestAWDateTimeFormatter::test_values() @@ -62,7 +59,7 @@ void TestAWDateTimeFormatter::test_copy() QCOMPARE(newFormatter->translateString(), formatter->translateString()); QCOMPARE(newFormatter->number(), 1); - delete newFormatter; + newFormatter->deleteLater(); } diff --git a/sources/test/testdesktopsource.cpp b/sources/test/testdesktopsource.cpp index fbff573..d24458d 100644 --- a/sources/test/testdesktopsource.cpp +++ b/sources/test/testdesktopsource.cpp @@ -31,10 +31,7 @@ void TestDesktopSource::initTestCase() } -void TestDesktopSource::cleanupTestCase() -{ - delete source; -} +void TestDesktopSource::cleanupTestCase() {} void TestDesktopSource::test_sources() diff --git a/sources/test/testdpplugin.cpp b/sources/test/testdpplugin.cpp index ed312ee..0e25e6d 100644 --- a/sources/test/testdpplugin.cpp +++ b/sources/test/testdpplugin.cpp @@ -32,10 +32,7 @@ void TestDPPlugin::initTestCase() } -void TestDPPlugin::cleanupTestCase() -{ - delete plugin; -} +void TestDPPlugin::cleanupTestCase() {} void TestDPPlugin::test_desktops() diff --git a/sources/test/testextitemaggregator.cpp b/sources/test/testextitemaggregator.cpp index c25dec6..c473004 100644 --- a/sources/test/testextitemaggregator.cpp +++ b/sources/test/testextitemaggregator.cpp @@ -27,14 +27,11 @@ void TestExtItemAggregator::initTestCase() { AWTestLibrary::init(); - aggregator = new ExtItemAggregator(nullptr, type); + aggregator = new ExtItemAggregator(this, type); } -void TestExtItemAggregator::cleanupTestCase() -{ - delete aggregator; -} +void TestExtItemAggregator::cleanupTestCase() {} void TestExtItemAggregator::test_values() diff --git a/sources/test/testextquotes.cpp b/sources/test/testextquotes.cpp index 1491965..b5aa0b6 100644 --- a/sources/test/testextquotes.cpp +++ b/sources/test/testextquotes.cpp @@ -26,7 +26,7 @@ void TestExtQuotes::initTestCase() { AWTestLibrary::init(); - extQuotes = new ExtQuotes(nullptr); + extQuotes = new ExtQuotes(this); extQuotes->setInterval(1); extQuotes->setTicker(ticker); extQuotes->setNumber(0); @@ -35,10 +35,7 @@ void TestExtQuotes::initTestCase() } -void TestExtQuotes::cleanupTestCase() -{ - delete extQuotes; -} +void TestExtQuotes::cleanupTestCase() {} void TestExtQuotes::test_values() @@ -96,7 +93,7 @@ void TestExtQuotes::test_copy() QCOMPARE(newExtQuotes->ticker(), extQuotes->ticker()); QCOMPARE(newExtQuotes->number(), 1); - delete newExtQuotes; + newExtQuotes->deleteLater(); } diff --git a/sources/test/testextscript.cpp b/sources/test/testextscript.cpp index ecfc714..b516ca9 100644 --- a/sources/test/testextscript.cpp +++ b/sources/test/testextscript.cpp @@ -28,7 +28,7 @@ void TestExtScript::initTestCase() AWTestLibrary::init(); randomString = AWTestLibrary::randomString(); - extScript = new ExtScript(nullptr); + extScript = new ExtScript(this); extScript->setInterval(1); extScript->setExecutable(QString("echo %1").arg(randomString)); extScript->setNumber(0); @@ -38,10 +38,7 @@ void TestExtScript::initTestCase() } -void TestExtScript::cleanupTestCase() -{ - delete extScript; -} +void TestExtScript::cleanupTestCase() {} void TestExtScript::test_values() @@ -95,7 +92,7 @@ void TestExtScript::test_copy() QCOMPARE(newExtScript->filters(), extScript->filters()); QCOMPARE(newExtScript->number(), 1); - delete newExtScript; + newExtScript->deleteLater(); } diff --git a/sources/test/testextupgrade.cpp b/sources/test/testextupgrade.cpp index a6a9ba7..a6491df 100644 --- a/sources/test/testextupgrade.cpp +++ b/sources/test/testextupgrade.cpp @@ -29,7 +29,7 @@ void TestExtUpgrade::initTestCase() randomStrings = AWTestLibrary::randomStringList(); cmd = QString("echo -e '%1'").arg(randomStrings.join("\n")); - extUpgrade = new ExtUpgrade(nullptr); + extUpgrade = new ExtUpgrade(this); extUpgrade->setInterval(1); extUpgrade->setExecutable(cmd); extUpgrade->setNumber(0); @@ -38,10 +38,7 @@ void TestExtUpgrade::initTestCase() } -void TestExtUpgrade::cleanupTestCase() -{ - delete extUpgrade; -} +void TestExtUpgrade::cleanupTestCase() {} void TestExtUpgrade::test_values() @@ -106,7 +103,7 @@ void TestExtUpgrade::test_copy() QCOMPARE(newExtUpgrade->null(), extUpgrade->null()); QCOMPARE(newExtUpgrade->number(), 1); - delete newExtUpgrade; + newExtUpgrade->deleteLater(); } diff --git a/sources/test/testextweather.cpp b/sources/test/testextweather.cpp index 9f581dd..c0c830b 100644 --- a/sources/test/testextweather.cpp +++ b/sources/test/testextweather.cpp @@ -26,7 +26,7 @@ void TestExtWeather::initTestCase() { AWTestLibrary::init(); - extWeather = new ExtWeather(nullptr); + extWeather = new ExtWeather(this); extWeather->setInterval(1); extWeather->setCity(city); extWeather->setCountry(country); @@ -37,10 +37,7 @@ void TestExtWeather::initTestCase() } -void TestExtWeather::cleanupTestCase() -{ - delete extWeather; -} +void TestExtWeather::cleanupTestCase() {} void TestExtWeather::test_values() @@ -95,7 +92,7 @@ void TestExtWeather::test_copy() QCOMPARE(newExtWeather->provider(), extWeather->provider()); QCOMPARE(newExtWeather->number(), 1); - delete newExtWeather; + newExtWeather->deleteLater(); } @@ -114,8 +111,8 @@ void TestExtWeather::run() && (arguments[extWeather->tag("humidity")].toInt() <= humidity.second)); QVERIFY((arguments[extWeather->tag("pressure")].toInt() > pressure.first) && (arguments[extWeather->tag("pressure")].toInt() < pressure.second)); - QVERIFY((arguments[extWeather->tag("temperature")].toFloat() > temp.first) - && (arguments[extWeather->tag("temperature")].toFloat() < temp.second)); + QVERIFY((arguments[extWeather->tag("temperature")].toDouble() > temp.first) + && (arguments[extWeather->tag("temperature")].toDouble() < temp.second)); // image should be only one symbol here if (extWeather->jsonMapFile().isEmpty()) QSKIP("No json map found for weather, skip image test"); diff --git a/sources/test/testfloatformatter.cpp b/sources/test/testfloatformatter.cpp index b0dc410..ed50026 100644 --- a/sources/test/testfloatformatter.cpp +++ b/sources/test/testfloatformatter.cpp @@ -27,14 +27,11 @@ void TestAWFloatFormatter::initTestCase() { AWTestLibrary::init(); - formatter = new AWFloatFormatter(nullptr); + formatter = new AWFloatFormatter(this); } -void TestAWFloatFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAWFloatFormatter::cleanupTestCase() {} void TestAWFloatFormatter::test_values() {} @@ -95,7 +92,7 @@ void TestAWFloatFormatter::test_forceWidth() void TestAWFloatFormatter::test_format() { // assign - QWARN("Lets assing 'z' formatter, it should cause a warning"); + qWarning("Lets assign 'z' formatter, it should cause a warning"); formatter->setFormat('z'); QCOMPARE(formatter->format(), 'f'); formatter->setFormat('e'); @@ -175,7 +172,7 @@ void TestAWFloatFormatter::test_copy() QCOMPARE(newFormatter->summand(), formatter->summand()); QCOMPARE(newFormatter->number(), 1); - delete newFormatter; + newFormatter->deleteLater(); } diff --git a/sources/test/testjsonformatter.cpp b/sources/test/testjsonformatter.cpp index 5ceffc2..24847f5 100644 --- a/sources/test/testjsonformatter.cpp +++ b/sources/test/testjsonformatter.cpp @@ -26,17 +26,14 @@ void TestAWJsonFormatter::initTestCase() { AWTestLibrary::init(); - formatter = new AWJsonFormatter(nullptr); + formatter = new AWJsonFormatter(this); generate(); formatter->setPath(path); } -void TestAWJsonFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAWJsonFormatter::cleanupTestCase() {} void TestAWJsonFormatter::test_values() @@ -58,7 +55,7 @@ void TestAWJsonFormatter::test_copy() QCOMPARE(newFormatter->path(), formatter->path()); QCOMPARE(newFormatter->number(), 1); - delete newFormatter; + newFormatter->deleteLater(); } @@ -79,8 +76,7 @@ void TestAWJsonFormatter::generate() } else { auto key = AWTestLibrary::randomString(); auto val = AWTestLibrary::randomString(); - QVariantMap dict; - dict[key] = val; + QVariantMap dict{{key, val}}; second.append(dict); } } diff --git a/sources/test/testlistformatter.cpp b/sources/test/testlistformatter.cpp index ef72b0a..ed77e23 100644 --- a/sources/test/testlistformatter.cpp +++ b/sources/test/testlistformatter.cpp @@ -28,15 +28,12 @@ void TestAWListFormatter::initTestCase() AWTestLibrary::init(); separator = AWTestLibrary::randomString(9, 10); - formatter = new AWListFormatter(nullptr); + formatter = new AWListFormatter(this); formatter->setSeparator(separator); } -void TestAWListFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAWListFormatter::cleanupTestCase() {} void TestAWListFormatter::test_values() @@ -85,7 +82,7 @@ void TestAWListFormatter::test_copy() QCOMPARE(newFormatter->separator(), formatter->separator()); QCOMPARE(newFormatter->isSorted(), formatter->isSorted()); - delete newFormatter; + newFormatter->deleteLater(); } diff --git a/sources/test/testnetworksource.cpp b/sources/test/testnetworksource.cpp index 69f74a5..ff84b99 100644 --- a/sources/test/testnetworksource.cpp +++ b/sources/test/testnetworksource.cpp @@ -30,10 +30,7 @@ void TestNetworkSource::initTestCase() } -void TestNetworkSource::cleanupTestCase() -{ - delete source; -} +void TestNetworkSource::cleanupTestCase() {} void TestNetworkSource::test_sources() diff --git a/sources/test/testnoformatter.cpp b/sources/test/testnoformatter.cpp index 9160b1a..e7062c4 100644 --- a/sources/test/testnoformatter.cpp +++ b/sources/test/testnoformatter.cpp @@ -26,14 +26,11 @@ void TestAWNoFormatter::initTestCase() { AWTestLibrary::init(); - formatter = new AWNoFormatter(nullptr); + formatter = new AWNoFormatter(this); } -void TestAWNoFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAWNoFormatter::cleanupTestCase() {} void TestAWNoFormatter::test_values() {} @@ -45,7 +42,7 @@ void TestAWNoFormatter::test_conversion() auto randomInt = AWTestLibrary::randomInt(); QCOMPARE(formatter->convert(randomInt), QString::number(randomInt)); // float - QWARN("Float conversion isn't tested here due to possible rounding errors"); + qWarning("Float conversion isn't tested here due to possible rounding errors"); // string auto randomString = AWTestLibrary::randomString(); QCOMPARE(formatter->convert(randomString), randomString); @@ -58,7 +55,7 @@ void TestAWNoFormatter::test_copy() QCOMPARE(newFormatter->number(), 1); - delete newFormatter; + newFormatter->deleteLater(); } diff --git a/sources/test/testplayersource.cpp b/sources/test/testplayersource.cpp index 25a3687..4a5871a 100644 --- a/sources/test/testplayersource.cpp +++ b/sources/test/testplayersource.cpp @@ -67,8 +67,10 @@ void TestPlayerSource::test_autoMpris() auto source = new PlayerSource(this, "mpris", mpdAddress, mpdPort, "auto", 10); auto empty = source->getAutoMpris().isEmpty(); + source->deleteLater(); + if (empty) - QWARN("No MPRIS found, manual check required"); + qWarning("No MPRIS found, manual check required"); else QVERIFY(!empty); } @@ -95,6 +97,8 @@ void TestPlayerSource::test_mpd() QSKIP("No mpd found"); QVERIFY(secondValue["progress"].toInt() < secondValue["duration"].toInt()); + + source->deleteLater(); } @@ -112,6 +116,8 @@ void TestPlayerSource::test_mpris() QSKIP("No mpris found"); QVERIFY(progress < duration); + + source->deleteLater(); } diff --git a/sources/test/testprocessessource.cpp b/sources/test/testprocessessource.cpp index d1c1f9b..b5668a3 100644 --- a/sources/test/testprocessessource.cpp +++ b/sources/test/testprocessessource.cpp @@ -30,10 +30,7 @@ void TestProcessesSource::initTestCase() } -void TestProcessesSource::cleanupTestCase() -{ - delete source; -} +void TestProcessesSource::cleanupTestCase() {} void TestProcessesSource::test_sources() diff --git a/sources/test/testscriptformatter.cpp b/sources/test/testscriptformatter.cpp index 14f710e..741bf4b 100644 --- a/sources/test/testscriptformatter.cpp +++ b/sources/test/testscriptformatter.cpp @@ -33,10 +33,7 @@ void TestAWScriptFormatter::initTestCase() } -void TestAWScriptFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAWScriptFormatter::cleanupTestCase() {} void TestAWScriptFormatter::test_values() @@ -100,7 +97,7 @@ void TestAWScriptFormatter::test_copy() QCOMPARE(newFormatter->program(), formatter->program()); QCOMPARE(newFormatter->number(), 1); - delete newFormatter; + newFormatter->deleteLater(); } diff --git a/sources/test/teststringformatter.cpp b/sources/test/teststringformatter.cpp index c6bbaf2..d31f9ef 100644 --- a/sources/test/teststringformatter.cpp +++ b/sources/test/teststringformatter.cpp @@ -26,14 +26,11 @@ void TestAWStringFormatter::initTestCase() { AWTestLibrary::init(); - formatter = new AWStringFormatter(nullptr); + formatter = new AWStringFormatter(this); } -void TestAWStringFormatter::cleanupTestCase() -{ - delete formatter; -} +void TestAWStringFormatter::cleanupTestCase() {} void TestAWStringFormatter::test_values() {} @@ -104,7 +101,7 @@ void TestAWStringFormatter::test_copy() QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth()); QCOMPARE(newFormatter->number(), 1); - delete newFormatter; + newFormatter->deleteLater(); }