summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2018-10-31 15:12:47 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2018-11-02 13:19:02 +0000
commit3d267cabf544bca4cbe6d02d66e81272526cd071 (patch)
tree5d1f3b991be4de5ec169bbeec16fab02f0189d75
parentcd36ba030e95688c453873df5b391a5f847d562a (diff)
Fix issues found by clazy and clang-tidy
- Call static member functions directly instead of through an instance that needs to be fetched - Avoid C style casts - Don't use elses after return - Mark an overridden member function final - Initialize members - Use nullptr instead of 0 - Define trivial destructor with "= default" Task-number: QTBUG-70548 Change-Id: I0d00568abfbffb52c39f0410ce60b89d9d682b6c Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
-rw-r--r--src/applicationsettings.cpp2
-rw-r--r--src/applicationsmodel.cpp29
-rw-r--r--src/circularindicator.cpp4
-rw-r--r--src/circularindicator.h2
-rw-r--r--src/engine.cpp6
5 files changed, 22 insertions, 21 deletions
diff --git a/src/applicationsettings.cpp b/src/applicationsettings.cpp
index 2811213..3b97851 100644
--- a/src/applicationsettings.cpp
+++ b/src/applicationsettings.cpp
@@ -50,7 +50,7 @@ bool ApplicationSettings::isShowFPSEnabled() const
bool ApplicationSettings::parseCommandLineArguments()
{
- QStringList args = QCoreApplication::instance()->arguments();
+ QStringList args = QCoreApplication::arguments();
for (int i=0; i<args.size(); ++i) {
if (args.at(i) == QStringLiteral("--main-file")) {
++i;
diff --git a/src/applicationsmodel.cpp b/src/applicationsmodel.cpp
index 63821cf..b0818da 100644
--- a/src/applicationsmodel.cpp
+++ b/src/applicationsmodel.cpp
@@ -38,7 +38,7 @@
#include <QJsonObject>
#include <QXmlStreamReader>
-const QEvent::Type RESULT_EVENT = (QEvent::Type) (QEvent::User + 1);
+const QEvent::Type RESULT_EVENT = static_cast<QEvent::Type>(QEvent::User + 1);
class ResultEvent : public QEvent
{
public:
@@ -54,15 +54,14 @@ static bool appOrder(const AppData& a, const AppData& b)
{
if (a.priority != b.priority)
return a.priority > b.priority;
- else
- return a.name < b.name;
+ return a.name < b.name;
}
class IndexingThread : public QThread
{
public:
- void run()
+ void run() final
{
QList<AppData> results;
QList<QString> roots = root.split(":");
@@ -136,7 +135,7 @@ public:
}
QString root;
- ApplicationsModel *model;
+ ApplicationsModel *model = nullptr;
QString target;
};
@@ -159,7 +158,7 @@ QHash<int, QByteArray> ApplicationsModel::roleNames() const
void ApplicationsModel::initialize(const QString &appsRoot)
{
- IndexingThread *thread = new IndexingThread;
+ auto *thread = new IndexingThread;
thread->root = appsRoot;
thread->model = this;
thread->start();
@@ -221,12 +220,18 @@ QVariant ApplicationsModel::query(int i, const QString &name) const
}
const AppData &ad = m_data.at(i);
- if (name == QStringLiteral("description")) return ad.description;
- else if (name == QStringLiteral("name")) return ad.name;
- else if (name == QStringLiteral("location")) return ad.location;
- else if (name == QStringLiteral("mainFile")) return ad.main;
- else if (name == QStringLiteral("icon")) return ad.icon;
- else if (name == QStringLiteral("priority")) return ad.priority;
+ if (name == QStringLiteral("description"))
+ return ad.description;
+ if (name == QStringLiteral("name"))
+ return ad.name;
+ if (name == QStringLiteral("location"))
+ return ad.location;
+ if (name == QStringLiteral("mainFile"))
+ return ad.main;
+ if (name == QStringLiteral("icon"))
+ return ad.icon;
+ if (name == QStringLiteral("priority"))
+ return ad.priority;
qWarning("ApplicationsModel::query: Asking for bad name %s", qPrintable(name));
diff --git a/src/circularindicator.cpp b/src/circularindicator.cpp
index f3f5a31..9afef84 100644
--- a/src/circularindicator.cpp
+++ b/src/circularindicator.cpp
@@ -39,10 +39,6 @@ CircularIndicator::CircularIndicator(QQuickItem *parent)
{
}
-CircularIndicator::~CircularIndicator()
-{
-}
-
int CircularIndicator::startAngle() const
{
return m_startAngle;
diff --git a/src/circularindicator.h b/src/circularindicator.h
index a03c742..00d3077 100644
--- a/src/circularindicator.h
+++ b/src/circularindicator.h
@@ -44,7 +44,7 @@ class CircularIndicator : public QQuickPaintedItem
public:
CircularIndicator(QQuickItem *parent = 0);
- ~CircularIndicator();
+ ~CircularIndicator() = default;
int startAngle() const;
int spanAngle() const;
diff --git a/src/engine.cpp b/src/engine.cpp
index c29a61c..3341d80 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -51,7 +51,7 @@
Engine::Engine(QQuickItem *parent)
: QQuickItem(parent)
- , m_fpsCounter(0)
+ , m_fpsCounter(nullptr)
, m_fps(0)
, m_intro_done(false)
, m_apps_ready(false)
@@ -98,7 +98,7 @@ void Engine::updateFPSCounter()
{
if (m_fpsCounter) {
delete m_fpsCounter;
- m_fpsCounter = 0;
+ m_fpsCounter = nullptr;
}
if (m_fps_enabled && window()) {
@@ -187,7 +187,7 @@ void Engine::launchApplication(const QUrl &path, const QString &mainFile, const
void Engine::closeApplication()
{
- emit activeIconChanged(0);
+ emit activeIconChanged(nullptr);
m_applicationMain = m_applicationUrl = QUrl();
m_applicationName = QString();