forked from qt-creator/qt-creator
VCS: Clean up submit editor handling
It was not possible to simultaneously open two commit editors for different version control systems, also there was no reason to scan all open editors for the submit editor, since the plugins can just remember the editor that they opened. Change-Id: I1bea6ece3cd6faa1ecc0566bdd6f5fb10c816963 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -112,7 +112,7 @@ static const VcsBase::VcsBaseSubmitEditorParameters submitEditorParameters = {
|
|||||||
BazaarPlugin *BazaarPlugin::m_instance = 0;
|
BazaarPlugin *BazaarPlugin::m_instance = 0;
|
||||||
|
|
||||||
BazaarPlugin::BazaarPlugin()
|
BazaarPlugin::BazaarPlugin()
|
||||||
: VcsBase::VcsBasePlugin(Constants::COMMIT_ID),
|
: VcsBase::VcsBasePlugin(),
|
||||||
m_optionsPage(0),
|
m_optionsPage(0),
|
||||||
m_client(0),
|
m_client(0),
|
||||||
m_commandLocator(0),
|
m_commandLocator(0),
|
||||||
@@ -517,7 +517,7 @@ void BazaarPlugin::createSubmitEditorActions()
|
|||||||
|
|
||||||
void BazaarPlugin::commit()
|
void BazaarPlugin::commit()
|
||||||
{
|
{
|
||||||
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
|
if (raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const VcsBase::VcsBasePluginState state = currentState();
|
const VcsBase::VcsBasePluginState state = currentState();
|
||||||
@@ -566,6 +566,7 @@ void BazaarPlugin::showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusIt
|
|||||||
outputWindow->appendError(tr("Unable to create a commit editor."));
|
outputWindow->appendError(tr("Unable to create a commit editor."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setSubmitEditor(commitEditor);
|
||||||
|
|
||||||
commitEditor->registerActions(m_editorUndo, m_editorRedo, m_editorCommit, m_editorDiff);
|
commitEditor->registerActions(m_editorUndo, m_editorRedo, m_editorCommit, m_editorDiff);
|
||||||
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
|
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
|
||||||
@@ -653,12 +654,12 @@ void BazaarPlugin::commitFromEditor()
|
|||||||
Core::ICore::editorManager()->closeEditor();
|
Core::ICore::editorManager()->closeEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
|
bool BazaarPlugin::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
Core::IDocument *editorDocument = submitEditor->document();
|
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
|
||||||
const CommitEditor *commitEditor = qobject_cast<const CommitEditor *>(submitEditor);
|
QTC_ASSERT(commitEditor, return true);
|
||||||
if (!editorDocument || !commitEditor)
|
Core::IDocument *editorDocument = commitEditor->document();
|
||||||
return true;
|
QTC_ASSERT(editorDocument, return true);
|
||||||
|
|
||||||
bool dummyPrompt = m_bazaarSettings.boolValue(BazaarSettings::promptOnSubmitKey);
|
bool dummyPrompt = m_bazaarSettings.boolValue(BazaarSettings::promptOnSubmitKey);
|
||||||
const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult response =
|
const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult response =
|
||||||
@@ -690,7 +691,7 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit
|
|||||||
*iFile = parts.last();
|
*iFile = parts.last();
|
||||||
}
|
}
|
||||||
|
|
||||||
const BazaarCommitWidget *commitWidget = commitEditor->commitWidget();
|
BazaarCommitWidget *commitWidget = commitEditor->commitWidget();
|
||||||
QStringList extraOptions;
|
QStringList extraOptions;
|
||||||
// Author
|
// Author
|
||||||
if (!commitWidget->committer().isEmpty())
|
if (!commitWidget->committer().isEmpty())
|
||||||
|
@@ -115,7 +115,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
||||||
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
|
bool submitEditorAboutToClose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Methods
|
// Methods
|
||||||
|
@@ -43,12 +43,6 @@ CommitEditor::CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *paramet
|
|||||||
setDisplayName(tr("Commit Editor"));
|
setDisplayName(tr("Commit Editor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const BazaarCommitWidget *CommitEditor::commitWidget() const
|
|
||||||
{
|
|
||||||
CommitEditor *nonConstThis = const_cast<CommitEditor *>(this);
|
|
||||||
return static_cast<const BazaarCommitWidget *>(nonConstThis->widget());
|
|
||||||
}
|
|
||||||
|
|
||||||
BazaarCommitWidget *CommitEditor::commitWidget()
|
BazaarCommitWidget *CommitEditor::commitWidget()
|
||||||
{
|
{
|
||||||
return static_cast<BazaarCommitWidget *>(widget());
|
return static_cast<BazaarCommitWidget *>(widget());
|
||||||
|
@@ -54,10 +54,9 @@ public:
|
|||||||
const QString &userName, const QString &email,
|
const QString &userName, const QString &email,
|
||||||
const QList<VcsBase::VcsBaseClient::StatusItem> &repoStatus);
|
const QList<VcsBase::VcsBaseClient::StatusItem> &repoStatus);
|
||||||
|
|
||||||
const BazaarCommitWidget *commitWidget() const;
|
BazaarCommitWidget *commitWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BazaarCommitWidget *commitWidget();
|
|
||||||
VcsBase::SubmitFileModel *m_fileModel;
|
VcsBase::SubmitFileModel *m_fileModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -469,15 +469,15 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// called before closing the submit editor
|
// called before closing the submit editor
|
||||||
bool ClearCasePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
|
bool ClearCasePlugin::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
if (!isCheckInEditorOpen())
|
if (!isCheckInEditorOpen())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Core::IDocument *editorDocument = submitEditor->document();
|
ClearCaseSubmitEditor *editor = qobject_cast<ClearCaseSubmitEditor *>(submitEditor());
|
||||||
ClearCaseSubmitEditor *editor = qobject_cast<ClearCaseSubmitEditor *>(submitEditor);
|
QTC_ASSERT(editor, return true);
|
||||||
if (!editorDocument || !editor)
|
Core::IDocument *editorDocument = editor->document();
|
||||||
return true;
|
QTC_ASSERT(editorDocument, return true);
|
||||||
|
|
||||||
// Submit editor closing. Make it write out the check in message
|
// Submit editor closing. Make it write out the check in message
|
||||||
// and retrieve files
|
// and retrieve files
|
||||||
@@ -1030,7 +1030,7 @@ void ClearCasePlugin::startCheckInActivity()
|
|||||||
* check in will start. */
|
* check in will start. */
|
||||||
void ClearCasePlugin::startCheckIn(const QString &workingDir, const QStringList &files)
|
void ClearCasePlugin::startCheckIn(const QString &workingDir, const QStringList &files)
|
||||||
{
|
{
|
||||||
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
|
if (raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
VcsBase::VcsBaseOutputWindow *outputwindow = VcsBase::VcsBaseOutputWindow::instance();
|
VcsBase::VcsBaseOutputWindow *outputwindow = VcsBase::VcsBaseOutputWindow::instance();
|
||||||
|
|
||||||
@@ -1059,6 +1059,7 @@ void ClearCasePlugin::startCheckIn(const QString &workingDir, const QStringList
|
|||||||
m_checkInView = workingDir;
|
m_checkInView = workingDir;
|
||||||
// Create a submit editor and set file list
|
// Create a submit editor and set file list
|
||||||
ClearCaseSubmitEditor *editor = openClearCaseSubmitEditor(m_checkInMessageFileName, m_viewData.isUcm);
|
ClearCaseSubmitEditor *editor = openClearCaseSubmitEditor(m_checkInMessageFileName, m_viewData.isUcm);
|
||||||
|
setSubmitEditor(editor);
|
||||||
editor->setStatusList(files);
|
editor->setStatusList(files);
|
||||||
|
|
||||||
if (m_viewData.isUcm && (files.size() == 1)) {
|
if (m_viewData.isUcm && (files.size() == 1)) {
|
||||||
|
@@ -201,7 +201,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
||||||
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
|
bool submitEditorAboutToClose();
|
||||||
QString ccGet(const QString &workingDir, const QString &file, const QString &prefix = QString());
|
QString ccGet(const QString &workingDir, const QString &file, const QString &prefix = QString());
|
||||||
QList<QStringPair> ccGetActivities() const;
|
QList<QStringPair> ccGetActivities() const;
|
||||||
|
|
||||||
|
@@ -162,7 +162,7 @@ static inline bool messageBoxQuestion(const QString &title, const QString &quest
|
|||||||
CvsPlugin *CvsPlugin::m_cvsPluginInstance = 0;
|
CvsPlugin *CvsPlugin::m_cvsPluginInstance = 0;
|
||||||
|
|
||||||
CvsPlugin::CvsPlugin() :
|
CvsPlugin::CvsPlugin() :
|
||||||
VcsBasePlugin(Constants::CVSCOMMITEDITOR_ID),
|
VcsBasePlugin(),
|
||||||
m_commandLocator(0),
|
m_commandLocator(0),
|
||||||
m_addAction(0),
|
m_addAction(0),
|
||||||
m_deleteAction(0),
|
m_deleteAction(0),
|
||||||
@@ -450,15 +450,15 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvsPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor)
|
bool CvsPlugin::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
if (!isCommitEditorOpen())
|
if (!isCommitEditorOpen())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
IDocument *editorDocument = submitEditor->document();
|
CvsSubmitEditor *editor = qobject_cast<CvsSubmitEditor *>(submitEditor());
|
||||||
const CvsSubmitEditor *editor = qobject_cast<CvsSubmitEditor *>(submitEditor);
|
QTC_ASSERT(editor, return true);
|
||||||
if (!editorDocument || !editor)
|
IDocument *editorDocument = editor->document();
|
||||||
return true;
|
QTC_ASSERT(editorDocument, return true);
|
||||||
|
|
||||||
// Submit editor closing. Make it write out the commit message
|
// Submit editor closing. Make it write out the commit message
|
||||||
// and retrieve files
|
// and retrieve files
|
||||||
@@ -759,7 +759,7 @@ void CvsPlugin::startCommitAll()
|
|||||||
* commit will start. */
|
* commit will start. */
|
||||||
void CvsPlugin::startCommit(const QString &workingDir, const QStringList &files)
|
void CvsPlugin::startCommit(const QString &workingDir, const QStringList &files)
|
||||||
{
|
{
|
||||||
if (VcsBaseSubmitEditor::raiseSubmitEditor())
|
if (raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
if (isCommitEditorOpen()) {
|
if (isCommitEditorOpen()) {
|
||||||
VcsBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
|
VcsBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
|
||||||
@@ -804,6 +804,7 @@ void CvsPlugin::startCommit(const QString &workingDir, const QStringList &files)
|
|||||||
m_commitMessageFileName = saver.fileName();
|
m_commitMessageFileName = saver.fileName();
|
||||||
// Create a submit editor and set file list
|
// Create a submit editor and set file list
|
||||||
CvsSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName);
|
CvsSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName);
|
||||||
|
setSubmitEditor(editor);
|
||||||
editor->setCheckScriptWorkingDirectory(m_commitRepository);
|
editor->setCheckScriptWorkingDirectory(m_commitRepository);
|
||||||
editor->setStateList(statusOutput);
|
editor->setStateList(statusOutput);
|
||||||
}
|
}
|
||||||
|
@@ -131,7 +131,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
||||||
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
|
bool submitEditorAboutToClose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isCommitEditorOpen() const;
|
bool isCommitEditorOpen() const;
|
||||||
|
@@ -125,7 +125,7 @@ using namespace Git::Internal;
|
|||||||
GitPlugin *GitPlugin::m_instance = 0;
|
GitPlugin *GitPlugin::m_instance = 0;
|
||||||
|
|
||||||
GitPlugin::GitPlugin() :
|
GitPlugin::GitPlugin() :
|
||||||
VcsBase::VcsBasePlugin(Git::Constants::GITSUBMITEDITOR_ID),
|
VcsBase::VcsBasePlugin(),
|
||||||
m_commandLocator(0),
|
m_commandLocator(0),
|
||||||
m_submitCurrentAction(0),
|
m_submitCurrentAction(0),
|
||||||
m_diffSelectedFilesAction(0),
|
m_diffSelectedFilesAction(0),
|
||||||
@@ -843,7 +843,7 @@ void GitPlugin::startCommit()
|
|||||||
|
|
||||||
void GitPlugin::startCommit(bool amend)
|
void GitPlugin::startCommit(bool amend)
|
||||||
{
|
{
|
||||||
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
|
if (raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
if (isCommitEditorOpen()) {
|
if (isCommitEditorOpen()) {
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently being executed."));
|
VcsBase::VcsBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently being executed."));
|
||||||
@@ -904,6 +904,7 @@ Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const Commit
|
|||||||
Core::EditorManager::ModeSwitch);
|
Core::EditorManager::ModeSwitch);
|
||||||
GitSubmitEditor *submitEditor = qobject_cast<GitSubmitEditor*>(editor);
|
GitSubmitEditor *submitEditor = qobject_cast<GitSubmitEditor*>(editor);
|
||||||
QTC_ASSERT(submitEditor, return 0);
|
QTC_ASSERT(submitEditor, return 0);
|
||||||
|
setSubmitEditor(submitEditor);
|
||||||
// The actions are for some reason enabled by the context switching
|
// The actions are for some reason enabled by the context switching
|
||||||
// mechanism. Disable them correctly.
|
// mechanism. Disable them correctly.
|
||||||
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentAction, m_diffSelectedFilesAction);
|
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentAction, m_diffSelectedFilesAction);
|
||||||
@@ -924,14 +925,14 @@ void GitPlugin::submitCurrentLog()
|
|||||||
Core::ICore::editorManager()->closeEditor();
|
Core::ICore::editorManager()->closeEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
|
bool GitPlugin::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
if (!isCommitEditorOpen())
|
if (!isCommitEditorOpen())
|
||||||
return false;
|
return false;
|
||||||
Core::IDocument *editorDocument = submitEditor->document();
|
GitSubmitEditor *editor = qobject_cast<GitSubmitEditor *>(submitEditor());
|
||||||
const GitSubmitEditor *editor = qobject_cast<GitSubmitEditor *>(submitEditor);
|
QTC_ASSERT(editor, return true);
|
||||||
if (!editorDocument || !editor)
|
Core::IDocument *editorDocument = editor->document();
|
||||||
return true;
|
QTC_ASSERT(editorDocument, return true);
|
||||||
// Submit editor closing. Make it write out the commit message
|
// Submit editor closing. Make it write out the commit message
|
||||||
// and retrieve files
|
// and retrieve files
|
||||||
const QFileInfo editorFile(editorDocument->fileName());
|
const QFileInfo editorFile(editorDocument->fileName());
|
||||||
|
@@ -149,7 +149,7 @@ private slots:
|
|||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
||||||
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
|
bool submitEditorAboutToClose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline ParameterActionCommandPair
|
inline ParameterActionCommandPair
|
||||||
|
@@ -115,7 +115,7 @@ static const VcsBaseSubmitEditorParameters submitEditorParameters = {
|
|||||||
MercurialPlugin *MercurialPlugin::m_instance = 0;
|
MercurialPlugin *MercurialPlugin::m_instance = 0;
|
||||||
|
|
||||||
MercurialPlugin::MercurialPlugin() :
|
MercurialPlugin::MercurialPlugin() :
|
||||||
VcsBasePlugin(Constants::COMMIT_ID),
|
VcsBasePlugin(),
|
||||||
optionsPage(0),
|
optionsPage(0),
|
||||||
m_client(0),
|
m_client(0),
|
||||||
core(0),
|
core(0),
|
||||||
@@ -534,7 +534,7 @@ void MercurialPlugin::createSubmitEditorActions()
|
|||||||
|
|
||||||
void MercurialPlugin::commit()
|
void MercurialPlugin::commit()
|
||||||
{
|
{
|
||||||
if (VcsBaseSubmitEditor::raiseSubmitEditor())
|
if (raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
@@ -578,6 +578,7 @@ void MercurialPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &s
|
|||||||
|
|
||||||
QTC_ASSERT(qobject_cast<CommitEditor *>(editor), return);
|
QTC_ASSERT(qobject_cast<CommitEditor *>(editor), return);
|
||||||
CommitEditor *commitEditor = static_cast<CommitEditor *>(editor);
|
CommitEditor *commitEditor = static_cast<CommitEditor *>(editor);
|
||||||
|
setSubmitEditor(commitEditor);
|
||||||
|
|
||||||
commitEditor->registerActions(editorUndo, editorRedo, editorCommit, editorDiff);
|
commitEditor->registerActions(editorUndo, editorRedo, editorCommit, editorDiff);
|
||||||
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
|
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
|
||||||
@@ -606,12 +607,12 @@ void MercurialPlugin::commitFromEditor()
|
|||||||
Core::ICore::editorManager()->closeEditor();
|
Core::ICore::editorManager()->closeEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MercurialPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor)
|
bool MercurialPlugin::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
Core::IDocument *editorFile = submitEditor->document();
|
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
|
||||||
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor);
|
QTC_ASSERT(commitEditor, return true);
|
||||||
if (!editorFile || !commitEditor)
|
Core::IDocument *editorFile = commitEditor->document();
|
||||||
return true;
|
QTC_ASSERT(editorFile, return true);
|
||||||
|
|
||||||
bool dummyPrompt = mercurialSettings.boolValue(MercurialSettings::promptOnSubmitKey);
|
bool dummyPrompt = mercurialSettings.boolValue(MercurialSettings::promptOnSubmitKey);
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult response =
|
const VcsBaseSubmitEditor::PromptSubmitResult response =
|
||||||
|
@@ -125,7 +125,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
||||||
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
|
bool submitEditorAboutToClose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createMenu();
|
void createMenu();
|
||||||
|
@@ -176,7 +176,7 @@ PerforceResponse::PerforceResponse() :
|
|||||||
PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL;
|
PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL;
|
||||||
|
|
||||||
PerforcePlugin::PerforcePlugin() :
|
PerforcePlugin::PerforcePlugin() :
|
||||||
VcsBase::VcsBasePlugin(Constants::PERFORCE_SUBMIT_EDITOR_ID),
|
VcsBase::VcsBasePlugin(),
|
||||||
m_commandLocator(0),
|
m_commandLocator(0),
|
||||||
m_editAction(0),
|
m_editAction(0),
|
||||||
m_addAction(0),
|
m_addAction(0),
|
||||||
@@ -596,7 +596,7 @@ void PerforcePlugin::printOpenedFileList()
|
|||||||
void PerforcePlugin::startSubmitProject()
|
void PerforcePlugin::startSubmitProject()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
|
if (raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isCommitEditorOpen()) {
|
if (isCommitEditorOpen()) {
|
||||||
@@ -661,6 +661,7 @@ Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName,
|
|||||||
Core::IEditor *editor = Core::EditorManager::openEditor(fileName, Constants::PERFORCE_SUBMIT_EDITOR_ID,
|
Core::IEditor *editor = Core::EditorManager::openEditor(fileName, Constants::PERFORCE_SUBMIT_EDITOR_ID,
|
||||||
Core::EditorManager::ModeSwitch);
|
Core::EditorManager::ModeSwitch);
|
||||||
PerforceSubmitEditor *submitEditor = static_cast<PerforceSubmitEditor*>(editor);
|
PerforceSubmitEditor *submitEditor = static_cast<PerforceSubmitEditor*>(editor);
|
||||||
|
setSubmitEditor(submitEditor);
|
||||||
submitEditor->restrictToProjectFiles(depotFileNames);
|
submitEditor->restrictToProjectFiles(depotFileNames);
|
||||||
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentLogAction, m_diffSelectedFiles);
|
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentLogAction, m_diffSelectedFiles);
|
||||||
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotSubmitDiff(QStringList)));
|
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotSubmitDiff(QStringList)));
|
||||||
@@ -1321,14 +1322,14 @@ bool PerforcePlugin::isCommitEditorOpen() const
|
|||||||
return !m_commitMessageFileName.isEmpty();
|
return !m_commitMessageFileName.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PerforcePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
|
bool PerforcePlugin::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
if (!isCommitEditorOpen())
|
if (!isCommitEditorOpen())
|
||||||
return true;
|
return true;
|
||||||
Core::IDocument *editorDocument = submitEditor->document();
|
PerforceSubmitEditor *perforceEditor = qobject_cast<PerforceSubmitEditor *>(submitEditor());
|
||||||
const PerforceSubmitEditor *perforceEditor = qobject_cast<PerforceSubmitEditor *>(submitEditor);
|
QTC_ASSERT(perforceEditor, return true);
|
||||||
if (!editorDocument || !perforceEditor)
|
Core::IDocument *editorDocument = perforceEditor->document();
|
||||||
return true;
|
QTC_ASSERT(editorDocument, return true);
|
||||||
// Prompt the user. Force a prompt unless submit was actually invoked (that
|
// Prompt the user. Force a prompt unless submit was actually invoked (that
|
||||||
// is, the editor was closed or shutdown).
|
// is, the editor was closed or shutdown).
|
||||||
bool wantsPrompt = m_settings.promptToSubmit();
|
bool wantsPrompt = m_settings.promptToSubmit();
|
||||||
@@ -1371,7 +1372,7 @@ bool PerforcePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *subm
|
|||||||
}
|
}
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->append(submitResponse.stdOut);
|
VcsBase::VcsBaseOutputWindow::instance()->append(submitResponse.stdOut);
|
||||||
if (submitResponse.stdOut.contains(QLatin1String("Out of date files must be resolved or reverted)")))
|
if (submitResponse.stdOut.contains(QLatin1String("Out of date files must be resolved or reverted)")))
|
||||||
QMessageBox::warning(submitEditor->widget(), tr("Pending change"), tr("Could not submit the change, because your workspace was out of date. Created a pending submit instead."));
|
QMessageBox::warning(perforceEditor->widget(), tr("Pending change"), tr("Could not submit the change, because your workspace was out of date. Created a pending submit instead."));
|
||||||
|
|
||||||
cleanCommitMessageFile();
|
cleanCommitMessageFile();
|
||||||
return true;
|
return true;
|
||||||
|
@@ -142,7 +142,7 @@ private slots:
|
|||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
||||||
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
|
bool submitEditorAboutToClose();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -186,7 +186,7 @@ static inline QStringList svnDirectories()
|
|||||||
SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0;
|
SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0;
|
||||||
|
|
||||||
SubversionPlugin::SubversionPlugin() :
|
SubversionPlugin::SubversionPlugin() :
|
||||||
VcsBase::VcsBasePlugin(Subversion::Constants::SUBVERSIONCOMMITEDITOR_ID),
|
VcsBase::VcsBasePlugin(),
|
||||||
m_svnDirectories(svnDirectories()),
|
m_svnDirectories(svnDirectories()),
|
||||||
m_commandLocator(0),
|
m_commandLocator(0),
|
||||||
m_addAction(0),
|
m_addAction(0),
|
||||||
@@ -455,15 +455,15 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SubversionPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
|
bool SubversionPlugin::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
if (!isCommitEditorOpen())
|
if (!isCommitEditorOpen())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Core::IDocument *editorDocument = submitEditor->document();
|
SubversionSubmitEditor *editor = qobject_cast<SubversionSubmitEditor *>(submitEditor());
|
||||||
const SubversionSubmitEditor *editor = qobject_cast<SubversionSubmitEditor *>(submitEditor);
|
QTC_ASSERT(editor, return true);
|
||||||
if (!editorDocument || !editor)
|
Core::IDocument *editorDocument = editor->document();
|
||||||
return true;
|
QTC_ASSERT(editorDocument, return true);
|
||||||
|
|
||||||
// Submit editor closing. Make it write out the commit message
|
// Submit editor closing. Make it write out the commit message
|
||||||
// and retrieve files
|
// and retrieve files
|
||||||
@@ -623,6 +623,7 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri
|
|||||||
Core::EditorManager::ModeSwitch);
|
Core::EditorManager::ModeSwitch);
|
||||||
SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
|
SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
|
||||||
QTC_CHECK(submitEditor);
|
QTC_CHECK(submitEditor);
|
||||||
|
setSubmitEditor(submitEditor);
|
||||||
submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
|
submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
|
||||||
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffCommitFiles(QStringList)));
|
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffCommitFiles(QStringList)));
|
||||||
submitEditor->setCheckScriptWorkingDirectory(m_commitRepository);
|
submitEditor->setCheckScriptWorkingDirectory(m_commitRepository);
|
||||||
@@ -766,7 +767,7 @@ void SubversionPlugin::startCommitProject()
|
|||||||
* commit will start. */
|
* commit will start. */
|
||||||
void SubversionPlugin::startCommit(const QString &workingDir, const QStringList &files)
|
void SubversionPlugin::startCommit(const QString &workingDir, const QStringList &files)
|
||||||
{
|
{
|
||||||
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
|
if (raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
if (isCommitEditorOpen()) {
|
if (isCommitEditorOpen()) {
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
|
VcsBase::VcsBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
|
||||||
|
@@ -144,7 +144,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
void updateActions(VcsBase::VcsBasePlugin::ActionState);
|
||||||
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
|
bool submitEditorAboutToClose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool isCommitEditorOpen() const;
|
inline bool isCommitEditorOpen() const;
|
||||||
|
@@ -490,11 +490,11 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state)
|
|||||||
|
|
||||||
struct VcsBasePluginPrivate
|
struct VcsBasePluginPrivate
|
||||||
{
|
{
|
||||||
explicit VcsBasePluginPrivate(const Core::Id submitEditorId);
|
explicit VcsBasePluginPrivate();
|
||||||
|
|
||||||
inline bool supportsRepositoryCreation() const;
|
inline bool supportsRepositoryCreation() const;
|
||||||
|
|
||||||
const Core::Id m_submitEditorId;
|
QPointer<VcsBaseSubmitEditor> m_submitEditor;
|
||||||
Core::IVersionControl *m_versionControl;
|
Core::IVersionControl *m_versionControl;
|
||||||
VcsBasePluginState m_state;
|
VcsBasePluginState m_state;
|
||||||
int m_actionState;
|
int m_actionState;
|
||||||
@@ -507,8 +507,7 @@ struct VcsBasePluginPrivate
|
|||||||
static Internal::StateListener *m_listener;
|
static Internal::StateListener *m_listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
VcsBasePluginPrivate::VcsBasePluginPrivate(const Core::Id submitEditorId) :
|
VcsBasePluginPrivate::VcsBasePluginPrivate() :
|
||||||
m_submitEditorId(submitEditorId),
|
|
||||||
m_versionControl(0),
|
m_versionControl(0),
|
||||||
m_actionState(-1),
|
m_actionState(-1),
|
||||||
m_testSnapshotAction(0),
|
m_testSnapshotAction(0),
|
||||||
@@ -525,8 +524,8 @@ bool VcsBasePluginPrivate::supportsRepositoryCreation() const
|
|||||||
|
|
||||||
Internal::StateListener *VcsBasePluginPrivate::m_listener = 0;
|
Internal::StateListener *VcsBasePluginPrivate::m_listener = 0;
|
||||||
|
|
||||||
VcsBasePlugin::VcsBasePlugin(const Core::Id submitEditorId) :
|
VcsBasePlugin::VcsBasePlugin() :
|
||||||
d(new VcsBasePluginPrivate(submitEditorId))
|
d(new VcsBasePluginPrivate())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,9 +560,11 @@ void VcsBasePlugin::extensionsInitialized()
|
|||||||
void VcsBasePlugin::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result)
|
void VcsBasePlugin::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << this << d->m_submitEditorId.name() << "Closing submit editor" << submitEditor << submitEditor->id().name();
|
qDebug() << this << "plugin's submit editor"
|
||||||
if (submitEditor->id() == d->m_submitEditorId)
|
<< d->m_submitEditor << (d->m_submitEditor ? d->m_submitEditor->id().name() : "")
|
||||||
*result = submitEditorAboutToClose(submitEditor);
|
<< "closing submit editor" << submitEditor << submitEditor->id().name();
|
||||||
|
if (submitEditor == d->m_submitEditor)
|
||||||
|
*result = submitEditorAboutToClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IVersionControl *VcsBasePlugin::versionControl() const
|
Core::IVersionControl *VcsBasePlugin::versionControl() const
|
||||||
@@ -673,6 +674,26 @@ void VcsBasePlugin::createRepository()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsBasePlugin::setSubmitEditor(VcsBaseSubmitEditor *submitEditor)
|
||||||
|
{
|
||||||
|
d->m_submitEditor = submitEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
VcsBaseSubmitEditor *VcsBasePlugin::submitEditor() const
|
||||||
|
{
|
||||||
|
return d->m_submitEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VcsBasePlugin::raiseSubmitEditor() const
|
||||||
|
{
|
||||||
|
if (!d->m_submitEditor)
|
||||||
|
return false;
|
||||||
|
Core::EditorManager::activateEditor(
|
||||||
|
d->m_submitEditor,
|
||||||
|
Core::EditorManager::IgnoreNavigationHistory | Core::EditorManager::ModeSwitch);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// For internal tests: Create actions driving IVersionControl's snapshot interface.
|
// For internal tests: Create actions driving IVersionControl's snapshot interface.
|
||||||
QList<QAction*> VcsBasePlugin::createSnapShotTestActions()
|
QList<QAction*> VcsBasePlugin::createSnapShotTestActions()
|
||||||
{
|
{
|
||||||
|
@@ -127,7 +127,7 @@ class VCSBASE_EXPORT VcsBasePlugin : public ExtensionSystem::IPlugin
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit VcsBasePlugin(const Core::Id submitEditorId);
|
explicit VcsBasePlugin();
|
||||||
|
|
||||||
void initializeVcs(Core::IVersionControl *vc);
|
void initializeVcs(Core::IVersionControl *vc);
|
||||||
virtual void extensionsInitialized();
|
virtual void extensionsInitialized();
|
||||||
@@ -207,10 +207,20 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
enum ActionState { NoVcsEnabled, OtherVcsEnabled, VcsEnabled };
|
enum ActionState { NoVcsEnabled, OtherVcsEnabled, VcsEnabled };
|
||||||
|
|
||||||
|
// Sets the current submit editor for this specific version control plugin.
|
||||||
|
// The plugin automatically checks if the submit editor is closed and calls
|
||||||
|
// submitEditorAboutToClose().
|
||||||
|
// The method raiseSubmitEditor can be used to check for a running submit editor and raise it.
|
||||||
|
void setSubmitEditor(VcsBaseSubmitEditor *submitEditor);
|
||||||
|
// Current submit editor set through setSubmitEditor, if it wasn't closed inbetween
|
||||||
|
VcsBaseSubmitEditor *submitEditor() const;
|
||||||
|
// Tries to raise the submit editor set through setSubmitEditor. Returns true if that was found.
|
||||||
|
bool raiseSubmitEditor() const;
|
||||||
|
|
||||||
// Implement to enable the plugin menu actions according to state.
|
// Implement to enable the plugin menu actions according to state.
|
||||||
virtual void updateActions(ActionState as) = 0;
|
virtual void updateActions(ActionState as) = 0;
|
||||||
// Implement to start the submit process.
|
// Implement to start the submit process, use submitEditor() to get the submit editor instance.
|
||||||
virtual bool submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor) = 0;
|
virtual bool submitEditorAboutToClose() = 0;
|
||||||
|
|
||||||
// A helper to enable the VCS menu action according to state:
|
// A helper to enable the VCS menu action according to state:
|
||||||
// NoVcsEnabled -> visible, enabled if repository creation is supported
|
// NoVcsEnabled -> visible, enabled if repository creation is supported
|
||||||
|
@@ -589,12 +589,12 @@ VcsBaseSubmitEditor::PromptSubmitResult
|
|||||||
const QString &checkFailureQuestion,
|
const QString &checkFailureQuestion,
|
||||||
bool *promptSetting,
|
bool *promptSetting,
|
||||||
bool forcePrompt,
|
bool forcePrompt,
|
||||||
bool canCommitOnFailure) const
|
bool canCommitOnFailure)
|
||||||
{
|
{
|
||||||
SubmitEditorWidget *submitWidget =
|
SubmitEditorWidget *submitWidget = static_cast<SubmitEditorWidget *>(this->widget());
|
||||||
static_cast<SubmitEditorWidget *>(const_cast<VcsBaseSubmitEditor *>(this)->widget());
|
|
||||||
|
|
||||||
raiseSubmitEditor();
|
Core::EditorManager::activateEditor(
|
||||||
|
this, Core::EditorManager::IgnoreNavigationHistory | Core::EditorManager::ModeSwitch);
|
||||||
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
QMessageBox::StandardButton answer = QMessageBox::Yes;
|
QMessageBox::StandardButton answer = QMessageBox::Yes;
|
||||||
@@ -814,23 +814,4 @@ void VcsBaseSubmitEditor::filterUntrackedFilesOfProject(const QString &repositor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to raise an already open submit editor to prevent opening twice.
|
|
||||||
bool VcsBaseSubmitEditor::raiseSubmitEditor()
|
|
||||||
{
|
|
||||||
// Nothing to do?
|
|
||||||
if (Core::IEditor *ce = Core::EditorManager::currentEditor())
|
|
||||||
if (qobject_cast<VcsBaseSubmitEditor*>(ce))
|
|
||||||
return true;
|
|
||||||
// Try to activate a hidden one
|
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
|
||||||
foreach (Core::IEditor *e, em->openedEditors()) {
|
|
||||||
if (qobject_cast<VcsBaseSubmitEditor*>(e)) {
|
|
||||||
Core::EditorManager::activateEditor(e,
|
|
||||||
Core::EditorManager::IgnoreNavigationHistory | Core::EditorManager::ModeSwitch);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
@@ -92,7 +92,7 @@ public:
|
|||||||
const QString &checkFailureQuestion,
|
const QString &checkFailureQuestion,
|
||||||
bool *promptSetting,
|
bool *promptSetting,
|
||||||
bool forcePrompt = false,
|
bool forcePrompt = false,
|
||||||
bool canCommitOnFailure = true) const;
|
bool canCommitOnFailure = true);
|
||||||
|
|
||||||
QAbstractItemView::SelectionMode fileListSelectionMode() const;
|
QAbstractItemView::SelectionMode fileListSelectionMode() const;
|
||||||
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
|
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
|
||||||
@@ -145,9 +145,6 @@ public:
|
|||||||
// that are actually part of the current project(s).
|
// that are actually part of the current project(s).
|
||||||
static void filterUntrackedFilesOfProject(const QString &repositoryDirectory, QStringList *untrackedFiles);
|
static void filterUntrackedFilesOfProject(const QString &repositoryDirectory, QStringList *untrackedFiles);
|
||||||
|
|
||||||
// Helper to raise an already open submit editor to prevent opening twice.
|
|
||||||
static bool raiseSubmitEditor();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void diffSelectedFiles(const QStringList &files);
|
void diffSelectedFiles(const QStringList &files);
|
||||||
void diffSelectedFiles(const QList<int> &rows);
|
void diffSelectedFiles(const QList<int> &rows);
|
||||||
|
Reference in New Issue
Block a user