Commit e31575a4 authored by Eike Ziller's avatar Eike Ziller
Browse files

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: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent d4f763ed
......@@ -112,7 +112,7 @@ static const VcsBase::VcsBaseSubmitEditorParameters submitEditorParameters = {
BazaarPlugin *BazaarPlugin::m_instance = 0;
BazaarPlugin::BazaarPlugin()
: VcsBase::VcsBasePlugin(Constants::COMMIT_ID),
: VcsBase::VcsBasePlugin(),
m_optionsPage(0),
m_client(0),
m_commandLocator(0),
......@@ -517,7 +517,7 @@ void BazaarPlugin::createSubmitEditorActions()
void BazaarPlugin::commit()
{
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
if (raiseSubmitEditor())
return;
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."));
return;
}
setSubmitEditor(commitEditor);
commitEditor->registerActions(m_editorUndo, m_editorRedo, m_editorCommit, m_editorDiff);
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
......@@ -653,12 +654,12 @@ void BazaarPlugin::commitFromEditor()
Core::ICore::editorManager()->closeEditor();
}
bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
bool BazaarPlugin::submitEditorAboutToClose()
{
Core::IDocument *editorDocument = submitEditor->document();
const CommitEditor *commitEditor = qobject_cast<const CommitEditor *>(submitEditor);
if (!editorDocument || !commitEditor)
return true;
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
QTC_ASSERT(commitEditor, return true);
Core::IDocument *editorDocument = commitEditor->document();
QTC_ASSERT(editorDocument, return true);
bool dummyPrompt = m_bazaarSettings.boolValue(BazaarSettings::promptOnSubmitKey);
const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult response =
......@@ -690,7 +691,7 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit
*iFile = parts.last();
}
const BazaarCommitWidget *commitWidget = commitEditor->commitWidget();
BazaarCommitWidget *commitWidget = commitEditor->commitWidget();
QStringList extraOptions;
// Author
if (!commitWidget->committer().isEmpty())
......
......@@ -115,7 +115,7 @@ private slots:
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
bool submitEditorAboutToClose();
private:
// Methods
......
......@@ -43,12 +43,6 @@ CommitEditor::CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *paramet
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()
{
return static_cast<BazaarCommitWidget *>(widget());
......
......@@ -54,10 +54,9 @@ public:
const QString &userName, const QString &email,
const QList<VcsBase::VcsBaseClient::StatusItem> &repoStatus);
const BazaarCommitWidget *commitWidget() const;
BazaarCommitWidget *commitWidget();
private:
BazaarCommitWidget *commitWidget();
VcsBase::SubmitFileModel *m_fileModel;
};
......
......@@ -469,15 +469,15 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
}
// called before closing the submit editor
bool ClearCasePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
bool ClearCasePlugin::submitEditorAboutToClose()
{
if (!isCheckInEditorOpen())
return true;
Core::IDocument *editorDocument = submitEditor->document();
ClearCaseSubmitEditor *editor = qobject_cast<ClearCaseSubmitEditor *>(submitEditor);
if (!editorDocument || !editor)
return true;
ClearCaseSubmitEditor *editor = qobject_cast<ClearCaseSubmitEditor *>(submitEditor());
QTC_ASSERT(editor, return true);
Core::IDocument *editorDocument = editor->document();
QTC_ASSERT(editorDocument, return true);
// Submit editor closing. Make it write out the check in message
// and retrieve files
......@@ -1030,7 +1030,7 @@ void ClearCasePlugin::startCheckInActivity()
* check in will start. */
void ClearCasePlugin::startCheckIn(const QString &workingDir, const QStringList &files)
{
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
if (raiseSubmitEditor())
return;
VcsBase::VcsBaseOutputWindow *outputwindow = VcsBase::VcsBaseOutputWindow::instance();
......@@ -1059,6 +1059,7 @@ void ClearCasePlugin::startCheckIn(const QString &workingDir, const QStringList
m_checkInView = workingDir;
// Create a submit editor and set file list
ClearCaseSubmitEditor *editor = openClearCaseSubmitEditor(m_checkInMessageFileName, m_viewData.isUcm);
setSubmitEditor(editor);
editor->setStatusList(files);
if (m_viewData.isUcm && (files.size() == 1)) {
......
......@@ -201,7 +201,7 @@ private slots:
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
bool submitEditorAboutToClose();
QString ccGet(const QString &workingDir, const QString &file, const QString &prefix = QString());
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() :
VcsBasePlugin(Constants::CVSCOMMITEDITOR_ID),
VcsBasePlugin(),
m_commandLocator(0),
m_addAction(0),
m_deleteAction(0),
......@@ -450,15 +450,15 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
return true;
}
bool CvsPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor)
bool CvsPlugin::submitEditorAboutToClose()
{
if (!isCommitEditorOpen())
return true;
IDocument *editorDocument = submitEditor->document();
const CvsSubmitEditor *editor = qobject_cast<CvsSubmitEditor *>(submitEditor);
if (!editorDocument || !editor)
return true;
CvsSubmitEditor *editor = qobject_cast<CvsSubmitEditor *>(submitEditor());
QTC_ASSERT(editor, return true);
IDocument *editorDocument = editor->document();
QTC_ASSERT(editorDocument, return true);
// Submit editor closing. Make it write out the commit message
// and retrieve files
......@@ -759,7 +759,7 @@ void CvsPlugin::startCommitAll()
* commit will start. */
void CvsPlugin::startCommit(const QString &workingDir, const QStringList &files)
{
if (VcsBaseSubmitEditor::raiseSubmitEditor())
if (raiseSubmitEditor())
return;
if (isCommitEditorOpen()) {
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();
// Create a submit editor and set file list
CvsSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName);
setSubmitEditor(editor);
editor->setCheckScriptWorkingDirectory(m_commitRepository);
editor->setStateList(statusOutput);
}
......
......@@ -131,7 +131,7 @@ private slots:
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
bool submitEditorAboutToClose();
private:
bool isCommitEditorOpen() const;
......
......@@ -125,7 +125,7 @@ using namespace Git::Internal;
GitPlugin *GitPlugin::m_instance = 0;
GitPlugin::GitPlugin() :
VcsBase::VcsBasePlugin(Git::Constants::GITSUBMITEDITOR_ID),
VcsBase::VcsBasePlugin(),
m_commandLocator(0),
m_submitCurrentAction(0),
m_diffSelectedFilesAction(0),
......@@ -843,7 +843,7 @@ void GitPlugin::startCommit()
void GitPlugin::startCommit(bool amend)
{
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
if (raiseSubmitEditor())
return;
if (isCommitEditorOpen()) {
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);
GitSubmitEditor *submitEditor = qobject_cast<GitSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, return 0);
setSubmitEditor(submitEditor);
// The actions are for some reason enabled by the context switching
// mechanism. Disable them correctly.
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentAction, m_diffSelectedFilesAction);
......@@ -924,14 +925,14 @@ void GitPlugin::submitCurrentLog()
Core::ICore::editorManager()->closeEditor();
}
bool GitPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
bool GitPlugin::submitEditorAboutToClose()
{
if (!isCommitEditorOpen())
return false;
Core::IDocument *editorDocument = submitEditor->document();
const GitSubmitEditor *editor = qobject_cast<GitSubmitEditor *>(submitEditor);
if (!editorDocument || !editor)
return true;
GitSubmitEditor *editor = qobject_cast<GitSubmitEditor *>(submitEditor());
QTC_ASSERT(editor, return true);
Core::IDocument *editorDocument = editor->document();
QTC_ASSERT(editorDocument, return true);
// Submit editor closing. Make it write out the commit message
// and retrieve files
const QFileInfo editorFile(editorDocument->fileName());
......
......@@ -149,7 +149,7 @@ private slots:
#endif
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
bool submitEditorAboutToClose();
private:
inline ParameterActionCommandPair
......
......@@ -115,7 +115,7 @@ static const VcsBaseSubmitEditorParameters submitEditorParameters = {
MercurialPlugin *MercurialPlugin::m_instance = 0;
MercurialPlugin::MercurialPlugin() :
VcsBasePlugin(Constants::COMMIT_ID),
VcsBasePlugin(),
optionsPage(0),
m_client(0),
core(0),
......@@ -534,7 +534,7 @@ void MercurialPlugin::createSubmitEditorActions()
void MercurialPlugin::commit()
{
if (VcsBaseSubmitEditor::raiseSubmitEditor())
if (raiseSubmitEditor())
return;
const VcsBasePluginState state = currentState();
......@@ -578,6 +578,7 @@ void MercurialPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &s
QTC_ASSERT(qobject_cast<CommitEditor *>(editor), return);
CommitEditor *commitEditor = static_cast<CommitEditor *>(editor);
setSubmitEditor(commitEditor);
commitEditor->registerActions(editorUndo, editorRedo, editorCommit, editorDiff);
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
......@@ -606,12 +607,12 @@ void MercurialPlugin::commitFromEditor()
Core::ICore::editorManager()->closeEditor();
}
bool MercurialPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor)
bool MercurialPlugin::submitEditorAboutToClose()
{
Core::IDocument *editorFile = submitEditor->document();
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor);
if (!editorFile || !commitEditor)
return true;
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
QTC_ASSERT(commitEditor, return true);
Core::IDocument *editorFile = commitEditor->document();
QTC_ASSERT(editorFile, return true);
bool dummyPrompt = mercurialSettings.boolValue(MercurialSettings::promptOnSubmitKey);
const VcsBaseSubmitEditor::PromptSubmitResult response =
......
......@@ -125,7 +125,7 @@ private slots:
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
bool submitEditorAboutToClose();
private:
void createMenu();
......
......@@ -176,7 +176,7 @@ PerforceResponse::PerforceResponse() :
PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL;
PerforcePlugin::PerforcePlugin() :
VcsBase::VcsBasePlugin(Constants::PERFORCE_SUBMIT_EDITOR_ID),
VcsBase::VcsBasePlugin(),
m_commandLocator(0),
m_editAction(0),
m_addAction(0),
......@@ -596,7 +596,7 @@ void PerforcePlugin::printOpenedFileList()
void PerforcePlugin::startSubmitProject()
{
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
if (raiseSubmitEditor())
return;
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::EditorManager::ModeSwitch);
PerforceSubmitEditor *submitEditor = static_cast<PerforceSubmitEditor*>(editor);
setSubmitEditor(submitEditor);
submitEditor->restrictToProjectFiles(depotFileNames);
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentLogAction, m_diffSelectedFiles);
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotSubmitDiff(QStringList)));
......@@ -1321,14 +1322,14 @@ bool PerforcePlugin::isCommitEditorOpen() const
return !m_commitMessageFileName.isEmpty();
}
bool PerforcePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
bool PerforcePlugin::submitEditorAboutToClose()
{
if (!isCommitEditorOpen())
return true;
Core::IDocument *editorDocument = submitEditor->document();
const PerforceSubmitEditor *perforceEditor = qobject_cast<PerforceSubmitEditor *>(submitEditor);
if (!editorDocument || !perforceEditor)
return true;
PerforceSubmitEditor *perforceEditor = qobject_cast<PerforceSubmitEditor *>(submitEditor());
QTC_ASSERT(perforceEditor, return true);
Core::IDocument *editorDocument = perforceEditor->document();
QTC_ASSERT(editorDocument, return true);
// Prompt the user. Force a prompt unless submit was actually invoked (that
// is, the editor was closed or shutdown).
bool wantsPrompt = m_settings.promptToSubmit();
......@@ -1371,7 +1372,7 @@ bool PerforcePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *subm
}
VcsBase::VcsBaseOutputWindow::instance()->append(submitResponse.stdOut);
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();
return true;
......
......@@ -142,7 +142,7 @@ private slots:
#endif
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
bool submitEditorAboutToClose();
private:
......
......@@ -186,7 +186,7 @@ static inline QStringList svnDirectories()
SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0;
SubversionPlugin::SubversionPlugin() :
VcsBase::VcsBasePlugin(Subversion::Constants::SUBVERSIONCOMMITEDITOR_ID),
VcsBase::VcsBasePlugin(),
m_svnDirectories(svnDirectories()),
m_commandLocator(0),
m_addAction(0),
......@@ -455,15 +455,15 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
return true;
}
bool SubversionPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor)
bool SubversionPlugin::submitEditorAboutToClose()
{
if (!isCommitEditorOpen())
return true;
Core::IDocument *editorDocument = submitEditor->document();
const SubversionSubmitEditor *editor = qobject_cast<SubversionSubmitEditor *>(submitEditor);
if (!editorDocument || !editor)
return true;
SubversionSubmitEditor *editor = qobject_cast<SubversionSubmitEditor *>(submitEditor());
QTC_ASSERT(editor, return true);
Core::IDocument *editorDocument = editor->document();
QTC_ASSERT(editorDocument, return true);
// Submit editor closing. Make it write out the commit message
// and retrieve files
......@@ -623,6 +623,7 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri
Core::EditorManager::ModeSwitch);
SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
QTC_CHECK(submitEditor);
setSubmitEditor(submitEditor);
submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffCommitFiles(QStringList)));
submitEditor->setCheckScriptWorkingDirectory(m_commitRepository);
......@@ -766,7 +767,7 @@ void SubversionPlugin::startCommitProject()
* commit will start. */
void SubversionPlugin::startCommit(const QString &workingDir, const QStringList &files)
{
if (VcsBase::VcsBaseSubmitEditor::raiseSubmitEditor())
if (raiseSubmitEditor())
return;
if (isCommitEditorOpen()) {
VcsBase::VcsBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
......
......@@ -144,7 +144,7 @@ private slots:
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
bool submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEditor);
bool submitEditorAboutToClose();
private:
inline bool isCommitEditorOpen() const;
......
......@@ -490,11 +490,11 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state)
struct VcsBasePluginPrivate
{
explicit VcsBasePluginPrivate(const Core::Id submitEditorId);
explicit VcsBasePluginPrivate();
inline bool supportsRepositoryCreation() const;
const Core::Id m_submitEditorId;
QPointer<VcsBaseSubmitEditor> m_submitEditor;
Core::IVersionControl *m_versionControl;
VcsBasePluginState m_state;
int m_actionState;
......@@ -507,8 +507,7 @@ struct VcsBasePluginPrivate
static Internal::StateListener *m_listener;
};
VcsBasePluginPrivate::VcsBasePluginPrivate(const Core::Id submitEditorId) :
m_submitEditorId(submitEditorId),
VcsBasePluginPrivate::VcsBasePluginPrivate() :
m_versionControl(0),
m_actionState(-1),
m_testSnapshotAction(0),
......@@ -525,8 +524,8 @@ bool VcsBasePluginPrivate::supportsRepositoryCreation() const
Internal::StateListener *VcsBasePluginPrivate::m_listener = 0;
VcsBasePlugin::VcsBasePlugin(const Core::Id submitEditorId) :
d(new VcsBasePluginPrivate(submitEditorId))
VcsBasePlugin::VcsBasePlugin() :
d(new VcsBasePluginPrivate())
{
}
......@@ -561,9 +560,11 @@ void VcsBasePlugin::extensionsInitialized()
void VcsBasePlugin::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result)
{
if (debug)
qDebug() << this << d->m_submitEditorId.name() << "Closing submit editor" << submitEditor << submitEditor->id().name();
if (submitEditor->id() == d->m_submitEditorId)
*result = submitEditorAboutToClose(submitEditor);
qDebug() << this << "plugin's submit editor"
<< d->m_submitEditor << (d->m_submitEditor ? d->m_submitEditor->id().name() : "")
<< "closing submit editor" << submitEditor << submitEditor->id().name();
if (submitEditor == d->m_submitEditor)
*result = submitEditorAboutToClose();
}
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.
QList<QAction*> VcsBasePlugin::createSnapShotTestActions()
{
......
......@@ -127,7 +127,7 @@ class VCSBASE_EXPORT VcsBasePlugin : public ExtensionSystem::IPlugin
Q_OBJECT
protected:
explicit VcsBasePlugin(const Core::Id submitEditorId);
explicit VcsBasePlugin();
void initializeVcs(Core::IVersionControl *vc);
virtual void extensionsInitialized();
......@@ -207,10 +207,20 @@ public slots:
protected:
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.
virtual void updateActions(ActionState as) = 0;
// Implement to start the submit process.
virtual bool submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor) = 0;
// Implement to start the submit process, use submitEditor() to get the submit editor instance.
virtual bool submitEditorAboutToClose() = 0;
// A helper to enable the VCS menu action according to state:
// NoVcsEnabled -> visible, enabled if repository creation is supported
......
......@@ -589,12 +589,12 @@ VcsBaseSubmitEditor::PromptSubmitResult
const QString &checkFailureQuestion,
bool *promptSetting,
bool forcePrompt,
bool canCommitOnFailure) const
bool canCommitOnFailure)
{
SubmitEditorWidget *submitWidget =
static_cast<SubmitEditorWidget *>(const_cast<VcsBaseSubmitEditor *>(this)->widget());
SubmitEditorWidget *submitWidget = static_cast<SubmitEditorWidget *>(this->widget());
raiseSubmitEditor();
Core::EditorManager::activateEditor(
this, Core::EditorManager::IgnoreNavigationHistory | Core::EditorManager::ModeSwitch);
QString errorMessage;
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
......@@ -92,7 +92,7 @@ public:
const QString &checkFailureQuestion,
bool *promptSetting,
bool forcePrompt = false,
bool canCommitOnFailure = true) const;
bool canCommitOnFailure = true);
QAbstractItemView::SelectionMode fileListSelectionMode() const;
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
......@@ -145,9 +145,6 @@ public:
// that are actually part of the current project(s).
static void filterUntrackedFilesOfProject(const QString &repositoryDirectory, QStringList *untrackedFiles);
// Helper to raise an already open submit editor to prevent opening twice.
static bool raiseSubmitEditor();
signals: