Commit fc31b812 authored by Christian Kandeler's avatar Christian Kandeler

Maemo: Optionally remove packaging data on target removal.

Task-number: QTCREATORBUG-2996
parent e79f6031
......@@ -149,6 +149,7 @@ MaemoGlobal::MaemoVersion MaemoGlobal::version(const QtVersion *qtVersion)
bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
{
error.clear();
QFileInfo fileInfo(filePath);
if (!fileInfo.exists())
return true;
......
......@@ -104,6 +104,8 @@ void MaemoTemplatesManager::handleActiveProjectChanged(ProjectExplorer::Project
this, SLOT(handleTarget(ProjectExplorer::Target*)));
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(handleTarget(ProjectExplorer::Target*)));
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
SLOT(handleTargetRemoved(ProjectExplorer::Target*)));
const QList<Target *> &targets = project->targets();
foreach (Target * const target, targets)
handleTarget(target);
......@@ -143,6 +145,32 @@ bool MaemoTemplatesManager::handleTarget(ProjectExplorer::Target *target)
return true;
}
void MaemoTemplatesManager::handleTargetRemoved(ProjectExplorer::Target *target)
{
if (target->id() != QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
return;
const QString debianPath = debianDirPath(target->project());
if (!QFileInfo(debianPath).exists())
return;
const int answer = QMessageBox::warning(0, tr("Qt Creator"),
tr("Do you want to remove the packaging directory\n"
"associated with the target?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (answer == QMessageBox::No)
return;
QString error;
if (!MaemoGlobal::removeRecursively(debianPath, error))
qDebug("%s", qPrintable(error));
const QString packagingPath = target->project()->projectDirectory()
+ QLatin1Char('/') + PackagingDirName;
const QStringList otherContents = QDir(packagingPath).entryList(QDir::Dirs
| QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot);
if (otherContents.isEmpty()) {
if (!MaemoGlobal::removeRecursively(packagingPath, error))
qDebug("%s", qPrintable(error));
}
}
bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplorer::Target *target)
{
Project * const project = target->project();
......
......@@ -95,6 +95,7 @@ private slots:
void handleDebianFileChanged(const QString &filePath);
void handleProjectToBeRemoved(ProjectExplorer::Project *project);
void handleProFileUpdated();
void handleTargetRemoved(ProjectExplorer::Target *target);
private:
explicit MaemoTemplatesManager(QObject *parent);
......
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