Verified Commit 51fd5866 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

refactor: fix various compiler warnings

Summary:
Fixes pessimizing move, implicit copy assignment operator, copies
in range for loops, deprecated Qt methods, missing `final` keyword
and unused lambda capture.

Built with Clang 10

Reviewers: #plasma, romangg

Reviewed By: #plasma, romangg

Subscribers: romangg, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27626
parent 1dc2ca34
......@@ -223,7 +223,7 @@ Control::OutputRetention ControlConfig::getOutputRetention(const KScreen::Output
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 @@ qreal ControlConfig::getScale(const QString &outputId, const QString &outputName
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 @@ bool ControlConfig::getAutoRotate(const QString &outputId, const QString &output
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 @@ bool ControlConfig::getAutoRotateOnlyInTabletMode(const QString &outputId,
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 @@ KScreen::OutputPtr ControlConfig::getReplicationSource(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;
......@@ -499,7 +499,7 @@ KScreen::OutputPtr ControlConfig::getReplicationSource(const QString &outputId,
return nullptr;
}
for (auto output : m_config->outputs()) {
for (const auto &output : m_config->outputs()) {
if (output->hashMd5() == sourceHash && output->name() == sourceName) {
return output;
}
......
......@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QObject>
#include <QOrientationReading>
class OrientationSensor : public QObject
class OrientationSensor final : public QObject
{
Q_OBJECT
public:
......
......@@ -374,7 +374,7 @@ void KCMKScreen::writeGlobalScale()
// 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);
......
......@@ -225,7 +225,7 @@ void OutputModel::add(const KScreen::OutputPtr &output)
connect(output.data(), &KScreen::Output::isPrimaryChanged,
this, [this, output](){
roleChanged(output->id(), {PrimaryRole});
roleChanged(output->id(), PrimaryRole);
});
Q_EMIT endInsertRows();
......
......@@ -87,10 +87,19 @@ private:
: 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);
......
......@@ -229,7 +229,7 @@ bool Config::writeFile(const QString &filePath)
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 @@ void Config::log()
return;
}
const auto outputs = m_data->outputs();
for (const auto o : outputs) {
for (const auto &o : outputs) {
if (o->isConnected()) {
qCDebug(KSCREEN_KDED) << o;
}
......
......@@ -330,7 +330,7 @@ void Generator::cloneScreens(KScreen::OutputList &connectedOutputs)
//At this point, we know we have common sizes, let's get the biggest on
QList<QSize> commonSizeList = commonSizes.toList();
QList<QSize> commonSizeList = commonSizes.values();
std::sort(commonSizeList.begin(), commonSizeList.end());
const QSize biggestSize = commonSizeList.last();
......
......@@ -163,7 +163,7 @@ void Output::adjustPositions(KScreen::ConfigPtr config, const QVariantList &outp
KScreen::OutputList outputs = config->outputs();
QVector<Out> sortedOutputs; // <id, pos>
for (const KScreen::OutputPtr output : outputs) {
for (const KScreen::OutputPtr &output : outputs) {
sortedOutputs.append(Out(output->id(), output->pos()));
}
......@@ -262,7 +262,7 @@ void Output::adjustPositions(KScreen::ConfigPtr config, const QVariantList &outp
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();
......
......@@ -115,7 +115,7 @@ void TestConfig::initTestCase()
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::testSimpleConfig()
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::testTwoScreenConfig()
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::testRotatedScreenConfig()
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,7 +228,7 @@ void TestConfig::testDisabledScreenConfig()
void TestConfig::testConfig404()
{
auto configWrapper = createConfig(true, true);
configWrapper = std::move(configWrapper->readFile(QStringLiteral("filenotfoundConfig.json")));
configWrapper = configWrapper->readFile(QStringLiteral("filenotfoundConfig.json"));
QVERIFY(!configWrapper);
}
......@@ -236,7 +236,7 @@ void TestConfig::testConfig404()
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::testCorruptConfig()
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::testCorruptEmptyConfig()
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 @@ void TestConfig::testIdenticalOutputs()
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 @@ void TestConfig::testMoveConfig()
// 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 @@ void TestConfig::testMoveConfig()
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 @@ void TestConfig::testMoveConfig()
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 @@ void TestConfig::testFixedConfig()
{
// 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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment