summaryrefslogtreecommitdiff
path: root/src/plugins/qmakeandroidsupport
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2017-07-17 14:34:05 +0200
committerTobias Hunger <tobias.hunger@qt.io>2017-07-28 17:26:03 +0000
commit131c7a1c4e60da68bd5cfc5a6d5df1dc81ed0125 (patch)
tree1b7515acaf4480411849fcfd61fb599cafc5241b /src/plugins/qmakeandroidsupport
parentc01ddc4660c10e8ddc605602fd623135fb607de0 (diff)
downloadqt-creator-131c7a1c4e60da68bd5cfc5a6d5df1dc81ed0125.tar.gz
ProjectExplorer: Introduce base class for enabled/disabled project configuration
... and use this as a base for all RunConfigurations. Clean out code in the individual run configurations dealing with their enabled/disabled state. Change-Id: Icc2ea136b056f7aea7ce96480b4402459d7ac0ce Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/qmakeandroidsupport')
-rw-r--r--src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp57
-rw-r--r--src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h6
2 files changed, 10 insertions, 53 deletions
diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp
index 6cb626ee7e..d30b2a0328 100644
--- a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp
+++ b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp
@@ -58,26 +58,20 @@ QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, Core:
: AndroidRunConfiguration(parent, id)
, m_proFilePath(path)
{
- QmakeProject *project = static_cast<QmakeProject *>(parent->project());
- m_parseSuccess = project->validParse(m_proFilePath);
- m_parseInProgress = project->parseInProgress(m_proFilePath);
- init();
+ ctor();
}
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, QmakeAndroidRunConfiguration *source)
: AndroidRunConfiguration(parent, source)
, m_proFilePath(source->m_proFilePath)
- , m_parseSuccess(source->m_parseSuccess)
- , m_parseInProgress(source->m_parseInProgress)
{
- init();
+ ctor();
}
-void QmakeAndroidRunConfiguration::init()
+void QmakeAndroidRunConfiguration::ctor()
{
setDefaultDisplayName(defaultDisplayName());
- connect(qmakeProject(), &QmakeProject::proFileUpdated,
- this, &QmakeAndroidRunConfiguration::proFileUpdated);
+ QTC_CHECK(!m_proFilePath.isEmpty());
}
bool QmakeAndroidRunConfiguration::fromMap(const QVariantMap &map)
@@ -86,24 +80,17 @@ bool QmakeAndroidRunConfiguration::fromMap(const QVariantMap &map)
QTC_ASSERT(project, return false);
const QDir projectDir = QDir(project->projectDirectory().toString());
m_proFilePath = Utils::FileName::fromUserInput(projectDir.filePath(map.value(PRO_FILE_KEY).toString()));
- m_parseSuccess = project->validParse(m_proFilePath);
- m_parseInProgress = project->parseInProgress(m_proFilePath);
return AndroidRunConfiguration::fromMap(map);
}
QVariantMap QmakeAndroidRunConfiguration::toMap() const
{
- QmakeProject *project = qmakeProject();
- if (m_proFilePath.isEmpty()) {
- if (!project->rootProjectNode())
- return QVariantMap();
- m_proFilePath = project->rootProjectNode()->filePath();
- }
-
- const QDir projectDir = QDir(project->projectDirectory().toString());
QVariantMap map(AndroidRunConfiguration::toMap());
+
+ const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
map.insert(PRO_FILE_KEY, projectDir.relativeFilePath(m_proFilePath.toString()));
+
return map;
}
@@ -120,18 +107,13 @@ QString QmakeAndroidRunConfiguration::defaultDisplayName()
return QFileInfo(pathFromId(id())).completeBaseName();
}
-bool QmakeAndroidRunConfiguration::isEnabled() const
-{
- return m_parseSuccess && !m_parseInProgress;
-}
-
QString QmakeAndroidRunConfiguration::disabledReason() const
{
- if (m_parseInProgress)
+ if (qmakeProject()->isParsing())
return tr("The .pro file \"%1\" is currently being parsed.")
.arg(m_proFilePath.fileName());
- if (!m_parseSuccess)
+ if (!qmakeProject()->hasParsingData())
return qmakeProject()->disabledReasonForRunConfiguration(m_proFilePath);
return QString();
}
@@ -141,27 +123,6 @@ QString QmakeAndroidRunConfiguration::buildSystemTarget() const
return qmakeProject()->mapProFilePathToTarget(m_proFilePath);
}
-void QmakeAndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFile *pro,
- bool success, bool parseInProgress)
-{
- QmakeProject *project = qmakeProject();
- if (m_proFilePath.isEmpty() && project->rootProjectNode())
- m_proFilePath = project->rootProjectNode()->filePath();
-
- if (m_proFilePath != pro->filePath())
- return;
-
- bool enabled = isEnabled();
- QString reason = disabledReason();
- m_parseSuccess = success;
- m_parseInProgress = parseInProgress;
- if (enabled != isEnabled() || reason != disabledReason())
- emit enabledChanged();
-
- if (!parseInProgress)
- setDefaultDisplayName(defaultDisplayName());
-}
-
QmakeProject *QmakeAndroidRunConfiguration::qmakeProject() const
{
Target *t = target();
diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h
index f7ff72987c..5a788b12cd 100644
--- a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h
+++ b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h
@@ -48,7 +48,6 @@ public:
Utils::FileName proFilePath() const;
- bool isEnabled() const override;
QString disabledReason() const override;
QString buildSystemTarget() const final;
@@ -61,13 +60,10 @@ protected:
QString defaultDisplayName();
private:
- void proFileUpdated(QmakeProjectManager::QmakeProFile *pro, bool success, bool parseInProgress);
QmakeProjectManager::QmakeProject *qmakeProject() const;
- void init();
+ void ctor();
mutable Utils::FileName m_proFilePath;
- bool m_parseSuccess;
- bool m_parseInProgress;
};
} // namespace Internal