From 62c5f9afc3bbe1e83ee63a1a8b9fe56b30c4849c Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Mon, 5 Sep 2016 22:12:36 +0200 Subject: [PATCH] QtDialog: fix clang-tidy warnings --- Source/QtDialog/AddCacheEntry.cxx | 3 ++- Source/QtDialog/CMakeSetup.cxx | 15 ++++++++------- Source/QtDialog/CMakeSetupDialog.cxx | 4 ++-- Source/QtDialog/Compilers.h | 4 +++- Source/QtDialog/FirstConfigure.cxx | 21 ++++++++++++++------- Source/QtDialog/QCMake.h | 4 +++- Source/QtDialog/QCMakeCacheView.cxx | 20 +++++++++++--------- Source/QtDialog/QCMakeWidgets.cxx | 6 +++--- Source/QtDialog/QCMakeWidgets.h | 7 +++++-- 9 files changed, 51 insertions(+), 33 deletions(-) diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index dc7a4b0a2..a94c54bc8 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -64,7 +64,8 @@ QVariant AddCacheEntry::value() const QWidget* w = this->StackedWidget->currentWidget(); if (qobject_cast(w)) { return static_cast(w)->text(); - } else if (qobject_cast(w)) { + } + if (qobject_cast(w)) { return static_cast(w)->isChecked(); } return QVariant(); diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 5a8a5bea2..4de4befb5 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -29,18 +29,19 @@ #include "cmSystemTools.h" // IWYU pragma: keep -static const char* cmDocumentationName[][2] = { { 0, +static const char* cmDocumentationName[][2] = { { CM_NULLPTR, " cmake-gui - CMake GUI." }, - { 0, 0 } }; + { CM_NULLPTR, CM_NULLPTR } }; static const char* cmDocumentationUsage[][2] = { - { 0, " cmake-gui [options]\n" - " cmake-gui [options] \n" - " cmake-gui [options] " }, - { 0, 0 } + { CM_NULLPTR, " cmake-gui [options]\n" + " cmake-gui [options] \n" + " cmake-gui [options] " }, + { CM_NULLPTR, CM_NULLPTR } }; -static const char* cmDocumentationOptions[][2] = { { 0, 0 } }; +static const char* cmDocumentationOptions[] + [2] = { { CM_NULLPTR, CM_NULLPTR } }; #if defined(Q_OS_MAC) static int cmOSXInstall(std::string dir); diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index fda3e5865..5b845971a 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -41,7 +41,7 @@ QCMakeThread::QCMakeThread(QObject* p) : QThread(p) - , CMakeInstance(NULL) + , CMakeInstance(CM_NULLPTR) { } @@ -57,7 +57,7 @@ void QCMakeThread::run() emit this->cmakeInitialized(); this->exec(); delete this->CMakeInstance; - this->CMakeInstance = NULL; + this->CMakeInstance = CM_NULLPTR; } CMakeSetupDialog::CMakeSetupDialog() diff --git a/Source/QtDialog/Compilers.h b/Source/QtDialog/Compilers.h index bdb1962b4..276e2a5d0 100644 --- a/Source/QtDialog/Compilers.h +++ b/Source/QtDialog/Compilers.h @@ -3,6 +3,8 @@ #ifndef COMPILERS_HPP #define COMPILERS_HPP +#include + #include #include @@ -11,7 +13,7 @@ class Compilers : public QWidget, public Ui::Compilers { Q_OBJECT public: - Compilers(QWidget* p = NULL) + Compilers(QWidget* p = CM_NULLPTR) : QWidget(p) { this->setupUi(this); diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index ca5e3b53f..c34751aa6 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -129,8 +129,9 @@ bool StartCompilerSetup::crossCompilerSetup() const void StartCompilerSetup::onSelectionChanged(bool on) { - if (on) + if (on) { selectionChanged(); + } } void StartCompilerSetup::onGeneratorChanged(QString const& name) @@ -144,12 +145,15 @@ void StartCompilerSetup::onGeneratorChanged(QString const& name) int StartCompilerSetup::nextId() const { - if (compilerSetup()) + if (compilerSetup()) { return NativeSetup; - if (crossCompilerSetup()) + } + if (crossCompilerSetup()) { return CrossSetup; - if (crossCompilerToolChainFile()) + } + if (crossCompilerToolChainFile()) { return ToolchainSetup; + } return -1; } @@ -515,7 +519,8 @@ QString FirstConfigure::getCCompiler() const { if (this->compilerSetup()) { return this->mNativeCompilerSetupPage->getCCompiler(); - } else if (this->crossCompilerSetup()) { + } + if (this->crossCompilerSetup()) { return this->mCrossCompilerSetupPage->getCCompiler(); } return QString(); @@ -525,7 +530,8 @@ QString FirstConfigure::getCXXCompiler() const { if (this->compilerSetup()) { return this->mNativeCompilerSetupPage->getCXXCompiler(); - } else if (this->crossCompilerSetup()) { + } + if (this->crossCompilerSetup()) { return this->mCrossCompilerSetupPage->getCXXCompiler(); } return QString(); @@ -535,7 +541,8 @@ QString FirstConfigure::getFortranCompiler() const { if (this->compilerSetup()) { return this->mNativeCompilerSetupPage->getFortranCompiler(); - } else if (this->crossCompilerSetup()) { + } + if (this->crossCompilerSetup()) { return this->mCrossCompilerSetupPage->getFortranCompiler(); } return QString(); diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index a818c6bd2..7eadb09d7 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -13,6 +13,8 @@ #ifndef QCMake_h #define QCMake_h +#include + #include "cmake.h" #ifdef _MSC_VER @@ -71,7 +73,7 @@ class QCMake : public QObject { Q_OBJECT public: - QCMake(QObject* p = 0); + QCMake(QObject* p = CM_NULLPTR); ~QCMake(); public slots: /// load the cache file in a directory diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index cc1f4aa1d..88ea049fa 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -33,7 +33,7 @@ public: } protected: - bool filterAcceptsRow(int row, const QModelIndex& p) const + bool filterAcceptsRow(int row, const QModelIndex& p) const CM_OVERRIDE { QStringList strs; const QAbstractItemModel* m = this->sourceModel(); @@ -87,7 +87,7 @@ public: protected: bool ShowAdvanced; - bool filterAcceptsRow(int row, const QModelIndex& p) const + bool filterAcceptsRow(int row, const QModelIndex& p) const CM_OVERRIDE { const QAbstractItemModel* m = this->sourceModel(); QModelIndex idx = m->index(row, 0, p); @@ -160,7 +160,8 @@ QModelIndex QCMakeCacheView::moveCursor(CursorAction act, // want home/end to go to begin/end of rows, not columns if (act == MoveHome) { return this->model()->index(0, 1); - } else if (act == MoveEnd) { + } + if (act == MoveEnd) { return this->model()->index(this->model()->rowCount() - 1, 1); } return QTreeView::moveCursor(act, mod); @@ -538,15 +539,16 @@ void QCMakeCacheModelDelegate::setFileDialogFlag(bool f) this->FileDialogFlag = f; } -QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p, - const QStyleOptionViewItem&, - const QModelIndex& idx) const +QWidget* QCMakeCacheModelDelegate::createEditor( + QWidget* p, const QStyleOptionViewItem& /*option*/, + const QModelIndex& idx) const { QModelIndex var = idx.sibling(idx.row(), 0); int type = var.data(QCMakeCacheModel::TypeRole).toInt(); if (type == QCMakeProperty::BOOL) { - return NULL; - } else if (type == QCMakeProperty::PATH) { + return CM_NULLPTR; + } + if (type == QCMakeProperty::PATH) { QCMakePathEditor* editor = new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString()); QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this, @@ -645,7 +647,7 @@ QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, QStyleOptionButton opt; opt.QStyleOption::operator=(option); sz = sz.expandedTo( - style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL) + style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, CM_NULLPTR) .size()); return sz; diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index 4b3eb3428..fc481b83b 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -67,7 +67,7 @@ void QCMakeFilePathEditor::chooseFile() this->fileDialogExists(true); path = QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(), - NULL, QFileDialog::DontResolveSymlinks); + CM_NULLPTR, QFileDialog::DontResolveSymlinks); this->fileDialogExists(false); if (!path.isEmpty()) { @@ -99,7 +99,7 @@ void QCMakePathEditor::chooseFile() // use same QDirModel for all completers static QDirModel* fileDirModel() { - static QDirModel* m = NULL; + static QDirModel* m = CM_NULLPTR; if (!m) { m = new QDirModel(); } @@ -107,7 +107,7 @@ static QDirModel* fileDirModel() } static QDirModel* pathDirModel() { - static QDirModel* m = NULL; + static QDirModel* m = CM_NULLPTR; if (!m) { m = new QDirModel(); m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h index f1e87ceed..0d95e635b 100644 --- a/Source/QtDialog/QCMakeWidgets.h +++ b/Source/QtDialog/QCMakeWidgets.h @@ -13,6 +13,8 @@ #ifndef QCMakeWidgets_h #define QCMakeWidgets_h +#include + #include #include #include @@ -43,7 +45,7 @@ class QCMakePathEditor : public QCMakeFileEditor { Q_OBJECT public: - QCMakePathEditor(QWidget* p = NULL, const QString& var = QString()); + QCMakePathEditor(QWidget* p = CM_NULLPTR, const QString& var = QString()); void chooseFile(); }; @@ -52,7 +54,8 @@ class QCMakeFilePathEditor : public QCMakeFileEditor { Q_OBJECT public: - QCMakeFilePathEditor(QWidget* p = NULL, const QString& var = QString()); + QCMakeFilePathEditor(QWidget* p = CM_NULLPTR, + const QString& var = QString()); void chooseFile(); };