From 8598a59b9fa1d98b99eeb03a93087f43aa2c74a5 Mon Sep 17 00:00:00 2001 From: mae <qtc-committer@nokia.com> Date: Mon, 16 Feb 2009 12:50:15 +0100 Subject: [PATCH] fix context definitions of the vcs editors (this makes shortcuts work again) --- src/plugins/git/gitconstants.h | 4 + src/plugins/git/gitplugin.cpp | 8 +- .../qtscripteditoractionhandler.cpp | 7 -- .../qtscripteditoractionhandler.h | 1 - src/plugins/subversion/subversionplugin.cpp | 16 +-- .../texteditor/texteditoractionhandler.cpp | 99 ++++++------------- .../texteditor/texteditoractionhandler.h | 4 +- src/plugins/vcsbase/basevcseditorfactory.cpp | 2 +- 8 files changed, 51 insertions(+), 90 deletions(-) diff --git a/src/plugins/git/gitconstants.h b/src/plugins/git/gitconstants.h index b539046ffb5..438d0f25b9a 100644 --- a/src/plugins/git/gitconstants.h +++ b/src/plugins/git/gitconstants.h @@ -38,9 +38,13 @@ namespace Git { namespace Constants { const char * const GIT_COMMAND_LOG_EDITOR_KIND = "Git Command Log Editor"; +const char * const C_GIT_COMMAND_LOG_EDITOR = "Git Command Log Editor"; const char * const GIT_LOG_EDITOR_KIND = "Git File Log Editor"; +const char * const C_GIT_LOG_EDITOR = "Git File Log Editor"; const char * const GIT_BLAME_EDITOR_KIND = "Git Annotation Editor"; +const char * const C_GIT_BLAME_EDITOR = "Git Annotation Editor"; const char * const GIT_DIFF_EDITOR_KIND = "Git Diff Editor"; +const char * const C_GIT_DIFF_EDITOR = "Git Diff Editor"; const char * const C_GITSUBMITEDITOR = "Git Submit Editor"; const char * const GITSUBMITEDITOR_KIND = "Git Submit Editor"; diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 11823909585..72069cef4dd 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -73,22 +73,22 @@ static const VCSBase::VCSBaseEditorParameters editorParameters[] = { { VCSBase::RegularCommandOutput, Git::Constants::GIT_COMMAND_LOG_EDITOR_KIND, - Core::Constants::C_GLOBAL, + Git::Constants::C_GIT_COMMAND_LOG_EDITOR, "application/vnd.nokia.text.scs_git_commandlog", "gitlog"}, { VCSBase::LogOutput, Git::Constants::GIT_LOG_EDITOR_KIND, - Core::Constants::C_GLOBAL, + Git::Constants::C_GIT_LOG_EDITOR, "application/vnd.nokia.text.scs_git_filelog", "gitfilelog"}, { VCSBase::AnnotateOutput, Git::Constants::GIT_BLAME_EDITOR_KIND, - Core::Constants::C_GLOBAL, + Git::Constants::C_GIT_BLAME_EDITOR, "application/vnd.nokia.text.scs_git_annotation", "gitsannotate"}, { VCSBase::DiffOutput, Git::Constants::GIT_DIFF_EDITOR_KIND, - Core::Constants::C_GLOBAL, + Git::Constants::C_GIT_DIFF_EDITOR, "text/x-patch","diff"} }; diff --git a/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp b/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp index 18d57a6a7b2..9d5a6b41907 100644 --- a/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp +++ b/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp @@ -70,13 +70,6 @@ void QtScriptEditorActionHandler::createActions() } -void QtScriptEditorActionHandler::updateActions(UpdateMode um) -{ - TextEditor::TextEditorActionHandler::updateActions(um); - if (m_runAction) - m_runAction->setEnabled(um != NoEditor); -} - void QtScriptEditorActionHandler::run() { typedef Core::ScriptManager::Stack Stack; diff --git a/src/plugins/qtscripteditor/qtscripteditoractionhandler.h b/src/plugins/qtscripteditor/qtscripteditoractionhandler.h index c4940cfa160..ca1fa27af28 100644 --- a/src/plugins/qtscripteditor/qtscripteditoractionhandler.h +++ b/src/plugins/qtscripteditor/qtscripteditoractionhandler.h @@ -48,7 +48,6 @@ public: private: virtual void createActions(); - virtual void updateActions(UpdateMode um); private slots: void run(); diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 3ab8b75f9bb..282c6dddf67 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -103,23 +103,23 @@ const char * const SubversionPlugin::DESCRIBE = "Subversion.Describe"; static const VCSBase::VCSBaseEditorParameters editorParameters[] = { { VCSBase::RegularCommandOutput, - "Subversion Command Log Editor", - Core::Constants::C_GLOBAL, + "Subversion Command Log Editor", // kind + "Subversion Command Log Editor", // context "application/vnd.nokia.text.scs_svn_commandlog", "scslog"}, { VCSBase::LogOutput, - "Subversion File Log Editor", - Core::Constants::C_GLOBAL, + "Subversion File Log Editor", // kind + "Subversion File Log Editor", // context "application/vnd.nokia.text.scs_svn_filelog", "scsfilelog"}, { VCSBase::AnnotateOutput, - "Subversion Annotation Editor", - Core::Constants::C_GLOBAL, + "Subversion Annotation Editor", // kind + "Subversion Annotation Editor", // context "application/vnd.nokia.text.scs_svn_annotation", "scsannotate"}, { VCSBase::DiffOutput, - "Subversion Diff Editor", - Core::Constants::C_GLOBAL, + "Subversion Diff Editor", // kind + "Subversion Diff Editor", // context "text/x-patch","diff"} }; diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 5ff46ef1353..ace1aa548c7 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -18,7 +18,7 @@ ** ** Alternatively, this file may be used under the terms of the GNU General ** Public License versions 2.0 or 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the packaging +** Foundation and appearing` in the file LICENSE.GPL included in the packaging ** of this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** @@ -91,8 +91,8 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context, m_contextId << Core::UniqueIDManager::instance()->uniqueIdentifier(context); - connect(Core::ICore::instance(), SIGNAL(contextAboutToChange(Core::IContext *)), - this, SLOT(updateCurrentEditor(Core::IContext *))); + connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), + this, SLOT(updateCurrentEditor(Core::IEditor *))); } void TextEditorActionHandler::setupActions(BaseTextEditor *editor) @@ -282,49 +282,31 @@ QAction *TextEditorActionHandler::registerNewAction(const QString &id, TextEditorActionHandler::UpdateMode TextEditorActionHandler::updateMode() const { - if (!m_currentEditor) - return NoEditor; + Q_ASSERT(m_currentEditor != 0); return m_currentEditor->file()->isReadOnly() ? ReadOnlyMode : WriteMode; } void TextEditorActionHandler::updateActions() { + if (!m_currentEditor || !m_initialized) + return; updateActions(updateMode()); } void TextEditorActionHandler::updateActions(UpdateMode um) { - if (!m_initialized) - return; - m_pasteAction->setEnabled(um != NoEditor); - m_selectAllAction->setEnabled(um != NoEditor); - m_gotoAction->setEnabled(um != NoEditor); - m_selectEncodingAction->setEnabled(um != NoEditor); - m_printAction->setEnabled(um != NoEditor); - m_formatAction->setEnabled((m_optionalActions & Format) && um != NoEditor); - m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != NoEditor); - m_collapseAction->setEnabled(um != NoEditor); - m_expandAction->setEnabled(um != NoEditor); - m_unCollapseAllAction->setEnabled((m_optionalActions & UnCollapseAll) && um != NoEditor); - m_decreaseFontSizeAction->setEnabled(um != NoEditor); - m_increaseFontSizeAction->setEnabled(um != NoEditor); - m_gotoBlockStartAction->setEnabled(um != NoEditor); - m_gotoBlockStartWithSelectionAction->setEnabled(um != NoEditor); - m_gotoBlockEndAction->setEnabled(um != NoEditor); - m_gotoBlockEndWithSelectionAction->setEnabled(um != NoEditor); - m_selectBlockUpAction->setEnabled(um != NoEditor); - m_selectBlockDownAction->setEnabled(um != NoEditor); - m_moveLineUpAction->setEnabled(um != NoEditor); - m_moveLineDownAction->setEnabled(um != NoEditor); - - m_visualizeWhitespaceAction->setEnabled(um != NoEditor); - if (m_currentEditor) - m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace); - m_cleanWhitespaceAction->setEnabled(um != NoEditor); + m_pasteAction->setEnabled(um != ReadOnlyMode); + m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode); + m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode); + m_moveLineUpAction->setEnabled(um != ReadOnlyMode); + m_moveLineDownAction->setEnabled(um != ReadOnlyMode); + + m_formatAction->setEnabled((m_optionalActions & Format)); + m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection)); + m_unCollapseAllAction->setEnabled((m_optionalActions & UnCollapseAll)); + m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace); if (m_textWrappingAction) { - m_textWrappingAction->setEnabled(um != NoEditor); - if (m_currentEditor) - m_textWrappingAction->setChecked(m_currentEditor->displaySettings().m_textWrapping); + m_textWrappingAction->setChecked(m_currentEditor->displaySettings().m_textWrapping); } updateRedoAction(); @@ -346,11 +328,12 @@ void TextEditorActionHandler::updateUndoAction() void TextEditorActionHandler::updateCopyAction() { - const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection(); + const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection(); if (m_cutAction) m_cutAction->setEnabled(hasCopyableText && updateMode() == WriteMode); - if (m_copyAction) + if (m_copyAction) { m_copyAction->setEnabled(hasCopyableText); + } } void TextEditorActionHandler::gotoAction() @@ -422,37 +405,19 @@ FUNCTION(selectBlockDown) FUNCTION(moveLineUp) FUNCTION(moveLineDown) -void TextEditorActionHandler::updateCurrentEditor(Core::IContext *object) +void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor) { - do { - if (!object) { - if (!m_currentEditor) - return; - - m_currentEditor = 0; - break; - } - BaseTextEditor *editor = qobject_cast<BaseTextEditor *>(object->widget()); - if (!editor) { - if (!m_currentEditor) - return; - - m_currentEditor = 0; - break; - } - - if (editor == m_currentEditor) - return; - - if (editor->actionHack() != this) { - m_currentEditor = 0; - break; - } - - m_currentEditor = editor; - - } while (false); - updateActions(); + m_currentEditor = 0; + + if (!editor) + return; + + BaseTextEditor *baseEditor = qobject_cast<BaseTextEditor *>(editor->widget()); + + if (baseEditor && baseEditor->actionHack() == this) { + m_currentEditor = baseEditor; + updateActions(); + } } diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 172617e9a27..28a97ad5eac 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -78,7 +78,7 @@ protected: QAction *registerNewAction(const QString &id, QObject *receiver, const char *slot, const QString &title = QString()); - enum UpdateMode { NoEditor , ReadOnlyMode, WriteMode }; + enum UpdateMode { ReadOnlyMode, WriteMode }; UpdateMode updateMode() const; virtual void createActions(); @@ -114,7 +114,7 @@ private slots: void selectBlockDown(); void moveLineUp(); void moveLineDown(); - void updateCurrentEditor(Core::IContext *object); + void updateCurrentEditor(Core::IEditor *editor); private: QAction *m_undoAction; diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index d7f85a9449d..d1d01b43a45 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -56,7 +56,7 @@ BaseVCSEditorFactoryPrivate::BaseVCSEditorFactoryPrivate(const VCSBaseEditorPara m_type(t), m_kind(QLatin1String(t->kind)), m_mimeTypes(QStringList(QLatin1String(t->mimeType))), - m_editorHandler(new TextEditor::TextEditorActionHandler(t->kind)) + m_editorHandler(new TextEditor::TextEditorActionHandler(t->context)) { } -- GitLab