QtDialog: fix clang-tidy warnings

This commit is contained in:
Daniel Pfeifer 2016-09-05 22:12:36 +02:00 committed by Brad King
parent bfdf1322e7
commit 62c5f9afc3
9 changed files with 51 additions and 33 deletions

View File

@ -64,7 +64,8 @@ QVariant AddCacheEntry::value() const
QWidget* w = this->StackedWidget->currentWidget(); QWidget* w = this->StackedWidget->currentWidget();
if (qobject_cast<QLineEdit*>(w)) { if (qobject_cast<QLineEdit*>(w)) {
return static_cast<QLineEdit*>(w)->text(); return static_cast<QLineEdit*>(w)->text();
} else if (qobject_cast<QCheckBox*>(w)) { }
if (qobject_cast<QCheckBox*>(w)) {
return static_cast<QCheckBox*>(w)->isChecked(); return static_cast<QCheckBox*>(w)->isChecked();
} }
return QVariant(); return QVariant();

View File

@ -29,18 +29,19 @@
#include "cmSystemTools.h" // IWYU pragma: keep #include "cmSystemTools.h" // IWYU pragma: keep
static const char* cmDocumentationName[][2] = { { 0, static const char* cmDocumentationName[][2] = { { CM_NULLPTR,
" cmake-gui - CMake GUI." }, " cmake-gui - CMake GUI." },
{ 0, 0 } }; { CM_NULLPTR, CM_NULLPTR } };
static const char* cmDocumentationUsage[][2] = { static const char* cmDocumentationUsage[][2] = {
{ 0, " cmake-gui [options]\n" { CM_NULLPTR, " cmake-gui [options]\n"
" cmake-gui [options] <path-to-source>\n" " cmake-gui [options] <path-to-source>\n"
" cmake-gui [options] <path-to-existing-build>" }, " cmake-gui [options] <path-to-existing-build>" },
{ 0, 0 } { 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) #if defined(Q_OS_MAC)
static int cmOSXInstall(std::string dir); static int cmOSXInstall(std::string dir);

View File

@ -41,7 +41,7 @@
QCMakeThread::QCMakeThread(QObject* p) QCMakeThread::QCMakeThread(QObject* p)
: QThread(p) : QThread(p)
, CMakeInstance(NULL) , CMakeInstance(CM_NULLPTR)
{ {
} }
@ -57,7 +57,7 @@ void QCMakeThread::run()
emit this->cmakeInitialized(); emit this->cmakeInitialized();
this->exec(); this->exec();
delete this->CMakeInstance; delete this->CMakeInstance;
this->CMakeInstance = NULL; this->CMakeInstance = CM_NULLPTR;
} }
CMakeSetupDialog::CMakeSetupDialog() CMakeSetupDialog::CMakeSetupDialog()

View File

@ -3,6 +3,8 @@
#ifndef COMPILERS_HPP #ifndef COMPILERS_HPP
#define COMPILERS_HPP #define COMPILERS_HPP
#include <cmConfigure.h>
#include <QWidget> #include <QWidget>
#include <ui_Compilers.h> #include <ui_Compilers.h>
@ -11,7 +13,7 @@ class Compilers : public QWidget, public Ui::Compilers
{ {
Q_OBJECT Q_OBJECT
public: public:
Compilers(QWidget* p = NULL) Compilers(QWidget* p = CM_NULLPTR)
: QWidget(p) : QWidget(p)
{ {
this->setupUi(this); this->setupUi(this);

View File

@ -129,9 +129,10 @@ bool StartCompilerSetup::crossCompilerSetup() const
void StartCompilerSetup::onSelectionChanged(bool on) void StartCompilerSetup::onSelectionChanged(bool on)
{ {
if (on) if (on) {
selectionChanged(); selectionChanged();
} }
}
void StartCompilerSetup::onGeneratorChanged(QString const& name) void StartCompilerSetup::onGeneratorChanged(QString const& name)
{ {
@ -144,12 +145,15 @@ void StartCompilerSetup::onGeneratorChanged(QString const& name)
int StartCompilerSetup::nextId() const int StartCompilerSetup::nextId() const
{ {
if (compilerSetup()) if (compilerSetup()) {
return NativeSetup; return NativeSetup;
if (crossCompilerSetup()) }
if (crossCompilerSetup()) {
return CrossSetup; return CrossSetup;
if (crossCompilerToolChainFile()) }
if (crossCompilerToolChainFile()) {
return ToolchainSetup; return ToolchainSetup;
}
return -1; return -1;
} }
@ -515,7 +519,8 @@ QString FirstConfigure::getCCompiler() const
{ {
if (this->compilerSetup()) { if (this->compilerSetup()) {
return this->mNativeCompilerSetupPage->getCCompiler(); return this->mNativeCompilerSetupPage->getCCompiler();
} else if (this->crossCompilerSetup()) { }
if (this->crossCompilerSetup()) {
return this->mCrossCompilerSetupPage->getCCompiler(); return this->mCrossCompilerSetupPage->getCCompiler();
} }
return QString(); return QString();
@ -525,7 +530,8 @@ QString FirstConfigure::getCXXCompiler() const
{ {
if (this->compilerSetup()) { if (this->compilerSetup()) {
return this->mNativeCompilerSetupPage->getCXXCompiler(); return this->mNativeCompilerSetupPage->getCXXCompiler();
} else if (this->crossCompilerSetup()) { }
if (this->crossCompilerSetup()) {
return this->mCrossCompilerSetupPage->getCXXCompiler(); return this->mCrossCompilerSetupPage->getCXXCompiler();
} }
return QString(); return QString();
@ -535,7 +541,8 @@ QString FirstConfigure::getFortranCompiler() const
{ {
if (this->compilerSetup()) { if (this->compilerSetup()) {
return this->mNativeCompilerSetupPage->getFortranCompiler(); return this->mNativeCompilerSetupPage->getFortranCompiler();
} else if (this->crossCompilerSetup()) { }
if (this->crossCompilerSetup()) {
return this->mCrossCompilerSetupPage->getFortranCompiler(); return this->mCrossCompilerSetupPage->getFortranCompiler();
} }
return QString(); return QString();

View File

@ -13,6 +13,8 @@
#ifndef QCMake_h #ifndef QCMake_h
#define QCMake_h #define QCMake_h
#include <cmConfigure.h>
#include "cmake.h" #include "cmake.h"
#ifdef _MSC_VER #ifdef _MSC_VER
@ -71,7 +73,7 @@ class QCMake : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
QCMake(QObject* p = 0); QCMake(QObject* p = CM_NULLPTR);
~QCMake(); ~QCMake();
public slots: public slots:
/// load the cache file in a directory /// load the cache file in a directory

View File

@ -33,7 +33,7 @@ public:
} }
protected: protected:
bool filterAcceptsRow(int row, const QModelIndex& p) const bool filterAcceptsRow(int row, const QModelIndex& p) const CM_OVERRIDE
{ {
QStringList strs; QStringList strs;
const QAbstractItemModel* m = this->sourceModel(); const QAbstractItemModel* m = this->sourceModel();
@ -87,7 +87,7 @@ public:
protected: protected:
bool ShowAdvanced; 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(); const QAbstractItemModel* m = this->sourceModel();
QModelIndex idx = m->index(row, 0, p); 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 // want home/end to go to begin/end of rows, not columns
if (act == MoveHome) { if (act == MoveHome) {
return this->model()->index(0, 1); return this->model()->index(0, 1);
} else if (act == MoveEnd) { }
if (act == MoveEnd) {
return this->model()->index(this->model()->rowCount() - 1, 1); return this->model()->index(this->model()->rowCount() - 1, 1);
} }
return QTreeView::moveCursor(act, mod); return QTreeView::moveCursor(act, mod);
@ -538,15 +539,16 @@ void QCMakeCacheModelDelegate::setFileDialogFlag(bool f)
this->FileDialogFlag = f; this->FileDialogFlag = f;
} }
QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p, QWidget* QCMakeCacheModelDelegate::createEditor(
const QStyleOptionViewItem&, QWidget* p, const QStyleOptionViewItem& /*option*/,
const QModelIndex& idx) const const QModelIndex& idx) const
{ {
QModelIndex var = idx.sibling(idx.row(), 0); QModelIndex var = idx.sibling(idx.row(), 0);
int type = var.data(QCMakeCacheModel::TypeRole).toInt(); int type = var.data(QCMakeCacheModel::TypeRole).toInt();
if (type == QCMakeProperty::BOOL) { if (type == QCMakeProperty::BOOL) {
return NULL; return CM_NULLPTR;
} else if (type == QCMakeProperty::PATH) { }
if (type == QCMakeProperty::PATH) {
QCMakePathEditor* editor = QCMakePathEditor* editor =
new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString()); new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString());
QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this, QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
@ -645,7 +647,7 @@ QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option,
QStyleOptionButton opt; QStyleOptionButton opt;
opt.QStyleOption::operator=(option); opt.QStyleOption::operator=(option);
sz = sz.expandedTo( sz = sz.expandedTo(
style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL) style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, CM_NULLPTR)
.size()); .size());
return sz; return sz;

View File

@ -67,7 +67,7 @@ void QCMakeFilePathEditor::chooseFile()
this->fileDialogExists(true); this->fileDialogExists(true);
path = path =
QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(), QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(),
NULL, QFileDialog::DontResolveSymlinks); CM_NULLPTR, QFileDialog::DontResolveSymlinks);
this->fileDialogExists(false); this->fileDialogExists(false);
if (!path.isEmpty()) { if (!path.isEmpty()) {
@ -99,7 +99,7 @@ void QCMakePathEditor::chooseFile()
// use same QDirModel for all completers // use same QDirModel for all completers
static QDirModel* fileDirModel() static QDirModel* fileDirModel()
{ {
static QDirModel* m = NULL; static QDirModel* m = CM_NULLPTR;
if (!m) { if (!m) {
m = new QDirModel(); m = new QDirModel();
} }
@ -107,7 +107,7 @@ static QDirModel* fileDirModel()
} }
static QDirModel* pathDirModel() static QDirModel* pathDirModel()
{ {
static QDirModel* m = NULL; static QDirModel* m = CM_NULLPTR;
if (!m) { if (!m) {
m = new QDirModel(); m = new QDirModel();
m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot);

View File

@ -13,6 +13,8 @@
#ifndef QCMakeWidgets_h #ifndef QCMakeWidgets_h
#define QCMakeWidgets_h #define QCMakeWidgets_h
#include <cmConfigure.h>
#include <QComboBox> #include <QComboBox>
#include <QCompleter> #include <QCompleter>
#include <QLineEdit> #include <QLineEdit>
@ -43,7 +45,7 @@ class QCMakePathEditor : public QCMakeFileEditor
{ {
Q_OBJECT Q_OBJECT
public: public:
QCMakePathEditor(QWidget* p = NULL, const QString& var = QString()); QCMakePathEditor(QWidget* p = CM_NULLPTR, const QString& var = QString());
void chooseFile(); void chooseFile();
}; };
@ -52,7 +54,8 @@ class QCMakeFilePathEditor : public QCMakeFileEditor
{ {
Q_OBJECT Q_OBJECT
public: public:
QCMakeFilePathEditor(QWidget* p = NULL, const QString& var = QString()); QCMakeFilePathEditor(QWidget* p = CM_NULLPTR,
const QString& var = QString());
void chooseFile(); void chooseFile();
}; };