Commit c9445676 authored by mae's avatar mae
Browse files

experiment with splitted views based on karsten's input.

The goal is to support both the emacs usecase and the
usecase with fixed views for certain sets of files. The changes
gives the user more control where the files are. Effectively
it should be easy now to put your cpp files in the left pane,
and the header files in the right pane, and use F4 to toggle
between them.

Also make the 'x' in the toolbar close the document, and not the view.
parent 3f735e44
......@@ -516,6 +516,9 @@ void EditorManager::setCurrentView(Core::Internal::SplitterOrView *view)
old->update();
if (view)
view->update();
if (view && !view->editor())
view->setFocus();
}
Core::Internal::SplitterOrView *EditorManager::currentView() const
......@@ -715,6 +718,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
foreach (EditorView *view, currentViews) {
IEditor *newCurrent = view->currentEditor();
#if 0
if (!newCurrent)
newCurrent = pickUnusedEditor();
if (!newCurrent) {
......@@ -726,7 +730,10 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
}
}
}
#else
if (!newCurrent && view == m_d->m_view)
newCurrent = pickUnusedEditor();
#endif
if (newCurrent) {
activateEditor(view, newCurrent, NoActivate);
} else {
......@@ -833,15 +840,18 @@ Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core
sourceView->view()->removeEditor(editor);
view->addEditor(editor);
view->setCurrentEditor(editor);
#if 0
if (!sourceView->editor()) {
if (IEditor *replacement = pickUnusedEditor()) {
sourceView->view()->addEditor(replacement);
}
}
#endif
return editor;
} else if (duplicateSupported) {
editor = duplicateEditor(editor);
Q_ASSERT(editor);
m_d->m_editorModel->makeOriginal(editor);
}
}
view->addEditor(editor);
......
......@@ -229,6 +229,17 @@ QList<IEditor *> EditorModel::duplicatesFor(IEditor *editor) const
return result;
}
void EditorModel::makeOriginal(IEditor *duplicate)
{
Q_ASSERT(isDuplicate(duplicate));
IEditor *original = originalForDuplicate(duplicate);
Q_ASSERT(original);
int i = findEditor(original);
m_editors[i].editor = duplicate;
m_duplicateEditors.removeOne(duplicate);
m_duplicateEditors.append(original);
}
void EditorModel::emitDataChanged(IEditor *editor)
{
int idx = findEditor(editor);
......@@ -504,7 +515,12 @@ bool EditorView::hasEditor(IEditor *editor) const
void EditorView::closeView()
{
EditorManager *em = CoreImpl::instance()->editorManager();
#if 1
if (IEditor *editor = currentEditor())
em->closeEditor(editor);
#else
em->closeView(this);
#endif
}
void EditorView::removeEditor(IEditor *editor)
......@@ -547,7 +563,9 @@ void EditorView::setCurrentEditor(IEditor *editor)
{
if (!editor || m_container->count() <= 0
|| m_container->indexOf(editor->widget()) == -1)
// ### TODO the combo box m_editorList should show an empty item
return;
m_editors.removeAll(editor);
m_editors.append(editor);
......@@ -862,20 +880,24 @@ void SplitterOrView::split(Qt::Orientation orientation)
EditorManager *em = CoreImpl::instance()->editorManager();
Core::IEditor *e = m_view->currentEditor();
SplitterOrView *view = 0;
if (e) {
m_view->removeEditor(e);
m_splitter->addWidget(new SplitterOrView(e));
#if 0
if (e->duplicateSupported()) {
Core::IEditor *duplicate = em->duplicateEditor(e);
m_splitter->addWidget(new SplitterOrView(duplicate));
} else {
m_splitter->addWidget(new SplitterOrView());
}
#else
m_splitter->addWidget((view = new SplitterOrView()));
#endif
} else {
m_splitter->addWidget(new SplitterOrView());
m_splitter->addWidget(new SplitterOrView());
m_splitter->addWidget((view = new SplitterOrView()));
}
m_layout->setCurrentWidget(m_splitter);
......@@ -886,9 +908,11 @@ void SplitterOrView::split(Qt::Orientation orientation)
m_view = 0;
}
em->setCurrentView(findFirstView());
em->setCurrentView(view);
#if 0
if (e)
em->activateEditor(e);
#endif
}
void SplitterOrView::unsplitAll()
......
......@@ -95,6 +95,7 @@ public:
bool isDuplicate(IEditor *editor) const;
QList<IEditor *> duplicatesFor(IEditor *editor) const;
IEditor *originalForDuplicate(IEditor *duplicate) const;
void makeOriginal(IEditor *duplicate);
QModelIndex indexOf(IEditor *editor) const;
QModelIndex indexOf(const QString &filename) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment