forked from qt-creator/qt-creator
QmlDesigner: de-templatize
Since the templates add unnecessary complexity, we use function pointers instead. Change-Id: I023b3907ad8826c25d985aba0fed1d5a69265b15 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -224,45 +224,39 @@ QmlModelView *DesignerActionManager::view()
|
|||||||
return instance()->m_view.data();
|
return instance()->m_view.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ACTION,
|
class VisiblityModelNodeAction : public ModelNodeAction
|
||||||
class ENABLED = SelectionContextFunctors::Always,
|
|
||||||
class VISIBILITY = SelectionContextFunctors::Always>
|
|
||||||
class VisiblityModelNodeActionFactory : public ModelNodeActionFactory<ACTION, ENABLED, VISIBILITY>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VisiblityModelNodeActionFactory(const QString &description, const QString &category, int priority) :
|
VisiblityModelNodeAction(const QString &description, const QString &category, int priority,
|
||||||
ModelNodeActionFactory<ACTION, ENABLED, VISIBILITY>(description, category, priority)
|
ModelNodeOperations::SelectionAction action,
|
||||||
|
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
||||||
|
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
||||||
|
ModelNodeAction(description, category, priority, action, enabled, visibility)
|
||||||
{}
|
{}
|
||||||
virtual void updateContext()
|
virtual void updateContext()
|
||||||
{
|
{
|
||||||
this->m_action->setSelectionContext(this->m_selectionContext);
|
m_action->setSelectionContext(m_selectionContext);
|
||||||
if (this->m_selectionContext.isValid()) {
|
if (m_selectionContext.isValid()) {
|
||||||
this->m_action->setEnabled(this->isEnabled(this->m_selectionContext));
|
m_action->setEnabled(isEnabled(m_selectionContext));
|
||||||
this->m_action->setVisible(this->isVisible(this->m_selectionContext));
|
m_action->setVisible(isVisible(m_selectionContext));
|
||||||
|
|
||||||
this->m_action->setCheckable(true);
|
m_action->setCheckable(true);
|
||||||
QmlItemNode itemNode = QmlItemNode(this->m_selectionContext.currentSingleSelectedNode());
|
QmlItemNode itemNode = QmlItemNode(m_selectionContext.currentSingleSelectedNode());
|
||||||
if (itemNode.isValid())
|
if (itemNode.isValid())
|
||||||
this->m_action->setChecked(itemNode.instanceValue("visible").toBool());
|
m_action->setChecked(itemNode.instanceValue("visible").toBool());
|
||||||
else
|
else
|
||||||
this->m_action->setEnabled(false);
|
m_action->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <void (*T)(const SelectionContext &)>
|
class SelectionModelNodeAction : public MenuDesignerAction
|
||||||
struct Functor {
|
|
||||||
void operator() (const SelectionContext &selectionState) { T(selectionState); }
|
|
||||||
};
|
|
||||||
|
|
||||||
class SelectionModelNodeAction : public MenuDesignerAction<SelectionContextFunctors::Always, SelectionContextFunctors::SelectionEnabled>
|
|
||||||
{
|
{
|
||||||
typedef ActionTemplate<Functor<ModelNodeOperations::select> > SelectionAction;
|
|
||||||
typedef QSharedPointer<SelectionAction> SelectionActionPtr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SelectionModelNodeAction(const QString &displayName, const QString &menuId, int priority) :
|
SelectionModelNodeAction(const QString &displayName, const QString &menuId, int priority) :
|
||||||
MenuDesignerAction<SelectionContextFunctors::Always, SelectionContextFunctors::SelectionEnabled>(displayName, menuId, priority)
|
MenuDesignerAction(displayName, menuId, priority,
|
||||||
|
&SelectionContextFunctors::always, &SelectionContextFunctors::selectionEnabled)
|
||||||
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void updateContext()
|
virtual void updateContext()
|
||||||
@@ -277,7 +271,7 @@ public:
|
|||||||
if (m_action->isEnabled()) {
|
if (m_action->isEnabled()) {
|
||||||
ModelNode parentNode;
|
ModelNode parentNode;
|
||||||
if (m_selectionContext.singleSelected() && !m_selectionContext.currentSingleSelectedNode().isRootNode()) {
|
if (m_selectionContext.singleSelected() && !m_selectionContext.currentSingleSelectedNode().isRootNode()) {
|
||||||
SelectionAction* selectionAction = new SelectionAction(QString());
|
ActionTemplate *selectionAction = new ActionTemplate(QString(), &ModelNodeOperations::select);
|
||||||
selectionAction->setParent(m_menu.data());
|
selectionAction->setParent(m_menu.data());
|
||||||
|
|
||||||
parentNode = m_selectionContext.currentSingleSelectedNode().parentProperty().parentModelNode();
|
parentNode = m_selectionContext.currentSingleSelectedNode().parentProperty().parentModelNode();
|
||||||
@@ -294,8 +288,8 @@ public:
|
|||||||
&& contains(node, m_selectionContext.scenePos())
|
&& contains(node, m_selectionContext.scenePos())
|
||||||
&& !node.isRootNode()) {
|
&& !node.isRootNode()) {
|
||||||
m_selectionContext.setTargetNode(node);
|
m_selectionContext.setTargetNode(node);
|
||||||
SelectionAction* selectionAction =
|
QString what = QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select: %1")).arg(captionForModelNode(node));
|
||||||
new SelectionAction(QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select: %1")).arg(captionForModelNode(node)));
|
ActionTemplate *selectionAction = new ActionTemplate(what, &ModelNodeOperations::select);
|
||||||
selectionAction->setSelectionContext(m_selectionContext);
|
selectionAction->setSelectionContext(m_selectionContext);
|
||||||
|
|
||||||
m_menu->addAction(selectionAction);
|
m_menu->addAction(selectionAction);
|
||||||
@@ -311,68 +305,105 @@ char zProperty[] = "z";
|
|||||||
char widthProperty[] = "width";
|
char widthProperty[] = "width";
|
||||||
char heightProperty[] = "height";
|
char heightProperty[] = "height";
|
||||||
|
|
||||||
|
using namespace SelectionContextFunctors;
|
||||||
|
|
||||||
|
bool multiSelection(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return !singleSelection(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool singleSelectionAndInBaseState(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return singleSelection(context) && inBaseState(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool multiSelectionAndInBaseState(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return multiSelection(context) && inBaseState(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool selectionHasProperty1or2(const SelectionContext &context, const char *x, const char *y)
|
||||||
|
{
|
||||||
|
return selectionHasProperty(context, x) || selectionHasProperty(context, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool selectionHasSameParentAndInBaseState(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return selectionHasSameParent(context) && inBaseState(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool selectionCanBeLayouted(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return selectionHasSameParentAndInBaseState(context) && inBaseState(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool selectionNotEmptyAndHasZProperty(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return selectionNotEmpty(context) && selectionHasProperty(context, zProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool selectionNotEmptyAndHasWidthOrHeightProperty(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return selectionNotEmpty(context)
|
||||||
|
&& selectionHasProperty1or2(context, widthProperty, heightProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool selectionNotEmptyAndHasXorYProperty(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return selectionNotEmpty(context)
|
||||||
|
&& selectionHasProperty1or2(context, xProperty, yProperty);
|
||||||
|
}
|
||||||
|
|
||||||
void DesignerActionManager::createDefaultDesignerActions()
|
void DesignerActionManager::createDefaultDesignerActions()
|
||||||
{
|
{
|
||||||
typedef Functor<ModelNodeOperations::resetPosition> resetPositionFunctor;
|
|
||||||
|
|
||||||
using namespace SelectionContextFunctors;
|
using namespace SelectionContextFunctors;
|
||||||
using namespace ComponentCoreConstants;
|
using namespace ComponentCoreConstants;
|
||||||
|
using namespace ModelNodeOperations;
|
||||||
typedef Not<SingleSelection> MultiSelection;
|
|
||||||
typedef And<SingleSelection, InBaseState> SingleSelection_And_InBaseState;
|
|
||||||
typedef And<MultiSelection, InBaseState> MultiSelection_And_InBaseState;
|
|
||||||
typedef Or<SelectionHasProperty<xProperty>, SelectionHasProperty<yProperty> >
|
|
||||||
SelectionHasPropertyX_Or_SelectionHasPropertyY;
|
|
||||||
typedef Or<SelectionHasProperty<widthProperty>, SelectionHasProperty<heightProperty> >
|
|
||||||
SelectionHasPropertyWidth_Or_SelectionHasPropertyHeight;
|
|
||||||
typedef And<SelectionHasSameParent, InBaseState> SelectionHasSameParent_And_InBaseState;
|
|
||||||
typedef And<SelectionHasSameParent_And_InBaseState, MultiSelection> SelectionCanBeLayouted;
|
|
||||||
|
|
||||||
addDesignerAction(new SelectionModelNodeAction(selectionCategoryDisplayName, selectionCategory, prioritySelectionCategory));
|
addDesignerAction(new SelectionModelNodeAction(selectionCategoryDisplayName, selectionCategory, prioritySelectionCategory));
|
||||||
|
|
||||||
addDesignerAction(new MenuDesignerAction<Always>(stackCategoryDisplayName, stackCategory, priorityStackCategory));
|
addDesignerAction(new MenuDesignerAction(stackCategoryDisplayName, stackCategory, priorityStackCategory, &always));
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::toFront>, SingleSelection>
|
addDesignerAction(new ModelNodeAction
|
||||||
(toFrontDisplayName, stackCategory, 200));
|
(toFrontDisplayName, stackCategory, 200, &toFront, &singleSelection));
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::toBack>, SingleSelection>
|
addDesignerAction(new ModelNodeAction
|
||||||
(toBackDisplayName, stackCategory, 180));
|
(toBackDisplayName, stackCategory, 180, &toBack, &singleSelection));
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::raise>, SelectionNotEmpty>
|
addDesignerAction(new ModelNodeAction
|
||||||
(raiseDisplayName, stackCategory, 160));
|
(raiseDisplayName, stackCategory, 160, &raise, &selectionNotEmpty));
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::lower>, SelectionNotEmpty>
|
addDesignerAction(new ModelNodeAction
|
||||||
(lowerDisplayName, stackCategory, 140));
|
(lowerDisplayName, stackCategory, 140, &lower, &selectionNotEmpty));
|
||||||
addDesignerAction(new SeperatorDesignerAction<>(stackCategory, 120));
|
addDesignerAction(new SeperatorDesignerAction(stackCategory, 120));
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::resetZ>,
|
addDesignerAction(new ModelNodeAction
|
||||||
And<SelectionNotEmpty, SelectionHasProperty<zProperty> > >
|
(resetZDisplayName, stackCategory, 100, &resetZ, &selectionNotEmptyAndHasZProperty));
|
||||||
(resetZDisplayName, stackCategory, 100));
|
|
||||||
|
|
||||||
addDesignerAction(new MenuDesignerAction<SelectionNotEmpty>(editCategoryDisplayName, editCategory, priorityEditCategory));
|
addDesignerAction(new MenuDesignerAction(editCategoryDisplayName, editCategory, priorityEditCategory, &selectionNotEmpty));
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::resetPosition>,
|
addDesignerAction(new ModelNodeAction
|
||||||
And<SelectionNotEmpty, SelectionHasPropertyWidth_Or_SelectionHasPropertyHeight> >
|
(resetPositionDisplayName, editCategory, 200, &resetPosition, &selectionNotEmptyAndHasXorYProperty));
|
||||||
(resetPositionDisplayName, editCategory, 200));
|
addDesignerAction(new ModelNodeAction
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::resetSize>,
|
(resetSizeDisplayName, editCategory, 180, &resetSize, &selectionNotEmptyAndHasWidthOrHeightProperty));
|
||||||
And<SelectionNotEmpty, SelectionHasPropertyX_Or_SelectionHasPropertyY> >
|
addDesignerAction(new VisiblityModelNodeAction
|
||||||
(resetSizeDisplayName, editCategory, 180));
|
(visibilityDisplayName, editCategory, 160, &setVisible, &singleSelectedItem));
|
||||||
addDesignerAction(new VisiblityModelNodeActionFactory<Functor<ModelNodeOperations::setVisible>, SingleSelectedItem>
|
|
||||||
(visibilityDisplayName, editCategory, 160));
|
|
||||||
|
|
||||||
addDesignerAction(new MenuDesignerAction<SingleSelection_And_InBaseState>(anchorsCategoryDisplayName, anchorsCategory, priorityAnchorsCategory));
|
addDesignerAction(new MenuDesignerAction(anchorsCategoryDisplayName, anchorsCategory,
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::anchorsFill>, SingleSelectionItemNotAnchored>
|
priorityAnchorsCategory, &singleSelectionAndInBaseState));
|
||||||
(anchorsFillDisplayName, anchorsCategory, 200));
|
addDesignerAction(new ModelNodeAction
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::anchorsReset>,
|
(anchorsFillDisplayName, anchorsCategory, 200, &anchorsFill, &singleSelectionItemIsNotAnchored));
|
||||||
SingleSelectionItemIsAnchored>(anchorsResetDisplayName, anchorsCategory, 180));
|
addDesignerAction(new ModelNodeAction
|
||||||
|
(anchorsResetDisplayName, anchorsCategory, 180, &anchorsReset, &singleSelectionItemIsAnchored));
|
||||||
|
|
||||||
addDesignerAction(new MenuDesignerAction<MultiSelection_And_InBaseState>(layoutCategoryDisplayName, layoutCategory, priorityLayoutCategory));
|
addDesignerAction(new MenuDesignerAction(layoutCategoryDisplayName, layoutCategory,
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::layoutRow>, SelectionCanBeLayouted>
|
priorityLayoutCategory, &multiSelectionAndInBaseState));
|
||||||
(layoutRowDisplayName, layoutCategory, 200));
|
addDesignerAction(new ModelNodeAction
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::layoutColumn>, SelectionCanBeLayouted>
|
(layoutRowDisplayName, layoutCategory, 200, &layoutRow, &selectionCanBeLayouted));
|
||||||
(layoutColumnDisplayName, layoutCategory, 180));
|
addDesignerAction(new ModelNodeAction
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::layoutColumn>, SelectionCanBeLayouted>
|
(layoutColumnDisplayName, layoutCategory, 180, &layoutColumn, &selectionCanBeLayouted));
|
||||||
(layoutGridDisplayName, layoutCategory, 160));
|
addDesignerAction(new ModelNodeAction
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::layoutFlow>, SelectionCanBeLayouted>
|
(layoutGridDisplayName, layoutCategory, 160, &layoutGrid, &selectionCanBeLayouted));
|
||||||
(layoutFlowDisplayName, layoutCategory, 140));
|
addDesignerAction(new ModelNodeAction
|
||||||
|
(layoutFlowDisplayName, layoutCategory, 140, &layoutFlow, &selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new SeperatorDesignerAction<>(rootCategory, priorityTopLevelSeperator));
|
addDesignerAction(new SeperatorDesignerAction(rootCategory, priorityTopLevelSeperator));
|
||||||
addDesignerAction(new ModelNodeActionFactory<Functor<ModelNodeOperations::goIntoComponent>,
|
addDesignerAction(new ModelNodeAction
|
||||||
SelectionIsComponent>(goIntoComponentDisplayName, rootCategory, priorityGoIntoComponent));
|
(goIntoComponentDisplayName, rootCategory, priorityGoIntoComponent, &goIntoComponent, &selectionIsComponent));
|
||||||
}
|
}
|
||||||
|
|
||||||
DesignerActionManager *DesignerActionManager::instance()
|
DesignerActionManager *DesignerActionManager::instance()
|
||||||
|
@@ -219,9 +219,10 @@ static inline void openInlineComponent(const ModelNode &node)
|
|||||||
//rootModelNode.setAuxiliaryData("height", height);
|
//rootModelNode.setAuxiliaryData("height", height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentUtils::goIntoComponent(const ModelNode &modelNode)
|
namespace ComponentUtils {
|
||||||
{
|
|
||||||
|
|
||||||
|
void goIntoComponent(const ModelNode &modelNode)
|
||||||
|
{
|
||||||
if (modelNode.isValid() && modelNodeIsComponent(modelNode)) {
|
if (modelNode.isValid() && modelNodeIsComponent(modelNode)) {
|
||||||
if (isFileComponent(modelNode))
|
if (isFileComponent(modelNode))
|
||||||
openFileForComponent(modelNode);
|
openFileForComponent(modelNode);
|
||||||
@@ -230,9 +231,12 @@ void ComponentUtils::goIntoComponent(const ModelNode &modelNode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ComponentUtils
|
||||||
|
|
||||||
namespace SelectionContextFunctors {
|
namespace SelectionContextFunctors {
|
||||||
|
|
||||||
bool SingleSelectionItemIsAnchored::operator() (const SelectionContext &selectionState) {
|
bool singleSelectionItemIsAnchored(const SelectionContext &selectionState)
|
||||||
|
{
|
||||||
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
|
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
|
||||||
if (selectionState.isInBaseState() && itemNode.isValid()) {
|
if (selectionState.isInBaseState() && itemNode.isValid()) {
|
||||||
bool anchored = itemNode.instanceHasAnchors();
|
bool anchored = itemNode.instanceHasAnchors();
|
||||||
@@ -241,7 +245,8 @@ bool SingleSelectionItemIsAnchored::operator() (const SelectionContext &selectio
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SingleSelectionItemNotAnchored::operator() (const SelectionContext &selectionState) {
|
bool singleSelectionItemIsNotAnchored(const SelectionContext &selectionState)
|
||||||
|
{
|
||||||
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
|
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
|
||||||
if (selectionState.isInBaseState() && itemNode.isValid()) {
|
if (selectionState.isInBaseState() && itemNode.isValid()) {
|
||||||
bool anchored = itemNode.instanceHasAnchors();
|
bool anchored = itemNode.instanceHasAnchors();
|
||||||
@@ -250,12 +255,12 @@ bool SingleSelectionItemNotAnchored::operator() (const SelectionContext &selecti
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SelectionHasSameParent::operator() (const SelectionContext &selectionState)
|
bool selectionHasSameParent(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
return !selectionState.selectedModelNodes().isEmpty() && itemsHaveSameParent(selectionState.selectedModelNodes());
|
return !selectionState.selectedModelNodes().isEmpty() && itemsHaveSameParent(selectionState.selectedModelNodes());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SelectionIsComponent::operator() (const SelectionContext &selectionState)
|
bool selectionIsComponent(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
return modelNodeIsComponent(selectionState.currentSingleSelectedNode());
|
return modelNodeIsComponent(selectionState.currentSingleSelectedNode());
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#define MODELNODECONTEXTMENU_HELPER_H
|
#define MODELNODECONTEXTMENU_HELPER_H
|
||||||
|
|
||||||
#include "modelnodecontextmenu.h"
|
#include "modelnodecontextmenu.h"
|
||||||
|
#include "modelnodeoperations.h"
|
||||||
#include "designeractionmanager.h"
|
#include "designeractionmanager.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -38,114 +39,70 @@
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
typedef bool (*SelectionContextFunction)(const SelectionContext &);
|
||||||
|
|
||||||
namespace SelectionContextFunctors {
|
namespace SelectionContextFunctors {
|
||||||
|
|
||||||
struct Always {
|
inline bool always(const SelectionContext &)
|
||||||
bool operator() (const SelectionContext &) {
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct InBaseState {
|
inline bool inBaseState(const SelectionContext &selectionState)
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
{
|
||||||
return selectionState.isInBaseState();
|
return selectionState.isInBaseState();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct SingleSelection {
|
inline bool singleSelection(const SelectionContext &selectionState)
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
{
|
||||||
return selectionState.singleSelected();
|
return selectionState.singleSelected();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct SelectionEnabled {
|
inline bool selectionEnabled(const SelectionContext &selectionState)
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
{
|
||||||
return selectionState.showSelectionTools();
|
return selectionState.showSelectionTools();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct SelectionNotEmpty {
|
inline bool selectionNotEmpty(const SelectionContext &selectionState)
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
{
|
||||||
return !selectionState.selectedModelNodes().isEmpty();
|
return !selectionState.selectedModelNodes().isEmpty();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct SingleSelectionNotRoot {
|
inline bool singleSelectionNotRoot(const SelectionContext &selectionState)
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
{
|
||||||
return selectionState.singleSelected()
|
return selectionState.singleSelected()
|
||||||
&& !selectionState.currentSingleSelectedNode().isRootNode();
|
&& !selectionState.currentSingleSelectedNode().isRootNode();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
inline bool selectionHasProperty(const SelectionContext &selectionState, const char *property)
|
||||||
struct And {
|
{
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
|
||||||
T1 t1;
|
|
||||||
T2 t2;
|
|
||||||
return t1(selectionState) && t2(selectionState);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct Or {
|
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
|
||||||
T1 t1;
|
|
||||||
T2 t2;
|
|
||||||
return t1(selectionState) || t2(selectionState);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1>
|
|
||||||
struct Not {
|
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
|
||||||
T1 t1;
|
|
||||||
return !t1(selectionState);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <char* PROPERTYNAME>
|
|
||||||
struct SelectionHasProperty {
|
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
|
||||||
foreach (const ModelNode &modelNode, selectionState.selectedModelNodes())
|
foreach (const ModelNode &modelNode, selectionState.selectedModelNodes())
|
||||||
if (modelNode.hasProperty(QLatin1String(PROPERTYNAME)))
|
if (modelNode.hasProperty(QLatin1String(property)))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct SelectionHasSameParent {
|
inline bool singleSelectedItem(const SelectionContext &selectionState)
|
||||||
bool operator() (const SelectionContext &selectionState);
|
{
|
||||||
};
|
|
||||||
|
|
||||||
struct SelectionIsComponent {
|
|
||||||
bool operator() (const SelectionContext &selectionState);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SingleSelectionItemIsAnchored {
|
|
||||||
bool operator() (const SelectionContext &selectionState);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SingleSelectionItemNotAnchored {
|
|
||||||
bool operator() (const SelectionContext &selectionState);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SingleSelectedItem {
|
|
||||||
bool operator() (const SelectionContext &selectionState) {
|
|
||||||
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
|
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
|
||||||
return itemNode.isValid();
|
return itemNode.isValid();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
} //SelectionStateFunctors
|
bool selectionHasSameParent(const SelectionContext &selectionState);
|
||||||
|
bool selectionIsComponent(const SelectionContext &selectionState);
|
||||||
|
bool selectionIsComponent(const SelectionContext &selectionState);
|
||||||
|
bool singleSelectionItemIsAnchored(const SelectionContext &selectionState);
|
||||||
|
bool singleSelectionItemIsNotAnchored(const SelectionContext &selectionState);
|
||||||
|
|
||||||
|
} // namespace SelectionStateFunctors
|
||||||
|
|
||||||
|
|
||||||
class ComponentUtils {
|
namespace ComponentUtils {
|
||||||
public:
|
void goIntoComponent(const ModelNode &modelNode);
|
||||||
static void goIntoComponent(const ModelNode &modelNode);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
class DefaultAction : public QAction {
|
|
||||||
|
|
||||||
|
class DefaultAction : public QAction
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -167,19 +124,36 @@ protected:
|
|||||||
SelectionContext m_selectionContext;
|
SelectionContext m_selectionContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ActionTemplate : public DefaultAction
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
ActionTemplate(const QString &description, ModelNodeOperations::SelectionAction action)
|
||||||
|
: DefaultAction(description), m_action(action)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public /*slots*/:
|
||||||
|
virtual void actionTriggered(bool b)
|
||||||
|
{
|
||||||
|
m_selectionContext.setToggled(b);
|
||||||
|
return m_action(m_selectionContext);
|
||||||
|
}
|
||||||
|
ModelNodeOperations::SelectionAction m_action;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class DefaultDesignerAction : public AbstractDesignerAction
|
class DefaultDesignerAction : public AbstractDesignerAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DefaultDesignerAction(const QString &description) : m_action(new DefaultAction(description))
|
DefaultDesignerAction() : m_action(new DefaultAction(QString()))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DefaultDesignerAction(DefaultAction *action) : m_action(action)
|
DefaultDesignerAction(DefaultAction *action) : m_action(action)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual QAction *action() const
|
QAction *action() const { return m_action; }
|
||||||
{ return m_action; }
|
|
||||||
|
|
||||||
virtual void setCurrentContext(const SelectionContext &selectionContext)
|
void setCurrentContext(const SelectionContext &selectionContext)
|
||||||
{
|
{
|
||||||
m_selectionContext = selectionContext;
|
m_selectionContext = selectionContext;
|
||||||
updateContext();
|
updateContext();
|
||||||
@@ -199,41 +173,30 @@ protected:
|
|||||||
SelectionContext m_selectionContext;
|
SelectionContext m_selectionContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class ENABLED = SelectionContextFunctors::Always,
|
|
||||||
class VISIBILITY = SelectionContextFunctors::Always>
|
|
||||||
class MenuDesignerAction : public AbstractDesignerAction
|
class MenuDesignerAction : public AbstractDesignerAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MenuDesignerAction(const QString &displayName, const QString &menuId, int priority) :
|
MenuDesignerAction(const QString &displayName, const QString &menuId, int priority,
|
||||||
|
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
||||||
|
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
||||||
m_displayName(displayName),
|
m_displayName(displayName),
|
||||||
m_menuId(menuId),
|
m_menuId(menuId),
|
||||||
m_priority(priority),
|
m_priority(priority),
|
||||||
m_menu(new QMenu)
|
m_menu(new QMenu),
|
||||||
|
m_enabled(enabled),
|
||||||
|
m_visibility(visibility)
|
||||||
{
|
{
|
||||||
m_menu->setTitle(displayName);
|
m_menu->setTitle(displayName);
|
||||||
m_action = m_menu->menuAction();
|
m_action = m_menu->menuAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isVisible(const SelectionContext &m_selectionState) const
|
bool isVisible(const SelectionContext &m_selectionState) const { return m_visibility(m_selectionState); }
|
||||||
{ VISIBILITY visibility; return visibility(m_selectionState); }
|
bool isEnabled(const SelectionContext &m_selectionState) const { return m_enabled(m_selectionState); }
|
||||||
|
QString category() const { return QString(); }
|
||||||
virtual bool isEnabled(const SelectionContext &m_selectionState) const
|
QString menuId() const { return m_menuId; }
|
||||||
{ ENABLED enabled; return enabled(m_selectionState); }
|
int priority() const { return m_priority; }
|
||||||
|
AbstractDesignerAction::Type type() const { return AbstractDesignerAction::Menu; }
|
||||||
virtual QString category() const
|
QAction *action() const { return m_action; }
|
||||||
{ return QString(""); }
|
|
||||||
|
|
||||||
virtual QString menuId() const
|
|
||||||
{ return m_menuId; }
|
|
||||||
|
|
||||||
virtual int priority() const
|
|
||||||
{ return m_priority; }
|
|
||||||
|
|
||||||
virtual AbstractDesignerAction::Type type() const
|
|
||||||
{ return AbstractDesignerAction::Menu; }
|
|
||||||
|
|
||||||
virtual QAction *action() const
|
|
||||||
{ return m_action; }
|
|
||||||
|
|
||||||
virtual void setCurrentContext(const SelectionContext &selectionContext)
|
virtual void setCurrentContext(const SelectionContext &selectionContext)
|
||||||
{
|
{
|
||||||
@@ -256,91 +219,59 @@ protected:
|
|||||||
SelectionContext m_selectionContext;
|
SelectionContext m_selectionContext;
|
||||||
QScopedPointer<QMenu> m_menu;
|
QScopedPointer<QMenu> m_menu;
|
||||||
QAction *m_action;
|
QAction *m_action;
|
||||||
|
SelectionContextFunction m_enabled;
|
||||||
|
SelectionContextFunction m_visibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class VISIBILITY = SelectionContextFunctors::Always>
|
|
||||||
class SeperatorDesignerAction : public DefaultDesignerAction
|
class SeperatorDesignerAction : public DefaultDesignerAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SeperatorDesignerAction(const QString &category, int priority) :
|
SeperatorDesignerAction(const QString &category, int priority) :
|
||||||
DefaultDesignerAction(QString()),
|
m_category(category),
|
||||||
m_category(category), m_priority(priority)
|
m_priority(priority),
|
||||||
|
m_visibility(&SelectionContextFunctors::always)
|
||||||
{ m_action->setSeparator(true); }
|
{ m_action->setSeparator(true); }
|
||||||
|
|
||||||
virtual bool isVisible(const SelectionContext &m_selectionState) const
|
bool isVisible(const SelectionContext &m_selectionState) const { return m_visibility(m_selectionState); }
|
||||||
{ VISIBILITY visibility; return visibility(m_selectionState); }
|
bool isEnabled(const SelectionContext &) const { return true; }
|
||||||
|
QString category() const { return m_category; }
|
||||||
|
QString menuId() const { return QString(); }
|
||||||
|
int priority() const { return m_priority; }
|
||||||
|
Type type() const { return Action; }
|
||||||
|
void setCurrentContext(const SelectionContext &) {}
|
||||||
|
|
||||||
virtual bool isEnabled(const SelectionContext &) const
|
|
||||||
{ return true; }
|
|
||||||
|
|
||||||
virtual QString category() const
|
|
||||||
{ return m_category; }
|
|
||||||
|
|
||||||
virtual QString menuId() const
|
|
||||||
{ return QString(); }
|
|
||||||
|
|
||||||
virtual int priority() const
|
|
||||||
{ return m_priority; }
|
|
||||||
|
|
||||||
virtual Type type() const
|
|
||||||
{ return Action; }
|
|
||||||
|
|
||||||
virtual void setCurrentContext(const SelectionContext &)
|
|
||||||
{}
|
|
||||||
private:
|
private:
|
||||||
const QString m_category;
|
const QString m_category;
|
||||||
const int m_priority;
|
const int m_priority;
|
||||||
|
SelectionContextFunction m_visibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class ACTION>
|
class ModelNodeAction : public DefaultDesignerAction
|
||||||
class ActionTemplate : public DefaultAction {
|
|
||||||
|
|
||||||
public:
|
|
||||||
ActionTemplate(const QString &description) : DefaultAction(description)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public /*slots*/:
|
|
||||||
virtual void actionTriggered(bool b)
|
|
||||||
{
|
|
||||||
m_selectionContext.setToggled(b);
|
|
||||||
ACTION action;
|
|
||||||
return action(m_selectionContext);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class ACTION,
|
|
||||||
class ENABLED = SelectionContextFunctors::Always,
|
|
||||||
class VISIBILITY = SelectionContextFunctors::Always>
|
|
||||||
class ModelNodeActionFactory : public DefaultDesignerAction
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ModelNodeActionFactory(const QString &description, const QString &category, int priority) :
|
ModelNodeAction(const QString &description, const QString &category, int priority,
|
||||||
DefaultDesignerAction(new ActionTemplate<ACTION>(description)),
|
ModelNodeOperations::SelectionAction selectionAction,
|
||||||
|
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
||||||
|
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
||||||
|
DefaultDesignerAction(new ActionTemplate(description, selectionAction)),
|
||||||
m_category(category),
|
m_category(category),
|
||||||
m_priority(priority)
|
m_priority(priority),
|
||||||
|
m_enabled(enabled),
|
||||||
|
m_visibility(visibility)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual bool isVisible(const SelectionContext &selectionState) const
|
bool isVisible(const SelectionContext &selectionState) const { return m_visibility(selectionState); }
|
||||||
{ VISIBILITY visibility; return visibility(selectionState); }
|
bool isEnabled(const SelectionContext &selectionState) const { return m_enabled(selectionState); }
|
||||||
|
QString category() const { return m_category; }
|
||||||
virtual bool isEnabled(const SelectionContext &selectionState) const
|
QString menuId() const { return QString(); }
|
||||||
{ ENABLED enabled; return enabled(selectionState); }
|
int priority() const { return m_priority; }
|
||||||
|
Type type() const { return Action; }
|
||||||
virtual QString category() const
|
|
||||||
{ return m_category; }
|
|
||||||
|
|
||||||
virtual QString menuId() const
|
|
||||||
{ return QString(); }
|
|
||||||
|
|
||||||
virtual int priority() const
|
|
||||||
{ return m_priority; }
|
|
||||||
|
|
||||||
virtual Type type() const
|
|
||||||
{ return Action; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_category;
|
const QString m_category;
|
||||||
const int m_priority;
|
const int m_priority;
|
||||||
|
const SelectionContextFunction m_enabled;
|
||||||
|
const SelectionContextFunction m_visibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -112,18 +112,21 @@ static inline bool modelNodesHaveProperty(const QList<ModelNode> &modelNodeList,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::goIntoComponent(const ModelNode &modelNode)
|
|
||||||
|
namespace ModelNodeOperations {
|
||||||
|
|
||||||
|
void goIntoComponent(const ModelNode &modelNode)
|
||||||
{
|
{
|
||||||
ComponentUtils::goIntoComponent(modelNode);
|
ComponentUtils::goIntoComponent(modelNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::select(const SelectionContext &selectionState)
|
void select(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (selectionState.view())
|
if (selectionState.view())
|
||||||
selectionState.view()->setSelectedModelNodes(QList<ModelNode>() << selectionState.targetNode());
|
selectionState.view()->setSelectedModelNodes(QList<ModelNode>() << selectionState.targetNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::deSelect(const SelectionContext &selectionState)
|
void deSelect(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (selectionState.view()) {
|
if (selectionState.view()) {
|
||||||
QList<ModelNode> selectedNodes = selectionState.view()->selectedModelNodes();
|
QList<ModelNode> selectedNodes = selectionState.view()->selectedModelNodes();
|
||||||
@@ -135,20 +138,20 @@ void ModelNodeOperations::deSelect(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::cut(const SelectionContext &)
|
void cut(const SelectionContext &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelNodeOperations::copy(const SelectionContext &)
|
void copy(const SelectionContext &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::deleteSelection(const SelectionContext &)
|
void deleteSelection(const SelectionContext &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::toFront(const SelectionContext &selectionState)
|
void toFront(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -166,7 +169,7 @@ void ModelNodeOperations::toFront(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelNodeOperations::toBack(const SelectionContext &selectionState)
|
void toBack(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -183,7 +186,7 @@ void ModelNodeOperations::toBack(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::raise(const SelectionContext &selectionState)
|
void raise(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -203,7 +206,7 @@ void ModelNodeOperations::raise(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::lower(const SelectionContext &selectionState)
|
void lower(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
@@ -224,19 +227,19 @@ void ModelNodeOperations::lower(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::paste(const SelectionContext &)
|
void paste(const SelectionContext &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::undo(const SelectionContext &)
|
void undo(const SelectionContext &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::redo(const SelectionContext &)
|
void redo(const SelectionContext &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::setVisible(const SelectionContext &selectionState)
|
void setVisible(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -249,7 +252,7 @@ void ModelNodeOperations::setVisible(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelNodeOperations::resetSize(const SelectionContext &selectionState)
|
void resetSize(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -265,7 +268,7 @@ void ModelNodeOperations::resetSize(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::resetPosition(const SelectionContext &selectionState)
|
void resetPosition(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -281,16 +284,16 @@ void ModelNodeOperations::resetPosition(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::goIntoComponent(const SelectionContext &selectionState)
|
void goIntoComponent(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
goIntoComponent(selectionState.currentSingleSelectedNode());
|
goIntoComponent(selectionState.currentSingleSelectedNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::setId(const SelectionContext &)
|
void setId(const SelectionContext &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::resetZ(const SelectionContext &selectionState)
|
void resetZ(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -321,7 +324,7 @@ static inline void restoreProperty(ModelNode node, const QString &propertyName)
|
|||||||
node.variantProperty(propertyName) = node.auxiliaryData(auxDataString + propertyName);
|
node.variantProperty(propertyName) = node.auxiliaryData(auxDataString + propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::anchorsFill(const SelectionContext &selectionState)
|
void anchorsFill(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -340,7 +343,7 @@ void ModelNodeOperations::anchorsFill(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::anchorsReset(const SelectionContext &selectionState)
|
void anchorsReset(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -423,7 +426,7 @@ static inline QPoint getUpperLeftPosition(const QList<ModelNode> &modelNodeList)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::layoutRow(const SelectionContext &selectionState)
|
void layoutRow(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -468,7 +471,7 @@ void ModelNodeOperations::layoutRow(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::layoutColumn(const SelectionContext &selectionState)
|
void layoutColumn(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -511,7 +514,7 @@ void ModelNodeOperations::layoutColumn(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::layoutGrid(const SelectionContext &selectionState)
|
void layoutGrid(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -555,7 +558,7 @@ void ModelNodeOperations::layoutGrid(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelNodeOperations::layoutFlow(const SelectionContext &selectionState)
|
void layoutFlow(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
@@ -598,4 +601,6 @@ void ModelNodeOperations::layoutFlow(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Mode
|
||||||
|
|
||||||
} //QmlDesigner
|
} //QmlDesigner
|
||||||
|
@@ -33,38 +33,38 @@
|
|||||||
#include "selectioncontext.h"
|
#include "selectioncontext.h"
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
namespace ModelNodeOperations {
|
||||||
|
|
||||||
class ModelNodeOperations
|
void goIntoComponent(const ModelNode &modelNode);
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void goIntoComponent(const ModelNode &modelNode);
|
|
||||||
|
|
||||||
static void select(const SelectionContext &selectionState);
|
typedef void (*SelectionAction)(const SelectionContext &);
|
||||||
static void deSelect(const SelectionContext &selectionState);
|
|
||||||
static void cut(const SelectionContext &selectionState);
|
|
||||||
static void copy(const SelectionContext &selectionState);
|
|
||||||
static void deleteSelection(const SelectionContext &selectionState);
|
|
||||||
static void toFront(const SelectionContext &selectionState);
|
|
||||||
static void toBack(const SelectionContext &selectionState);
|
|
||||||
static void raise(const SelectionContext &selectionState);
|
|
||||||
static void lower(const SelectionContext &selectionState);
|
|
||||||
static void paste(const SelectionContext &selectionState);
|
|
||||||
static void undo(const SelectionContext &selectionState);
|
|
||||||
static void redo(const SelectionContext &selectionState);
|
|
||||||
static void setVisible(const SelectionContext &selectionState);
|
|
||||||
static void resetSize(const SelectionContext &selectionState);
|
|
||||||
static void resetPosition(const SelectionContext &selectionState);
|
|
||||||
static void goIntoComponent(const SelectionContext &selectionState);
|
|
||||||
static void setId(const SelectionContext &selectionState);
|
|
||||||
static void resetZ(const SelectionContext &selectionState);
|
|
||||||
static void anchorsFill(const SelectionContext &selectionState);
|
|
||||||
static void anchorsReset(const SelectionContext &selectionState);
|
|
||||||
static void layoutRow(const SelectionContext &selectionState);
|
|
||||||
static void layoutColumn(const SelectionContext &selectionState);
|
|
||||||
static void layoutGrid(const SelectionContext &selectionState);
|
|
||||||
static void layoutFlow(const SelectionContext &selectionState);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
void select(const SelectionContext &selectionState);
|
||||||
|
void deSelect(const SelectionContext &selectionState);
|
||||||
|
void cut(const SelectionContext &selectionState);
|
||||||
|
void copy(const SelectionContext &selectionState);
|
||||||
|
void deleteSelection(const SelectionContext &selectionState);
|
||||||
|
void toFront(const SelectionContext &selectionState);
|
||||||
|
void toBack(const SelectionContext &selectionState);
|
||||||
|
void raise(const SelectionContext &selectionState);
|
||||||
|
void lower(const SelectionContext &selectionState);
|
||||||
|
void paste(const SelectionContext &selectionState);
|
||||||
|
void undo(const SelectionContext &selectionState);
|
||||||
|
void redo(const SelectionContext &selectionState);
|
||||||
|
void setVisible(const SelectionContext &selectionState);
|
||||||
|
void resetSize(const SelectionContext &selectionState);
|
||||||
|
void resetPosition(const SelectionContext &selectionState);
|
||||||
|
void goIntoComponent(const SelectionContext &selectionState);
|
||||||
|
void setId(const SelectionContext &selectionState);
|
||||||
|
void resetZ(const SelectionContext &selectionState);
|
||||||
|
void anchorsFill(const SelectionContext &selectionState);
|
||||||
|
void anchorsReset(const SelectionContext &selectionState);
|
||||||
|
void layoutRow(const SelectionContext &selectionState);
|
||||||
|
void layoutColumn(const SelectionContext &selectionState);
|
||||||
|
void layoutGrid(const SelectionContext &selectionState);
|
||||||
|
void layoutFlow(const SelectionContext &selectionState);
|
||||||
|
|
||||||
|
} // namespace ModelNodeOperationso
|
||||||
} //QmlDesigner
|
} //QmlDesigner
|
||||||
|
|
||||||
#endif //MODELNODEOPERATIONS_H
|
#endif //MODELNODEOPERATIONS_H
|
||||||
|
Reference in New Issue
Block a user