QmlDesigner.ComponentCore: Making members private

Change-Id: I5674499c66acf6bb86abd0f56c318ceff021e1bb
Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
Thomas Hartmann
2014-06-19 14:21:40 +02:00
parent 30b206a53b
commit 72906cc776
4 changed files with 27 additions and 22 deletions

View File

@@ -56,6 +56,11 @@ QMenu *AbstractActionGroup::menu() const
return m_menu.data(); return m_menu.data();
} }
SelectionContext AbstractActionGroup::selectionContext() const
{
return m_selectionContext;
}
void AbstractActionGroup::currentContextChanged(const SelectionContext &selectionContext) void AbstractActionGroup::currentContextChanged(const SelectionContext &selectionContext)
{ {
m_selectionContext = selectionContext; m_selectionContext = selectionContext;

View File

@@ -48,11 +48,12 @@ public:
AbstractDesignerAction::Type type() const QTC_OVERRIDE; AbstractDesignerAction::Type type() const QTC_OVERRIDE;
QAction *action() const QTC_OVERRIDE; QAction *action() const QTC_OVERRIDE;
QMenu *menu() const; QMenu *menu() const;
SelectionContext selectionContext() const;
virtual void currentContextChanged(const SelectionContext &selectionContext) QTC_OVERRIDE; virtual void currentContextChanged(const SelectionContext &selectionContext) QTC_OVERRIDE;
virtual void updateContext(); virtual void updateContext();
protected: private:
const QString m_displayName; const QString m_displayName;
SelectionContext m_selectionContext; SelectionContext m_selectionContext;
QScopedPointer<QMenu> m_menu; QScopedPointer<QMenu> m_menu;

View File

@@ -150,41 +150,41 @@ public:
virtual void updateContext() virtual void updateContext()
{ {
m_menu->clear(); menu()->clear();
if (m_selectionContext.isValid()) { if (selectionContext().isValid()) {
m_action->setEnabled(isEnabled(m_selectionContext)); action()->setEnabled(isEnabled(selectionContext()));
m_action->setVisible(isVisible(m_selectionContext)); action()->setVisible(isVisible(selectionContext()));
} else { } else {
return; return;
} }
if (m_action->isEnabled()) { if (action()->isEnabled()) {
ModelNode parentNode; ModelNode parentNode;
if (m_selectionContext.singleNodeIsSelected() if (selectionContext().singleNodeIsSelected()
&& !m_selectionContext.currentSingleSelectedNode().isRootNode() && !selectionContext().currentSingleSelectedNode().isRootNode()
&& m_selectionContext.currentSingleSelectedNode().hasParentProperty()) { && selectionContext().currentSingleSelectedNode().hasParentProperty()) {
ActionTemplate *selectionAction = new ActionTemplate(QString(), &ModelNodeOperations::select); ActionTemplate *selectionAction = new ActionTemplate(QString(), &ModelNodeOperations::select);
selectionAction->setParent(m_menu.data()); selectionAction->setParent(menu());
parentNode = m_selectionContext.currentSingleSelectedNode().parentProperty().parentModelNode(); parentNode = selectionContext().currentSingleSelectedNode().parentProperty().parentModelNode();
m_selectionContext.setTargetNode(parentNode); selectionContext().setTargetNode(parentNode);
selectionAction->setText(QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select parent: %1")).arg( selectionAction->setText(QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select parent: %1")).arg(
captionForModelNode(parentNode))); captionForModelNode(parentNode)));
selectionAction->setSelectionContext(m_selectionContext); selectionAction->setSelectionContext(selectionContext());
m_menu->addAction(selectionAction); menu()->addAction(selectionAction);
} }
foreach (const ModelNode &node, m_selectionContext.view()->allModelNodes()) { foreach (const ModelNode &node, selectionContext().view()->allModelNodes()) {
if (node != m_selectionContext.currentSingleSelectedNode() if (node != selectionContext().currentSingleSelectedNode()
&& node != parentNode && node != parentNode
&& contains(node, m_selectionContext.scenePosition()) && contains(node, selectionContext().scenePosition())
&& !node.isRootNode()) { && !node.isRootNode()) {
m_selectionContext.setTargetNode(node); selectionContext().setTargetNode(node);
QString what = QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select: %1")).arg(captionForModelNode(node)); QString what = QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select: %1")).arg(captionForModelNode(node));
ActionTemplate *selectionAction = new ActionTemplate(what, &ModelNodeOperations::select); ActionTemplate *selectionAction = new ActionTemplate(what, &ModelNodeOperations::select);
selectionAction->setSelectionContext(m_selectionContext); selectionAction->setSelectionContext(selectionContext());
m_menu->addAction(selectionAction); menu()->addAction(selectionAction);
} }
} }
} }

View File

@@ -134,9 +134,8 @@ public:
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; } AbstractDesignerAction::Type type() const { return AbstractDesignerAction::Menu; }
QAction *action() const { return m_action; }
protected: private:
const QByteArray m_menuId; const QByteArray m_menuId;
const int m_priority; const int m_priority;
SelectionContextFunction m_enabled; SelectionContextFunction m_enabled;