forked from qt-creator/qt-creator
QmlDesigner: Move states functions from QmlModelView to StatesEditorView
Change-Id: I1ac99fbf805b21823e062749bd3342be1641072a Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
905aeeadcc
commit
8e54a2a58d
@@ -178,7 +178,7 @@ void FormEditorWidget::changeRootItemHeight(const QString &heighText)
|
||||
|
||||
void FormEditorWidget::resetNodeInstanceView()
|
||||
{
|
||||
m_formEditorView->setCurrentState(m_formEditorView->baseState());
|
||||
m_formEditorView->setAcutalStateNode(m_formEditorView->rootModelNode());
|
||||
m_formEditorView->emitCustomNotification(QLatin1String("reset QmlPuppet"));
|
||||
}
|
||||
|
||||
|
@@ -96,7 +96,7 @@ void MoveTool::mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
|
||||
FormEditorItem *containerItem = containerFormEditorItem(itemList, m_movingItems);
|
||||
if (containerItem
|
||||
&& view()->currentState().isBaseState()) {
|
||||
&& QmlModelState::isBaseState(view()->actualStateNode())) {
|
||||
if (containerItem != m_movingItems.first()->parentItem()
|
||||
&& event->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||
m_moveManipulator.reparentTo(containerItem);
|
||||
|
@@ -738,6 +738,8 @@ void PropertyEditor::resetView()
|
||||
|
||||
NodeType *type = m_typeHash.value(qmlFile.toString());
|
||||
|
||||
QString currentStateName = QmlModelState::isValidQmlModelState(actualStateNode()) ? QmlModelState(actualStateNode()).name() : QLatin1String("invalid state");
|
||||
|
||||
if (!type) {
|
||||
type = new NodeType(this);
|
||||
|
||||
@@ -750,7 +752,7 @@ void PropertyEditor::resetView()
|
||||
Q_ASSERT(qmlObjectNode.isValid());
|
||||
}
|
||||
QDeclarativeContext *ctxt = type->m_view->rootContext();
|
||||
type->setup(qmlObjectNode, currentState().name(), qmlSpecificsFile, this);
|
||||
type->setup(qmlObjectNode, currentStateName, qmlSpecificsFile, this);
|
||||
ctxt->setContextProperty("finishedNotify", QVariant(false));
|
||||
if (specificQmlData.isEmpty())
|
||||
type->m_contextObject->setSpecificQmlData(specificQmlData);
|
||||
@@ -768,7 +770,6 @@ void PropertyEditor::resetView()
|
||||
ctxt->setContextProperty("finishedNotify", QVariant(false));
|
||||
if (specificQmlData.isEmpty())
|
||||
type->m_contextObject->setSpecificQmlData(specificQmlData);
|
||||
QString currentStateName = currentState().isValid() ? currentState().name() : QLatin1String("invalid state");
|
||||
type->setup(qmlObjectNode, currentStateName, qmlSpecificsFile, this);
|
||||
type->m_contextObject->setGlobalBaseUrl(qmlFile);
|
||||
type->m_contextObject->setSpecificQmlData(specificQmlData);
|
||||
|
@@ -243,6 +243,30 @@ void StatesEditorView::duplicateCurrentState()
|
||||
setCurrentState(newState);
|
||||
}
|
||||
|
||||
QmlModelState StatesEditorView::currentState() const
|
||||
{
|
||||
return QmlModelState(actualStateNode());
|
||||
}
|
||||
|
||||
void StatesEditorView::setCurrentState(const QmlModelState &state)
|
||||
{
|
||||
if (!model() && !state.isValid())
|
||||
return;
|
||||
|
||||
if (actualStateNode() != state.modelNode())
|
||||
setAcutalStateNode(state.modelNode());
|
||||
}
|
||||
|
||||
QmlModelState StatesEditorView::baseState() const
|
||||
{
|
||||
return QmlModelState::createBaseState(this);
|
||||
}
|
||||
|
||||
QmlModelStateGroup StatesEditorView::rootStateGroup() const
|
||||
{
|
||||
return QmlModelStateGroup(rootModelNode());
|
||||
}
|
||||
|
||||
bool StatesEditorView::validStateName(const QString &name) const
|
||||
{
|
||||
if (name == tr("base state"))
|
||||
|
@@ -47,6 +47,10 @@ 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;
|
||||
|
||||
// AbstractView
|
||||
void modelAttached(Model *model) QTC_OVERRIDE;
|
||||
|
@@ -119,7 +119,7 @@ QMLDESIGNERCORE_EXPORT uint qHash(const QmlItemNode &node);
|
||||
class QMLDESIGNERCORE_EXPORT QmlModelStateGroup
|
||||
{
|
||||
friend class QmlItemNode;
|
||||
friend class QmlModelView;
|
||||
friend class StatesEditorView;
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -50,17 +50,12 @@ class QMLDESIGNERCORE_EXPORT QmlModelView : public AbstractView
|
||||
public:
|
||||
QmlModelView(QObject *parent) ;
|
||||
|
||||
void setCurrentState(const QmlModelState &state);
|
||||
QmlModelState currentState() const;
|
||||
|
||||
QmlModelState baseState() const;
|
||||
QmlModelStateGroup rootStateGroup() const;
|
||||
|
||||
|
||||
QmlItemNode rootQmlItemNode() const;
|
||||
|
||||
|
||||
void activateState(const QmlModelState &state);
|
||||
|
||||
};
|
||||
|
||||
} //QmlDesigner
|
||||
|
@@ -42,7 +42,7 @@ class QmlObjectNode;
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT QmlModelState : public QmlModelNodeFacade
|
||||
{
|
||||
friend class QmlModelView;
|
||||
friend class StatesEditorView;
|
||||
|
||||
public:
|
||||
QmlModelState();
|
||||
|
@@ -56,30 +56,6 @@ QmlModelView::QmlModelView(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void QmlModelView::setCurrentState(const QmlModelState &state)
|
||||
{
|
||||
if (!model() && !state.isValid())
|
||||
return;
|
||||
|
||||
if (actualStateNode() != state.modelNode())
|
||||
setAcutalStateNode(state.modelNode());
|
||||
}
|
||||
|
||||
QmlModelState QmlModelView::currentState() const
|
||||
{
|
||||
return QmlModelState(actualStateNode());
|
||||
}
|
||||
|
||||
QmlModelState QmlModelView::baseState() const
|
||||
{
|
||||
return QmlModelState::createBaseState(this);
|
||||
}
|
||||
|
||||
QmlModelStateGroup QmlModelView::rootStateGroup() const
|
||||
{
|
||||
return QmlModelStateGroup(rootModelNode());
|
||||
}
|
||||
|
||||
QmlItemNode QmlModelView::rootQmlItemNode() const
|
||||
{
|
||||
return QmlItemNode(rootModelNode());
|
||||
|
@@ -76,7 +76,7 @@ void QmlObjectNode::setBindingProperty(const PropertyName &name, const QString &
|
||||
QmlModelState QmlObjectNode::currentState() const
|
||||
{
|
||||
if (isValid())
|
||||
return qmlModelView()->currentState();
|
||||
return QmlModelState(qmlModelView()->actualStateNode());
|
||||
else
|
||||
return QmlModelState();
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ void ViewManager::detachRewriterView()
|
||||
void ViewManager::switchStateEditorViewToBaseState()
|
||||
{
|
||||
if (m_statesEditorView.isAttached()) {
|
||||
m_savedState = m_statesEditorView.currentState();
|
||||
m_savedState = QmlModelState(m_statesEditorView.actualStateNode());
|
||||
m_statesEditorView.setCurrentState(m_statesEditorView.baseState());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user