Commit e06f7e1d authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Move currentState to AbstractView

Change-Id: I3252d85dceff606c85898895e91b7e955441033b
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 0dd5f681
......@@ -63,7 +63,7 @@ bool SelectionContext::singleNodeIsSelected() const
bool SelectionContext::isInBaseState() const
{
return QmlModelState(view()->currentStateNode()).isBaseState();
return view()->currentState().isBaseState();
}
ModelNode SelectionContext::currentSingleSelectedNode() const
......
......@@ -95,8 +95,7 @@ void MoveTool::mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
m_resizeIndicator.hide();
FormEditorItem *containerItem = containerFormEditorItem(itemList, m_movingItems);
if (containerItem
&& QmlModelState::isBaseState(view()->currentStateNode())) {
if (containerItem && view()->currentState().isBaseState()) {
if (containerItem != m_movingItems.first()->parentItem()
&& event->modifiers().testFlag(Qt::ShiftModifier)) {
m_moveManipulator.reparentTo(containerItem);
......
......@@ -738,7 +738,7 @@ void PropertyEditor::resetView()
NodeType *type = m_typeHash.value(qmlFile.toString());
QString currentStateName = QmlModelState::isValidQmlModelState(currentStateNode()) ? QmlModelState(currentStateNode()).name() : QLatin1String("invalid state");
QString currentStateName = currentState().isBaseState() ? currentState().name() : QLatin1String("invalid state");
if (!type) {
type = new NodeType(this);
......
......@@ -245,11 +245,6 @@ void StatesEditorView::duplicateCurrentState()
setCurrentState(newState);
}
QmlModelState StatesEditorView::currentState() const
{
return QmlModelState(currentStateNode());
}
void StatesEditorView::setCurrentState(const QmlModelState &state)
{
if (!model() && !state.isValid())
......
......@@ -49,7 +49,6 @@ public:
void renameState(int nodeId,const QString &newName);
bool validStateName(const QString &name) const;
QString currentStateName() const;
QmlModelState currentState() const;
void setCurrentState(const QmlModelState &state);
QmlModelState baseState() const;
QmlModelStateGroup rootStateGroup() const;
......
......@@ -57,6 +57,7 @@ namespace QmlDesigner {
class NodeInstanceView;
class RewriterView;
class QmlModelState;
class WidgetInfo {
......@@ -235,6 +236,7 @@ public:
void setCurrentStateNode(const ModelNode &node);
ModelNode currentStateNode() const;
QmlModelState currentState() const;
int majorQtQuickVersion() const;
......
......@@ -33,6 +33,7 @@
#include "model_p.h"
#include "internalnode_p.h"
#include "nodeinstanceview.h"
#include <qmlstate.h>
namespace QmlDesigner {
......@@ -537,6 +538,11 @@ ModelNode AbstractView::currentStateNode() const
return ModelNode();
}
QmlModelState AbstractView::currentState() const
{
return QmlModelState(currentStateNode());
}
static int getMajorVersionFromImport(const Model *model)
{
foreach (const Import &import, model->imports()) {
......
......@@ -155,7 +155,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
newQmlItemNode.setId(view->generateNewId("image"));
if (!QmlModelState(view->currentStateNode()).isBaseState()) {
if (!view->currentState().isBaseState()) {
newQmlItemNode.modelNode().variantProperty("opacity").setValue(0);
newQmlItemNode.setVariantProperty("opacity", 1);
}
......@@ -221,7 +221,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
newQmlItemNode.setId(view->generateNewId("image"));
if (!QmlModelState(view->currentStateNode()).isBaseState()) {
if (!view->currentState().isBaseState()) {
newQmlItemNode.modelNode().variantProperty("opacity").setValue(0);
newQmlItemNode.setVariantProperty("opacity", 1);
}
......
......@@ -67,7 +67,7 @@ void ViewManager::detachRewriterView()
void ViewManager::switchStateEditorViewToBaseState()
{
if (m_statesEditorView.isAttached()) {
m_savedState = QmlModelState(m_statesEditorView.currentStateNode());
m_savedState = m_statesEditorView.currentState();
m_statesEditorView.setCurrentState(m_statesEditorView.baseState());
}
}
......
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