Maemo: Don't create desktop files, ask before updating project files.

Also don't waste performance by repeatedly reacting to the same
project file change.
This is relevant for bigger projects to which a Maemo target might
have been added by mistake.

Task-number: QTCREATORBUG-2647
Reviewed-by: kh1
This commit is contained in:
Christian Kandeler
2010-10-11 15:40:25 +02:00
parent a48139b8d0
commit d23afc8e61
12 changed files with 421 additions and 33 deletions

View File

@@ -41,10 +41,11 @@
#include "maemodeployables.h"
#include "maemodeployablelistmodel.h"
#include "maemoprofilesupdatedialog.h"
#include <profileevaluator.h>
#include <projectexplorer/buildstep.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4target.h>
@@ -55,46 +56,91 @@ namespace Qt4ProjectManager {
namespace Internal {
MaemoDeployables::MaemoDeployables(const ProjectExplorer::BuildStep *buildStep)
: m_buildStep(buildStep)
: m_buildStep(buildStep), m_updateTimer(new QTimer(this))
{
QTimer::singleShot(0, this, SLOT(init()));
m_updateTimer->setInterval(1500);
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(createModels()));
}
MaemoDeployables::~MaemoDeployables() {}
void MaemoDeployables::init()
{
createModels();
connect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
this, SLOT(createModels()));
m_updateTimer, SLOT(start()));
createModels();
}
void MaemoDeployables::createModels()
{
qDeleteAll(m_listModels);
m_listModels.clear();
if (!qt4BuildConfiguration() || !qt4BuildConfiguration()->qt4Target()
|| qt4BuildConfiguration()->qt4Target()->project()->activeTarget()->id()
!= QLatin1String(Qt4ProjectManager::Constants::MAEMO_DEVICE_TARGET_ID))
return;
disconnect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
m_updateTimer, SLOT(start()));
m_updateTimer->stop();
m_proFileOption = QSharedPointer<ProFileOption>(new ProFileOption);
m_proFileOption->properties
= qt4BuildConfiguration()->qtVersion()->versionInfo();
m_proFileOption->target_mode = ProFileOption::TARG_UNIX_MODE;
createModels(qt4BuildConfiguration()->qt4Target()->qt4Project()
->rootProjectNode());
const Qt4ProFileNode *const rootNode
= qt4BuildConfiguration()->qt4Target()->qt4Project()->rootProjectNode();
if (!rootNode) // Happens on project creation by wizard.
return;
qDeleteAll(m_listModels);
m_listModels.clear();
createModels(rootNode);
QList<MaemoDeployableListModel *> modelsWithoutTargetPath;
foreach (MaemoDeployableListModel *const model, m_listModels) {
if (!model->hasTargetPath()) {
if (model->proFileUpdateSetting() == MaemoDeployableListModel::AskToUpdateProFile)
modelsWithoutTargetPath << model;
}
}
if (!modelsWithoutTargetPath.isEmpty()) {
MaemoProFilesUpdateDialog dialog(modelsWithoutTargetPath);
dialog.exec();
const QList<MaemoProFilesUpdateDialog::UpdateSetting> &settings
= dialog.getUpdateSettings();
foreach (const MaemoProFilesUpdateDialog::UpdateSetting &setting, settings) {
const MaemoDeployableListModel::ProFileUpdateSetting updateSetting
= setting.second
? MaemoDeployableListModel::UpdateProFile
: MaemoDeployableListModel::DontUpdateProFile;
m_updateSettings.insert(setting.first->proFileNode()->path(),
updateSetting);
setting.first->setProFileUpdateSetting(updateSetting);
}
}
emit modelsCreated();
connect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
m_updateTimer, SLOT(start()));
}
void MaemoDeployables::createModels(const Qt4ProFileNode *proFileNode)
{
if (!proFileNode) // Happens on project creation by wizard.
return;
const Qt4ProjectType type = proFileNode->projectType() ;
switch (type) {
switch (proFileNode->projectType()) {
case ApplicationTemplate:
case LibraryTemplate:
case ScriptTemplate:
m_listModels
<< new MaemoDeployableListModel(proFileNode, m_proFileOption, this);
case ScriptTemplate: {
UpdateSettingsMap::ConstIterator it
= m_updateSettings.find(proFileNode->path());
const MaemoDeployableListModel::ProFileUpdateSetting updateSetting
= it != m_updateSettings.end()
? it.value() : MaemoDeployableListModel::AskToUpdateProFile;
MaemoDeployableListModel *const newModel
= new MaemoDeployableListModel(proFileNode, m_proFileOption,
updateSetting, this);
m_listModels << newModel;
break;
}
case SubDirsTemplate: {
const QList<ProjectExplorer::ProjectNode *> &subProjects
= proFileNode->subProjectNodes();
@@ -160,7 +206,6 @@ const Qt4BuildConfiguration *MaemoDeployables::qt4BuildConfiguration() const
{
const Qt4BuildConfiguration * const bc
= qobject_cast<Qt4BuildConfiguration *>(m_buildStep->target()->activeBuildConfiguration());
Q_ASSERT(bc);
return bc;
}