forked from qt-creator/qt-creator
AndroidRunConfigurations: Split up into general and qmake specific parts
The plan is to eventually move the qmake specific class into the qmake plugin. Change-Id: I5653c45ed88b1be296f4963ab4117bbfa791fb85 Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
@@ -36,36 +36,21 @@
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace {
|
||||
const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile";
|
||||
}
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using QmakeProjectManager::QmakeProject;
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, Core::Id id, const QString &path)
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, Core::Id id)
|
||||
: RunConfiguration(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();
|
||||
}
|
||||
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, AndroidRunConfiguration *source)
|
||||
: RunConfiguration(parent, source)
|
||||
, m_proFilePath(source->m_proFilePath)
|
||||
, m_parseSuccess(source->m_parseSuccess)
|
||||
, m_parseInProgress(source->m_parseInProgress)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -73,55 +58,6 @@ AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, AndroidRunConfi
|
||||
void AndroidRunConfiguration::init()
|
||||
{
|
||||
setDefaultDisplayName(defaultDisplayName());
|
||||
connect(target()->project(), SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)),
|
||||
this, SLOT(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)));
|
||||
}
|
||||
|
||||
bool AndroidRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
||||
m_proFilePath = QDir::cleanPath(projectDir.filePath(map.value(QLatin1String(PRO_FILE_KEY)).toString()));
|
||||
m_parseSuccess = static_cast<QmakeProject *>(target()->project())->validParse(m_proFilePath);
|
||||
m_parseInProgress = static_cast<QmakeProject *>(target()->project())->parseInProgress(m_proFilePath);
|
||||
|
||||
return RunConfiguration::fromMap(map);
|
||||
}
|
||||
|
||||
QVariantMap AndroidRunConfiguration::toMap() const
|
||||
{
|
||||
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
||||
QVariantMap map(RunConfiguration::toMap());
|
||||
map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath));
|
||||
return map;
|
||||
}
|
||||
|
||||
bool AndroidRunConfiguration::isEnabled() const
|
||||
{
|
||||
return m_parseSuccess && !m_parseInProgress;
|
||||
}
|
||||
|
||||
QString AndroidRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (m_parseInProgress)
|
||||
return tr("The .pro file \"%1\" is currently being parsed.")
|
||||
.arg(QFileInfo(m_proFilePath).fileName());
|
||||
|
||||
if (!m_parseSuccess)
|
||||
return static_cast<QmakeProject *>(target()->project())->disabledReasonForRunConfiguration(m_proFilePath);
|
||||
return QString();
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress)
|
||||
{
|
||||
if (m_proFilePath != pro->path())
|
||||
return;
|
||||
|
||||
bool enabled = isEnabled();
|
||||
QString reason = disabledReason();
|
||||
m_parseSuccess = success;
|
||||
m_parseInProgress = parseInProgress;
|
||||
if (enabled != isEnabled() || reason != disabledReason())
|
||||
emit enabledChanged();
|
||||
}
|
||||
|
||||
QWidget *AndroidRunConfiguration::createConfigurationWidget()
|
||||
@@ -144,10 +80,4 @@ const QString AndroidRunConfiguration::remoteChannel() const
|
||||
return QLatin1String(":5039");
|
||||
}
|
||||
|
||||
QString AndroidRunConfiguration::proFilePath() const
|
||||
{
|
||||
return m_proFilePath;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
Reference in New Issue
Block a user