forked from qt-creator/qt-creator
Added VCS integration to ResourceEditor.
Made add and remove operations of ResourceEditor VCS-aware. Also, remove operation now can remove files from filesystem. FileUtils::removeFile() and VcsManager::promptToAdd functions were extracted from ProjectExplorer to prevent code duplication. RemoveFileDialog was also moved to coreplugin. Change-Id: Ia51127288030e52ce9475b369e56ea034dfa5d1e Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
bd7499b896
commit
728579ef52
@@ -97,7 +97,8 @@ SOURCES += mainwindow.cpp \
|
|||||||
featureprovider.cpp \
|
featureprovider.cpp \
|
||||||
idocument.cpp \
|
idocument.cpp \
|
||||||
textdocument.cpp \
|
textdocument.cpp \
|
||||||
documentmanager.cpp
|
documentmanager.cpp \
|
||||||
|
removefiledialog.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
editmode.h \
|
editmode.h \
|
||||||
@@ -194,7 +195,8 @@ HEADERS += mainwindow.h \
|
|||||||
idocument.h \
|
idocument.h \
|
||||||
idocumentfactory.h \
|
idocumentfactory.h \
|
||||||
textdocument.h \
|
textdocument.h \
|
||||||
documentmanager.h
|
documentmanager.h \
|
||||||
|
removefiledialog.h
|
||||||
|
|
||||||
FORMS += dialogs/newdialog.ui \
|
FORMS += dialogs/newdialog.ui \
|
||||||
actionmanager/commandmappings.ui \
|
actionmanager/commandmappings.ui \
|
||||||
@@ -205,7 +207,8 @@ FORMS += dialogs/newdialog.ui \
|
|||||||
dialogs/externaltoolconfig.ui \
|
dialogs/externaltoolconfig.ui \
|
||||||
variablechooser.ui \
|
variablechooser.ui \
|
||||||
mimetypesettingspage.ui \
|
mimetypesettingspage.ui \
|
||||||
mimetypemagicdialog.ui
|
mimetypemagicdialog.ui \
|
||||||
|
removefiledialog.ui
|
||||||
|
|
||||||
RESOURCES += core.qrc \
|
RESOURCES += core.qrc \
|
||||||
fancyactionbar.qrc
|
fancyactionbar.qrc
|
||||||
|
@@ -122,6 +122,9 @@ QtcPlugin {
|
|||||||
"outputwindow.h",
|
"outputwindow.h",
|
||||||
"plugindialog.cpp",
|
"plugindialog.cpp",
|
||||||
"plugindialog.h",
|
"plugindialog.h",
|
||||||
|
"removefiledialog.cpp",
|
||||||
|
"removefiledialog.h",
|
||||||
|
"removefiledialog.ui",
|
||||||
"rightpane.cpp",
|
"rightpane.cpp",
|
||||||
"rightpane.h",
|
"rightpane.h",
|
||||||
"settingsdatabase.cpp",
|
"settingsdatabase.cpp",
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
|
#include <coreplugin/removefiledialog.h>
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
|
||||||
@@ -171,6 +172,25 @@ QString FileUtils::msgTerminalAction()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileUtils::removeFile(const QString &filePath, bool deleteFromFS)
|
||||||
|
{
|
||||||
|
// remove from version control
|
||||||
|
ICore::vcsManager()->promptToDelete(filePath);
|
||||||
|
|
||||||
|
// remove from file system
|
||||||
|
if (deleteFromFS) {
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
if (file.exists()) {
|
||||||
|
// could have been deleted by vc
|
||||||
|
if (!file.remove())
|
||||||
|
QMessageBox::warning(ICore::mainWindow(),
|
||||||
|
QApplication::translate("Core::Internal", "Deleting File Failed"),
|
||||||
|
QApplication::translate("Core::Internal", "Could not delete file %1.").arg(filePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool fileSystemRenameFile(const QString &orgFilePath,
|
static inline bool fileSystemRenameFile(const QString &orgFilePath,
|
||||||
const QString &newFilePath)
|
const QString &newFilePath)
|
||||||
{
|
{
|
||||||
|
@@ -47,7 +47,8 @@ struct CORE_EXPORT FileUtils
|
|||||||
// Platform-dependent action descriptions
|
// Platform-dependent action descriptions
|
||||||
static QString msgGraphicalShellAction();
|
static QString msgGraphicalShellAction();
|
||||||
static QString msgTerminalAction();
|
static QString msgTerminalAction();
|
||||||
// File rename aware of version control and file system case-insensitiveness
|
// File operations aware of version control and file system case-insensitiveness
|
||||||
|
static void removeFile(const QString &filePath, bool deleteFromFS);
|
||||||
static bool renameFile(const QString &from, const QString &to);
|
static bool renameFile(const QString &from, const QString &to);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace Core;
|
||||||
|
|
||||||
RemoveFileDialog::RemoveFileDialog(const QString &filePath, QWidget *parent) :
|
RemoveFileDialog::RemoveFileDialog(const QString &filePath, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
@@ -31,16 +31,17 @@
|
|||||||
#ifndef REMOVEFILEDIALOG_H
|
#ifndef REMOVEFILEDIALOG_H
|
||||||
#define REMOVEFILEDIALOG_H
|
#define REMOVEFILEDIALOG_H
|
||||||
|
|
||||||
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace Core {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class RemoveFileDialog;
|
class RemoveFileDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RemoveFileDialog : public QDialog
|
class CORE_EXPORT RemoveFileDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -58,7 +59,6 @@ private:
|
|||||||
Ui::RemoveFileDialog *m_ui;
|
Ui::RemoveFileDialog *m_ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Core
|
||||||
} // namespace ProjectExplorer
|
|
||||||
|
|
||||||
#endif // REMOVEFILEDIALOG_H
|
#endif // REMOVEFILEDIALOG_H
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>ProjectExplorer::Internal::RemoveFileDialog</class>
|
<class>Core::RemoveFileDialog</class>
|
||||||
<widget class="QDialog" name="ProjectExplorer::Internal::RemoveFileDialog">
|
<widget class="QDialog" name="Core::RemoveFileDialog">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@@ -41,6 +41,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">placeholder</string>
|
<string notr="true">placeholder</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -96,7 +99,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>ProjectExplorer::Internal::RemoveFileDialog</receiver>
|
<receiver>Core::RemoveFileDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@@ -112,7 +115,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>ProjectExplorer::Internal::RemoveFileDialog</receiver>
|
<receiver>Core::RemoveFileDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
@@ -326,4 +326,31 @@ bool VcsManager::promptToDelete(IVersionControl *vc, const QString &fileName)
|
|||||||
return vc->vcsDelete(fileName);
|
return vc->vcsDelete(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNames)
|
||||||
|
{
|
||||||
|
IVersionControl *vc = findVersionControlForDirectory(directory);
|
||||||
|
if (!vc || !vc->supportsOperation(Core::IVersionControl::AddOperation))
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString files = fileNames.join(QString(QLatin1Char('\n')));
|
||||||
|
QMessageBox::StandardButton button =
|
||||||
|
QMessageBox::question(Core::ICore::mainWindow(), tr("Add to Version Control"),
|
||||||
|
tr("Add files\n%1\nto version control (%2)?").arg(files, vc->displayName()),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (button == QMessageBox::Yes) {
|
||||||
|
QStringList notAddedToVc;
|
||||||
|
foreach (const QString &file, fileNames) {
|
||||||
|
if (!vc->vcsAdd(file))
|
||||||
|
notAddedToVc << file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!notAddedToVc.isEmpty()) {
|
||||||
|
const QString message = tr("Could not add following files to version control (%1)\n").arg(vc->displayName());
|
||||||
|
const QString filesNotAdded = notAddedToVc.join(QString(QLatin1Char('\n')));
|
||||||
|
QMessageBox::warning(Core::ICore::mainWindow(), tr("Adding to Version Control Failed"),
|
||||||
|
message + filesNotAdded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -78,11 +78,15 @@ public:
|
|||||||
QString repositoryUrl(const QString &directory);
|
QString repositoryUrl(const QString &directory);
|
||||||
|
|
||||||
// Shows a confirmation dialog, whether the file should also be deleted
|
// Shows a confirmation dialog, whether the file should also be deleted
|
||||||
// from revision control Calls sccDelete on the file. Returns false
|
// from revision control. Calls vcsDelete on the file. Returns false
|
||||||
// if a failure occurs
|
// if a failure occurs
|
||||||
bool promptToDelete(const QString &fileName);
|
bool promptToDelete(const QString &fileName);
|
||||||
bool promptToDelete(IVersionControl *versionControl, const QString &fileName);
|
bool promptToDelete(IVersionControl *versionControl, const QString &fileName);
|
||||||
|
|
||||||
|
// Shows a confirmation dialog, whether the files in the list should be
|
||||||
|
// added to revision control. Calls vcsAdd for each file.
|
||||||
|
void promptToAdd(const QString &directory, const QStringList &fileNames);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repositoryChanged(const QString &repository);
|
void repositoryChanged(const QString &repository);
|
||||||
|
|
||||||
|
@@ -67,7 +67,6 @@
|
|||||||
#include "projectfilewizardextension.h"
|
#include "projectfilewizardextension.h"
|
||||||
#include "projecttreewidget.h"
|
#include "projecttreewidget.h"
|
||||||
#include "projectwindow.h"
|
#include "projectwindow.h"
|
||||||
#include "removefiledialog.h"
|
|
||||||
#include "runsettingspropertiespage.h"
|
#include "runsettingspropertiespage.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "projectnodes.h"
|
#include "projectnodes.h"
|
||||||
@@ -111,6 +110,7 @@
|
|||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
#include <coreplugin/variablemanager.h>
|
#include <coreplugin/variablemanager.h>
|
||||||
#include <coreplugin/fileutils.h>
|
#include <coreplugin/fileutils.h>
|
||||||
|
#include <coreplugin/removefiledialog.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <find/searchresultwindow.h>
|
#include <find/searchresultwindow.h>
|
||||||
#include <utils/consoleprocess.h>
|
#include <utils/consoleprocess.h>
|
||||||
@@ -2668,28 +2668,7 @@ void ProjectExplorerPlugin::addExistingFiles(ProjectNode *projectNode, const QSt
|
|||||||
fileNames.removeOne(file);
|
fileNames.removeOne(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core::IVersionControl *vcManager = Core::ICore::vcsManager()->findVersionControlForDirectory(dir))
|
Core::ICore::vcsManager()->promptToAdd(dir, fileNames);
|
||||||
if (vcManager->supportsOperation(Core::IVersionControl::AddOperation)) {
|
|
||||||
const QString files = fileNames.join(QString(QLatin1Char('\n')));
|
|
||||||
QMessageBox::StandardButton button =
|
|
||||||
QMessageBox::question(Core::ICore::mainWindow(), tr("Add to Version Control"),
|
|
||||||
tr("Add files\n%1\nto version control (%2)?").arg(files, vcManager->displayName()),
|
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
|
||||||
if (button == QMessageBox::Yes) {
|
|
||||||
QStringList notAddedToVc;
|
|
||||||
foreach (const QString &file, fileNames) {
|
|
||||||
if (!vcManager->vcsAdd(file))
|
|
||||||
notAddedToVc << file;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!notAddedToVc.isEmpty()) {
|
|
||||||
const QString message = tr("Could not add following files to version control (%1)\n").arg(vcManager->displayName());
|
|
||||||
const QString filesNotAdded = notAddedToVc.join(QString(QLatin1Char('\n')));
|
|
||||||
QMessageBox::warning(Core::ICore::mainWindow(), tr("Adding to Version Control Failed"),
|
|
||||||
message + filesNotAdded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorerPlugin::removeProject()
|
void ProjectExplorerPlugin::removeProject()
|
||||||
@@ -2697,7 +2676,7 @@ void ProjectExplorerPlugin::removeProject()
|
|||||||
ProjectNode *subProjectNode = qobject_cast<ProjectNode*>(d->m_currentNode->projectNode());
|
ProjectNode *subProjectNode = qobject_cast<ProjectNode*>(d->m_currentNode->projectNode());
|
||||||
ProjectNode *projectNode = qobject_cast<ProjectNode *>(subProjectNode->parentFolderNode());
|
ProjectNode *projectNode = qobject_cast<ProjectNode *>(subProjectNode->parentFolderNode());
|
||||||
if (projectNode) {
|
if (projectNode) {
|
||||||
RemoveFileDialog removeFileDialog(subProjectNode->path(), Core::ICore::mainWindow());
|
Core::RemoveFileDialog removeFileDialog(subProjectNode->path(), Core::ICore::mainWindow());
|
||||||
removeFileDialog.setDeleteFileVisible(false);
|
removeFileDialog.setDeleteFileVisible(false);
|
||||||
if (removeFileDialog.exec() == QDialog::Accepted)
|
if (removeFileDialog.exec() == QDialog::Accepted)
|
||||||
projectNode->removeSubProjects(QStringList() << subProjectNode->path());
|
projectNode->removeSubProjects(QStringList() << subProjectNode->path());
|
||||||
@@ -2736,7 +2715,7 @@ void ProjectExplorerPlugin::removeFile()
|
|||||||
FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode);
|
FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode);
|
||||||
|
|
||||||
QString filePath = d->m_currentNode->path();
|
QString filePath = d->m_currentNode->path();
|
||||||
RemoveFileDialog removeFileDialog(filePath, Core::ICore::mainWindow());
|
Core::RemoveFileDialog removeFileDialog(filePath, Core::ICore::mainWindow());
|
||||||
|
|
||||||
if (removeFileDialog.exec() == QDialog::Accepted) {
|
if (removeFileDialog.exec() == QDialog::Accepted) {
|
||||||
const bool deleteFile = removeFileDialog.isDeleteFileChecked();
|
const bool deleteFile = removeFileDialog.isDeleteFileChecked();
|
||||||
@@ -2751,20 +2730,7 @@ void ProjectExplorerPlugin::removeFile()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove from version control
|
Core::FileUtils::removeFile(filePath, deleteFile);
|
||||||
Core::ICore::vcsManager()->promptToDelete(filePath);
|
|
||||||
|
|
||||||
// remove from file system
|
|
||||||
if (deleteFile) {
|
|
||||||
QFile file(filePath);
|
|
||||||
|
|
||||||
if (file.exists()) {
|
|
||||||
// could have been deleted by vc
|
|
||||||
if (!file.remove())
|
|
||||||
QMessageBox::warning(Core::ICore::mainWindow(), tr("Deleting File Failed"),
|
|
||||||
tr("Could not delete file %1.").arg(filePath));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -79,7 +79,6 @@ HEADERS += projectexplorer.h \
|
|||||||
sessiondialog.h \
|
sessiondialog.h \
|
||||||
projectwizardpage.h \
|
projectwizardpage.h \
|
||||||
buildstepspage.h \
|
buildstepspage.h \
|
||||||
removefiledialog.h \
|
|
||||||
nodesvisitor.h \
|
nodesvisitor.h \
|
||||||
projectmodels.h \
|
projectmodels.h \
|
||||||
currentprojectfind.h \
|
currentprojectfind.h \
|
||||||
@@ -184,7 +183,6 @@ SOURCES += projectexplorer.cpp \
|
|||||||
sessiondialog.cpp \
|
sessiondialog.cpp \
|
||||||
projectwizardpage.cpp \
|
projectwizardpage.cpp \
|
||||||
buildstepspage.cpp \
|
buildstepspage.cpp \
|
||||||
removefiledialog.cpp \
|
|
||||||
nodesvisitor.cpp \
|
nodesvisitor.cpp \
|
||||||
projectmodels.cpp \
|
projectmodels.cpp \
|
||||||
currentprojectfind.cpp \
|
currentprojectfind.cpp \
|
||||||
@@ -229,7 +227,6 @@ FORMS += processstep.ui \
|
|||||||
editorsettingspropertiespage.ui \
|
editorsettingspropertiespage.ui \
|
||||||
sessiondialog.ui \
|
sessiondialog.ui \
|
||||||
projectwizardpage.ui \
|
projectwizardpage.ui \
|
||||||
removefiledialog.ui \
|
|
||||||
projectexplorersettingspage.ui \
|
projectexplorersettingspage.ui \
|
||||||
targetsettingswidget.ui \
|
targetsettingswidget.ui \
|
||||||
doubletabwidget.ui \
|
doubletabwidget.ui \
|
||||||
|
@@ -27,7 +27,6 @@ QtcPlugin {
|
|||||||
"doubletabwidget.ui",
|
"doubletabwidget.ui",
|
||||||
"processstep.ui",
|
"processstep.ui",
|
||||||
"projectexplorer.qrc",
|
"projectexplorer.qrc",
|
||||||
"removefiledialog.ui",
|
|
||||||
"sessiondialog.ui",
|
"sessiondialog.ui",
|
||||||
"targetsettingswidget.ui",
|
"targetsettingswidget.ui",
|
||||||
"projectwizardpage.ui",
|
"projectwizardpage.ui",
|
||||||
@@ -142,8 +141,6 @@ QtcPlugin {
|
|||||||
"projectwindow.cpp",
|
"projectwindow.cpp",
|
||||||
"projectwindow.h",
|
"projectwindow.h",
|
||||||
"projectwizardpage.h",
|
"projectwizardpage.h",
|
||||||
"removefiledialog.cpp",
|
|
||||||
"removefiledialog.h",
|
|
||||||
"runconfigurationmodel.cpp",
|
"runconfigurationmodel.cpp",
|
||||||
"runconfigurationmodel.h",
|
"runconfigurationmodel.h",
|
||||||
"runsettingspropertiespage.cpp",
|
"runsettingspropertiespage.cpp",
|
||||||
|
@@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#include <coreplugin/fileiconprovider.h>
|
#include <coreplugin/fileiconprovider.h>
|
||||||
#include <coreplugin/fileutils.h>
|
#include <coreplugin/fileutils.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/vcsmanager.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@@ -981,6 +983,9 @@ void ResourceModel::addFiles(int prefixIndex, const QStringList &fileNames, int
|
|||||||
|
|
||||||
firstFile = cnt;
|
firstFile = cnt;
|
||||||
lastFile = cnt + unique_list.count() - 1;
|
lastFile = cnt + unique_list.count() - 1;
|
||||||
|
|
||||||
|
Core::ICore::vcsManager()->promptToAdd(QFileInfo(m_resource_file.fileName()).absolutePath(),
|
||||||
|
fileNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -32,6 +32,10 @@
|
|||||||
|
|
||||||
#include "undocommands_p.h"
|
#include "undocommands_p.h"
|
||||||
|
|
||||||
|
#include <coreplugin/fileutils.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/removefiledialog.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -165,8 +169,17 @@ EntryBackup * RelativeResourceModel::removeEntry(const QModelIndex &index)
|
|||||||
} else {
|
} else {
|
||||||
const QString fileNameBackup = file(index);
|
const QString fileNameBackup = file(index);
|
||||||
const QString aliasBackup = alias(index);
|
const QString aliasBackup = alias(index);
|
||||||
deleteItem(index);
|
if (!QFile::exists(fileNameBackup)) {
|
||||||
return new FileEntryBackup(*this, prefixIndex.row(), index.row(), fileNameBackup, aliasBackup);
|
deleteItem(index);
|
||||||
|
return new FileEntryBackup(*this, prefixIndex.row(), index.row(), fileNameBackup, aliasBackup);
|
||||||
|
}
|
||||||
|
Core::RemoveFileDialog removeFileDialog(fileNameBackup, Core::ICore::mainWindow());
|
||||||
|
if (removeFileDialog.exec() == QDialog::Accepted) {
|
||||||
|
deleteItem(index);
|
||||||
|
Core::FileUtils::removeFile(fileNameBackup, removeFileDialog.isDeleteFileChecked());
|
||||||
|
return new FileEntryBackup(*this, prefixIndex.row(), index.row(), fileNameBackup, aliasBackup);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user