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:
Konstantin Tokarev
2012-07-18 13:41:13 +04:00
committed by Tobias Hunger
parent bd7499b896
commit 728579ef52
14 changed files with 101 additions and 62 deletions

View File

@@ -326,4 +326,31 @@ bool VcsManager::promptToDelete(IVersionControl *vc, const QString &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