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