QtSupport: Modernize

modernize-*

Change-Id: Id52c06ff440a35d9a4169306c5636f54bfc2125a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Alessandro Portale
2018-11-24 15:05:19 +01:00
parent 0bff017616
commit a9fa1fe5b1
11 changed files with 38 additions and 50 deletions

View File

@@ -1478,7 +1478,7 @@ QList<Task> BaseQtVersion::reportIssues(const QString &proFile, const QString &b
QtConfigWidget *BaseQtVersion::createConfigurationWidget() const
{
return 0;
return nullptr;
}
static QByteArray runQmakeQuery(const FileName &binary, const Environment &env,

View File

@@ -45,7 +45,7 @@ template <class Predicate>
bool changeDomElementContents(const QDomElement &element,
Predicate p,
const QString &newValue,
QString *ptrToOldValue = 0)
QString *ptrToOldValue = nullptr)
{
// Find text in "<element>text</element>"
const QDomNodeList children = element.childNodes();

View File

@@ -90,8 +90,7 @@ void CodeGenSettingsPageWidget::setUiEmbedding(int v)
// ---------- CodeGenSettingsPage
CodeGenSettingsPage::CodeGenSettingsPage(QObject *parent) :
Core::IOptionsPage(parent),
m_widget(0)
Core::IOptionsPage(parent)
{
m_parameters.fromSettings(Core::ICore::settings());
setId(Constants::CODEGEN_SETTINGS_PAGE_ID);

View File

@@ -40,7 +40,7 @@ class CodeGenSettingsPageWidget : public QWidget
{
Q_OBJECT
public:
explicit CodeGenSettingsPageWidget(QWidget *parent = 0);
explicit CodeGenSettingsPageWidget(QWidget *parent = nullptr);
CodeGenSettings parameters() const;
void setParameters(const CodeGenSettings &p);
@@ -55,11 +55,11 @@ private:
class CodeGenSettingsPage : public Core::IOptionsPage
{
public:
explicit CodeGenSettingsPage(QObject *parent = 0);
explicit CodeGenSettingsPage(QObject *parent = nullptr);
QWidget *widget();
void apply();
void finish();
QWidget *widget() override;
void apply() override;
void finish() override;
private:
QPointer<CodeGenSettingsPageWidget> m_widget;

View File

@@ -114,11 +114,7 @@ QString DesktopQtVersion::qmlsceneCommand() const
return m_qmlsceneCommand;
}
DesktopQtVersion::DesktopQtVersion(const DesktopQtVersion &other)
: BaseQtVersion(other),
m_qmlsceneCommand(other.m_qmlsceneCommand)
{
}
DesktopQtVersion::DesktopQtVersion(const DesktopQtVersion &other) = default;
QString DesktopQtVersion::findTargetBinary(TargetBinaries binary) const
{

View File

@@ -38,10 +38,7 @@ DesktopQtVersionFactory::DesktopQtVersionFactory(QObject *parent)
}
DesktopQtVersionFactory::~DesktopQtVersionFactory()
{
}
DesktopQtVersionFactory::~DesktopQtVersionFactory() = default;
bool DesktopQtVersionFactory::canRestore(const QString &type)
{
@@ -51,8 +48,8 @@ bool DesktopQtVersionFactory::canRestore(const QString &type)
BaseQtVersion *DesktopQtVersionFactory::restore(const QString &type, const QVariantMap &data)
{
if (!canRestore(type))
return 0;
DesktopQtVersion *v = new DesktopQtVersion;
return nullptr;
auto v = new DesktopQtVersion;
v->fromMap(data);
return v;
}
@@ -70,5 +67,5 @@ BaseQtVersion *DesktopQtVersionFactory::create(const Utils::FileName &qmakePath,
QFileInfo fi = qmakePath.toFileInfo();
if (fi.exists() && fi.isExecutable() && fi.isFile())
return new DesktopQtVersion(qmakePath, isAutoDetected, autoDetectionSource);
return 0;
return nullptr;
}

View File

@@ -33,14 +33,15 @@ namespace Internal {
class DesktopQtVersionFactory : public QtVersionFactory
{
public:
explicit DesktopQtVersionFactory(QObject *parent = 0);
~DesktopQtVersionFactory();
explicit DesktopQtVersionFactory(QObject *parent = nullptr);
~DesktopQtVersionFactory() override;
virtual bool canRestore(const QString &type);
virtual BaseQtVersion *restore(const QString &type, const QVariantMap &data);
bool canRestore(const QString &type) override;
BaseQtVersion *restore(const QString &type, const QVariantMap &data) override;
virtual int priority() const;
virtual BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
int priority() const override;
BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator,
bool isAutoDetected = false, const QString &autoDetectionSource = QString()) override;
};
} // Internal

View File

@@ -129,7 +129,7 @@ void ExampleSetModel::recreateModel(const QList<BaseQtVersion *> &qtVersions)
QSet<QString> extraManifestDirs;
for (int i = 0; i < m_extraExampleSets.size(); ++i) {
const ExtraExampleSet &set = m_extraExampleSets.at(i);
QStandardItem *newItem = new QStandardItem();
auto newItem = new QStandardItem();
newItem->setData(set.displayName, Qt::DisplayRole);
newItem->setData(set.displayName, Qt::UserRole + 1);
newItem->setData(QVariant(), Qt::UserRole + 2);
@@ -148,7 +148,7 @@ void ExampleSetModel::recreateModel(const QList<BaseQtVersion *> &qtVersions)
}
continue;
}
QStandardItem *newItem = new QStandardItem();
auto newItem = new QStandardItem();
newItem->setData(version->displayName(), Qt::DisplayRole);
newItem->setData(version->displayName(), Qt::UserRole + 1);
newItem->setData(version->uniqueId(), Qt::UserRole + 2);

View File

@@ -99,8 +99,8 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI
{
const QString projectDir = proFileInfo.canonicalPath();
QDialog d(ICore::mainWindow());
QGridLayout *lay = new QGridLayout(&d);
QLabel *descrLbl = new QLabel;
auto lay = new QGridLayout(&d);
auto descrLbl = new QLabel;
d.setWindowTitle(tr("Copy Project to writable Location?"));
descrLbl->setTextFormat(Qt::RichText);
descrLbl->setWordWrap(false);
@@ -116,8 +116,8 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI
"be able to alter or compile your project in the current location.</p>")
.arg(nativeProjectDir));
lay->addWidget(descrLbl, 0, 0, 1, 2);
QLabel *txt = new QLabel(tr("&Location:"));
PathChooser *chooser = new PathChooser;
auto txt = new QLabel(tr("&Location:"));
auto chooser = new PathChooser;
txt->setBuddy(chooser);
chooser->setExpectedKind(PathChooser::ExistingDirectory);
chooser->setHistoryCompleter(QLatin1String("Qt.WritableExamplesDir.History"));
@@ -127,7 +127,7 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI
lay->addWidget(txt, 1, 0);
lay->addWidget(chooser, 1, 1);
enum { Copy = QDialog::Accepted + 1, Keep = QDialog::Accepted + 2 };
QDialogButtonBox *bb = new QDialogButtonBox;
auto bb = new QDialogButtonBox;
QPushButton *copyBtn = bb->addButton(tr("&Copy Project and Open"), QDialogButtonBox::AcceptRole);
connect(copyBtn, &QAbstractButton::released, &d, [&d] { d.done(Copy); });
copyBtn->setDefault(true);
@@ -298,9 +298,6 @@ class GridProxyModel : public QAbstractItemModel
public:
using OptModelIndex = Utils::optional<QModelIndex>;
GridProxyModel()
{}
void setSourceModel(QAbstractItemModel *newModel)
{
if (m_sourceModel == newModel)
@@ -544,7 +541,7 @@ public:
m_currentTagRects.clear();
int xx = 0;
int yy = y + tagsBase;
for (const QString tag : item.tags) {
for (const QString &tag : item.tags) {
const int ww = tagsFontMetrics.width(tag) + 5;
if (xx + ww > w - 30) {
yy += 15;
@@ -579,7 +576,7 @@ public:
const QPoint pos = mev->pos();
if (pos.y() > option.rect.y() + tagsSeparatorY) {
//const QStringList tags = idx.data(Tags).toStringList();
for (auto it : m_currentTagRects) {
for (const auto &it : m_currentTagRects) {
if (it.second.contains(pos))
emit tagClicked(it.first);
}
@@ -594,7 +591,7 @@ public:
}
}
}
return QAbstractItemDelegate::editorEvent(ev, model, option, idx);
return QStyledItemDelegate::editorEvent(ev, model, option, idx);
}
void setShowExamples(bool showExamples) { m_showExamples = showExamples; goon(); }
@@ -624,7 +621,7 @@ public:
{
m_exampleDelegate.setShowExamples(isExamples);
const int sideMargin = 27;
static ExamplesListModel *s_examplesModel = new ExamplesListModel(this);
static auto s_examplesModel = new ExamplesListModel(this);
m_examplesModel = s_examplesModel;
auto filteredModel = new ExamplesListModelFilter(m_examplesModel, !m_isExamples, this);

View File

@@ -118,12 +118,10 @@ QHash<ProFile *, QVector<ProFile *> > ProFileReader::includeFiles() const
return m_includeFiles;
}
ProFileCacheManager *ProFileCacheManager::s_instance = 0;
ProFileCacheManager *ProFileCacheManager::s_instance = nullptr;
ProFileCacheManager::ProFileCacheManager(QObject *parent) :
QObject(parent),
m_cache(0),
m_refCount(0)
QObject(parent)
{
s_instance = this;
m_timer.setInterval(5000);
@@ -147,7 +145,7 @@ void ProFileCacheManager::decRefCount()
ProFileCacheManager::~ProFileCacheManager()
{
s_instance = 0;
s_instance = nullptr;
clear();
}
@@ -165,7 +163,7 @@ void ProFileCacheManager::clear()
// obtaining a cache pointer and using it is atomic as far as the main
// loop is concerned. Use a shared pointer once this is not true anymore.
delete m_cache;
m_cache = 0;
m_cache = nullptr;
}
void ProFileCacheManager::discardFiles(const QString &prefix, QMakeVfs *vfs)

View File

@@ -44,7 +44,7 @@ class QTSUPPORT_EXPORT ProMessageHandler : public QObject, public QMakeHandler
public:
ProMessageHandler(bool verbose = true, bool exact = true);
~ProMessageHandler() override {}
~ProMessageHandler() override = default;
void aboutToEval(ProFile *, ProFile *, EvalFileType) override {}
void doneWithEval(ProFile *) override {}
@@ -102,8 +102,8 @@ private:
ProFileCacheManager(QObject *parent);
~ProFileCacheManager() override;
void clear();
ProFileCache *m_cache;
int m_refCount;
ProFileCache *m_cache = nullptr;
int m_refCount = 0;
QTimer m_timer;
static ProFileCacheManager *s_instance;