OSDN Git Service

QmlDesigner: code cleanup
authorThomas Hartmann <Thomas.Hartmann@nokia.com>
Tue, 20 Sep 2011 09:46:37 +0000 (11:46 +0200)
committerThomas Hartmann <Thomas.Hartmann@nokia.com>
Tue, 20 Sep 2011 12:02:25 +0000 (14:02 +0200)
Change-Id: Id2ce92b7b1f6bc190c0ac4899c951b8f3cff9535
Reviewed-on: http://codereview.qt-project.org/5225
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Marco Bubke <marco.bubke@nokia.com>
src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
src/plugins/qmldesigner/components/formeditor/formeditorview.h
src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
src/plugins/qmldesigner/designmodewidget.cpp

index 2cbe18e..d53c3f1 100644 (file)
@@ -40,6 +40,7 @@
 #include "formeditornodeinstanceview.h"
 #include "formeditoritem.h"
 #include "formeditorscene.h"
+#include "toolbox.h"
 #include <rewritertransaction.h>
 #include <modelnode.h>
 #include <itemlibraryinfo.h>
@@ -641,6 +642,14 @@ void FormEditorView::actualStateChanged(const ModelNode &node)
 //    m_currentTool->formEditorItemsChanged(itemList);
 }
 
+Utils::CrumblePath *FormEditorView::crumblePath() const
+{
+    if (widget() && widget()->toolBox()) {
+        return widget()->toolBox()->crumblePath();
+    }
+    return 0;
+}
+
 void FormEditorView::reset()
 {
    QTimer::singleShot(200, this, SLOT(delayedReset()));
index d6676c8..8df1e16 100644 (file)
@@ -40,6 +40,10 @@ class QGraphicsScene;
 class QGraphicsSceneMouseEvent;
 QT_END_NAMESPACE
 
+namespace Utils {
+class CrumblePath;
+}
+
 namespace QmlDesigner {
 
 class FormEditorWidget;
@@ -118,6 +122,8 @@ public:
 
     void actualStateChanged(const ModelNode &node);
 
+    Utils::CrumblePath *crumblePath() const;
+
 protected:
     void reset();
 
index ae11f4b..f5d2690 100644 (file)
@@ -330,8 +330,8 @@ void DesignDocumentController::setCrumbleBarInfo(const CrumbleBarInfo &crumbleBa
 {
     DesignDocumentControllerPrivate::clearCrumblePath = false;
     DesignDocumentControllerPrivate::pushCrumblePath = false;
-    while (!compareCrumbleBarInfo(d->formEditorView->widget()->toolBox()->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>(), crumbleBarInfo))
-        d->formEditorView->widget()->toolBox()->crumblePath()->popElement();
+    while (!compareCrumbleBarInfo(d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>(), crumbleBarInfo))
+        d->formEditorView->crumblePath()->popElement();
     Core::EditorManager::instance()->openEditor(crumbleBarInfo.fileName);
     DesignDocumentControllerPrivate::pushCrumblePath = true;
     Internal::DesignModeWidget::instance()->currentDesignDocumentController()->changeToSubComponent(crumbleBarInfo.modelNode);
@@ -448,10 +448,10 @@ void DesignDocumentController::changeCurrentModelTo(const ModelNode &node)
     if (Internal::DesignModeWidget::instance()->currentDesignDocumentController() != this)
         return;
     DesignDocumentControllerPrivate::clearCrumblePath = false;
-    while (!d->formEditorView->widget()->toolBox()->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>().modelNode.isRootNode())
-        d->formEditorView->widget()->toolBox()->crumblePath()->popElement();
+    while (!d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>().modelNode.isRootNode())
+        d->formEditorView->crumblePath()->popElement();
     if (node.isRootNode())
-        d->formEditorView->widget()->toolBox()->crumblePath()->popElement();
+        d->formEditorView->crumblePath()->popElement();
     changeToSubComponent(node);
     DesignDocumentControllerPrivate::clearCrumblePath = true;
 }
@@ -568,12 +568,12 @@ void DesignDocumentController::loadCurrentModel()
 
 
     if (DesignDocumentControllerPrivate::clearCrumblePath)
-        d->formEditorView->widget()->toolBox()->crumblePath()->clear();
+        d->formEditorView->crumblePath()->clear();
 
     if (DesignDocumentControllerPrivate::pushCrumblePath &&
-            !compareCrumbleBarInfo(d->formEditorView->widget()->toolBox()->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>(),
+            !compareCrumbleBarInfo(d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>(),
                                    createCrumbleBarInfo().value<CrumbleBarInfo>()))
-        d->formEditorView->widget()->toolBox()->crumblePath()->pushElement(simplfiedDisplayName(), createCrumbleBarInfo());
+        d->formEditorView->crumblePath()->pushElement(simplfiedDisplayName(), createCrumbleBarInfo());
 
     d->documentLoaded = true;
     Q_ASSERT(d->masterModel);
index 84dd531..1532a96 100644 (file)
@@ -705,7 +705,7 @@ void DesignModeWidget::setup()
     m_statesEditorView = new StatesEditorView(this);
 
     m_formEditorView = new FormEditorView(this);
-    connect(m_formEditorView->widget()->toolBox()->crumblePath(), SIGNAL(elementClicked(QVariant)), this, SLOT(onCrumblePathElementClicked(QVariant)));
+    connect(m_formEditorView->crumblePath(), SIGNAL(elementClicked(QVariant)), this, SLOT(onCrumblePathElementClicked(QVariant)));
 
     m_componentView = new ComponentView(this);
     m_formEditorView->widget()->toolBox()->addLeftSideAction(m_componentView->action());