Commit 8c7a9a51 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Move DesignerActionManagerView in ViewManager



Change-Id: I28d1e1aff0bcb3172494c133bf383582127f28c3
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 7971b6e7
......@@ -48,26 +48,9 @@ static inline bool contains(const QmlItemNode &node, const QPointF &position)
return node.isValid() && node.instanceSceneTransform().mapRect(node.instanceBoundingRect()).contains(position);
}
namespace Internal {
} //Internal
DesignerActionManager *DesignerActionManager::m_instance = 0;
void DesignerActionManager::addDesignerAction(AbstractDesignerAction *newAction)
{
instance()->addDesignerActionInternal(newAction);
}
QList<AbstractDesignerAction* > DesignerActionManager::designerActions()
{
return instance()->factoriesInternal();
}
AbstractView *DesignerActionManager::view()
{
return instance()->m_view;
return m_designerActionManagerView;
}
class VisiblityModelNodeAction : public ModelNodeAction
......@@ -437,23 +420,13 @@ void DesignerActionManager::createDefaultDesignerActions()
(goIntoComponentDisplayName, rootCategory, priorityGoIntoComponent, &goIntoComponent, &selectionIsComponent));
}
DesignerActionManager *DesignerActionManager::instance()
{
if (!m_instance) {
m_instance = new DesignerActionManager;
createDefaultDesignerActions();
}
return m_instance;
}
void DesignerActionManager::addDesignerActionInternal(AbstractDesignerAction *newAction)
void DesignerActionManager::addDesignerAction(AbstractDesignerAction *newAction)
{
m_designerActions.append(QSharedPointer<AbstractDesignerAction>(newAction));
m_view->setDesignerActionList(designerActions());
m_designerActionManagerView->setDesignerActionList(designerActions());
}
QList<AbstractDesignerAction* > DesignerActionManager::factoriesInternal() const
QList<AbstractDesignerAction* > DesignerActionManager::designerActions() const
{
QList<AbstractDesignerAction* > list;
foreach (const QSharedPointer<AbstractDesignerAction> &pointer, m_designerActions) {
......@@ -463,14 +436,13 @@ QList<AbstractDesignerAction* > DesignerActionManager::factoriesInternal() const
return list;
}
DesignerActionManager::DesignerActionManager()
: m_view(new DesignerActionManagerView)
DesignerActionManager::DesignerActionManager(DesignerActionManagerView *designerActionManagerView)
: m_designerActionManagerView(designerActionManagerView)
{
}
DesignerActionManager::~DesignerActionManager()
{
delete m_view;
}
} //QmlDesigner
......@@ -40,23 +40,18 @@ class DesignerActionManagerView;
class QMLDESIGNERCORE_EXPORT DesignerActionManager {
public:
static void addDesignerAction(AbstractDesignerAction *newAction);
static QList<AbstractDesignerAction* > designerActions();
DesignerActionManager(DesignerActionManagerView *designerActionManagerView);
~DesignerActionManager();
static void createDefaultDesignerActions();
static AbstractView *view();
void addDesignerAction(AbstractDesignerAction *newAction);
QList<AbstractDesignerAction* > designerActions() const;
protected:
static DesignerActionManager *instance();
void addDesignerActionInternal(AbstractDesignerAction *newAction);
QList<AbstractDesignerAction* > factoriesInternal() const;
DesignerActionManager();
~DesignerActionManager();
void createDefaultDesignerActions();
AbstractView *view();
private:
static DesignerActionManager *m_instance;
QList<QSharedPointer<AbstractDesignerAction> > m_designerActions;
DesignerActionManagerView *m_view;
DesignerActionManagerView *m_designerActionManagerView;
};
} //QmlDesigner
......
......@@ -36,9 +36,12 @@ namespace QmlDesigner {
DesignerActionManagerView::DesignerActionManagerView()
: AbstractView(0),
m_designerActionManager(this),
m_isInRewriterTransaction(false),
m_setupContextDirty(false)
{}
{
m_designerActionManager.createDefaultDesignerActions();
}
void DesignerActionManagerView::modelAttached(Model *model)
{
......@@ -167,6 +170,16 @@ void DesignerActionManagerView::signalHandlerPropertiesChanged(const QVector<Sig
setupContext();
}
DesignerActionManager &DesignerActionManagerView::designerActionManager()
{
return m_designerActionManager;
}
const DesignerActionManager &DesignerActionManagerView::designerActionManager() const
{
return m_designerActionManager;
}
void DesignerActionManagerView::setupContext()
{
if (m_isInRewriterTransaction) {
......
......@@ -32,6 +32,8 @@
#include <abstractview.h>
#include "designeractionmanager.h"
namespace QmlDesigner {
class AbstractDesignerAction;
......@@ -79,10 +81,14 @@ public:
void setDesignerActionList(const QList<AbstractDesignerAction* > &designerActionList);
void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/);
DesignerActionManager &designerActionManager();
const DesignerActionManager &designerActionManager() const;
protected:
void setupContext();
private:
DesignerActionManager m_designerActionManager;
QList<AbstractDesignerAction* > m_designerActionList;
bool m_isInRewriterTransaction;
bool m_setupContextDirty;
......
......@@ -30,6 +30,7 @@
#include "modelnodecontextmenu.h"
#include "modelnodecontextmenu_helper.h"
#include "designeractionmanager.h"
#include <qmldesignerplugin.h>
#include <modelnode.h>
......@@ -98,7 +99,7 @@ void ModelNodeContextMenu::execute(const QPoint &position, bool selectionMenuBoo
QSet<AbstractDesignerAction* > factories =
QSet<AbstractDesignerAction* >::fromList(DesignerActionManager::designerActions());
QSet<AbstractDesignerAction* >::fromList(QmlDesignerPlugin::instance()->designerActionManager().designerActions());
populateMenu(factories, QString(""), mainMenu, m_selectionContext);
......
......@@ -42,6 +42,7 @@
#include <componentview.h>
#include <debugview.h>
#include <importmanagerview.h>
#include <designeractionmanagerview.h>
#include <QWidgetAction>
namespace QmlDesigner {
......@@ -89,6 +90,9 @@ public:
QWidgetAction *componentViewAction();
DesignerActionManager &designerActionManager();
const DesignerActionManager &designerActionManager() const;
private: // functions
Q_DISABLE_COPY(ViewManager)
......@@ -115,6 +119,7 @@ private: // variables
PropertyEditorView m_propertyEditorView;
StatesEditorView m_statesEditorView;
NodeInstanceView m_nodeInstanceView;
DesignerActionManagerView m_designerActionManagerView;
QList<QWeakPointer<AbstractView> > m_additionalViews;
};
......
#include "viewmanager.h"
#include "componentaction.h"
#include "designeractionmanager.h"
#include "designmodewidget.h"
#include "crumblebar.h"
......@@ -98,7 +97,7 @@ void ViewManager::detachViewsExceptRewriterAndComponetView()
{
switchStateEditorViewToBaseState();
detachAdditionalViews();
currentModel()->detachView(DesignerActionManager::view());
currentModel()->detachView(&m_designerActionManagerView);
currentModel()->detachView(&m_formEditorView);
currentModel()->detachView(&m_navigatorView);
currentModel()->detachView(&m_itemLibraryView);
......@@ -152,7 +151,7 @@ void ViewManager::attachViewsExceptRewriterAndComponetView()
attachItemLibraryView();
currentModel()->attachView(&m_statesEditorView);
currentModel()->attachView(&m_propertyEditorView);
currentModel()->attachView(DesignerActionManager::view());
currentModel()->attachView(&m_designerActionManagerView);
attachAdditionalViews();
switchStateEditorViewToSavedState();
}
......@@ -236,6 +235,16 @@ QWidgetAction *ViewManager::componentViewAction()
return m_componentView.action();
}
DesignerActionManager &ViewManager::designerActionManager()
{
return m_designerActionManagerView.designerActionManager();
}
const DesignerActionManager &ViewManager::designerActionManager() const
{
return m_designerActionManagerView.designerActionManager();
}
Model *ViewManager::currentModel() const
{
return currentDesignDocument()->currentModel();
......
......@@ -419,6 +419,16 @@ const ViewManager &QmlDesignerPlugin::viewManager() const
return m_viewManager;
}
DesignerActionManager &QmlDesignerPlugin::designerActionManager()
{
return m_viewManager.designerActionManager();
}
const DesignerActionManager &QmlDesignerPlugin::designerActionManager() const
{
return m_viewManager.designerActionManager();
}
void QmlDesignerPlugin::switchTextDesign()
{
if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_EDIT) {
......
......@@ -39,6 +39,7 @@
#include "documentmanager.h"
#include "viewmanager.h"
#include "shortcutmanager.h"
#include <designeractionmanager.h>
#include <QStringList>
......@@ -82,6 +83,9 @@ public:
ViewManager &viewManager();
const ViewManager &viewManager() const;
DesignerActionManager &designerActionManager();
const DesignerActionManager &designerActionManager() const;
DesignerSettings settings();
void setSettings(const DesignerSettings &s);
......
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