diff --git a/examples/dataengines/customDataContainers/customDataContainersEngine.h b/examples/dataengines/customDataContainers/customDataContainersEngine.h --- a/examples/dataengines/customDataContainers/customDataContainersEngine.h +++ b/examples/dataengines/customDataContainers/customDataContainersEngine.h @@ -36,8 +36,8 @@ DataContainersEngine(QObject *parent, const QVariantList &args); protected: - bool sourceRequestEvent(const QString &source); - bool updateSourceEvent(const QString &source); + bool sourceRequestEvent(const QString &source) override; + bool updateSourceEvent(const QString &source) override; }; #endif diff --git a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp --- a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp +++ b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp @@ -49,7 +49,7 @@ // the source to make sure it is indeed an http URL. QUrl url(source); qDebug() << "goin to fetch" << source << url << url.scheme(); - if (!url.scheme().startsWith("http", Qt::CaseInsensitive)) { + if (!url.scheme().startsWith(QLatin1String("http"), Qt::CaseInsensitive)) { return false; } diff --git a/examples/dataengines/customDataContainers/httpContainer.h b/examples/dataengines/customDataContainers/httpContainer.h --- a/examples/dataengines/customDataContainers/httpContainer.h +++ b/examples/dataengines/customDataContainers/httpContainer.h @@ -33,7 +33,7 @@ namespace KIO { class Job; -}; +} class HttpContainer : public Plasma::DataContainer { diff --git a/examples/dataengines/customDataContainers/httpContainer.cpp b/examples/dataengines/customDataContainers/httpContainer.cpp --- a/examples/dataengines/customDataContainers/httpContainer.cpp +++ b/examples/dataengines/customDataContainers/httpContainer.cpp @@ -74,15 +74,15 @@ // additional stats. Note that we don't include the source name, as that // is implied as this object *is* the DataContainer. setData is called // with just key/value pairs. - setData("Contents", m_data); - setData("Size", job->processedAmount(KJob::Bytes)); + setData(QStringLiteral("Contents"), m_data); + setData(QStringLiteral("Size"), job->processedAmount(KJob::Bytes)); // Since we only create TransferJobs, it's safe to just static_cast here. // In many real-world situations, this isn't the safest thing to do and a // qobject_cast with a test on the result is often safer and cleaner. KIO::TransferJob *tjob = static_cast(job); - setData("Error Page", tjob->isErrorPage()); - setData("Mimetype", tjob->mimetype()); + setData(QStringLiteral("Error Page"), tjob->isErrorPage()); + setData(QStringLiteral("Mimetype"), tjob->mimetype()); // Let DataContainer know we have data that needs storing setNeedsToBeStored(true); diff --git a/examples/dataengines/simpleEngine/simpleEngine.cpp b/examples/dataengines/simpleEngine/simpleEngine.cpp --- a/examples/dataengines/simpleEngine/simpleEngine.cpp +++ b/examples/dataengines/simpleEngine/simpleEngine.cpp @@ -56,21 +56,21 @@ // This is the simplest form, with source name and one bit of data. // Note how the source name is not translated! They can be marked with // I18N_NOOP, however, if they should be translatable in a visualization. - setData("Simple Source", i18n("Very simple data")); + setData(QStringLiteral("Simple Source"), i18n("Very simple data")); // a source can have multiple entries, differentiated by key names, // which are also not translated: - setData("Multiple Source", "First", i18n("First")); - setData("Multiple Source", "Second", i18n("Second")); + setData(QStringLiteral("Multiple Source"), QStringLiteral("First"), i18n("First")); + setData(QStringLiteral("Multiple Source"), QStringLiteral("Second"), i18n("Second")); // We can also set the data up first and apply it all at once // Note how data types other than strings can be used as well; anything // that works with QVariant, in fact. Plasma::DataEngine::Data data; - data.insert("Cow", "mooo"); - data.insert("Black", QColor(0, 0, 0)); - data.insert("Time", QTime::currentTime()); - setData("Another Source", data); + data.insert(QStringLiteral("Cow"), QStringLiteral("mooo")); + data.insert(QStringLiteral("Black"), QColor(0, 0, 0)); + data.insert(QStringLiteral("Time"), QTime::currentTime()); + setData(QStringLiteral("Another Source"), data); } // export the plugin; use the plugin name and the class name diff --git a/examples/dataengines/sourcesOnRequest/sourcesOnRequest.h b/examples/dataengines/sourcesOnRequest/sourcesOnRequest.h --- a/examples/dataengines/sourcesOnRequest/sourcesOnRequest.h +++ b/examples/dataengines/sourcesOnRequest/sourcesOnRequest.h @@ -36,8 +36,8 @@ SourcesOnRequestEngine(QObject *parent, const QVariantList &args); protected: - bool sourceRequestEvent(const QString &source); - bool updateSourceEvent(const QString &source); + bool sourceRequestEvent(const QString &source) override; + bool updateSourceEvent(const QString &source) override; }; #endif diff --git a/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp b/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp --- a/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp +++ b/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp @@ -51,7 +51,7 @@ // We're going to reject any sources that start with the letter 'a' // to demonstrate how to reject a request in a DataEngine. - if (source.startsWith('a') || source.startsWith('A')) { + if (source.startsWith(QLatin1Char('a')) || source.startsWith(QLatin1Char('A'))) { return false; } @@ -62,13 +62,13 @@ // In such a case the DataEngine will remain happy and Do The Right Thing(tm) // but the visualization will not get the source connected to it as it // expects. So ALWAYS key the new data by the source string as below: - setData(source, "Update Count", 0); + setData(source, QStringLiteral("Update Count"), 0); if (!modelForSource(source)) { QStandardItemModel *m = new QStandardItemModel; - m->appendRow(new QStandardItem("Item1, first update")); - m->appendRow(new QStandardItem("Item2, first update")); - m->appendRow(new QStandardItem("Item3, first update")); + m->appendRow(new QStandardItem(QStringLiteral("Item1, first update"))); + m->appendRow(new QStandardItem(QStringLiteral("Item2, first update"))); + m->appendRow(new QStandardItem(QStringLiteral("Item3, first update"))); setModel(source, m); } @@ -92,15 +92,15 @@ // sourceRequestEvent, however, this will result in expected behavior: visualizations // connected to the sources which have setData called for them will be notified // of these changes. - const int updateCount = containerForSource(source)->data().value("Update Count").toInt() + 1; - setData(source, "Update Count", updateCount); + const int updateCount = containerForSource(source)->data().value(QStringLiteral("Update Count")).toInt() + 1; + setData(source, QStringLiteral("Update Count"), updateCount); QStandardItemModel *m = qobject_cast(modelForSource(source)); if (m) { m->clear(); - m->appendRow(new QStandardItem(QString("Item1, update %1").arg(updateCount))); - m->appendRow(new QStandardItem(QString("Item2, update %1").arg(updateCount))); - m->appendRow(new QStandardItem(QString("Item3, update %1").arg(updateCount))); + m->appendRow(new QStandardItem(QStringLiteral("Item1, update %1").arg(updateCount))); + m->appendRow(new QStandardItem(QStringLiteral("Item2, update %1").arg(updateCount))); + m->appendRow(new QStandardItem(QStringLiteral("Item3, update %1").arg(updateCount))); } // Since we updated the source immediately here, we need to return true so the DataEngine diff --git a/examples/shell/customcorona.h b/examples/shell/customcorona.h --- a/examples/shell/customcorona.h +++ b/examples/shell/customcorona.h @@ -29,8 +29,8 @@ Q_OBJECT public: - explicit CustomCorona(QObject * parent = nullptr); - QRect screenGeometry(int id) const; + explicit CustomCorona(QObject *parent = nullptr); + QRect screenGeometry(int id) const override; public Q_SLOTS: void load(); diff --git a/examples/shell/customcorona.cpp b/examples/shell/customcorona.cpp --- a/examples/shell/customcorona.cpp +++ b/examples/shell/customcorona.cpp @@ -44,8 +44,6 @@ load(); } - - QRect CustomCorona::screenGeometry(int id) const { Q_UNUSED(id); @@ -57,7 +55,6 @@ { loadLayout(QStringLiteral("exampleplasmashell-appletsrc")); - bool desktopFound = false; for (auto c : containments()) { if (c->containmentType() == Plasma::Types::DesktopContainment) { @@ -69,18 +66,17 @@ if (!desktopFound) { qDebug() << "Loading default layout"; Plasma::Containment *c = createContainment(QStringLiteral("org.kde.desktopcontainment")); - c->createApplet("org.kde.plasma.analogclock"); + c->createApplet(QStringLiteral("org.kde.plasma.analogclock")); saveLayout(QStringLiteral("exampleplasmashell-appletsrc")); } //don't let containments to be removed for (auto c : containments()) { if (c->containmentType() == Plasma::Types::DesktopContainment) { //example of a shell without a wallpaper - c->setWallpaper("null"); + c->setWallpaper(QStringLiteral("null")); m_view->setContainment(c); - QAction *removeAction = c->actions()->action(QStringLiteral("remove")); - if(removeAction) { + if (QAction *removeAction = c->actions()->action(QStringLiteral("remove"))) { removeAction->deleteLater(); } break; diff --git a/examples/shell/main.cpp b/examples/shell/main.cpp --- a/examples/shell/main.cpp +++ b/examples/shell/main.cpp @@ -27,14 +27,12 @@ #include "customcorona.h" -static const char version[] = "1.0"; - int main(int argc, char **argv) { QQuickWindow::setDefaultAlphaBuffer(true); QApplication app(argc, argv); - app.setApplicationVersion(version); + app.setApplicationVersion(QStringLiteral("1.0")); app.setOrganizationDomain(QStringLiteral("kde.org")); KDBusService service(KDBusService::Unique); diff --git a/examples/testcontainmentactionsplugin/test.h b/examples/testcontainmentactionsplugin/test.h --- a/examples/testcontainmentactionsplugin/test.h +++ b/examples/testcontainmentactionsplugin/test.h @@ -32,14 +32,14 @@ void init(const KConfigGroup &config); - QList contextualActions(); + QList contextualActions() override; - void performNextAction(); - void performPreviousAction(); + void performNextAction() override; + void performPreviousAction() override; - QWidget *createConfigurationInterface(QWidget *parent); - void configurationAccepted(); - void save(KConfigGroup &config); + QWidget *createConfigurationInterface(QWidget *parent) override; + void configurationAccepted() override; + void save(KConfigGroup &config) override; private: Ui::Config m_ui; diff --git a/examples/testcontainmentactionsplugin/test.cpp b/examples/testcontainmentactionsplugin/test.cpp --- a/examples/testcontainmentactionsplugin/test.cpp +++ b/examples/testcontainmentactionsplugin/test.cpp @@ -37,7 +37,7 @@ Plasma::Containment *c = containment(); Q_ASSERT(c); QList actions; - actions << c->actions()->action("configure"); + actions << c->actions()->action(QStringLiteral("configure")); return actions; }