From c44f09caeb9df5ed4d02248ecbc9c1b5ce767c37 Mon Sep 17 00:00:00 2001
From: hjk <hjk121@nokiamail.com>
Date: Fri, 1 Aug 2014 17:54:26 +0200
Subject: [PATCH] GLSL: Move toolbar creation to Widget constructor

It doesn't need the editor parameter anymore, so the two-phase
setup can go. Note that both paths through ctor() finally hit
*Widget::createEditor() (one directly, one indirectly through
the first BaseTextEditorWidget::editor() call), so this doesn't
change what's set up, only when.

Change-Id: If92a7e2a60ea3df417ecdeabc6f8e9dc3a23e4f8
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
---
 src/plugins/glsleditor/glsleditor.cpp | 49 ++++++++++++---------------
 src/plugins/glsleditor/glsleditor.h   |  1 -
 2 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index fdffd25d798..844adcfb021 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -168,6 +168,27 @@ void GlslEditorWidget::ctor()
 
     new Highlighter(textDocument());
 
+    m_outlineCombo = new QComboBox;
+    m_outlineCombo->setMinimumContentsLength(22);
+
+    // ### m_outlineCombo->setModel(m_outlineModel);
+
+    QTreeView *treeView = new QTreeView;
+    treeView->header()->hide();
+    treeView->setItemsExpandable(false);
+    treeView->setRootIsDecorated(false);
+    m_outlineCombo->setView(treeView);
+    treeView->expandAll();
+
+    //m_outlineCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
+
+    // Make the combo box prefer to expand
+    QSizePolicy policy = m_outlineCombo->sizePolicy();
+    policy.setHorizontalPolicy(QSizePolicy::Expanding);
+    m_outlineCombo->setSizePolicy(policy);
+
+    insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, m_outlineCombo);
+
 //    if (m_modelManager) {
 //        m_semanticHighlighter->setModelManager(m_modelManager);
 //        connect(m_modelManager, SIGNAL(documentUpdated(GLSL::Document::Ptr)),
@@ -222,33 +243,7 @@ QString GlslEditorWidget::wordUnderCursor() const
 
 TextEditor::BaseTextEditor *GlslEditorWidget::createEditor()
 {
-    GlslEditor *editable = new GlslEditor(this);
-    createToolBar(editable);
-    return editable;
-}
-
-void GlslEditorWidget::createToolBar(GlslEditor *editor)
-{
-    m_outlineCombo = new QComboBox;
-    m_outlineCombo->setMinimumContentsLength(22);
-
-    // ### m_outlineCombo->setModel(m_outlineModel);
-
-    QTreeView *treeView = new QTreeView;
-    treeView->header()->hide();
-    treeView->setItemsExpandable(false);
-    treeView->setRootIsDecorated(false);
-    m_outlineCombo->setView(treeView);
-    treeView->expandAll();
-
-    //m_outlineCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
-
-    // Make the combo box prefer to expand
-    QSizePolicy policy = m_outlineCombo->sizePolicy();
-    policy.setHorizontalPolicy(QSizePolicy::Expanding);
-    m_outlineCombo->setSizePolicy(policy);
-
-    insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, m_outlineCombo);
+    return new GlslEditor(this);
 }
 
 void GlslEditorWidget::updateDocument()
diff --git a/src/plugins/glsleditor/glsleditor.h b/src/plugins/glsleditor/glsleditor.h
index 39f185a7549..380a7be537f 100644
--- a/src/plugins/glsleditor/glsleditor.h
+++ b/src/plugins/glsleditor/glsleditor.h
@@ -105,7 +105,6 @@ private slots:
 
 protected:
     TextEditor::BaseTextEditor *createEditor();
-    void createToolBar(Internal::GlslEditor *editable);
 
 private:
     GlslEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
-- 
GitLab