diff --git a/src/plugins/git/gitconstants.h b/src/plugins/git/gitconstants.h index b539046ffb5228a5637199b6fed2dccfac6c0272..438d0f25b9a4440356f38cf2a691f8f29b7dfb54 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 11823909585901a621faa645e81e33634af047b6..72069cef4ddb1e048f8b79f387956e2a66b6d932 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 18d57a6a7b2394156658cf4ace54d0e168d58e76..9d5a6b41907a35204003b715b9db1b7cfbdeed79 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 c4940cfa160495f43be885fa7cc82832ef9e2626..ca1fa27af28f61875ad91377805e3be30456f415 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 3ab8b75f9bb2093cdaa038b31685c9d3b47a1257..282c6dddf67f7d3b7612658534ca887dec3e8ceb 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 5ff46ef1353f94174ff13db0d390ba93fe070004..ace1aa548c73b5b62cc514855c8316bf5b472b4e 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 172617e9a27e7b7fc55869b9a0f87262a05e62f4..28a97ad5eac57a7c305a422afcd1a0592f41b9e7 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 d7f85a9449d2ce4389bd597ba5562a06f676b22a..d1d01b43a4554845ffa10d64f017134085adc527 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)) { }