From ebcb9dce5af99e3148e5531f05d2fa31a0372217 Mon Sep 17 00:00:00 2001 From: mae <qtc-committer@nokia.com> Date: Mon, 26 Jan 2009 16:36:02 +0100 Subject: [PATCH] separate EM::setCurrentEditor and EM::activateEditor --- .../editormanager/editormanager.cpp | 6 +- .../coreplugin/editormanager/editormanager.h | 2 + .../editormanager/openeditorswindow.cpp | 2 +- .../scriptmanager/qworkbench_wrapper.cpp | 73 +------------------ .../scriptmanager/qworkbench_wrapper.h | 37 +--------- src/plugins/git/gitclient.cpp | 2 +- src/plugins/perforce/perforceplugin.cpp | 2 +- src/plugins/quickopen/opendocumentsfilter.cpp | 2 +- src/plugins/subversion/subversionplugin.cpp | 8 +- 9 files changed, 17 insertions(+), 117 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 7668bf8322..973d4153ee 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -687,7 +687,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA } if (currentEditorRemoved) { if (m_d->m_editorHistory.count() > 0) { - setCurrentEditor(m_d->m_editorHistory.first(), true); + activateEditor(m_d->m_editorHistory.first(), true); } else { editorChanged(currentEditor()); } @@ -1223,7 +1223,7 @@ void EditorManager::updateActions() QList<IEditor*> EditorManager::openedEditors() const { - return m_d->m_view->editors(); + return m_d->m_editorModel->editors(); } Internal::EditorModel *EditorManager::openedEditorsModel() const @@ -1611,7 +1611,7 @@ void EditorManager::unsplitAll() { m_d->m_splitter->unsplit(0); if (IEditor *e = m_d->m_splitter->editor()) - setCurrentEditor(e); + activateEditor(e); } void EditorManager::gotoOtherWindow() diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 36448d44a3..833032be42 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -116,7 +116,9 @@ public: bool hasEditor(const QString &fileName) const; QList<IEditor *> editorsForFileName(const QString &filename) const; +private: void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false); +public: IEditor *currentEditor() const; IEditor *activateEditor(IEditor *editor, bool ignoreNavigationHistory = false); // EditorGroup *currentEditorGroup() const; diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 316843c88e..f653e23511 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -235,7 +235,7 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item) IEditor *editor = 0; if (item) editor = item->data(0, Qt::UserRole).value<IEditor*>(); - EditorManager::instance()->setCurrentEditor(editor); + EditorManager::instance()->activateEditor(editor); } void OpenEditorsWindow::editorClicked(QTreeWidgetItem *item) diff --git a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp index b85732c4a4..e7dee79aef 100644 --- a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp +++ b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp @@ -252,9 +252,9 @@ Core::IEditor *EditorManagerPrototype::currentEditor() const return callee()->currentEditor(); } -void EditorManagerPrototype::setCurrentEditor(Core::IEditor *editor) +void EditorManagerPrototype::activateEditor(Core::IEditor *editor) { - callee()->setCurrentEditor(editor); + callee()->activateEditor(editor); } QList<Core::IEditor*> EditorManagerPrototype::openedEditors() const @@ -267,11 +267,6 @@ QList<Core::IEditor*> EditorManagerPrototype::editorHistory() const return callee()->editorHistory(); } -//QList<Core::EditorGroup *> EditorManagerPrototype::editorGroups() const -//{ -// return callee()->editorGroups(); -//} - QList<Core::IEditor*> EditorManagerPrototype::editorsForFiles(QList<Core::IFile*> files) const { return callee()->editorsForFiles(files); @@ -376,70 +371,6 @@ QString EditorPrototype::toString() const return rc; } -// ----------- EditorGroupPrototype - -EditorGroupPrototype::EditorGroupPrototype(QObject *parent) : - QObject(parent) -{ -} - -int EditorGroupPrototype::editorCount() const -{ - return callee()->editorCount(); -} - -Core::IEditor *EditorGroupPrototype::currentEditor() const -{ - return callee()->currentEditor(); -} - -void EditorGroupPrototype::setCurrentEditor(Core::IEditor *editor) -{ - callee()->setCurrentEditor(editor); -} - -QList<Core::IEditor*> EditorGroupPrototype::editors() const -{ - return callee()->editors(); -} - -void EditorGroupPrototype::addEditor(Core::IEditor *editor) -{ - callee()->addEditor(editor); -} - -void EditorGroupPrototype::insertEditor(int i, Core::IEditor *editor) -{ - callee()->insertEditor(i, editor); -} - -void EditorGroupPrototype::removeEditor(Core::IEditor *editor) -{ - callee()->removeEditor(editor); -} - - -void EditorGroupPrototype::moveEditorsFromGroup(Core::EditorGroup *group) -{ - callee()->moveEditorsFromGroup(group); -} - -void EditorGroupPrototype::moveEditorFromGroup(Core::EditorGroup *group, Core::IEditor *editor) -{ - callee()->moveEditorFromGroup(group, editor); -} - -QString EditorGroupPrototype::toString() const -{ - return QLatin1String("EditorGroup"); -} - -Core::EditorGroup *EditorGroupPrototype::callee() const -{ - EditorGroup *rc = qscriptvalue_cast<EditorGroup *>(thisObject()); - QTC_ASSERT(rc, return 0); - return rc; -} } // namespace Internal } // namespace Core diff --git a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.h b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.h index 3df8de92c0..d2b3889e5c 100644 --- a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.h +++ b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.h @@ -167,20 +167,18 @@ private: class EditorManagerPrototype : public QObject, public QScriptable { Q_OBJECT - Q_PROPERTY(Core::IEditor* currentEditor READ currentEditor WRITE setCurrentEditor DESIGNABLE false SCRIPTABLE true STORED false) + Q_PROPERTY(Core::IEditor* currentEditor READ currentEditor WRITE activateEditor DESIGNABLE false SCRIPTABLE true STORED false) Q_PROPERTY(QList<Core::IEditor*> openedEditors READ openedEditors DESIGNABLE false SCRIPTABLE true STORED false) Q_PROPERTY(QList<Core::IEditor*> editorHistory READ editorHistory DESIGNABLE false SCRIPTABLE true STORED false) -// Q_PROPERTY(QList<Core::EditorGroup *> editorGroups READ editorGroups DESIGNABLE false SCRIPTABLE true STORED false) public: typedef Core::EditorManager EditorManager; EditorManagerPrototype(QObject *parent = 0); Core::IEditor *currentEditor() const; - void setCurrentEditor(Core::IEditor *editor); + void activateEditor(Core::IEditor *editor); QList<Core::IEditor*> openedEditors() const; QList<Core::IEditor*> editorHistory() const; -// QList<Core::EditorGroup *> editorGroups() const; public slots: QList<Core::IEditor*> editorsForFiles(QList<Core::IFile*> files) const; @@ -229,37 +227,6 @@ private: Core::IEditor *callee() const; }; -// Script prototype for the editor group interface with Script-managed life cycle. - -class EditorGroupPrototype : public QObject, public QScriptable -{ - Q_OBJECT - Q_PROPERTY(int editorCount READ editorCount DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(Core::IEditor* currentEditor READ currentEditor WRITE setCurrentEditor DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(QList<Core::IEditor*> editors READ editors DESIGNABLE false SCRIPTABLE true STORED false) - -public: - EditorGroupPrototype(QObject *parent = 0); - - int editorCount() const; - Core::IEditor *currentEditor() const; - void setCurrentEditor(Core::IEditor *editor); - QList<Core::IEditor*> editors() const; - -public slots: - void addEditor(Core::IEditor *editor); - void insertEditor(int i, Core::IEditor *editor); - void removeEditor(Core::IEditor *editor); - - void moveEditorsFromGroup(Core::EditorGroup *group); - void moveEditorFromGroup(Core::EditorGroup *group, Core::IEditor *editor); - - QString toString() const; - -private: - Core::EditorGroup *callee() const; -}; - } // namespace Internal } // namespace Core diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index e20ee11f96..5f7225e36d 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -169,7 +169,7 @@ VCSBase::VCSBaseEditor outputEditor->createNew(m_msgWait); rc = VCSBase::VCSBaseEditor::getVcsBaseEditor(outputEditor); QTC_ASSERT(rc, return 0); - m_core->editorManager()->setCurrentEditor(outputEditor); + m_core->editorManager()->activateEditor(outputEditor); } else { // Create new, set wait message, set up with source and codec outputEditor = m_core->editorManager()->newFile(kind, &title, m_msgWait); diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index b17cb7e5b6..2b4da85bf2 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -912,7 +912,7 @@ void PerforcePlugin::p4Diff(const QStringList &files, QString diffname) } else if (!displayInEditor && existingEditor) { if (existingEditor) { existingEditor->createNew(result.stdOut); - Core::EditorManager::instance()->setCurrentEditor(existingEditor); + Core::EditorManager::instance()->activateEditor(existingEditor); } } } diff --git a/src/plugins/quickopen/opendocumentsfilter.cpp b/src/plugins/quickopen/opendocumentsfilter.cpp index 7b09fdcede..a5419cde01 100644 --- a/src/plugins/quickopen/opendocumentsfilter.cpp +++ b/src/plugins/quickopen/opendocumentsfilter.cpp @@ -97,7 +97,7 @@ void OpenDocumentsFilter::accept(FilterEntry selection) const { IEditor *editor = selection.internalData.value<IEditor *>(); if (editor) { - m_editorManager->setCurrentEditor(editor); + m_editorManager->activateEditor(editor); return; } m_editorManager->openEditor(selection.internalData.toString()); diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 7f6ea476eb..115259bc5f 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -513,7 +513,7 @@ void SubversionPlugin::svnDiff(const QStringList &files, QString diffname) // Show in the same editor if diff has been executed before if (Core::IEditor *editor = locateEditor("originalFileName", files.front())) { editor->createNew(response.stdOut); - Core::EditorManager::instance()->setCurrentEditor(editor); + Core::EditorManager::instance()->activateEditor(editor); return; } } @@ -776,7 +776,7 @@ void SubversionPlugin::filelog(const QString &file) if (Core::IEditor *editor = locateEditor("logFileName", file)) { editor->createNew(response.stdOut); - Core::EditorManager::instance()->setCurrentEditor(editor); + Core::EditorManager::instance()->activateEditor(editor); } else { const QString title = tr("svn log %1").arg(QFileInfo(file).fileName()); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, file, codec); @@ -819,7 +819,7 @@ void SubversionPlugin::annotate(const QString &file) if (Core::IEditor *editor = locateEditor("annotateFileName", file)) { editor->createNew(response.stdOut); - Core::EditorManager::instance()->setCurrentEditor(editor); + Core::EditorManager::instance()->activateEditor(editor); } else { const QString title = tr("svn annotate %1").arg(QFileInfo(file).fileName()); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, file, codec); @@ -873,7 +873,7 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) const QString id = diffArg + source; if (Core::IEditor *editor = locateEditor("describeChange", id)) { editor->createNew(response.stdOut); - Core::EditorManager::instance()->setCurrentEditor(editor); + Core::EditorManager::instance()->activateEditor(editor); } else { const QString title = tr("svn describe %1#%2").arg(QFileInfo(source).fileName(), changeNr); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::DiffOutput, source, codec); -- GitLab