forked from qt-creator/qt-creator
		
	QmakeProjectManager et al: Reduce use of qmake specific logic
Change-Id: I8f7e5d822ccb27e3ec241b814ec67aed7fe7539f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
		@@ -159,27 +159,13 @@ void IosRunConfiguration::updateEnabledState()
 | 
			
		||||
 | 
			
		||||
bool IosRunConfiguration::canRunForNode(const Node *node) const
 | 
			
		||||
{
 | 
			
		||||
    return node->filePath() == profilePath();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FileName IosRunConfiguration::profilePath() const
 | 
			
		||||
{
 | 
			
		||||
    return FileName::fromString(buildKey());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static QmakeProFile *proFile(const IosRunConfiguration *rc)
 | 
			
		||||
{
 | 
			
		||||
    auto pro = qobject_cast<const QmakeProject *>(rc->target()->project());
 | 
			
		||||
    QmakeProFile *proFile = pro ? pro->rootProFile() : nullptr;
 | 
			
		||||
    if (proFile)
 | 
			
		||||
        proFile = proFile->findProFile(rc->profilePath());
 | 
			
		||||
    return proFile;
 | 
			
		||||
    return node->filePath().toString() == buildKey();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString IosRunConfiguration::applicationName() const
 | 
			
		||||
{
 | 
			
		||||
    QmakeProFile *pro = proFile(this);
 | 
			
		||||
    if (pro) {
 | 
			
		||||
    Project *project = target()->project();
 | 
			
		||||
    if (auto pro = dynamic_cast<const QmakeProFileNode *>(project->findNodeForBuildKey(buildKey()))) {
 | 
			
		||||
        TargetInformation ti = pro->targetInformation();
 | 
			
		||||
        if (ti.valid)
 | 
			
		||||
            return ti.target;
 | 
			
		||||
@@ -197,7 +183,8 @@ FileName IosRunConfiguration::bundleDirectory() const
 | 
			
		||||
        return res;
 | 
			
		||||
    }
 | 
			
		||||
    if (BuildConfiguration *bc = target()->activeBuildConfiguration()) {
 | 
			
		||||
        const QmakeProFile *pro = proFile(this);
 | 
			
		||||
        Project *project = target()->project();
 | 
			
		||||
        auto pro = dynamic_cast<const QmakeProFileNode *>(project->findNodeForBuildKey(buildKey()));
 | 
			
		||||
        if (pro) {
 | 
			
		||||
            TargetInformation ti = pro->targetInformation();
 | 
			
		||||
            if (ti.valid)
 | 
			
		||||
 
 | 
			
		||||
@@ -61,10 +61,8 @@ QVariant QmakeAndroidSupport::targetData(Core::Id role, const Target *target) co
 | 
			
		||||
        return {};
 | 
			
		||||
 | 
			
		||||
    const FileName projectFilePath = FileName::fromString(rc->buildKey());
 | 
			
		||||
    const QmakeProject *pro = qobject_cast<QmakeProject *>(target->project());
 | 
			
		||||
    QTC_ASSERT(pro, return {});
 | 
			
		||||
    QTC_ASSERT(pro->rootProjectNode(), return {});
 | 
			
		||||
    const QmakeProFileNode *profileNode = pro->rootProjectNode()->findProFileFor(projectFilePath);
 | 
			
		||||
    const ProjectNode *projectNode = target->project()->findNodeForBuildKey(rc->buildKey());
 | 
			
		||||
    auto profileNode = dynamic_cast<const QmakeProFileNode *>(projectNode);
 | 
			
		||||
    QTC_ASSERT(profileNode, return {});
 | 
			
		||||
 | 
			
		||||
    if (role == Android::Constants::AndroidPackageSourceDir)
 | 
			
		||||
 
 | 
			
		||||
@@ -864,12 +864,12 @@ bool PackageLibraryDetailsController::isLinkPackageGenerated() const
 | 
			
		||||
    if (!project)
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    const auto *rootProject = dynamic_cast<const QmakeProFileNode *>(project->rootProjectNode());
 | 
			
		||||
    if (!rootProject)
 | 
			
		||||
    const ProjectNode *projectNode = project->findNodeForBuildKey(proFile());
 | 
			
		||||
    if (!projectNode)
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    const QmakeProFileNode *currentProject =
 | 
			
		||||
            rootProject->findProFileFor(Utils::FileName::fromString(proFile()));
 | 
			
		||||
            dynamic_cast<const QmakeProFileNode *>(projectNode);
 | 
			
		||||
    if (!currentProject)
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -198,18 +198,6 @@ FolderNode::AddNewInformation QmakePriFileNode::addNewInformation(const QStringL
 | 
			
		||||
    return FolderNode::AddNewInformation(filePath().fileName(), context && context->parentProjectNode() == this ? 120 : 90);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QmakeProFileNode *QmakeProFileNode::findProFileFor(const FileName &fileName) const
 | 
			
		||||
{
 | 
			
		||||
    if (fileName == filePath())
 | 
			
		||||
        return const_cast<QmakeProFileNode *>(this);
 | 
			
		||||
    for (Node *node : nodes()) {
 | 
			
		||||
        if (auto *qmakeProFileNode = dynamic_cast<QmakeProFileNode *>(node))
 | 
			
		||||
            if (QmakeProFileNode *result = qmakeProFileNode->findProFileFor(fileName))
 | 
			
		||||
                return result;
 | 
			
		||||
    }
 | 
			
		||||
    return nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
  \class QmakeProFileNode
 | 
			
		||||
  Implements abstract ProjectNode class
 | 
			
		||||
 
 | 
			
		||||
@@ -102,7 +102,6 @@ public:
 | 
			
		||||
    QStringList variableValue(const Variable var) const;
 | 
			
		||||
    QString singleVariableValue(const Variable var) const;
 | 
			
		||||
 | 
			
		||||
    QmakeProFileNode *findProFileFor(const Utils::FileName &string) const;
 | 
			
		||||
    TargetInformation targetInformation() const;
 | 
			
		||||
 | 
			
		||||
    bool showInSimpleTree(ProjectType projectType) const;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user