Commit 063b9775 authored by Tobias Hunger's avatar Tobias Hunger

Autotools: Modernize

* Use pragma once
* Make sure overrides are everywhere
* Clean up code here and there
* Remove useless code from initializer lists

Change-Id: I9c285a803ea36cb32d14b3335757fd4b57f27d02
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 9b3016c2
......@@ -53,10 +53,8 @@ const char AUTOGEN_STEP_ID[] = "AutotoolsProjectManager.AutogenStep";
/////////////////////////////
// AutogenStepFactory class
/////////////////////////////
AutogenStepFactory::AutogenStepFactory(QObject *parent) :
IBuildStepFactory(parent)
{
}
AutogenStepFactory::AutogenStepFactory(QObject *parent) : IBuildStepFactory(parent)
{ }
QList<Core::Id> AutogenStepFactory::availableCreationIds(BuildStepList *parent) const
{
......@@ -122,21 +120,17 @@ bool AutogenStepFactory::canHandle(BuildStepList *parent) const
////////////////////////
// AutogenStep class
////////////////////////
AutogenStep::AutogenStep(BuildStepList *bsl) :
AbstractProcessStep(bsl, Core::Id(AUTOGEN_STEP_ID)),
m_runAutogen(false)
AutogenStep::AutogenStep(BuildStepList *bsl) : AbstractProcessStep(bsl, Core::Id(AUTOGEN_STEP_ID))
{
ctor();
}
AutogenStep::AutogenStep(BuildStepList *bsl, Core::Id id) :
AbstractProcessStep(bsl, id)
AutogenStep::AutogenStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id)
{
ctor();
}
AutogenStep::AutogenStep(BuildStepList *bsl, AutogenStep *bs) :
AbstractProcessStep(bsl, bs),
AutogenStep::AutogenStep(BuildStepList *bsl, AutogenStep *bs) : AbstractProcessStep(bsl, bs),
m_additionalArguments(bs->additionalArguments())
{
ctor();
......@@ -236,15 +230,13 @@ bool AutogenStep::fromMap(const QVariantMap &map)
//////////////////////////////////
AutogenStepConfigWidget::AutogenStepConfigWidget(AutogenStep *autogenStep) :
m_autogenStep(autogenStep),
m_summaryText(),
m_additionalArguments(0)
m_additionalArguments(new QLineEdit)
{
QFormLayout *fl = new QFormLayout(this);
fl->setMargin(0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
m_additionalArguments = new QLineEdit(this);
fl->addRow(tr("Arguments:"), m_additionalArguments);
m_additionalArguments->setText(m_autogenStep->additionalArguments());
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOGENSTEP_H
#define AUTOGENSTEP_H
#pragma once
#include <projectexplorer/abstractprocessstep.h>
......@@ -114,7 +113,7 @@ private:
void ctor();
QString m_additionalArguments;
bool m_runAutogen;
bool m_runAutogen = false;
};
//////////////////////////////////
......@@ -132,8 +131,8 @@ class AutogenStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
public:
AutogenStepConfigWidget(AutogenStep *autogenStep);
QString displayName() const;
QString summaryText() const;
QString displayName() const override;
QString summaryText() const override;
private slots:
void updateDetails();
......@@ -146,6 +145,3 @@ private:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOGENSTEP_H
......@@ -52,10 +52,8 @@ const char AUTORECONF_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.Auto
////////////////////////////////
// AutoreconfStepFactory class
////////////////////////////////
AutoreconfStepFactory::AutoreconfStepFactory(QObject *parent) :
IBuildStepFactory(parent)
{
}
AutoreconfStepFactory::AutoreconfStepFactory(QObject *parent) : IBuildStepFactory(parent)
{ }
QList<Core::Id> AutoreconfStepFactory::availableCreationIds(BuildStepList *parent) const
{
......@@ -122,14 +120,12 @@ bool AutoreconfStepFactory::canHandle(BuildStepList *parent) const
// AutoreconfStep class
/////////////////////////
AutoreconfStep::AutoreconfStep(BuildStepList *bsl) :
AbstractProcessStep(bsl, Core::Id(AUTORECONF_STEP_ID)),
m_runAutoreconf(false)
AbstractProcessStep(bsl, Core::Id(AUTORECONF_STEP_ID))
{
ctor();
}
AutoreconfStep::AutoreconfStep(BuildStepList *bsl, Core::Id id) :
AbstractProcessStep(bsl, id)
AutoreconfStep::AutoreconfStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id)
{
ctor();
}
......@@ -229,15 +225,13 @@ bool AutoreconfStep::fromMap(const QVariantMap &map)
//////////////////////////////////////
AutoreconfStepConfigWidget::AutoreconfStepConfigWidget(AutoreconfStep *autoreconfStep) :
m_autoreconfStep(autoreconfStep),
m_summaryText(),
m_additionalArguments(0)
m_additionalArguments(new QLineEdit(this))
{
QFormLayout *fl = new QFormLayout(this);
fl->setMargin(0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
m_additionalArguments = new QLineEdit(this);
fl->addRow(tr("Arguments:"), m_additionalArguments);
m_additionalArguments->setText(m_autoreconfStep->additionalArguments());
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTORECONFSTEP_H
#define AUTORECONFSTEP_H
#pragma once
#include <projectexplorer/abstractprocessstep.h>
......@@ -114,7 +113,7 @@ private:
void ctor();
QString m_additionalArguments;
bool m_runAutoreconf;
bool m_runAutoreconf = false;
};
//////////////////////////////////////
......@@ -132,8 +131,8 @@ class AutoreconfStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
public:
AutoreconfStepConfigWidget(AutoreconfStep *autoreconfStep);
QString displayName() const;
QString summaryText() const;
QString displayName() const override;
QString summaryText() const override;
private slots:
void updateDetails();
......@@ -146,6 +145,3 @@ private:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTORECONFSTEP_H
......@@ -57,8 +57,8 @@ using namespace ProjectExplorer::Constants;
//////////////////////////////////////
// AutotoolsBuildConfiguration class
//////////////////////////////////////
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent)
: BuildConfiguration(parent, Core::Id(AUTOTOOLS_BC_ID))
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent) :
BuildConfiguration(parent, Core::Id(AUTOTOOLS_BC_ID))
{
// /<foobar> is used so the un-changed check in setBuildDirectory() works correctly.
// The leading / is to avoid the relative the path expansion in BuildConfiguration::buildDirectory.
......@@ -70,13 +70,13 @@ NamedWidget *AutotoolsBuildConfiguration::createConfigWidget()
return new AutotoolsBuildSettingsWidget(this);
}
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent, Core::Id id)
: BuildConfiguration(parent, id)
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent, Core::Id id) :
BuildConfiguration(parent, id)
{ }
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent,
AutotoolsBuildConfiguration *source)
: BuildConfiguration(parent, source)
AutotoolsBuildConfiguration *source) :
BuildConfiguration(parent, source)
{
cloneSteps(source);
}
......@@ -86,8 +86,7 @@ AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent,
//////////////////////////////////////
AutotoolsBuildConfigurationFactory::AutotoolsBuildConfigurationFactory(QObject *parent) :
IBuildConfigurationFactory(parent)
{
}
{ }
int AutotoolsBuildConfigurationFactory::priority(const Target *parent) const
{
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSBUILDCONFIGURATION_H
#define AUTOTOOLSBUILDCONFIGURATION_H
#pragma once
#include <projectexplorer/buildconfiguration.h>
......@@ -88,4 +87,3 @@ private:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSBUILDCONFIGURATION_H
......@@ -46,13 +46,13 @@ using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer;
AutotoolsBuildSettingsWidget::AutotoolsBuildSettingsWidget(AutotoolsBuildConfiguration *bc) :
m_pathChooser(new Utils::PathChooser),
m_buildConfiguration(bc)
{
QFormLayout *fl = new QFormLayout(this);
fl->setContentsMargins(0, 0, 0, 0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
m_pathChooser = new Utils::PathChooser(this);
m_pathChooser->setEnabled(true);
m_pathChooser->setExpectedKind(Utils::PathChooser::Directory);
m_pathChooser->setBaseFileName(bc->target()->project()->projectDirectory());
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSBUILDSETTINGSWIDGET_H
#define AUTOTOOLSBUILDSETTINGSWIDGET_H
#pragma once
#include <projectexplorer/namedwidget.h>
......@@ -64,5 +63,3 @@ private:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSBUILDSETTINGSWIDGET_H
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSMANAGER_H
#define AUTOTOOLSMANAGER_H
#pragma once
#include <projectexplorer/iprojectmanager.h>
......@@ -45,13 +44,9 @@ class AutotoolsManager : public ProjectExplorer::IProjectManager
Q_OBJECT
public:
AutotoolsManager() {}
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
QString mimeType() const;
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString) override;
QString mimeType() const override;
};
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSMANAGER_H
......@@ -42,10 +42,10 @@ using namespace AutotoolsProjectManager::Internal;
//////////////////////////////////////
AutotoolsOpenProjectWizard::AutotoolsOpenProjectWizard(AutotoolsManager *manager,
const QString &sourceDirectory,
QWidget *parent)
: Utils::Wizard(parent),
m_manager(manager),
m_sourceDirectory(sourceDirectory)
QWidget *parent) :
Utils::Wizard(parent),
m_manager(manager),
m_sourceDirectory(sourceDirectory)
{
QDir dir(m_sourceDirectory);
m_buildDirectory = dir.absolutePath();
......@@ -79,8 +79,8 @@ void AutotoolsOpenProjectWizard::setBuildDirectory(const QString &directory)
/////////////////////////
// BuildPathPage class
/////////////////////////
BuildPathPage::BuildPathPage(AutotoolsOpenProjectWizard *wizard)
: QWizardPage(wizard), m_wizard(wizard)
BuildPathPage::BuildPathPage(AutotoolsOpenProjectWizard *w) : QWizardPage(w),
m_pc(new Utils::PathChooser)
{
QFormLayout *fl = new QFormLayout;
this->setLayout(fl);
......@@ -92,10 +92,10 @@ BuildPathPage::BuildPathPage(AutotoolsOpenProjectWizard *wizard)
"This ensures that the source directory remains clean and enables multiple builds "
"with different settings."));
fl->addWidget(label);
m_pc = new Utils::PathChooser(this);
m_pc->setHistoryCompleter(QLatin1String("AutoTools.BuildDir.History"));
m_pc->setBaseDirectory(m_wizard->sourceDirectory());
m_pc->setPath(m_wizard->buildDirectory());
AutotoolsOpenProjectWizard *wiz = static_cast<AutotoolsOpenProjectWizard *>(wizard());
m_pc->setBaseDirectory(wiz->sourceDirectory());
m_pc->setPath(wiz->buildDirectory());
connect(m_pc, &Utils::PathChooser::rawPathChanged, this, &BuildPathPage::buildDirectoryChanged);
fl->addRow(tr("Build directory:"), m_pc);
setTitle(tr("Build Location"));
......@@ -103,5 +103,5 @@ BuildPathPage::BuildPathPage(AutotoolsOpenProjectWizard *wizard)
void BuildPathPage::buildDirectoryChanged()
{
m_wizard->setBuildDirectory(m_pc->path());
static_cast<AutotoolsOpenProjectWizard *>(wizard())->setBuildDirectory(m_pc->path());
}
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSOPENPROJECTWIZARD_H
#define AUTOTOOLSOPENPROJECTWIZARD_H
#pragma once
#include <utils/wizard.h>
......@@ -42,13 +41,9 @@ class AutotoolsOpenProjectWizard : public Utils::Wizard
Q_OBJECT
public:
enum PageId
{
BuildPathPageId
};
enum PageId { BuildPathPageId };
AutotoolsOpenProjectWizard(AutotoolsManager *manager,
const QString &sourceDirectory,
AutotoolsOpenProjectWizard(AutotoolsManager *manager, const QString &sourceDirectory,
QWidget *parent = 0);
QString buildDirectory() const;
......@@ -73,10 +68,8 @@ private slots:
void buildDirectoryChanged();
private:
AutotoolsOpenProjectWizard *m_wizard;
Utils::PathChooser *m_pc;
};
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif //AUTOTOOLSOPENPROJECTWIZARD_H
......@@ -69,8 +69,7 @@ using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer;
AutotoolsProject::AutotoolsProject(AutotoolsManager *manager, const QString &fileName) :
m_fileWatcher(new Utils::FileSystemWatcher(this)),
m_makefileParserThread(0)
m_fileWatcher(new Utils::FileSystemWatcher(this))
{
setId(Constants::AUTOTOOLS_PROJECT_ID);
setProjectManager(manager);
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSPROJECT_H
#define AUTOTOOLSPROJECT_H
#pragma once
#include <projectexplorer/project.h>
......@@ -41,7 +40,7 @@ namespace Utils { class FileSystemWatcher; }
namespace ProjectExplorer {
class Node;
class FolderNode;
}
} // namespace ProjectExplorer
namespace AutotoolsProjectManager {
namespace Internal {
......@@ -76,7 +75,7 @@ public:
protected:
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
private slots:
private:
/**
* Loads the project tree by parsing the makefiles.
*/
......@@ -103,7 +102,6 @@ private slots:
*/
void onFileChanged(const QString &file);
private:
/**
* Creates folder-nodes and file-nodes for the project tree.
*/
......@@ -128,7 +126,6 @@ private:
*/
void updateCppCodeModel();
private:
QString m_projectName;
/// Return value for AutotoolsProject::files()
......@@ -139,12 +136,10 @@ private:
QStringList m_watchedFiles;
/// Responsible for parsing the makefiles asynchronously in a thread
MakefileParserThread *m_makefileParserThread;
MakefileParserThread *m_makefileParserThread = nullptr;
QFuture<void> m_codeModelFuture;
};
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSPROJECT_H
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSPROJECTCONSTANTS_H
#define AUTOTOOLSPROJECTCONSTANTS_H
#pragma once
namespace AutotoolsProjectManager {
/**
......@@ -43,5 +42,3 @@ namespace Constants {
const char PROJECT_CONTEXT[] = "AutotoolsProject.ProjectContext";
} // namespace Constants
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSPROJECTCONSTANTS_H
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSPROJECTFILE_H
#define AUTOTOOLSPROJECTFILE_H
#pragma once
#include <coreplugin/idocument.h>
......@@ -60,5 +59,3 @@ public:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSPROJECTFILE_H
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSPROJECTNODE_H
#define AUTOTOOLSPROJECTNODE_H
#pragma once
#include <projectexplorer/projectnodes.h>
......@@ -57,5 +56,3 @@ public:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSPROJECTNODE_H
......@@ -39,13 +39,8 @@
using namespace AutotoolsProjectManager::Internal;
AutotoolsProjectPlugin::AutotoolsProjectPlugin()
{
}
void AutotoolsProjectPlugin::extensionsInitialized()
{
}
{ }
bool AutotoolsProjectPlugin::initialize(const QStringList &arguments,
QString *errorString)
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef AUTOTOOLSPROJECTPLUGIN_H
#define AUTOTOOLSPROJECTPLUGIN_H
#pragma once
#include <extensionsystem/iplugin.h>
......@@ -67,13 +66,9 @@ class AutotoolsProjectPlugin : public ExtensionSystem::IPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "AutotoolsProjectManager.json")
public:
AutotoolsProjectPlugin();
void extensionsInitialized();
bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized() override;
bool initialize(const QStringList &arguments, QString *errorString) override;
};
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // AUTOTOOLSPROJECTPLUGIN_H
......@@ -67,10 +67,8 @@ static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) {
////////////////////////////////
// ConfigureStepFactory Class
////////////////////////////////
ConfigureStepFactory::ConfigureStepFactory(QObject *parent) :
IBuildStepFactory(parent)
{
}
ConfigureStepFactory::ConfigureStepFactory(QObject *parent) : IBuildStepFactory(parent)
{ }
QList<Core::Id> ConfigureStepFactory::availableCreationIds(BuildStepList *parent) const
{
......@@ -137,20 +135,17 @@ bool ConfigureStepFactory::canHandle(BuildStepList *parent) const
// ConfigureStep class
////////////////////////
ConfigureStep::ConfigureStep(BuildStepList* bsl) :
AbstractProcessStep(bsl, Core::Id(CONFIGURE_STEP_ID)),
m_runConfigure(false)
AbstractProcessStep(bsl, Core::Id(CONFIGURE_STEP_ID))
{
ctor();
}
ConfigureStep::ConfigureStep(BuildStepList *bsl, Core::Id id) :
AbstractProcessStep(bsl, id)
ConfigureStep::ConfigureStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id)
{
ctor();
}
ConfigureStep::ConfigureStep(BuildStepList *bsl, ConfigureStep *bs) :
AbstractProcessStep(bsl, bs),
ConfigureStep::ConfigureStep(BuildStepList *bsl, ConfigureStep *bs) : AbstractProcessStep(bsl, bs),
m_additionalArguments(bs->additionalArguments())
{
ctor();
......@@ -252,15 +247,13 @@ bool ConfigureStep::fromMap(const QVariantMap &map)
/////////////////////////////////////
ConfigureStepConfigWidget::ConfigureStepConfigWidget(ConfigureStep *configureStep) :
m_configureStep(configureStep),
m_summaryText(),
m_additionalArguments(0)
m_additionalArguments(new QLineEdit)
{
QFormLayout *fl = new QFormLayout(this);
fl->setMargin(0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
m_additionalArguments = new QLineEdit(this);
fl->addRow(tr("Arguments:"), m_additionalArguments);
m_additionalArguments->setText(m_configureStep->additionalArguments());
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef CONFIGURESTEP_H
#define CONFIGURESTEP_H
#pragma once
#include <projectexplorer/abstractprocessstep.h>
......@@ -115,7 +114,7 @@ private:
void ctor();
QString m_additionalArguments;
bool m_runConfigure;
bool m_runConfigure = false;
};
/////////////////////////////////////
......@@ -133,8 +132,8 @@ class ConfigureStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
public:
ConfigureStepConfigWidget(ConfigureStep *configureStep);
QString displayName() const;
QString summaryText() const;
QString displayName() const override;
QString summaryText() const override;
private slots:
void updateDetails();
......@@ -147,6 +146,3 @@ private:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // CONFIGURESTEP_H
......@@ -37,20 +37,8 @@
using namespace AutotoolsProjectManager::Internal;
MakefileParser::MakefileParser(const QString &makefile) :
QObject(),
m_success(false),
m_cancel(false),
m_mutex(),
m_makefile(makefile),
m_executable(),
m_sources(),
m_makefiles(),
m_includePaths(),
m_line(),
m_textStream()
{
}
MakefileParser::MakefileParser(const QString &makefile) : m_makefile(makefile)
{ }
MakefileParser::~MakefileParser()
{
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef MAKEFILEPARSER_H
#define MAKEFILEPARSER_H
#pragma once
#include <QMutex>
#include <QStringList>
......@@ -258,10 +257,9 @@ private:
*/
bool maybeParseCPPFlag(const QString &term);
private:
bool m_success; ///< Return value for MakefileParser::parse().
bool m_success = false; ///< Return value for MakefileParser::parse().
bool m_cancel; ///< True, if the parsing should be cancelled.
bool m_cancel = false; ///< True, if the parsing should be cancelled.
mutable QMutex m_mutex; ///< Mutex to protect m_cancel.
QString m_makefile; ///< Filename of the makefile
......@@ -280,6 +278,3 @@ private:
} // namespace Internal
} // namespace AutotoolsProjectManager
#endif // MAKEFILEPARSER_H
......@@ -31,15 +31,7 @@
using namespace AutotoolsProjectManager::Internal;
MakefileParserThread::MakefileParserThread(const QString &makefile) :
QThread(),
m_parser(makefile),
m_mutex(),
m_hasError(false),
m_executable(),
m_sources(),
m_makefiles(),
m_includePaths()
MakefileParserThread::MakefileParserThread(const QString &makefile) : m_parser(makefile)
{
connect(&m_parser, &MakefileParser::status,
this, &MakefileParserThread::status);
......
......@@ -25,8 +25,7 @@
**
****************************************************************************/
#ifndef MAKEFILEPARSERTHREAD_H
#define MAKEFILEPARSERTHREAD_H
#pragma once
#include "makefileparser.h"
......@@ -131,7 +130,7 @@ private:
MakefileParser m_parser; ///< Is not accessible outside the thread
mutable QMutex m_mutex;
bool m_hasError; ///< Return value for MakefileParserThread::hasError()
bool m_hasError = false; ///< Return value for MakefileParserThread::hasError()
QString m_executable; ///< Return value for MakefileParserThread::executable()