Commit 9d43e11b authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

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: default avatarMarco Bubke <marco.bubke@digia.com>
parent f36a1b48
......@@ -41,9 +41,9 @@ AbstractActionGroup::AbstractActionGroup(const QString &displayName) :
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
......
......@@ -30,7 +30,7 @@
#ifndef MENUDESIGNERACTION_H
#define MENUDESIGNERACTION_H
#include "abstractdesigneraction.h"
#include "actioninterface.h"
#include <QAction>
#include <QMenu>
......@@ -38,14 +38,14 @@
namespace QmlDesigner {
class QMLDESIGNERCORE_EXPORT AbstractActionGroup : public AbstractDesignerAction
class QMLDESIGNERCORE_EXPORT AbstractActionGroup : public ActionInterface
{
public:
AbstractActionGroup(const QString &displayName);
virtual bool isVisible(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;
QMenu *menu() const;
SelectionContext selectionContext() const;
......
......@@ -39,7 +39,7 @@ QT_END_NAMESPACE
namespace QmlDesigner {
class QMLDESIGNERCORE_EXPORT AbstractDesignerAction
class QMLDESIGNERCORE_EXPORT ActionInterface
{
public:
enum Type {
......@@ -54,7 +54,7 @@ public:
LowestPriority = ComponentCoreConstants::priorityLast
};
virtual ~AbstractDesignerAction() {}
virtual ~ActionInterface() {}
virtual QAction *action() const = 0;
virtual QByteArray category() const = 0;
......
......@@ -19,6 +19,6 @@ HEADERS += selectioncontext.h
HEADERS += componentcore_constants.h
HEADERS += designeractionmanager.h
HEADERS += modelnodeoperations.h
HEADERS += abstractdesigneraction.h
HEADERS += actioninterface.h
HEADERS += crumblebar.h
......@@ -31,7 +31,7 @@
#ifndef QMLDESIGNER_DEFAULTDESIGNERACTION_H
#define QMLDESIGNER_DEFAULTDESIGNERACTION_H
#include "abstractdesigneraction.h"
#include "actioninterface.h"
#include <QAction>
#include <QScopedPointer>
......@@ -56,7 +56,7 @@ protected:
SelectionContext m_selectionContext;
};
class QMLDESIGNERCORE_EXPORT DefaultDesignerAction : public AbstractDesignerAction
class QMLDESIGNERCORE_EXPORT DefaultDesignerAction : public ActionInterface
{
public:
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());
}
QList<AbstractDesignerAction* > DesignerActionManager::designerActions() const
QList<ActionInterface* > DesignerActionManager::designerActions() const
{
QList<AbstractDesignerAction* > list;
foreach (const QSharedPointer<AbstractDesignerAction> &pointer, m_designerActions) {
QList<ActionInterface* > list;
foreach (const QSharedPointer<ActionInterface> &pointer, m_designerActions) {
list.append(pointer.data());
}
......
......@@ -31,7 +31,7 @@
#define DESIGNERACTIONMANAGER_H
#include <qmldesignercorelib_global.h>
#include "abstractdesigneraction.h"
#include "actioninterface.h"
#include "abstractview.h"
namespace QmlDesigner {
......@@ -43,14 +43,14 @@ public:
DesignerActionManager(DesignerActionManagerView *designerActionManagerView);
~DesignerActionManager();
void addDesignerAction(AbstractDesignerAction *newAction);
QList<AbstractDesignerAction* > designerActions() const;
void addDesignerAction(ActionInterface *newAction);
QList<ActionInterface* > designerActions() const;
void createDefaultDesignerActions();
AbstractView *view();
private:
QList<QSharedPointer<AbstractDesignerAction> > m_designerActions;
QList<QSharedPointer<ActionInterface> > m_designerActions;
DesignerActionManagerView *m_designerActionManagerView;
};
......
......@@ -30,7 +30,7 @@
#include "designeractionmanagerview.h"
#include <selectioncontext.h>
#include <abstractdesigneraction.h>
#include <actioninterface.h>
namespace QmlDesigner {
......@@ -160,7 +160,7 @@ void DesignerActionManagerView::importsChanged(const QList<Import> &, const QLis
void DesignerActionManagerView::scriptFunctionsChanged(const ModelNode &, const QStringList &)
{}
void DesignerActionManagerView::setDesignerActionList(const QList<AbstractDesignerAction *> &designerActionList)
void DesignerActionManagerView::setDesignerActionList(const QList<ActionInterface *> &designerActionList)
{
m_designerActionList = designerActionList;
}
......@@ -187,7 +187,7 @@ void DesignerActionManagerView::setupContext()
return;
}
SelectionContext selectionContext(this);
foreach (AbstractDesignerAction* action, m_designerActionList) {
foreach (ActionInterface* action, m_designerActionList) {
action->currentContextChanged(selectionContext);
}
m_setupContextDirty = false;
......
......@@ -36,7 +36,7 @@
namespace QmlDesigner {
class AbstractDesignerAction;
class ActionInterface;
class DesignerActionManagerView : public AbstractView
{
......@@ -78,7 +78,7 @@ public:
void nodeOrderChanged(const NodeListProperty &, const ModelNode &, int );
void importsChanged(const QList<Import> &, const QList<Import> &);
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*/);
DesignerActionManager &designerActionManager();
......@@ -89,7 +89,7 @@ protected:
private:
DesignerActionManager m_designerActionManager;
QList<AbstractDesignerAction* > m_designerActionList;
QList<ActionInterface* > m_designerActionList;
bool m_isInRewriterTransaction;
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)
{
QSet<AbstractDesignerAction* > ret;
QSet<ActionInterface* > ret;
foreach (AbstractDesignerAction* factory, designerActionSet) {
foreach (ActionInterface* factory, actionInterface) {
if (factory->category() == category)
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,
QMenu* menu,
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();
Utils::sort(matchingFactoriesList, [](AbstractDesignerAction *l, AbstractDesignerAction *r) {
QList<ActionInterface* > matchingFactoriesList = matchingFactories.toList();
Utils::sort(matchingFactoriesList, [](ActionInterface *l, ActionInterface *r) {
return l->priority() > r->priority();
});
foreach (AbstractDesignerAction* designerAction, matchingFactoriesList) {
if (designerAction->type() == AbstractDesignerAction::Menu) {
designerAction->currentContextChanged(selectionContext);
QMenu *newMenu = designerAction->action()->menu();
foreach (ActionInterface* actionInterface, matchingFactoriesList) {
if (actionInterface->type() == ActionInterface::Menu) {
actionInterface->currentContextChanged(selectionContext);
QMenu *newMenu = actionInterface->action()->menu();
menu->addMenu(newMenu);
//recurse
populateMenu(abstractDesignerActions, designerAction->menuId(), newMenu, selectionContext);
} else if (designerAction->type() == AbstractDesignerAction::Action) {
QAction* action = designerAction->action();
designerAction->currentContextChanged(selectionContext);
populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext);
} else if (actionInterface->type() == ActionInterface::Action) {
QAction* action = actionInterface->action();
actionInterface->currentContextChanged(selectionContext);
menu->addAction(action);
}
}
......@@ -97,8 +97,8 @@ void ModelNodeContextMenu::execute(const QPoint &position, bool selectionMenuBoo
m_selectionContext.setScenePosition(m_scenePos);
QSet<AbstractDesignerAction* > factories =
QSet<AbstractDesignerAction* >::fromList(QmlDesignerPlugin::instance()->designerActionManager().designerActions());
QSet<ActionInterface* > factories =
QSet<ActionInterface* >::fromList(QmlDesignerPlugin::instance()->designerActionManager().designerActions());
populateMenu(factories, QString(""), mainMenu, m_selectionContext);
......
......@@ -133,7 +133,7 @@ public:
QByteArray category() const { return QByteArray(); }
QByteArray menuId() const { return m_menuId; }
int priority() const { return m_priority; }
AbstractDesignerAction::Type type() const { return AbstractDesignerAction::Menu; }
Type type() const { return Menu; }
private:
const QByteArray m_menuId;
......
......@@ -77,7 +77,7 @@ int AddTabDesignerAction::priority() const
return CustomActionsPriority;
}
AbstractDesignerAction::Type AddTabDesignerAction::type() const
ActionInterface::Type AddTabDesignerAction::type() const
{
return Action;
}
......
Supports Markdown
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