Move Component refactoring - ask before adding file to vcs

Task-number: QTCREATORBUG-7391
Change-Id: I746266976f2fb9cd1b38751bf185a747b32780a5
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Kai Koehne
2012-05-09 14:50:03 +02:00
parent 0183a9021f
commit 576d87ab6d

View File

@@ -47,6 +47,8 @@
#include <QCoreApplication>
#include <QDir>
#include <QFileInfo>
#include <QMainWindow>
#include <QMessageBox>
using namespace QmlJS::AST;
using namespace QmlJSEditor;
@@ -109,9 +111,25 @@ public:
return;
Core::IVersionControl *versionControl = Core::ICore::vcsManager()->findVersionControlForDirectory(path);
if (versionControl)
versionControl->vcsAdd(newFileName);
if (versionControl
&& versionControl->supportsOperation(Core::IVersionControl::AddOperation)) {
QString title = QCoreApplication::translate("QmlJSEditor::ComponentFromObjectDef",
"Add to Version Control");
QString question = QCoreApplication::translate("QmlJSEditor::ComponentFromObjectDef",
"Add file\n%1\nto version control (%2)?")
.arg(newFileName, versionControl->displayName());
QString error = QCoreApplication::translate("QmlJSEditor::ComponentFromObjectDef",
"Could not add file\n%1\nto version control (%2).")
.arg(newFileName, versionControl->displayName());
QMessageBox::StandardButton button =
QMessageBox::question(Core::ICore::mainWindow(), title,
question, QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes) {
if (!versionControl->vcsAdd(newFileName))
QMessageBox::warning(Core::ICore::mainWindow(), title, error);
}
}
QString replacement = componentName + QLatin1String(" {\n");
if (!m_idName.isEmpty())
replacement += QLatin1String("id: ") + m_idName