Commit d6ddff93 authored by Eike Ziller's avatar Eike Ziller
Browse files

EditorManager: Move close split button updating to editor areas



No need to have editor manager being responsible for that.

Change-Id: I25f06a38fc2a543749fa1f10a7fa3f2e37c60cf0
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 62acde46
...@@ -52,9 +52,11 @@ EditorArea::EditorArea() ...@@ -52,9 +52,11 @@ EditorArea::EditorArea()
ICore::addContextObject(m_context); ICore::addContextObject(m_context);
setCurrentView(view()); setCurrentView(view());
updateCloseSplitButton();
connect(qApp, &QApplication::focusChanged, connect(qApp, &QApplication::focusChanged,
this, &EditorArea::focusChanged); this, &EditorArea::focusChanged);
connect(this, &SplitterOrView::splitStateChanged, this, &EditorArea::updateCloseSplitButton);
} }
EditorArea::~EditorArea() EditorArea::~EditorArea()
...@@ -123,5 +125,11 @@ void EditorArea::updateCurrentEditor(IEditor *editor) ...@@ -123,5 +125,11 @@ void EditorArea::updateCurrentEditor(IEditor *editor)
emit windowTitleNeedsUpdate(); emit windowTitleNeedsUpdate();
} }
void EditorArea::updateCloseSplitButton()
{
if (EditorView *v = view())
v->setCloseSplitEnabled(false);
}
} // Internal } // Internal
} // Core } // Core
...@@ -57,6 +57,7 @@ private: ...@@ -57,6 +57,7 @@ private:
void focusChanged(QWidget *old, QWidget *now); void focusChanged(QWidget *old, QWidget *now);
void setCurrentView(EditorView *view); void setCurrentView(EditorView *view);
void updateCurrentEditor(IEditor *editor); void updateCurrentEditor(IEditor *editor);
void updateCloseSplitButton();
IContext *m_context; IContext *m_context;
QPointer<EditorView> m_currentView; QPointer<EditorView> m_currentView;
......
...@@ -1240,19 +1240,6 @@ void EditorManagerPrivate::updateAutoSave() ...@@ -1240,19 +1240,6 @@ void EditorManagerPrivate::updateAutoSave()
d->m_autoSaveTimer->stop(); d->m_autoSaveTimer->stop();
} }
void EditorManagerPrivate::setCloseSplitEnabled(SplitterOrView *splitterOrView, bool enable)
{
if (splitterOrView->isView())
splitterOrView->view()->setCloseSplitEnabled(enable);
QSplitter *splitter = splitterOrView->splitter();
if (splitter) {
for (int i = 0; i < splitter->count(); ++i) {
if (SplitterOrView *subSplitterOrView = qobject_cast<SplitterOrView*>(splitter->widget(i)))
setCloseSplitEnabled(subSplitterOrView, enable);
}
}
}
void EditorManagerPrivate::updateMakeWritableWarning() void EditorManagerPrivate::updateMakeWritableWarning()
{ {
IDocument *document = EditorManager::currentDocument(); IDocument *document = EditorManager::currentDocument();
...@@ -1324,9 +1311,6 @@ void EditorManagerPrivate::updateActions() ...@@ -1324,9 +1311,6 @@ void EditorManagerPrivate::updateActions()
if (curDocument) if (curDocument)
updateMakeWritableWarning(); updateMakeWritableWarning();
foreach (EditorArea *area, d->m_editorAreas)
setCloseSplitEnabled(area, area->isSplitter());
QString quotedName; QString quotedName;
if (curDocument) if (curDocument)
quotedName = QLatin1Char('"') + curDocument->displayName() + QLatin1Char('"'); quotedName = QLatin1Char('"') + curDocument->displayName() + QLatin1Char('"');
......
...@@ -166,7 +166,6 @@ private: ...@@ -166,7 +166,6 @@ private:
static IEditor *pickUnusedEditor(Internal::EditorView **foundView = 0); static IEditor *pickUnusedEditor(Internal::EditorView **foundView = 0);
static void addDocumentToRecentFiles(IDocument *document); static void addDocumentToRecentFiles(IDocument *document);
static void updateAutoSave(); static void updateAutoSave();
static void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
static void updateMakeWritableWarning(); static void updateMakeWritableWarning();
static void setupSaveActions(IDocument *document, QAction *saveAction, static void setupSaveActions(IDocument *document, QAction *saveAction,
QAction *saveAsAction, QAction *revertToSavedAction); QAction *saveAsAction, QAction *revertToSavedAction);
......
...@@ -644,6 +644,7 @@ void SplitterOrView::split(Qt::Orientation orientation) ...@@ -644,6 +644,7 @@ void SplitterOrView::split(Qt::Orientation orientation)
m_layout->addWidget(m_splitter); m_layout->addWidget(m_splitter);
m_layout->removeWidget(m_view); m_layout->removeWidget(m_view);
EditorView *editorView = m_view; EditorView *editorView = m_view;
editorView->setCloseSplitEnabled(true); // might have been disabled for root view
m_view = 0; m_view = 0;
IEditor *e = editorView->currentEditor(); IEditor *e = editorView->currentEditor();
...@@ -670,6 +671,7 @@ void SplitterOrView::split(Qt::Orientation orientation) ...@@ -670,6 +671,7 @@ void SplitterOrView::split(Qt::Orientation orientation)
EditorManagerPrivate::activateEditor(otherView->view(), e); EditorManagerPrivate::activateEditor(otherView->view(), e);
else else
EditorManagerPrivate::setCurrentView(otherView->view()); EditorManagerPrivate::setCurrentView(otherView->view());
emit splitStateChanged();
} }
void SplitterOrView::unsplitAll() void SplitterOrView::unsplitAll()
...@@ -706,6 +708,7 @@ void SplitterOrView::unsplitAll() ...@@ -706,6 +708,7 @@ void SplitterOrView::unsplitAll()
else else
m_view->setFocus(); m_view->setFocus();
} }
emit splitStateChanged();
} }
void SplitterOrView::unsplitAll_helper() void SplitterOrView::unsplitAll_helper()
...@@ -769,6 +772,7 @@ void SplitterOrView::unsplit() ...@@ -769,6 +772,7 @@ void SplitterOrView::unsplit()
} }
delete oldSplitter; delete oldSplitter;
EditorManagerPrivate::setCurrentView(findFirstView()); EditorManagerPrivate::setCurrentView(findFirstView());
emit splitStateChanged();
} }
......
...@@ -199,6 +199,9 @@ public: ...@@ -199,6 +199,9 @@ public:
void unsplitAll(); void unsplitAll();
signals:
void splitStateChanged();
private: private:
void unsplitAll_helper(); void unsplitAll_helper();
QStackedLayout *m_layout; QStackedLayout *m_layout;
......
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