forked from qt-creator/qt-creator
QmlDesigner: Move views in ViewManager in a data class
To prevent the export of all the view and to reduce compile times we move the views in the ViewManager in a data class. Change-Id: Ib568101433268abc1aedd502e5877d2f07076fa5 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
|
||||
#include <QTime>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <variantproperty.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
#include <viewmanager.h>
|
||||
#include <nodeinstanceview.h>
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
@@ -32,27 +32,21 @@
|
||||
|
||||
#include "abstractview.h"
|
||||
|
||||
#include <rewriterview.h>
|
||||
#include <nodeinstanceview.h>
|
||||
#include <itemlibraryview.h>
|
||||
#include <navigatorview.h>
|
||||
#include <stateseditorview.h>
|
||||
#include <formeditorview.h>
|
||||
#include <propertyeditorview.h>
|
||||
#include <componentview.h>
|
||||
#include <debugview.h>
|
||||
#include <importmanagerview.h>
|
||||
#include <designeractionmanagerview.h>
|
||||
#include <QWidgetAction>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class DesignDocument;
|
||||
class AbstractCustomTool;
|
||||
class DesignerActionManager;
|
||||
class NodeInstanceView;
|
||||
|
||||
namespace Internal {
|
||||
class DesignModeWidget;
|
||||
}
|
||||
|
||||
class ViewManagerData;
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT ViewManager
|
||||
{
|
||||
public:
|
||||
@@ -111,18 +105,7 @@ private: // functions
|
||||
void switchStateEditorViewToSavedState();
|
||||
|
||||
private: // variables
|
||||
QmlModelState m_savedState;
|
||||
Internal::DebugView m_debugView;
|
||||
ComponentView m_componentView;
|
||||
FormEditorView m_formEditorView;
|
||||
ItemLibraryView m_itemLibraryView;
|
||||
NavigatorView m_navigatorView;
|
||||
PropertyEditorView m_propertyEditorView;
|
||||
StatesEditorView m_statesEditorView;
|
||||
NodeInstanceView m_nodeInstanceView;
|
||||
DesignerActionManagerView m_designerActionManagerView;
|
||||
|
||||
QList<QWeakPointer<AbstractView> > m_additionalViews;
|
||||
ViewManagerData *d;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
#include "viewmanager.h"
|
||||
|
||||
#include <rewriterview.h>
|
||||
#include <nodeinstanceview.h>
|
||||
#include <itemlibraryview.h>
|
||||
#include <navigatorview.h>
|
||||
#include <stateseditorview.h>
|
||||
#include <formeditorview.h>
|
||||
#include <propertyeditorview.h>
|
||||
#include <componentview.h>
|
||||
#include <debugview.h>
|
||||
#include <importmanagerview.h>
|
||||
#include <designeractionmanagerview.h>
|
||||
|
||||
#include "componentaction.h"
|
||||
#include "designmodewidget.h"
|
||||
#include "crumblebar.h"
|
||||
@@ -11,19 +23,39 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ViewManagerData
|
||||
{
|
||||
public:
|
||||
QmlModelState savedState;
|
||||
Internal::DebugView debugView;
|
||||
ComponentView componentView;
|
||||
FormEditorView formEditorView;
|
||||
ItemLibraryView itemLibraryView;
|
||||
NavigatorView navigatorView;
|
||||
PropertyEditorView propertyEditorView;
|
||||
StatesEditorView statesEditorView;
|
||||
NodeInstanceView nodeInstanceView;
|
||||
DesignerActionManagerView designerActionManagerView;
|
||||
|
||||
QList<QWeakPointer<AbstractView> > additionalViews;
|
||||
};
|
||||
|
||||
|
||||
static CrumbleBar *crumbleBar() {
|
||||
return QmlDesignerPlugin::instance()->mainWidget()->crumbleBar();
|
||||
}
|
||||
|
||||
ViewManager::ViewManager()
|
||||
: d(new ViewManagerData)
|
||||
{
|
||||
}
|
||||
|
||||
ViewManager::~ViewManager()
|
||||
{
|
||||
foreach (const QWeakPointer<AbstractView> &view, m_additionalViews)
|
||||
foreach (const QWeakPointer<AbstractView> &view, d->additionalViews)
|
||||
delete view.data();
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
DesignDocument *ViewManager::currentDesignDocument() const
|
||||
@@ -45,7 +77,7 @@ QString ViewManager::pathToQt() const
|
||||
void ViewManager::attachNodeInstanceView()
|
||||
{
|
||||
setNodeInstanceViewQtPath(pathToQt());
|
||||
currentModel()->setNodeInstanceView(&m_nodeInstanceView);
|
||||
currentModel()->setNodeInstanceView(&d->nodeInstanceView);
|
||||
}
|
||||
|
||||
void ViewManager::attachRewriterView()
|
||||
@@ -66,46 +98,46 @@ void ViewManager::detachRewriterView()
|
||||
|
||||
void ViewManager::switchStateEditorViewToBaseState()
|
||||
{
|
||||
if (m_statesEditorView.isAttached()) {
|
||||
m_savedState = m_statesEditorView.currentState();
|
||||
m_statesEditorView.setCurrentState(m_statesEditorView.baseState());
|
||||
if (d->statesEditorView.isAttached()) {
|
||||
d->savedState = d->statesEditorView.currentState();
|
||||
d->statesEditorView.setCurrentState(d->statesEditorView.baseState());
|
||||
}
|
||||
}
|
||||
|
||||
void ViewManager::switchStateEditorViewToSavedState()
|
||||
{
|
||||
if (m_savedState.isValid() && m_statesEditorView.isAttached())
|
||||
m_statesEditorView.setCurrentState(m_savedState);
|
||||
if (d->savedState.isValid() && d->statesEditorView.isAttached())
|
||||
d->statesEditorView.setCurrentState(d->savedState);
|
||||
}
|
||||
|
||||
void ViewManager::resetPropertyEditorView()
|
||||
{
|
||||
m_propertyEditorView.resetView();
|
||||
d->propertyEditorView.resetView();
|
||||
}
|
||||
|
||||
void ViewManager::registerFormEditorToolTakingOwnership(AbstractCustomTool *tool)
|
||||
{
|
||||
m_formEditorView.registerTool(tool);
|
||||
d->formEditorView.registerTool(tool);
|
||||
}
|
||||
|
||||
void ViewManager::registerViewTakingOwnership(AbstractView *view)
|
||||
{
|
||||
m_additionalViews.append(view);
|
||||
d->additionalViews.append(view);
|
||||
}
|
||||
|
||||
void ViewManager::detachViewsExceptRewriterAndComponetView()
|
||||
{
|
||||
switchStateEditorViewToBaseState();
|
||||
detachAdditionalViews();
|
||||
currentModel()->detachView(&m_designerActionManagerView);
|
||||
currentModel()->detachView(&m_formEditorView);
|
||||
currentModel()->detachView(&m_navigatorView);
|
||||
currentModel()->detachView(&m_itemLibraryView);
|
||||
currentModel()->detachView(&m_statesEditorView);
|
||||
currentModel()->detachView(&m_propertyEditorView);
|
||||
currentModel()->detachView(&d->designerActionManagerView);
|
||||
currentModel()->detachView(&d->formEditorView);
|
||||
currentModel()->detachView(&d->navigatorView);
|
||||
currentModel()->detachView(&d->itemLibraryView);
|
||||
currentModel()->detachView(&d->statesEditorView);
|
||||
currentModel()->detachView(&d->propertyEditorView);
|
||||
|
||||
if (m_debugView.isAttached())
|
||||
currentModel()->detachView(&m_debugView);
|
||||
if (d->debugView.isAttached())
|
||||
currentModel()->detachView(&d->debugView);
|
||||
|
||||
currentModel()->setNodeInstanceView(0);
|
||||
}
|
||||
@@ -113,70 +145,70 @@ void ViewManager::detachViewsExceptRewriterAndComponetView()
|
||||
void ViewManager::attachItemLibraryView()
|
||||
{
|
||||
setItemLibraryViewResourcePath(QFileInfo(currentDesignDocument()->fileName()).absolutePath());
|
||||
currentModel()->attachView(&m_itemLibraryView);
|
||||
currentModel()->attachView(&d->itemLibraryView);
|
||||
}
|
||||
|
||||
void ViewManager::attachAdditionalViews()
|
||||
{
|
||||
foreach (const QWeakPointer<AbstractView> &view, m_additionalViews)
|
||||
foreach (const QWeakPointer<AbstractView> &view, d->additionalViews)
|
||||
currentModel()->attachView(view.data());
|
||||
}
|
||||
|
||||
void ViewManager::detachAdditionalViews()
|
||||
{
|
||||
foreach (const QWeakPointer<AbstractView> &view, m_additionalViews)
|
||||
foreach (const QWeakPointer<AbstractView> &view, d->additionalViews)
|
||||
currentModel()->detachView(view.data());
|
||||
}
|
||||
|
||||
void ViewManager::attachComponentView()
|
||||
{
|
||||
documentModel()->attachView(&m_componentView);
|
||||
QObject::connect(m_componentView.action(), SIGNAL(currentComponentChanged(ModelNode)), currentDesignDocument(), SLOT(changeToSubComponent(ModelNode)));
|
||||
QObject::connect(m_componentView.action(), SIGNAL(changedToMaster()), currentDesignDocument(), SLOT(changeToMaster()));
|
||||
documentModel()->attachView(&d->componentView);
|
||||
QObject::connect(d->componentView.action(), SIGNAL(currentComponentChanged(ModelNode)), currentDesignDocument(), SLOT(changeToSubComponent(ModelNode)));
|
||||
QObject::connect(d->componentView.action(), SIGNAL(changedToMaster()), currentDesignDocument(), SLOT(changeToMaster()));
|
||||
}
|
||||
|
||||
void ViewManager::detachComponentView()
|
||||
{
|
||||
QObject::disconnect(m_componentView.action(), SIGNAL(currentComponentChanged(ModelNode)), currentDesignDocument(), SLOT(changeToSubComponent(ModelNode)));
|
||||
QObject::disconnect(m_componentView.action(), SIGNAL(changedToMaster()), currentDesignDocument(), SLOT(changeToMaster()));
|
||||
QObject::disconnect(d->componentView.action(), SIGNAL(currentComponentChanged(ModelNode)), currentDesignDocument(), SLOT(changeToSubComponent(ModelNode)));
|
||||
QObject::disconnect(d->componentView.action(), SIGNAL(changedToMaster()), currentDesignDocument(), SLOT(changeToMaster()));
|
||||
|
||||
documentModel()->detachView(&m_componentView);
|
||||
documentModel()->detachView(&d->componentView);
|
||||
}
|
||||
|
||||
void ViewManager::attachViewsExceptRewriterAndComponetView()
|
||||
{
|
||||
if (QmlDesignerPlugin::instance()->settings().enableDebugView)
|
||||
currentModel()->attachView(&m_debugView);
|
||||
currentModel()->attachView(&d->debugView);
|
||||
|
||||
attachNodeInstanceView();
|
||||
currentModel()->attachView(&m_formEditorView);
|
||||
currentModel()->attachView(&m_navigatorView);
|
||||
currentModel()->attachView(&d->formEditorView);
|
||||
currentModel()->attachView(&d->navigatorView);
|
||||
attachItemLibraryView();
|
||||
currentModel()->attachView(&m_statesEditorView);
|
||||
currentModel()->attachView(&m_propertyEditorView);
|
||||
currentModel()->attachView(&m_designerActionManagerView);
|
||||
currentModel()->attachView(&d->statesEditorView);
|
||||
currentModel()->attachView(&d->propertyEditorView);
|
||||
currentModel()->attachView(&d->designerActionManagerView);
|
||||
attachAdditionalViews();
|
||||
switchStateEditorViewToSavedState();
|
||||
}
|
||||
|
||||
void ViewManager::setItemLibraryViewResourcePath(const QString &resourcePath)
|
||||
{
|
||||
m_itemLibraryView.setResourcePath(resourcePath);
|
||||
d->itemLibraryView.setResourcePath(resourcePath);
|
||||
}
|
||||
|
||||
void ViewManager::setComponentNode(const ModelNode &componentNode)
|
||||
{
|
||||
m_componentView.setComponentNode(componentNode);
|
||||
d->componentView.setComponentNode(componentNode);
|
||||
}
|
||||
|
||||
void ViewManager::setComponentViewToMaster()
|
||||
{
|
||||
m_componentView.setComponentToMaster();
|
||||
d->componentView.setComponentToMaster();
|
||||
}
|
||||
|
||||
void ViewManager::setNodeInstanceViewQtPath(const QString &qtPath)
|
||||
{
|
||||
m_nodeInstanceView.setPathToQt(qtPath);
|
||||
d->nodeInstanceView.setPathToQt(qtPath);
|
||||
}
|
||||
|
||||
static bool widgetInfoLessThan(const WidgetInfo &firstWidgetInfo, const WidgetInfo &secondWidgetInfo)
|
||||
@@ -188,15 +220,15 @@ QList<WidgetInfo> ViewManager::widgetInfos()
|
||||
{
|
||||
QList<WidgetInfo> widgetInfoList;
|
||||
|
||||
widgetInfoList.append(m_formEditorView.widgetInfo());
|
||||
widgetInfoList.append(m_itemLibraryView.widgetInfo());
|
||||
widgetInfoList.append(m_navigatorView.widgetInfo());
|
||||
widgetInfoList.append(m_propertyEditorView.widgetInfo());
|
||||
widgetInfoList.append(m_statesEditorView.widgetInfo());
|
||||
if (m_debugView.hasWidget())
|
||||
widgetInfoList.append(m_debugView.widgetInfo());
|
||||
widgetInfoList.append(d->formEditorView.widgetInfo());
|
||||
widgetInfoList.append(d->itemLibraryView.widgetInfo());
|
||||
widgetInfoList.append(d->navigatorView.widgetInfo());
|
||||
widgetInfoList.append(d->propertyEditorView.widgetInfo());
|
||||
widgetInfoList.append(d->statesEditorView.widgetInfo());
|
||||
if (d->debugView.hasWidget())
|
||||
widgetInfoList.append(d->debugView.widgetInfo());
|
||||
|
||||
foreach (const QWeakPointer<AbstractView> &abstractView, m_additionalViews) {
|
||||
foreach (const QWeakPointer<AbstractView> &abstractView, d->additionalViews) {
|
||||
if (abstractView && abstractView->hasWidget())
|
||||
widgetInfoList.append(abstractView->widgetInfo());
|
||||
}
|
||||
@@ -235,22 +267,22 @@ void ViewManager::nextFileIsCalledInternally()
|
||||
|
||||
NodeInstanceView *ViewManager::nodeInstanceView()
|
||||
{
|
||||
return &m_nodeInstanceView;
|
||||
return &d->nodeInstanceView;
|
||||
}
|
||||
|
||||
QWidgetAction *ViewManager::componentViewAction()
|
||||
{
|
||||
return m_componentView.action();
|
||||
return d->componentView.action();
|
||||
}
|
||||
|
||||
DesignerActionManager &ViewManager::designerActionManager()
|
||||
{
|
||||
return m_designerActionManagerView.designerActionManager();
|
||||
return d->designerActionManagerView.designerActionManager();
|
||||
}
|
||||
|
||||
const DesignerActionManager &ViewManager::designerActionManager() const
|
||||
{
|
||||
return m_designerActionManagerView.designerActionManager();
|
||||
return d->designerActionManagerView.designerActionManager();
|
||||
}
|
||||
|
||||
Model *ViewManager::currentModel() const
|
||||
|
||||
Reference in New Issue
Block a user