Hide static cast in accessor methods

This commit is contained in:
dt
2009-11-26 14:43:27 +01:00
parent d9a1769542
commit 801e9948f5
31 changed files with 169 additions and 70 deletions

View File

@@ -51,6 +51,11 @@ CMakeBuildConfiguration::~CMakeBuildConfiguration()
delete m_toolChain;
}
CMakeProject *CMakeBuildConfiguration::cmakeProject() const
{
return static_cast<CMakeProject *>(project());
}
ProjectExplorer::Environment CMakeBuildConfiguration::baseEnvironment() const
{
ProjectExplorer::Environment env = useSystemEnvironment() ?
@@ -99,7 +104,7 @@ QString CMakeBuildConfiguration::buildDirectory() const
{
QString buildDirectory = value("buildDirectory").toString();
if (buildDirectory.isEmpty())
buildDirectory = static_cast<CMakeProject *>(project())->sourceDirectory() + "/qtcreator-build";
buildDirectory = cmakeProject()->sourceDirectory() + "/qtcreator-build";
return buildDirectory;
}

View File

@@ -46,6 +46,8 @@ public:
CMakeBuildConfiguration(BuildConfiguration *source);
~CMakeBuildConfiguration();
CMakeProject *cmakeProject() const;
ProjectExplorer::Environment environment() const;
ProjectExplorer::Environment baseEnvironment() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);

View File

@@ -166,6 +166,11 @@ CMakeProject::~CMakeProject()
delete m_rootNode;
}
CMakeBuildConfiguration *CMakeProject::activeCMakeBuildConfiguration() const
{
return static_cast<CMakeBuildConfiguration *>(activeBuildConfiguration());
}
IBuildConfigurationFactory *CMakeProject::buildConfigurationFactory() const
{
return m_buildConfigurationFactory;
@@ -228,8 +233,8 @@ QString CMakeProject::sourceDirectory() const
bool CMakeProject::parseCMakeLists()
{
// Find cbp file
CMakeBuildConfiguration *activeCmakeBuildConfiguration = static_cast<CMakeBuildConfiguration *>(activeBuildConfiguration());
QString cbpFile = CMakeManager::findCbpFile(activeCmakeBuildConfiguration->buildDirectory());
CMakeBuildConfiguration *activeBC = activeCMakeBuildConfiguration();
QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory());
// setFolderName
m_rootNode->setFolderName(QFileInfo(cbpFile).completeBaseName());
@@ -238,7 +243,7 @@ bool CMakeProject::parseCMakeLists()
//qDebug()<<"Parsing file "<<cbpFile;
if (cbpparser.parseCbpFile(cbpFile)) {
// ToolChain
activeCmakeBuildConfiguration->updateToolChain(cbpparser.compilerName());
activeBC->updateToolChain(cbpparser.compilerName());
m_projectName = cbpparser.projectName();
m_rootNode->setFolderName(cbpparser.projectName());
@@ -291,7 +296,7 @@ bool CMakeProject::parseCMakeLists()
QStringList allIncludePaths;
QStringList allFrameworkPaths;
QList<ProjectExplorer::HeaderPath> allHeaderPaths = activeCmakeBuildConfiguration->toolChain()->systemHeaderPaths();
QList<ProjectExplorer::HeaderPath> allHeaderPaths = activeBC->toolChain()->systemHeaderPaths();
foreach (ProjectExplorer::HeaderPath headerPath, allHeaderPaths) {
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
allFrameworkPaths.append(headerPath.path());
@@ -307,12 +312,12 @@ bool CMakeProject::parseCMakeLists()
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
if (pinfo.includePaths != allIncludePaths
|| pinfo.sourceFiles != m_files
|| pinfo.defines != activeCmakeBuildConfiguration->toolChain()->predefinedMacros()
|| pinfo.defines != activeBC->toolChain()->predefinedMacros()
|| pinfo.frameworkPaths != allFrameworkPaths) {
pinfo.includePaths = allIncludePaths;
// TODO we only want C++ files, not all other stuff that might be in the project
pinfo.sourceFiles = m_files;
pinfo.defines = activeCmakeBuildConfiguration->toolChain()->predefinedMacros(); // TODO this is to simplistic
pinfo.defines = activeBC->toolChain()->predefinedMacros(); // TODO this is to simplistic
pinfo.frameworkPaths = allFrameworkPaths;
modelmanager->updateProjectInfo(pinfo);
modelmanager->updateSourceFiles(pinfo.sourceFiles);
@@ -370,7 +375,7 @@ bool CMakeProject::parseCMakeLists()
} else {
// TODO report error
qDebug()<<"Parsing failed";
activeCmakeBuildConfiguration->updateToolChain(QString::null);
activeBC->updateToolChain(QString::null);
return false;
}
return true;

View File

@@ -91,6 +91,8 @@ public:
CMakeProject(CMakeManager *manager, const QString &filename);
~CMakeProject();
CMakeBuildConfiguration *activeCMakeBuildConfiguration() const;
virtual QString name() const;
virtual Core::IFile *file() const;
virtual ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const;

View File

@@ -66,6 +66,12 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &t
CMakeRunConfiguration::~CMakeRunConfiguration()
{
}
CMakeProject *CMakeRunConfiguration::cmakeProject() const
{
return static_cast<CMakeProject *>(project());
}
QString CMakeRunConfiguration::type() const
@@ -228,7 +234,7 @@ void CMakeRunConfiguration::setUserEnvironmentChanges(const QList<ProjectExplore
ProjectExplorer::ToolChain::ToolChainType CMakeRunConfiguration::toolChainType() const
{
CMakeBuildConfiguration *bc = static_cast<CMakeBuildConfiguration *>(project()->activeBuildConfiguration());
CMakeBuildConfiguration *bc = cmakeProject()->activeCMakeBuildConfiguration();
return bc->toolChainType();
}

View File

@@ -53,6 +53,8 @@ class CMakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfigu
public:
CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory, const QString &title);
virtual ~CMakeRunConfiguration();
CMakeProject *cmakeProject() const;
virtual QString type() const;
virtual QString executable() const;
virtual RunMode runMode() const;

View File

@@ -64,6 +64,11 @@ MakeStep::~MakeStep()
}
CMakeBuildConfiguration *MakeStep::cmakeBuildConfiguration() const
{
return static_cast<CMakeBuildConfiguration *>(buildConfiguration());
}
void MakeStep::setClean(bool clean)
{
m_clean = clean;
@@ -96,7 +101,7 @@ void MakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map)
bool MakeStep::init()
{
CMakeBuildConfiguration *bc = static_cast<CMakeBuildConfiguration *>(buildConfiguration());
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
// TODO, we should probably have a member cmakeBuildConfiguration();
setBuildParser(bc->buildParser());
@@ -204,7 +209,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
// TODO update this list also on rescans of the CMakeLists.txt
// TODO shouldn't be accessing project
CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->buildConfiguration()->project());
CMakeProject *pro = m_makeStep->cmakeBuildConfiguration()->cmakeProject();
foreach(const QString& target, pro->targets()) {
QListWidgetItem *item = new QListWidgetItem(target, m_targetsList);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
@@ -254,7 +259,7 @@ void MakeStepConfigWidget::updateDetails()
QStringList arguments = m_makeStep->m_buildTargets;
arguments << m_makeStep->additionalArguments();
CMakeBuildConfiguration *bc = static_cast<CMakeBuildConfiguration *>(m_makeStep->buildConfiguration());
CMakeBuildConfiguration *bc = m_makeStep->cmakeBuildConfiguration();
m_summaryText = tr("<b>Make:</b> %1 %2").arg(bc->toolChain()->makeCommand(), arguments.join(" "));
emit updateSummary();
}

View File

@@ -41,7 +41,7 @@ QT_END_NAMESPACE
namespace CMakeProjectManager {
namespace Internal {
class CMakeProject;
class CMakeBuildConfiguration;
class MakeStep : public ProjectExplorer::AbstractMakeStep
{
@@ -52,6 +52,9 @@ public:
MakeStep(ProjectExplorer::BuildConfiguration *bc);
MakeStep(MakeStep *bs, ProjectExplorer::BuildConfiguration *bc);
~MakeStep();
CMakeBuildConfiguration *cmakeBuildConfiguration() const;
virtual bool init();
virtual void run(QFutureInterface<bool> &fi);