fix context definitions of the vcs editors (this makes shortcuts work again)

This commit is contained in:
mae
2009-02-16 12:50:15 +01:00
parent 2ff2c9c14b
commit 8598a59b9f
8 changed files with 47 additions and 86 deletions

View File

@@ -38,9 +38,13 @@ namespace Git {
namespace Constants { namespace Constants {
const char * const GIT_COMMAND_LOG_EDITOR_KIND = "Git Command Log Editor"; 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 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 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 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 C_GITSUBMITEDITOR = "Git Submit Editor";
const char * const GITSUBMITEDITOR_KIND = "Git Submit Editor"; const char * const GITSUBMITEDITOR_KIND = "Git Submit Editor";

View File

@@ -73,22 +73,22 @@ static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
{ {
VCSBase::RegularCommandOutput, VCSBase::RegularCommandOutput,
Git::Constants::GIT_COMMAND_LOG_EDITOR_KIND, 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", "application/vnd.nokia.text.scs_git_commandlog",
"gitlog"}, "gitlog"},
{ VCSBase::LogOutput, { VCSBase::LogOutput,
Git::Constants::GIT_LOG_EDITOR_KIND, Git::Constants::GIT_LOG_EDITOR_KIND,
Core::Constants::C_GLOBAL, Git::Constants::C_GIT_LOG_EDITOR,
"application/vnd.nokia.text.scs_git_filelog", "application/vnd.nokia.text.scs_git_filelog",
"gitfilelog"}, "gitfilelog"},
{ VCSBase::AnnotateOutput, { VCSBase::AnnotateOutput,
Git::Constants::GIT_BLAME_EDITOR_KIND, Git::Constants::GIT_BLAME_EDITOR_KIND,
Core::Constants::C_GLOBAL, Git::Constants::C_GIT_BLAME_EDITOR,
"application/vnd.nokia.text.scs_git_annotation", "application/vnd.nokia.text.scs_git_annotation",
"gitsannotate"}, "gitsannotate"},
{ VCSBase::DiffOutput, { VCSBase::DiffOutput,
Git::Constants::GIT_DIFF_EDITOR_KIND, Git::Constants::GIT_DIFF_EDITOR_KIND,
Core::Constants::C_GLOBAL, Git::Constants::C_GIT_DIFF_EDITOR,
"text/x-patch","diff"} "text/x-patch","diff"}
}; };

View File

@@ -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() void QtScriptEditorActionHandler::run()
{ {
typedef Core::ScriptManager::Stack Stack; typedef Core::ScriptManager::Stack Stack;

View File

@@ -48,7 +48,6 @@ public:
private: private:
virtual void createActions(); virtual void createActions();
virtual void updateActions(UpdateMode um);
private slots: private slots:
void run(); void run();

View File

@@ -103,23 +103,23 @@ const char * const SubversionPlugin::DESCRIBE = "Subversion.Describe";
static const VCSBase::VCSBaseEditorParameters editorParameters[] = { static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
{ {
VCSBase::RegularCommandOutput, VCSBase::RegularCommandOutput,
"Subversion Command Log Editor", "Subversion Command Log Editor", // kind
Core::Constants::C_GLOBAL, "Subversion Command Log Editor", // context
"application/vnd.nokia.text.scs_svn_commandlog", "application/vnd.nokia.text.scs_svn_commandlog",
"scslog"}, "scslog"},
{ VCSBase::LogOutput, { VCSBase::LogOutput,
"Subversion File Log Editor", "Subversion File Log Editor", // kind
Core::Constants::C_GLOBAL, "Subversion File Log Editor", // context
"application/vnd.nokia.text.scs_svn_filelog", "application/vnd.nokia.text.scs_svn_filelog",
"scsfilelog"}, "scsfilelog"},
{ VCSBase::AnnotateOutput, { VCSBase::AnnotateOutput,
"Subversion Annotation Editor", "Subversion Annotation Editor", // kind
Core::Constants::C_GLOBAL, "Subversion Annotation Editor", // context
"application/vnd.nokia.text.scs_svn_annotation", "application/vnd.nokia.text.scs_svn_annotation",
"scsannotate"}, "scsannotate"},
{ VCSBase::DiffOutput, { VCSBase::DiffOutput,
"Subversion Diff Editor", "Subversion Diff Editor", // kind
Core::Constants::C_GLOBAL, "Subversion Diff Editor", // context
"text/x-patch","diff"} "text/x-patch","diff"}
}; };

View File

@@ -18,7 +18,7 @@
** **
** Alternatively, this file may be used under the terms of the GNU General ** 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 ** 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 ** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met: ** General Public Licensing requirements will be met:
** **
@@ -91,8 +91,8 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context,
m_contextId << Core::UniqueIDManager::instance()->uniqueIdentifier(context); m_contextId << Core::UniqueIDManager::instance()->uniqueIdentifier(context);
connect(Core::ICore::instance(), SIGNAL(contextAboutToChange(Core::IContext *)), connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateCurrentEditor(Core::IContext *))); this, SLOT(updateCurrentEditor(Core::IEditor *)));
} }
void TextEditorActionHandler::setupActions(BaseTextEditor *editor) void TextEditorActionHandler::setupActions(BaseTextEditor *editor)
@@ -282,48 +282,30 @@ QAction *TextEditorActionHandler::registerNewAction(const QString &id,
TextEditorActionHandler::UpdateMode TextEditorActionHandler::updateMode() const TextEditorActionHandler::UpdateMode TextEditorActionHandler::updateMode() const
{ {
if (!m_currentEditor) Q_ASSERT(m_currentEditor != 0);
return NoEditor;
return m_currentEditor->file()->isReadOnly() ? ReadOnlyMode : WriteMode; return m_currentEditor->file()->isReadOnly() ? ReadOnlyMode : WriteMode;
} }
void TextEditorActionHandler::updateActions() void TextEditorActionHandler::updateActions()
{ {
if (!m_currentEditor || !m_initialized)
return;
updateActions(updateMode()); updateActions(updateMode());
} }
void TextEditorActionHandler::updateActions(UpdateMode um) void TextEditorActionHandler::updateActions(UpdateMode um)
{ {
if (!m_initialized) m_pasteAction->setEnabled(um != ReadOnlyMode);
return; m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode);
m_pasteAction->setEnabled(um != NoEditor); m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode);
m_selectAllAction->setEnabled(um != NoEditor); m_moveLineUpAction->setEnabled(um != ReadOnlyMode);
m_gotoAction->setEnabled(um != NoEditor); m_moveLineDownAction->setEnabled(um != ReadOnlyMode);
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); m_formatAction->setEnabled((m_optionalActions & Format));
if (m_currentEditor) m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection));
m_unCollapseAllAction->setEnabled((m_optionalActions & UnCollapseAll));
m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace); m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
m_cleanWhitespaceAction->setEnabled(um != NoEditor);
if (m_textWrappingAction) { 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);
} }
@@ -349,8 +331,9 @@ void TextEditorActionHandler::updateCopyAction()
const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection(); const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection();
if (m_cutAction) if (m_cutAction)
m_cutAction->setEnabled(hasCopyableText && updateMode() == WriteMode); m_cutAction->setEnabled(hasCopyableText && updateMode() == WriteMode);
if (m_copyAction) if (m_copyAction) {
m_copyAction->setEnabled(hasCopyableText); m_copyAction->setEnabled(hasCopyableText);
}
} }
void TextEditorActionHandler::gotoAction() void TextEditorActionHandler::gotoAction()
@@ -422,37 +405,19 @@ FUNCTION(selectBlockDown)
FUNCTION(moveLineUp) FUNCTION(moveLineUp)
FUNCTION(moveLineDown) FUNCTION(moveLineDown)
void TextEditorActionHandler::updateCurrentEditor(Core::IContext *object) void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor)
{ {
do { m_currentEditor = 0;
if (!object) {
if (!m_currentEditor) if (!editor)
return; return;
m_currentEditor = 0; BaseTextEditor *baseEditor = qobject_cast<BaseTextEditor *>(editor->widget());
break;
}
BaseTextEditor *editor = qobject_cast<BaseTextEditor *>(object->widget());
if (!editor) {
if (!m_currentEditor)
return;
m_currentEditor = 0; if (baseEditor && baseEditor->actionHack() == this) {
break; m_currentEditor = baseEditor;
}
if (editor == m_currentEditor)
return;
if (editor->actionHack() != this) {
m_currentEditor = 0;
break;
}
m_currentEditor = editor;
} while (false);
updateActions(); updateActions();
}
} }

View File

@@ -78,7 +78,7 @@ protected:
QAction *registerNewAction(const QString &id, QObject *receiver, const char *slot, QAction *registerNewAction(const QString &id, QObject *receiver, const char *slot,
const QString &title = QString()); const QString &title = QString());
enum UpdateMode { NoEditor , ReadOnlyMode, WriteMode }; enum UpdateMode { ReadOnlyMode, WriteMode };
UpdateMode updateMode() const; UpdateMode updateMode() const;
virtual void createActions(); virtual void createActions();
@@ -114,7 +114,7 @@ private slots:
void selectBlockDown(); void selectBlockDown();
void moveLineUp(); void moveLineUp();
void moveLineDown(); void moveLineDown();
void updateCurrentEditor(Core::IContext *object); void updateCurrentEditor(Core::IEditor *editor);
private: private:
QAction *m_undoAction; QAction *m_undoAction;

View File

@@ -56,7 +56,7 @@ BaseVCSEditorFactoryPrivate::BaseVCSEditorFactoryPrivate(const VCSBaseEditorPara
m_type(t), m_type(t),
m_kind(QLatin1String(t->kind)), m_kind(QLatin1String(t->kind)),
m_mimeTypes(QStringList(QLatin1String(t->mimeType))), m_mimeTypes(QStringList(QLatin1String(t->mimeType))),
m_editorHandler(new TextEditor::TextEditorActionHandler(t->kind)) m_editorHandler(new TextEditor::TextEditorActionHandler(t->context))
{ {
} }