Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
780899b1
Commit
780899b1
authored
Feb 16, 2010
by
Marco Bubke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor state changes in Bauhaus
parent
5864d9d7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
20 deletions
+64
-20
src/plugins/qmldesigner/core/include/nodeinstanceview.h
src/plugins/qmldesigner/core/include/nodeinstanceview.h
+3
-0
src/plugins/qmldesigner/core/include/qmlmodelview.h
src/plugins/qmldesigner/core/include/qmlmodelview.h
+2
-0
src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
+10
-1
src/plugins/qmldesigner/core/instances/qmlstatenodeinstance.cpp
...ugins/qmldesigner/core/instances/qmlstatenodeinstance.cpp
+2
-0
src/plugins/qmldesigner/core/model/qmlmodelview.cpp
src/plugins/qmldesigner/core/model/qmlmodelview.cpp
+47
-19
No files found.
src/plugins/qmldesigner/core/include/nodeinstanceview.h
View file @
780899b1
...
...
@@ -114,6 +114,8 @@ public:
void
setQmlModelView
(
QmlModelView
*
qmlModelView
);
QmlModelView
*
qmlModelView
()
const
;
void
setBlockStatePropertyChanges
(
bool
block
);
signals:
void
instanceRemoved
(
const
NodeInstance
&
nodeInstance
);
...
...
@@ -148,6 +150,7 @@ private: //variables
QWeakPointer
<
QmlModelView
>
m_qmlModelView
;
bool
m_blockChangeSignal
;
bool
m_blockStatePropertyChanges
;
};
}
...
...
src/plugins/qmldesigner/core/include/qmlmodelview.h
View file @
780899b1
...
...
@@ -99,6 +99,8 @@ protected:
virtual
void
otherPropertyChanged
(
const
QmlObjectNode
&
qmlObjectNode
,
const
QString
&
propertyName
);
virtual
void
stateChanged
(
const
QmlModelState
&
newQmlModelState
,
const
QmlModelState
&
oldQmlModelState
);
void
activateState
(
const
QmlModelState
&
state
);
void
changeToState
(
const
ModelNode
&
node
,
const
QString
&
stateName
);
private:
QmlModelState
m_state
;
...
...
src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
View file @
780899b1
...
...
@@ -92,7 +92,8 @@ NodeInstanceView::NodeInstanceView(QObject *parent)
:
AbstractView
(
parent
),
m_graphicsView
(
new
QGraphicsView
),
m_engine
(
new
QmlEngine
(
this
)),
m_blockChangeSignal
(
false
)
m_blockChangeSignal
(
false
),
m_blockStatePropertyChanges
(
false
)
{
m_graphicsView
->
setAttribute
(
Qt
::
WA_DontShowOnScreen
,
true
);
m_graphicsView
->
setViewportUpdateMode
(
QGraphicsView
::
NoViewportUpdate
);
...
...
@@ -500,6 +501,9 @@ void NodeInstanceView::removeInstanceNodeRelationship(const ModelNode &node)
void
NodeInstanceView
::
notifyPropertyChange
(
const
ModelNode
&
node
,
const
QString
&
propertyName
)
{
if
(
m_blockStatePropertyChanges
&&
propertyName
==
"state"
)
return
;
if
(
qmlModelView
())
{
qmlModelView
()
->
nodeInstancePropertyChanged
(
ModelNode
(
node
,
qmlModelView
()),
propertyName
);
}
...
...
@@ -516,6 +520,11 @@ QmlModelView *NodeInstanceView::qmlModelView() const
return
m_qmlModelView
.
data
();
}
void
NodeInstanceView
::
setBlockStatePropertyChanges
(
bool
block
)
{
m_blockStatePropertyChanges
=
block
;
}
void
NodeInstanceView
::
emitParentChanged
(
QObject
*
child
)
{
if
(
hasInstanceForObject
(
child
))
{
...
...
src/plugins/qmldesigner/core/instances/qmlstatenodeinstance.cpp
View file @
780899b1
...
...
@@ -76,8 +76,10 @@ void QmlStateNodeInstance::deactivateState()
void
QmlStateNodeInstance
::
refreshState
()
{
nodeInstanceView
()
->
setBlockStatePropertyChanges
(
true
);
deactivateState
();
activateState
();
nodeInstanceView
()
->
setBlockStatePropertyChanges
(
false
);
}
QmlState
*
QmlStateNodeInstance
::
stateObject
()
const
...
...
src/plugins/qmldesigner/core/model/qmlmodelview.cpp
View file @
780899b1
...
...
@@ -49,9 +49,9 @@ QmlModelView::QmlModelView(QObject *parent)
void
QmlModelView
::
setCurrentState
(
const
QmlModelState
&
state
)
{
if
(
m_
state
==
state
)
if
(
!
state
.
isValid
()
)
return
;
QmlModelState
oldState
=
m_state
;
emitCustomNotification
(
"__state changed__"
,
QList
<
ModelNode
>
()
<<
state
.
modelNode
());
}
...
...
@@ -223,9 +223,9 @@ void QmlModelView::customNotification(const AbstractView * /* view */, const QSt
if
(
identifier
==
"__state changed__"
)
{
QmlModelState
state
(
nodeList
.
first
());
if
(
state
.
isValid
())
stateChanged
(
state
,
currentState
()
);
activateState
(
state
);
else
stateChanged
(
baseState
(),
current
State
());
activateState
(
base
State
());
}
}
...
...
@@ -283,10 +283,52 @@ void QmlModelView::nodeInstancePropertyChanged(const ModelNode &node, const QStr
transformChanged
(
qmlObjectNode
,
propertyName
);
else
if
(
propertyName
==
"parent"
)
parentChanged
(
qmlObjectNode
);
else
if
(
propertyName
==
"state"
)
changeToState
(
node
,
qmlObjectNode
.
instanceValue
(
propertyName
).
toString
());
else
otherPropertyChanged
(
qmlObjectNode
,
propertyName
);
}
void
QmlModelView
::
activateState
(
const
QmlModelState
&
state
)
{
if
(
!
state
.
isValid
())
return
;
if
(
m_state
==
state
)
return
;
QmlModelState
oldState
=
m_state
;
NodeInstance
newStateInstance
=
instanceForModelNode
(
state
.
modelNode
());
NodeInstance
oldStateInstance
=
instanceForModelNode
(
oldState
.
modelNode
());
if
(
state
.
isBaseState
())
{
oldStateInstance
.
deactivateState
();
}
else
{
newStateInstance
.
activateState
();
}
}
void
QmlModelView
::
changeToState
(
const
ModelNode
&
node
,
const
QString
&
stateName
)
{
QmlItemNode
itemNode
(
node
);
QmlModelState
newState
;
if
(
stateName
.
isEmpty
())
newState
=
baseState
();
else
newState
=
itemNode
.
states
().
state
(
stateName
);
QmlModelState
oldState
=
m_state
;
if
(
newState
.
isValid
())
m_state
=
newState
;
stateChanged
(
newState
,
oldState
);
}
void
QmlModelView
::
transformChanged
(
const
QmlObjectNode
&
/*qmlObjectNode*/
,
const
QString
&
/*propertyName*/
)
{
}
...
...
@@ -302,22 +344,8 @@ void QmlModelView::otherPropertyChanged(const QmlObjectNode &/*qmlObjectNode*/,
}
void
QmlModelView
::
stateChanged
(
const
QmlModelState
&
newQmlModelState
,
const
QmlModelState
&
oldQmlModelState
)
void
QmlModelView
::
stateChanged
(
const
QmlModelState
&
newQmlModelState
,
const
QmlModelState
&
/*
oldQmlModelState
*/
)
{
m_state
=
newQmlModelState
;
if
(
newQmlModelState
.
isValid
())
{
NodeInstance
newStateInstance
=
instanceForModelNode
(
newQmlModelState
.
modelNode
());
Q_ASSERT
(
newStateInstance
.
isValid
());
if
(
!
newQmlModelState
.
isBaseState
())
newStateInstance
.
activateState
();
}
if
(
oldQmlModelState
.
isValid
())
{
NodeInstance
oldStateInstance
=
instanceForModelNode
(
oldQmlModelState
.
modelNode
());
Q_ASSERT
(
oldStateInstance
.
isValid
());
if
(
!
oldQmlModelState
.
isBaseState
())
oldStateInstance
.
deactivateState
();
}
}
}
//QmlDesigner
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment