forked from qt-creator/qt-creator
QmlDesigner: Rename AbstractDesignerAction to ActionInterface
We are already in the QmlDesigner namespace and the class is a pure abstract interface. Change-Id: Ibabea5f8091fda22a3086ae032af794bc12ebf38 Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
@@ -41,9 +41,9 @@ AbstractActionGroup::AbstractActionGroup(const QString &displayName) :
|
|||||||
m_action = m_menu->menuAction();
|
m_action = m_menu->menuAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractDesignerAction::Type AbstractActionGroup::type() const
|
ActionInterface::Type AbstractActionGroup::type() const
|
||||||
{
|
{
|
||||||
return AbstractDesignerAction::Menu;
|
return ActionInterface::Menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *AbstractActionGroup::action() const
|
QAction *AbstractActionGroup::action() const
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#ifndef MENUDESIGNERACTION_H
|
#ifndef MENUDESIGNERACTION_H
|
||||||
#define MENUDESIGNERACTION_H
|
#define MENUDESIGNERACTION_H
|
||||||
|
|
||||||
#include "abstractdesigneraction.h"
|
#include "actioninterface.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@@ -38,14 +38,14 @@
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class QMLDESIGNERCORE_EXPORT AbstractActionGroup : public AbstractDesignerAction
|
class QMLDESIGNERCORE_EXPORT AbstractActionGroup : public ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractActionGroup(const QString &displayName);
|
AbstractActionGroup(const QString &displayName);
|
||||||
|
|
||||||
virtual bool isVisible(const SelectionContext &m_selectionState) const = 0;
|
virtual bool isVisible(const SelectionContext &m_selectionState) const = 0;
|
||||||
virtual bool isEnabled(const SelectionContext &m_selectionState) const = 0;
|
virtual bool isEnabled(const SelectionContext &m_selectionState) const = 0;
|
||||||
AbstractDesignerAction::Type type() const QTC_OVERRIDE;
|
ActionInterface::Type type() const QTC_OVERRIDE;
|
||||||
QAction *action() const QTC_OVERRIDE;
|
QAction *action() const QTC_OVERRIDE;
|
||||||
QMenu *menu() const;
|
QMenu *menu() const;
|
||||||
SelectionContext selectionContext() const;
|
SelectionContext selectionContext() const;
|
||||||
|
@@ -39,7 +39,7 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class QMLDESIGNERCORE_EXPORT AbstractDesignerAction
|
class QMLDESIGNERCORE_EXPORT ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
LowestPriority = ComponentCoreConstants::priorityLast
|
LowestPriority = ComponentCoreConstants::priorityLast
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~AbstractDesignerAction() {}
|
virtual ~ActionInterface() {}
|
||||||
|
|
||||||
virtual QAction *action() const = 0;
|
virtual QAction *action() const = 0;
|
||||||
virtual QByteArray category() const = 0;
|
virtual QByteArray category() const = 0;
|
@@ -19,6 +19,6 @@ HEADERS += selectioncontext.h
|
|||||||
HEADERS += componentcore_constants.h
|
HEADERS += componentcore_constants.h
|
||||||
HEADERS += designeractionmanager.h
|
HEADERS += designeractionmanager.h
|
||||||
HEADERS += modelnodeoperations.h
|
HEADERS += modelnodeoperations.h
|
||||||
HEADERS += abstractdesigneraction.h
|
HEADERS += actioninterface.h
|
||||||
HEADERS += crumblebar.h
|
HEADERS += crumblebar.h
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#ifndef QMLDESIGNER_DEFAULTDESIGNERACTION_H
|
#ifndef QMLDESIGNER_DEFAULTDESIGNERACTION_H
|
||||||
#define QMLDESIGNER_DEFAULTDESIGNERACTION_H
|
#define QMLDESIGNER_DEFAULTDESIGNERACTION_H
|
||||||
|
|
||||||
#include "abstractdesigneraction.h"
|
#include "actioninterface.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
@@ -56,7 +56,7 @@ protected:
|
|||||||
SelectionContext m_selectionContext;
|
SelectionContext m_selectionContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QMLDESIGNERCORE_EXPORT DefaultDesignerAction : public AbstractDesignerAction
|
class QMLDESIGNERCORE_EXPORT DefaultDesignerAction : public ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DefaultDesignerAction(const QString &description = QString());
|
DefaultDesignerAction(const QString &description = QString());
|
||||||
|
@@ -431,16 +431,16 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignerActionManager::addDesignerAction(AbstractDesignerAction *newAction)
|
void DesignerActionManager::addDesignerAction(ActionInterface *newAction)
|
||||||
{
|
{
|
||||||
m_designerActions.append(QSharedPointer<AbstractDesignerAction>(newAction));
|
m_designerActions.append(QSharedPointer<ActionInterface>(newAction));
|
||||||
m_designerActionManagerView->setDesignerActionList(designerActions());
|
m_designerActionManagerView->setDesignerActionList(designerActions());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<AbstractDesignerAction* > DesignerActionManager::designerActions() const
|
QList<ActionInterface* > DesignerActionManager::designerActions() const
|
||||||
{
|
{
|
||||||
QList<AbstractDesignerAction* > list;
|
QList<ActionInterface* > list;
|
||||||
foreach (const QSharedPointer<AbstractDesignerAction> &pointer, m_designerActions) {
|
foreach (const QSharedPointer<ActionInterface> &pointer, m_designerActions) {
|
||||||
list.append(pointer.data());
|
list.append(pointer.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#define DESIGNERACTIONMANAGER_H
|
#define DESIGNERACTIONMANAGER_H
|
||||||
|
|
||||||
#include <qmldesignercorelib_global.h>
|
#include <qmldesignercorelib_global.h>
|
||||||
#include "abstractdesigneraction.h"
|
#include "actioninterface.h"
|
||||||
#include "abstractview.h"
|
#include "abstractview.h"
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -43,14 +43,14 @@ public:
|
|||||||
DesignerActionManager(DesignerActionManagerView *designerActionManagerView);
|
DesignerActionManager(DesignerActionManagerView *designerActionManagerView);
|
||||||
~DesignerActionManager();
|
~DesignerActionManager();
|
||||||
|
|
||||||
void addDesignerAction(AbstractDesignerAction *newAction);
|
void addDesignerAction(ActionInterface *newAction);
|
||||||
QList<AbstractDesignerAction* > designerActions() const;
|
QList<ActionInterface* > designerActions() const;
|
||||||
|
|
||||||
void createDefaultDesignerActions();
|
void createDefaultDesignerActions();
|
||||||
AbstractView *view();
|
AbstractView *view();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QSharedPointer<AbstractDesignerAction> > m_designerActions;
|
QList<QSharedPointer<ActionInterface> > m_designerActions;
|
||||||
DesignerActionManagerView *m_designerActionManagerView;
|
DesignerActionManagerView *m_designerActionManagerView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#include "designeractionmanagerview.h"
|
#include "designeractionmanagerview.h"
|
||||||
|
|
||||||
#include <selectioncontext.h>
|
#include <selectioncontext.h>
|
||||||
#include <abstractdesigneraction.h>
|
#include <actioninterface.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ void DesignerActionManagerView::importsChanged(const QList<Import> &, const QLis
|
|||||||
void DesignerActionManagerView::scriptFunctionsChanged(const ModelNode &, const QStringList &)
|
void DesignerActionManagerView::scriptFunctionsChanged(const ModelNode &, const QStringList &)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void DesignerActionManagerView::setDesignerActionList(const QList<AbstractDesignerAction *> &designerActionList)
|
void DesignerActionManagerView::setDesignerActionList(const QList<ActionInterface *> &designerActionList)
|
||||||
{
|
{
|
||||||
m_designerActionList = designerActionList;
|
m_designerActionList = designerActionList;
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ void DesignerActionManagerView::setupContext()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SelectionContext selectionContext(this);
|
SelectionContext selectionContext(this);
|
||||||
foreach (AbstractDesignerAction* action, m_designerActionList) {
|
foreach (ActionInterface* action, m_designerActionList) {
|
||||||
action->currentContextChanged(selectionContext);
|
action->currentContextChanged(selectionContext);
|
||||||
}
|
}
|
||||||
m_setupContextDirty = false;
|
m_setupContextDirty = false;
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class AbstractDesignerAction;
|
class ActionInterface;
|
||||||
|
|
||||||
class DesignerActionManagerView : public AbstractView
|
class DesignerActionManagerView : public AbstractView
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
void nodeOrderChanged(const NodeListProperty &, const ModelNode &, int );
|
void nodeOrderChanged(const NodeListProperty &, const ModelNode &, int );
|
||||||
void importsChanged(const QList<Import> &, const QList<Import> &);
|
void importsChanged(const QList<Import> &, const QList<Import> &);
|
||||||
void scriptFunctionsChanged(const ModelNode &, const QStringList &);
|
void scriptFunctionsChanged(const ModelNode &, const QStringList &);
|
||||||
void setDesignerActionList(const QList<AbstractDesignerAction* > &designerActionList);
|
void setDesignerActionList(const QList<ActionInterface* > &designerActionList);
|
||||||
void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/);
|
void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/);
|
||||||
|
|
||||||
DesignerActionManager &designerActionManager();
|
DesignerActionManager &designerActionManager();
|
||||||
@@ -89,7 +89,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DesignerActionManager m_designerActionManager;
|
DesignerActionManager m_designerActionManager;
|
||||||
QList<AbstractDesignerAction* > m_designerActionList;
|
QList<ActionInterface* > m_designerActionList;
|
||||||
bool m_isInRewriterTransaction;
|
bool m_isInRewriterTransaction;
|
||||||
bool m_setupContextDirty;
|
bool m_setupContextDirty;
|
||||||
};
|
};
|
||||||
|
@@ -45,12 +45,12 @@ ModelNodeContextMenu::ModelNodeContextMenu(AbstractView *view) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static QSet<AbstractDesignerAction* > findMembers(QSet<AbstractDesignerAction* > designerActionSet,
|
static QSet<ActionInterface* > findMembers(QSet<ActionInterface* > actionInterface,
|
||||||
const QString &category)
|
const QString &category)
|
||||||
{
|
{
|
||||||
QSet<AbstractDesignerAction* > ret;
|
QSet<ActionInterface* > ret;
|
||||||
|
|
||||||
foreach (AbstractDesignerAction* factory, designerActionSet) {
|
foreach (ActionInterface* factory, actionInterface) {
|
||||||
if (factory->category() == category)
|
if (factory->category() == category)
|
||||||
ret.insert(factory);
|
ret.insert(factory);
|
||||||
}
|
}
|
||||||
@@ -58,32 +58,32 @@ static QSet<AbstractDesignerAction* > findMembers(QSet<AbstractDesignerAction* >
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void populateMenu(QSet<AbstractDesignerAction* > &abstractDesignerActions,
|
void populateMenu(QSet<ActionInterface* > &actionInterfaces,
|
||||||
const QString &category,
|
const QString &category,
|
||||||
QMenu* menu,
|
QMenu* menu,
|
||||||
const SelectionContext &selectionContext)
|
const SelectionContext &selectionContext)
|
||||||
{
|
{
|
||||||
QSet<AbstractDesignerAction* > matchingFactories = findMembers(abstractDesignerActions, category);
|
QSet<ActionInterface* > matchingFactories = findMembers(actionInterfaces, category);
|
||||||
|
|
||||||
abstractDesignerActions.subtract(matchingFactories);
|
actionInterfaces.subtract(matchingFactories);
|
||||||
|
|
||||||
QList<AbstractDesignerAction* > matchingFactoriesList = matchingFactories.toList();
|
QList<ActionInterface* > matchingFactoriesList = matchingFactories.toList();
|
||||||
Utils::sort(matchingFactoriesList, [](AbstractDesignerAction *l, AbstractDesignerAction *r) {
|
Utils::sort(matchingFactoriesList, [](ActionInterface *l, ActionInterface *r) {
|
||||||
return l->priority() > r->priority();
|
return l->priority() > r->priority();
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (AbstractDesignerAction* designerAction, matchingFactoriesList) {
|
foreach (ActionInterface* actionInterface, matchingFactoriesList) {
|
||||||
if (designerAction->type() == AbstractDesignerAction::Menu) {
|
if (actionInterface->type() == ActionInterface::Menu) {
|
||||||
designerAction->currentContextChanged(selectionContext);
|
actionInterface->currentContextChanged(selectionContext);
|
||||||
QMenu *newMenu = designerAction->action()->menu();
|
QMenu *newMenu = actionInterface->action()->menu();
|
||||||
menu->addMenu(newMenu);
|
menu->addMenu(newMenu);
|
||||||
|
|
||||||
//recurse
|
//recurse
|
||||||
|
|
||||||
populateMenu(abstractDesignerActions, designerAction->menuId(), newMenu, selectionContext);
|
populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext);
|
||||||
} else if (designerAction->type() == AbstractDesignerAction::Action) {
|
} else if (actionInterface->type() == ActionInterface::Action) {
|
||||||
QAction* action = designerAction->action();
|
QAction* action = actionInterface->action();
|
||||||
designerAction->currentContextChanged(selectionContext);
|
actionInterface->currentContextChanged(selectionContext);
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,8 +97,8 @@ void ModelNodeContextMenu::execute(const QPoint &position, bool selectionMenuBoo
|
|||||||
m_selectionContext.setScenePosition(m_scenePos);
|
m_selectionContext.setScenePosition(m_scenePos);
|
||||||
|
|
||||||
|
|
||||||
QSet<AbstractDesignerAction* > factories =
|
QSet<ActionInterface* > factories =
|
||||||
QSet<AbstractDesignerAction* >::fromList(QmlDesignerPlugin::instance()->designerActionManager().designerActions());
|
QSet<ActionInterface* >::fromList(QmlDesignerPlugin::instance()->designerActionManager().designerActions());
|
||||||
|
|
||||||
populateMenu(factories, QString(""), mainMenu, m_selectionContext);
|
populateMenu(factories, QString(""), mainMenu, m_selectionContext);
|
||||||
|
|
||||||
|
@@ -133,7 +133,7 @@ public:
|
|||||||
QByteArray category() const { return QByteArray(); }
|
QByteArray category() const { return QByteArray(); }
|
||||||
QByteArray menuId() const { return m_menuId; }
|
QByteArray menuId() const { return m_menuId; }
|
||||||
int priority() const { return m_priority; }
|
int priority() const { return m_priority; }
|
||||||
AbstractDesignerAction::Type type() const { return AbstractDesignerAction::Menu; }
|
Type type() const { return Menu; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QByteArray m_menuId;
|
const QByteArray m_menuId;
|
||||||
|
@@ -77,7 +77,7 @@ int AddTabDesignerAction::priority() const
|
|||||||
return CustomActionsPriority;
|
return CustomActionsPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractDesignerAction::Type AddTabDesignerAction::type() const
|
ActionInterface::Type AddTabDesignerAction::type() const
|
||||||
{
|
{
|
||||||
return Action;
|
return Action;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user