keep stack history in each editor view.

This commit is contained in:
mae
2009-02-16 11:29:50 +01:00
parent 799686602d
commit 2ff2c9c14b
2 changed files with 27 additions and 18 deletions

View File

@@ -329,9 +329,11 @@ EditorView::~EditorView()
void EditorView::addEditor(IEditor *editor) void EditorView::addEditor(IEditor *editor)
{ {
if (m_container->indexOf(editor->widget()) != -1) if (m_editors.contains(editor))
return; return;
m_editors.append(editor);
m_container->addWidget(editor->widget()); m_container->addWidget(editor->widget());
m_widgetEditorMap.insert(editor->widget(), editor); m_widgetEditorMap.insert(editor->widget(), editor);
@@ -348,7 +350,7 @@ void EditorView::addEditor(IEditor *editor)
bool EditorView::hasEditor(IEditor *editor) const bool EditorView::hasEditor(IEditor *editor) const
{ {
return (m_container->indexOf(editor->widget()) != -1); return m_editors.contains(editor);
} }
void EditorView::closeView() void EditorView::closeView()
@@ -360,26 +362,30 @@ void EditorView::closeView()
void EditorView::removeEditor(IEditor *editor) void EditorView::removeEditor(IEditor *editor)
{ {
QTC_ASSERT(editor, return); QTC_ASSERT(editor, return);
if (!m_editors.contains(editor))
return;
const int index = m_container->indexOf(editor->widget()); const int index = m_container->indexOf(editor->widget());
QTC_ASSERT((index != -1), return);
bool wasCurrent = (index == m_container->currentIndex()); bool wasCurrent = (index == m_container->currentIndex());
if (index != -1) { m_editors.removeAll(editor);
m_container->removeWidget(editor->widget());
m_widgetEditorMap.remove(editor->widget()); m_container->removeWidget(editor->widget());
editor->widget()->setParent(0); m_widgetEditorMap.remove(editor->widget());
disconnect(editor, SIGNAL(changed()), this, SLOT(updateEditorStatus())); editor->widget()->setParent(0);
QToolBar *toolBar = editor->toolBar(); disconnect(editor, SIGNAL(changed()), this, SLOT(updateEditorStatus()));
if (toolBar != 0) { QToolBar *toolBar = editor->toolBar();
if (m_activeToolBar == toolBar) { if (toolBar != 0) {
m_activeToolBar = m_defaultToolBar; if (m_activeToolBar == toolBar) {
m_activeToolBar->setVisible(true); m_activeToolBar = m_defaultToolBar;
} m_activeToolBar->setVisible(true);
m_toolBar->layout()->removeWidget(toolBar);
toolBar->setVisible(false);
toolBar->setParent(0);
} }
m_toolBar->layout()->removeWidget(toolBar);
toolBar->setVisible(false);
toolBar->setParent(0);
} }
if (wasCurrent) if (wasCurrent && m_editors.count())
setCurrentEditor(currentEditor()); setCurrentEditor(m_editors.last());
} }
IEditor *EditorView::currentEditor() const IEditor *EditorView::currentEditor() const
@@ -394,6 +400,8 @@ void EditorView::setCurrentEditor(IEditor *editor)
if (!editor || m_container->count() <= 0 if (!editor || m_container->count() <= 0
|| m_container->indexOf(editor->widget()) == -1) || m_container->indexOf(editor->widget()) == -1)
return; return;
m_editors.removeAll(editor);
m_editors.append(editor);
const int idx = m_container->indexOf(editor->widget()); const int idx = m_container->indexOf(editor->widget());
QTC_ASSERT(idx >= 0, return); QTC_ASSERT(idx >= 0, return);

View File

@@ -144,6 +144,7 @@ private:
QToolButton *m_infoWidgetButton; QToolButton *m_infoWidgetButton;
IEditor *m_editorForInfoWidget; IEditor *m_editorForInfoWidget;
QSortFilterProxyModel m_proxyModel; QSortFilterProxyModel m_proxyModel;
QList<IEditor *>m_editors;
QMap<QWidget *, IEditor *> m_widgetEditorMap; QMap<QWidget *, IEditor *> m_widgetEditorMap;
}; };