forked from qt-creator/qt-creator
Maemo: Optionally remove packaging data on target removal.
Task-number: QTCREATORBUG-2996
This commit is contained in:
@@ -149,6 +149,7 @@ MaemoGlobal::MaemoVersion MaemoGlobal::version(const QtVersion *qtVersion)
|
|||||||
|
|
||||||
bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
|
bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
|
||||||
{
|
{
|
||||||
|
error.clear();
|
||||||
QFileInfo fileInfo(filePath);
|
QFileInfo fileInfo(filePath);
|
||||||
if (!fileInfo.exists())
|
if (!fileInfo.exists())
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ void MaemoTemplatesManager::handleActiveProjectChanged(ProjectExplorer::Project
|
|||||||
this, SLOT(handleTarget(ProjectExplorer::Target*)));
|
this, SLOT(handleTarget(ProjectExplorer::Target*)));
|
||||||
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
||||||
this, SLOT(handleTarget(ProjectExplorer::Target*)));
|
this, SLOT(handleTarget(ProjectExplorer::Target*)));
|
||||||
|
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
||||||
|
SLOT(handleTargetRemoved(ProjectExplorer::Target*)));
|
||||||
const QList<Target *> &targets = project->targets();
|
const QList<Target *> &targets = project->targets();
|
||||||
foreach (Target * const target, targets)
|
foreach (Target * const target, targets)
|
||||||
handleTarget(target);
|
handleTarget(target);
|
||||||
@@ -143,6 +145,32 @@ bool MaemoTemplatesManager::handleTarget(ProjectExplorer::Target *target)
|
|||||||
return true;
|
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)
|
bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplorer::Target *target)
|
||||||
{
|
{
|
||||||
Project * const project = target->project();
|
Project * const project = target->project();
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ private slots:
|
|||||||
void handleDebianFileChanged(const QString &filePath);
|
void handleDebianFileChanged(const QString &filePath);
|
||||||
void handleProjectToBeRemoved(ProjectExplorer::Project *project);
|
void handleProjectToBeRemoved(ProjectExplorer::Project *project);
|
||||||
void handleProFileUpdated();
|
void handleProFileUpdated();
|
||||||
|
void handleTargetRemoved(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit MaemoTemplatesManager(QObject *parent);
|
explicit MaemoTemplatesManager(QObject *parent);
|
||||||
|
|||||||
Reference in New Issue
Block a user