diff --git a/common/control.cpp b/common/control.cpp --- a/common/control.cpp +++ b/common/control.cpp @@ -223,7 +223,7 @@ Control::OutputRetention ControlConfig::getOutputRetention(const QString &outputId, const QString &outputName) const { const QVariantList outputsInfo = getOutputs(); - for (const auto variantInfo : outputsInfo) { + for (const auto &variantInfo : outputsInfo) { const QVariantMap info = variantInfo.toMap(); if (!infoIsOutput(info, outputId, outputName)) { continue; @@ -287,7 +287,7 @@ const auto retention = getOutputRetention(outputId, outputName); if (retention == OutputRetention::Individual) { const QVariantList outputsInfo = getOutputs(); - for (const auto variantInfo : outputsInfo) { + for (const auto &variantInfo : outputsInfo) { const QVariantMap info = variantInfo.toMap(); if (!infoIsOutput(info, outputId, outputName)) { continue; @@ -353,7 +353,7 @@ const auto retention = getOutputRetention(outputId, outputName); if (retention == OutputRetention::Individual) { const QVariantList outputsInfo = getOutputs(); - for (const auto variantInfo : outputsInfo) { + for (const auto &variantInfo : outputsInfo) { const QVariantMap info = variantInfo.toMap(); if (!infoIsOutput(info, outputId, outputName)) { continue; @@ -420,7 +420,7 @@ const auto retention = getOutputRetention(outputId, outputName); if (retention == OutputRetention::Individual) { const QVariantList outputsInfo = getOutputs(); - for (const auto variantInfo : outputsInfo) { + for (const auto &variantInfo : outputsInfo) { const QVariantMap info = variantInfo.toMap(); if (!infoIsOutput(info, outputId, outputName)) { continue; @@ -486,7 +486,7 @@ const QString &outputName) const { const QVariantList outputsInfo = getOutputs(); - for (const auto variantInfo : outputsInfo) { + for (const auto &variantInfo : outputsInfo) { const QVariantMap info = variantInfo.toMap(); if (!infoIsOutput(info, outputId, outputName)) { continue; @@ -499,7 +499,7 @@ return nullptr; } - for (auto output : m_config->outputs()) { + for (const auto &output : m_config->outputs()) { if (output->hashMd5() == sourceHash && output->name() == sourceName) { return output; } diff --git a/common/orientation_sensor.h b/common/orientation_sensor.h --- a/common/orientation_sensor.h +++ b/common/orientation_sensor.h @@ -19,7 +19,7 @@ #include #include -class OrientationSensor : public QObject +class OrientationSensor final : public QObject { Q_OBJECT public: diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -374,7 +374,7 @@ // Scaling the fonts makes sense if you don't also set a font DPI, but we NEED to set a font // DPI for both PlasmaShell which does it's own thing, and for KDE4/GTK2 applications. QString screenFactors; - for (const KScreen::OutputPtr output : m_config->config()->outputs()) { + for (const auto &output: m_config->config()->outputs()) { screenFactors.append(output->name() + QLatin1Char('=') + QString::number(m_globalScale) + QLatin1Char(';')); } config->group("KScreen").writeEntry("ScreenScaleFactors", screenFactors); diff --git a/kcm/output_model.h b/kcm/output_model.h --- a/kcm/output_model.h +++ b/kcm/output_model.h @@ -87,10 +87,19 @@ : ptr(output.ptr) , pos(output.pos) {} + Output(Output &&) noexcept = default; Output(KScreen::OutputPtr _ptr, const QPoint &_pos) : ptr(_ptr) , pos(_pos) {} + Output &operator=(const Output &output) { + ptr = output.ptr; + pos = output.pos; + posReset = QPoint(-1, -1); + return *this; + } + Output &operator=(Output &&) noexcept = default; + KScreen::OutputPtr ptr; QPoint pos; QPoint posReset = QPoint(-1, -1); diff --git a/kcm/output_model.cpp b/kcm/output_model.cpp --- a/kcm/output_model.cpp +++ b/kcm/output_model.cpp @@ -225,7 +225,7 @@ connect(output.data(), &KScreen::Output::isPrimaryChanged, this, [this, output](){ - roleChanged(output->id(), {PrimaryRole}); + roleChanged(output->id(), PrimaryRole); }); Q_EMIT endInsertRows(); diff --git a/kded/config.cpp b/kded/config.cpp --- a/kded/config.cpp +++ b/kded/config.cpp @@ -229,7 +229,7 @@ info[QStringLiteral("primary")] = output->isPrimary(); info[QStringLiteral("enabled")] = output->isEnabled(); - auto setOutputConfigInfo = [this, &info](const KScreen::OutputPtr &out) { + auto setOutputConfigInfo = [&info](const KScreen::OutputPtr &out) { if (!out) { return; } @@ -268,7 +268,7 @@ return; } const auto outputs = m_data->outputs(); - for (const auto o : outputs) { + for (const auto &o : outputs) { if (o->isConnected()) { qCDebug(KSCREEN_KDED) << o; } diff --git a/kded/generator.cpp b/kded/generator.cpp --- a/kded/generator.cpp +++ b/kded/generator.cpp @@ -330,7 +330,7 @@ //At this point, we know we have common sizes, let's get the biggest on - QList commonSizeList = commonSizes.toList(); + QList commonSizeList = commonSizes.values(); std::sort(commonSizeList.begin(), commonSizeList.end()); const QSize biggestSize = commonSizeList.last(); diff --git a/kded/output.cpp b/kded/output.cpp --- a/kded/output.cpp +++ b/kded/output.cpp @@ -163,7 +163,7 @@ KScreen::OutputList outputs = config->outputs(); QVector sortedOutputs; // - for (const KScreen::OutputPtr output : outputs) { + for (const KScreen::OutputPtr &output : outputs) { sortedOutputs.append(Out(output->id(), output->pos())); } @@ -262,7 +262,7 @@ const int bottomToBottomDiffAbs = qAbs(prevInfoGeo.y() + prevInfoGeo.height() - curInfoGeo.y() - curInfoGeo.height()); const int bottomToTopDiffAbs = qAbs(prevInfoGeo.y() + prevInfoGeo.height() - curInfoGeo.y()); - const bool yTopAligned = topToTopDiffAbs < bottomToBottomDiffAbs && topToTopDiffAbs <= bottomToTopDiffAbs || + const bool yTopAligned = (topToTopDiffAbs < bottomToBottomDiffAbs && topToTopDiffAbs <= bottomToTopDiffAbs) || topToBottomDiffAbs < bottomToBottomDiffAbs; int yInfoDiff = curInfoGeo.y() - prevInfoGeo.y(); diff --git a/tests/kded/configtest.cpp b/tests/kded/configtest.cpp --- a/tests/kded/configtest.cpp +++ b/tests/kded/configtest.cpp @@ -115,7 +115,7 @@ void TestConfig::testSimpleConfig() { auto configWrapper = createConfig(true, false); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("simpleConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("simpleConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -137,7 +137,7 @@ void TestConfig::testTwoScreenConfig() { auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("twoScreenConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -169,7 +169,7 @@ void TestConfig::testRotatedScreenConfig() { auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("rotatedScreenConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("rotatedScreenConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -201,7 +201,7 @@ void TestConfig::testDisabledScreenConfig() { auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("disabledScreenConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("disabledScreenConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -228,15 +228,15 @@ void TestConfig::testConfig404() { auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("filenotfoundConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("filenotfoundConfig.json")); QVERIFY(!configWrapper); } void TestConfig::testCorruptConfig() { auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("corruptConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("corruptConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -247,7 +247,7 @@ void TestConfig::testCorruptEmptyConfig() { auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("corruptEmptyConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("corruptEmptyConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -258,7 +258,7 @@ void TestConfig::testCorruptUselessConfig() { auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("corruptUselessConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("corruptUselessConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -381,7 +381,7 @@ positions[QStringLiteral("DVI-0")] = QPoint(4020, 1080); positions[QStringLiteral("DVI-1")] = QPoint(0, 0); - auto configWrapper2 = std::move(configWrapper.readFile(QStringLiteral("outputgrid_2x3.json"))); + auto configWrapper2 = configWrapper.readFile(QStringLiteral("outputgrid_2x3.json")); KScreen::ConfigPtr config2 = configWrapper2->data(); QVERIFY(config2); QVERIFY(config != config2); @@ -405,7 +405,7 @@ // Load a dualhead config auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("twoScreenConfig.json")); auto config = configWrapper->data(); QVERIFY(config); @@ -453,7 +453,7 @@ QVERIFY(closedCfg.exists()); // Switcheroolooloo... - configWrapper = std::move(configWrapper->readOpenLidFile()); + configWrapper = configWrapper->readOpenLidFile(); QVERIFY(configWrapper); // Check actual files, src should be gone, dest must exist @@ -474,7 +474,7 @@ QCOMPARE(output2->isPrimary(), false); // Make sure we don't screw up when there's no _lidOpened config - configWrapper = std::move(configWrapper->readOpenLidFile()); + configWrapper = configWrapper->readOpenLidFile(); config = configWrapper->data(); output = config->connectedOutputs().first(); @@ -492,7 +492,7 @@ { // Load a dualhead config auto configWrapper = createConfig(true, true); - configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); + configWrapper = configWrapper->readFile(QStringLiteral("twoScreenConfig.json")); auto config = configWrapper->data(); QVERIFY(config);