forked from qt-creator/qt-creator
separate EM::setCurrentEditor and EM::activateEditor
This commit is contained in:
@@ -687,7 +687,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
|
|||||||
}
|
}
|
||||||
if (currentEditorRemoved) {
|
if (currentEditorRemoved) {
|
||||||
if (m_d->m_editorHistory.count() > 0) {
|
if (m_d->m_editorHistory.count() > 0) {
|
||||||
setCurrentEditor(m_d->m_editorHistory.first(), true);
|
activateEditor(m_d->m_editorHistory.first(), true);
|
||||||
} else {
|
} else {
|
||||||
editorChanged(currentEditor());
|
editorChanged(currentEditor());
|
||||||
}
|
}
|
||||||
@@ -1223,7 +1223,7 @@ void EditorManager::updateActions()
|
|||||||
|
|
||||||
QList<IEditor*> EditorManager::openedEditors() const
|
QList<IEditor*> EditorManager::openedEditors() const
|
||||||
{
|
{
|
||||||
return m_d->m_view->editors();
|
return m_d->m_editorModel->editors();
|
||||||
}
|
}
|
||||||
|
|
||||||
Internal::EditorModel *EditorManager::openedEditorsModel() const
|
Internal::EditorModel *EditorManager::openedEditorsModel() const
|
||||||
@@ -1611,7 +1611,7 @@ void EditorManager::unsplitAll()
|
|||||||
{
|
{
|
||||||
m_d->m_splitter->unsplit(0);
|
m_d->m_splitter->unsplit(0);
|
||||||
if (IEditor *e = m_d->m_splitter->editor())
|
if (IEditor *e = m_d->m_splitter->editor())
|
||||||
setCurrentEditor(e);
|
activateEditor(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::gotoOtherWindow()
|
void EditorManager::gotoOtherWindow()
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ public:
|
|||||||
bool hasEditor(const QString &fileName) const;
|
bool hasEditor(const QString &fileName) const;
|
||||||
QList<IEditor *> editorsForFileName(const QString &filename) const;
|
QList<IEditor *> editorsForFileName(const QString &filename) const;
|
||||||
|
|
||||||
|
private:
|
||||||
void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
||||||
|
public:
|
||||||
IEditor *currentEditor() const;
|
IEditor *currentEditor() const;
|
||||||
IEditor *activateEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
IEditor *activateEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
||||||
// EditorGroup *currentEditorGroup() const;
|
// EditorGroup *currentEditorGroup() const;
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
|
|||||||
IEditor *editor = 0;
|
IEditor *editor = 0;
|
||||||
if (item)
|
if (item)
|
||||||
editor = item->data(0, Qt::UserRole).value<IEditor*>();
|
editor = item->data(0, Qt::UserRole).value<IEditor*>();
|
||||||
EditorManager::instance()->setCurrentEditor(editor);
|
EditorManager::instance()->activateEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::editorClicked(QTreeWidgetItem *item)
|
void OpenEditorsWindow::editorClicked(QTreeWidgetItem *item)
|
||||||
|
|||||||
@@ -252,9 +252,9 @@ Core::IEditor *EditorManagerPrototype::currentEditor() const
|
|||||||
return callee()->currentEditor();
|
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
|
QList<Core::IEditor*> EditorManagerPrototype::openedEditors() const
|
||||||
@@ -267,11 +267,6 @@ QList<Core::IEditor*> EditorManagerPrototype::editorHistory() const
|
|||||||
return callee()->editorHistory();
|
return callee()->editorHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
//QList<Core::EditorGroup *> EditorManagerPrototype::editorGroups() const
|
|
||||||
//{
|
|
||||||
// return callee()->editorGroups();
|
|
||||||
//}
|
|
||||||
|
|
||||||
QList<Core::IEditor*> EditorManagerPrototype::editorsForFiles(QList<Core::IFile*> files) const
|
QList<Core::IEditor*> EditorManagerPrototype::editorsForFiles(QList<Core::IFile*> files) const
|
||||||
{
|
{
|
||||||
return callee()->editorsForFiles(files);
|
return callee()->editorsForFiles(files);
|
||||||
@@ -376,70 +371,6 @@ QString EditorPrototype::toString() const
|
|||||||
return rc;
|
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 Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -167,20 +167,18 @@ private:
|
|||||||
class EditorManagerPrototype : public QObject, public QScriptable
|
class EditorManagerPrototype : public QObject, public QScriptable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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*> 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::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:
|
public:
|
||||||
typedef Core::EditorManager EditorManager;
|
typedef Core::EditorManager EditorManager;
|
||||||
|
|
||||||
EditorManagerPrototype(QObject *parent = 0);
|
EditorManagerPrototype(QObject *parent = 0);
|
||||||
|
|
||||||
Core::IEditor *currentEditor() const;
|
Core::IEditor *currentEditor() const;
|
||||||
void setCurrentEditor(Core::IEditor *editor);
|
void activateEditor(Core::IEditor *editor);
|
||||||
QList<Core::IEditor*> openedEditors() const;
|
QList<Core::IEditor*> openedEditors() const;
|
||||||
QList<Core::IEditor*> editorHistory() const;
|
QList<Core::IEditor*> editorHistory() const;
|
||||||
// QList<Core::EditorGroup *> editorGroups() const;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QList<Core::IEditor*> editorsForFiles(QList<Core::IFile*> files) const;
|
QList<Core::IEditor*> editorsForFiles(QList<Core::IFile*> files) const;
|
||||||
@@ -229,37 +227,6 @@ private:
|
|||||||
Core::IEditor *callee() const;
|
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 Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ VCSBase::VCSBaseEditor
|
|||||||
outputEditor->createNew(m_msgWait);
|
outputEditor->createNew(m_msgWait);
|
||||||
rc = VCSBase::VCSBaseEditor::getVcsBaseEditor(outputEditor);
|
rc = VCSBase::VCSBaseEditor::getVcsBaseEditor(outputEditor);
|
||||||
QTC_ASSERT(rc, return 0);
|
QTC_ASSERT(rc, return 0);
|
||||||
m_core->editorManager()->setCurrentEditor(outputEditor);
|
m_core->editorManager()->activateEditor(outputEditor);
|
||||||
} else {
|
} else {
|
||||||
// Create new, set wait message, set up with source and codec
|
// Create new, set wait message, set up with source and codec
|
||||||
outputEditor = m_core->editorManager()->newFile(kind, &title, m_msgWait);
|
outputEditor = m_core->editorManager()->newFile(kind, &title, m_msgWait);
|
||||||
|
|||||||
@@ -912,7 +912,7 @@ void PerforcePlugin::p4Diff(const QStringList &files, QString diffname)
|
|||||||
} else if (!displayInEditor && existingEditor) {
|
} else if (!displayInEditor && existingEditor) {
|
||||||
if (existingEditor) {
|
if (existingEditor) {
|
||||||
existingEditor->createNew(result.stdOut);
|
existingEditor->createNew(result.stdOut);
|
||||||
Core::EditorManager::instance()->setCurrentEditor(existingEditor);
|
Core::EditorManager::instance()->activateEditor(existingEditor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ void OpenDocumentsFilter::accept(FilterEntry selection) const
|
|||||||
{
|
{
|
||||||
IEditor *editor = selection.internalData.value<IEditor *>();
|
IEditor *editor = selection.internalData.value<IEditor *>();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
m_editorManager->setCurrentEditor(editor);
|
m_editorManager->activateEditor(editor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_editorManager->openEditor(selection.internalData.toString());
|
m_editorManager->openEditor(selection.internalData.toString());
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ void SubversionPlugin::svnDiff(const QStringList &files, QString diffname)
|
|||||||
// Show in the same editor if diff has been executed before
|
// Show in the same editor if diff has been executed before
|
||||||
if (Core::IEditor *editor = locateEditor("originalFileName", files.front())) {
|
if (Core::IEditor *editor = locateEditor("originalFileName", files.front())) {
|
||||||
editor->createNew(response.stdOut);
|
editor->createNew(response.stdOut);
|
||||||
Core::EditorManager::instance()->setCurrentEditor(editor);
|
Core::EditorManager::instance()->activateEditor(editor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -776,7 +776,7 @@ void SubversionPlugin::filelog(const QString &file)
|
|||||||
|
|
||||||
if (Core::IEditor *editor = locateEditor("logFileName", file)) {
|
if (Core::IEditor *editor = locateEditor("logFileName", file)) {
|
||||||
editor->createNew(response.stdOut);
|
editor->createNew(response.stdOut);
|
||||||
Core::EditorManager::instance()->setCurrentEditor(editor);
|
Core::EditorManager::instance()->activateEditor(editor);
|
||||||
} else {
|
} else {
|
||||||
const QString title = tr("svn log %1").arg(QFileInfo(file).fileName());
|
const QString title = tr("svn log %1").arg(QFileInfo(file).fileName());
|
||||||
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, file, codec);
|
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)) {
|
if (Core::IEditor *editor = locateEditor("annotateFileName", file)) {
|
||||||
editor->createNew(response.stdOut);
|
editor->createNew(response.stdOut);
|
||||||
Core::EditorManager::instance()->setCurrentEditor(editor);
|
Core::EditorManager::instance()->activateEditor(editor);
|
||||||
} else {
|
} else {
|
||||||
const QString title = tr("svn annotate %1").arg(QFileInfo(file).fileName());
|
const QString title = tr("svn annotate %1").arg(QFileInfo(file).fileName());
|
||||||
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, file, codec);
|
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;
|
const QString id = diffArg + source;
|
||||||
if (Core::IEditor *editor = locateEditor("describeChange", id)) {
|
if (Core::IEditor *editor = locateEditor("describeChange", id)) {
|
||||||
editor->createNew(response.stdOut);
|
editor->createNew(response.stdOut);
|
||||||
Core::EditorManager::instance()->setCurrentEditor(editor);
|
Core::EditorManager::instance()->activateEditor(editor);
|
||||||
} else {
|
} else {
|
||||||
const QString title = tr("svn describe %1#%2").arg(QFileInfo(source).fileName(), changeNr);
|
const QString title = tr("svn describe %1#%2").arg(QFileInfo(source).fileName(), changeNr);
|
||||||
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::DiffOutput, source, codec);
|
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::DiffOutput, source, codec);
|
||||||
|
|||||||
Reference in New Issue
Block a user