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
Marco Bubke
flatpak-qt-creator
Commits
09a78a3a
Commit
09a78a3a
authored
May 09, 2011
by
Christiaan Janssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QmlLivePreview: adding states to an item
Reviewed-by: Kai Koehne
parent
0d3fa271
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
16 deletions
+52
-16
share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp
.../qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp
+19
-7
src/libs/qmljs/qmljsdelta.cpp
src/libs/qmljs/qmljsdelta.cpp
+33
-9
No files found.
share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp
View file @
09a78a3a
...
...
@@ -421,16 +421,28 @@ void QDeclarativeViewObserverPrivate::_q_createQmlObject(const QString &qml, QOb
QObject
*
newObject
=
component
.
create
(
parentContext
);
if
(
newObject
)
{
newObject
->
setParent
(
parent
);
QDeclarativeItem
*
parentItem
=
qobject_cast
<
QDeclarativeItem
*>
(
parent
);
QDeclarativeItem
*
newItem
=
qobject_cast
<
QDeclarativeItem
*>
(
newObject
);
if
(
parentItem
&&
newItem
)
newItem
->
setParentItem
(
parentItem
);
else
{
do
{
QDeclarativeItem
*
parentItem
=
qobject_cast
<
QDeclarativeItem
*>
(
parent
);
QDeclarativeItem
*
newItem
=
qobject_cast
<
QDeclarativeItem
*>
(
newObject
);
if
(
parentItem
&&
newItem
)
{
newItem
->
setParentItem
(
parentItem
);
break
;
}
QDeclarativeState
*
parentState
=
qobject_cast
<
QDeclarativeState
*>
(
parent
);
QDeclarativeStateOperation
*
newPropertyChanges
=
qobject_cast
<
QDeclarativeStateOperation
*>
(
newObject
);
if
(
parentState
&&
newPropertyChanges
)
if
(
parentState
&&
newPropertyChanges
)
{
(
*
parentState
)
<<
newPropertyChanges
;
}
break
;
}
QDeclarativeState
*
newState
=
qobject_cast
<
QDeclarativeState
*>
(
newObject
);
if
(
parentItem
&&
newState
)
{
QDeclarativeListReference
statesList
(
parentItem
,
"states"
);
statesList
.
append
(
newObject
);
break
;
}
}
while
(
false
);
}
}
...
...
src/libs/qmljs/qmljsdelta.cpp
View file @
09a78a3a
...
...
@@ -350,12 +350,31 @@ void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const Q
if
(
!
member
||
!
parentMember
)
return
;
unsigned
begin
,
end
,
startColumn
,
startLine
;
bool
accepted
=
false
;
// create new objects
if
(
UiObjectDefinition
*
uiObjectDef
=
cast
<
UiObjectDefinition
*>
(
member
))
{
unsigned
begin
=
uiObjectDef
->
firstSourceLocation
().
begin
();
unsigned
end
=
uiObjectDef
->
lastSourceLocation
().
end
();
QString
qmlText
=
QString
(
uiObjectDef
->
firstSourceLocation
().
startColumn
-
1
,
QLatin1Char
(
' '
));
begin
=
uiObjectDef
->
firstSourceLocation
().
begin
();
end
=
uiObjectDef
->
lastSourceLocation
().
end
();
startColumn
=
uiObjectDef
->
firstSourceLocation
().
startColumn
;
startLine
=
uiObjectDef
->
firstSourceLocation
().
startLine
;
accepted
=
true
;
}
if
(
UiObjectBinding
*
uiObjectBind
=
cast
<
UiObjectBinding
*>
(
member
))
{
SourceLocation
definitionLocation
=
uiObjectBind
->
qualifiedTypeNameId
->
identifierToken
;
begin
=
definitionLocation
.
begin
();
end
=
uiObjectBind
->
lastSourceLocation
().
end
();
startColumn
=
definitionLocation
.
startColumn
;
startLine
=
definitionLocation
.
startLine
;
accepted
=
true
;
}
if
(
accepted
)
{
QString
qmlText
=
QString
(
startColumn
-
1
,
QLatin1Char
(
' '
));
qmlText
+=
doc
->
source
().
midRef
(
begin
,
end
-
begin
);
QStringList
importList
;
for
(
UiImportList
*
it
=
doc
->
qmlProgram
()
->
imports
;
it
;
it
=
it
->
next
)
{
if
(
!
it
->
import
)
...
...
@@ -368,7 +387,7 @@ void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const Q
// encode editorRevision, lineNumber in URL. See ClientProxy::buildDebugIdHashRecursive
QString
filename
=
QLatin1String
(
"file://"
)
+
doc
->
fileName
()
+
QLatin1Char
(
'_'
)
+
QString
::
number
(
doc
->
editorRevision
())
+
QLatin1Char
(
':'
)
+
QString
::
number
(
uiObjectDef
->
firstSourceLocation
().
startLine
-
importList
.
count
());
+
QLatin1Char
(
':'
)
+
QString
::
number
(
startLine
-
importList
.
count
());
foreach
(
DebugId
debugId
,
debugReferences
)
{
if
(
debugId
!=
-
1
)
{
createObject
(
qmlText
,
debugId
,
importList
,
filename
);
...
...
@@ -484,11 +503,14 @@ Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::P
if
(
!
M
.
way2
.
contains
(
y
))
{
UiObjectMember
*
parent
=
parents2
.
parent
.
value
(
y
);
if
(
!
M
.
way2
.
contains
(
parent
))
continue
;
if
(
debug
)
qDebug
()
<<
"Delta::operator(): insert "
<<
label
(
y
,
doc2
)
<<
" to "
<<
label
(
parent
,
doc2
);
insert
(
y
,
parent
,
newDebuggIds
.
value
(
parent
),
doc2
);
if
(
parent
->
kind
==
QmlJS
::
AST
::
Node
::
Kind_UiArrayBinding
)
parent
=
parents2
.
parent
.
value
(
parent
);
if
(
M
.
way2
.
contains
(
parent
)
&&
newDebuggIds
.
value
(
parent
).
count
()
>
0
)
{
if
(
debug
)
qDebug
()
<<
"Delta::operator(): insert "
<<
label
(
y
,
doc2
)
<<
" to "
<<
label
(
parent
,
doc2
);
insert
(
y
,
parent
,
newDebuggIds
.
value
(
parent
),
doc2
);
}
continue
;
}
UiObjectMember
*
x
=
M
.
way2
[
y
];
...
...
@@ -500,6 +522,8 @@ Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::P
updateIds
=
debugIds
[
x
];
newDebuggIds
[
y
]
=
updateIds
;
}
if
(
debug
)
qDebug
()
<<
"Delta::operator(): update "
<<
label
(
x
,
doc1
);
update
(
x
,
doc1
,
y
,
doc2
,
updateIds
);
}
//qDebug() << "Delta::operator(): match "<< label(x, doc1) << "with parent " << label(parents1.parent.value(x), doc1)
...
...
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