Commit 4827d3aa authored by dt's avatar dt

Qt4 Maemo: Simplfy code for adding OTHER_FILES to .pro file

Task-Nr: QTCREATORBUG-4085
parent edcfe082
......@@ -2267,8 +2267,13 @@ void ProjectExplorerPlugin::addExistingFiles()
void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths)
{
ProjectNode *projectNode = qobject_cast<ProjectNode*>(d->m_currentNode->projectNode());
addExistingFiles(projectNode, filePaths);
}
void ProjectExplorerPlugin::addExistingFiles(ProjectNode *projectNode, const QStringList &filePaths)
{
Core::ICore *core = Core::ICore::instance();
const QString dir = directoryFor(d->m_currentNode);
const QString dir = directoryFor(projectNode);
QStringList fileNames = filePaths;
QHash<FileType, QString> fileTypeToFiles;
foreach (const QString &fileName, fileNames) {
......
......@@ -61,6 +61,7 @@ class IRunControlFactory;
class Project;
class Node;
class BuildConfiguration;
class ProjectNode;
namespace Internal {
class ProjectFileFactory;
......@@ -120,6 +121,7 @@ public:
void runProject(Project *pro, const QString &mode);
void runRunConfiguration(ProjectExplorer::RunConfiguration *rc, const QString &mode);
void addExistingFiles(ProjectExplorer::ProjectNode *projectNode, const QStringList &filePaths);
void addExistingFiles(const QStringList &filePaths);
signals:
......
......@@ -115,8 +115,9 @@ AbstractQt4MaemoTarget::AbstractQt4MaemoTarget(Qt4Project *parent, const QString
{
setIcon(QIcon(":/projectexplorer/images/MaemoDevice.png"));
connect(parent, SIGNAL(addedTarget(ProjectExplorer::Target*)),
this, SLOT(handleTargetAdded(ProjectExplorer::Target*)),
Qt::QueuedConnection); // Otherwise ProjextExplorerPlugin::addExistingFiles() won't be ready.
this, SLOT(handleTargetAdded(ProjectExplorer::Target*)));
connect(parent, SIGNAL(fromMapFinished()),
this, SLOT(handleFromMapFinished()));
}
AbstractQt4MaemoTarget::~AbstractQt4MaemoTarget()
......@@ -273,11 +274,24 @@ QSharedPointer<QFile> AbstractQt4MaemoTarget::openFile(const QString &filePath,
return file;
}
void AbstractQt4MaemoTarget::handleFromMapFinished()
{
handleTargetAdded(this);
}
void AbstractQt4MaemoTarget::handleTargetAdded(ProjectExplorer::Target *target)
{
if (target != this)
return;
if (!project()->rootProjectNode()) {
// Project is not fully setup yet, happens on new project
// we wait for the fromMapFinished that comes afterwards
return;
}
disconnect(project(), SIGNAL(fromMapFinished()),
this, SLOT(handleFromMapFinished()));
disconnect(project(), SIGNAL(addedTarget(ProjectExplorer::Target*)),
this, SLOT(handleTargetAdded(ProjectExplorer::Target*)));
connect(project(), SIGNAL(aboutToRemoveTarget(ProjectExplorer::Target*)),
......@@ -346,7 +360,7 @@ AbstractQt4MaemoTarget::ActionStatus AbstractQt4MaemoTarget::createTemplates()
.arg(files.join(QLatin1String("\n "))),
QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes)
ProjectExplorer::ProjectExplorerPlugin::instance()->addExistingFiles(files);
ProjectExplorer::ProjectExplorerPlugin::instance()->addExistingFiles(project()->rootProjectNode(), files);
}
return actionStatus;
}
......
......@@ -104,6 +104,7 @@ protected:
private slots:
void handleTargetAdded(ProjectExplorer::Target *target);
void handleFromMapFinished();
void handleTargetToBeRemoved(ProjectExplorer::Target *target);
private:
......
......@@ -348,6 +348,8 @@ bool Qt4Project::fromMap(const QVariantMap &map)
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(activeTargetWasChanged()));
emit fromMapFinished();
return true;
}
......
......@@ -191,6 +191,7 @@ signals:
void proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *node, bool);
void proFileInvalidated(Qt4ProjectManager::Internal::Qt4ProFileNode *node);
void buildDirectoryInitialized();
void fromMapFinished();
public slots:
void proFileParseError(const QString &errorMessage);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment