Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
6622947c
Commit
6622947c
authored
Sep 23, 2010
by
Erik Verbruggen
Browse files
QML editor: also check for objectName property when guessing the name.
parent
825562eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
View file @
6622947c
...
@@ -46,8 +46,23 @@ using namespace QmlJSEditor::Internal;
...
@@ -46,8 +46,23 @@ using namespace QmlJSEditor::Internal;
namespace
{
namespace
{
static
QString
toString
(
Statement
*
statement
)
{
ExpressionStatement
*
expStmt
=
cast
<
ExpressionStatement
*>
(
statement
);
if
(
!
expStmt
)
return
QString
::
null
;
if
(
IdentifierExpression
*
idExp
=
cast
<
IdentifierExpression
*>
(
expStmt
->
expression
))
{
return
idExp
->
name
->
asString
();
}
else
if
(
StringLiteral
*
strExp
=
cast
<
StringLiteral
*>
(
expStmt
->
expression
))
{
return
strExp
->
value
->
asString
();
}
return
QString
::
null
;
}
static
QString
getIdProperty
(
UiObjectDefinition
*
def
)
static
QString
getIdProperty
(
UiObjectDefinition
*
def
)
{
{
QString
objectName
;
if
(
def
&&
def
->
initializer
)
{
if
(
def
&&
def
->
initializer
)
{
for
(
UiObjectMemberList
*
iter
=
def
->
initializer
->
members
;
iter
;
iter
=
iter
->
next
)
{
for
(
UiObjectMemberList
*
iter
=
def
->
initializer
->
members
;
iter
;
iter
=
iter
->
next
)
{
if
(
UiScriptBinding
*
script
=
cast
<
UiScriptBinding
*>
(
iter
->
member
))
{
if
(
UiScriptBinding
*
script
=
cast
<
UiScriptBinding
*>
(
iter
->
member
))
{
...
@@ -56,22 +71,16 @@ static QString getIdProperty(UiObjectDefinition *def)
...
@@ -56,22 +71,16 @@ static QString getIdProperty(UiObjectDefinition *def)
if
(
script
->
qualifiedId
->
next
)
if
(
script
->
qualifiedId
->
next
)
continue
;
continue
;
if
(
script
->
qualifiedId
->
name
)
{
if
(
script
->
qualifiedId
->
name
)
{
if
(
script
->
qualifiedId
->
name
->
asString
()
==
QLatin1String
(
"id"
))
{
if
(
script
->
qualifiedId
->
name
->
asString
()
==
QLatin1String
(
"id"
))
ExpressionStatement
*
expStmt
=
cast
<
ExpressionStatement
*>
(
script
->
statement
);
return
toString
(
script
->
statement
);
if
(
!
expStmt
)
if
(
script
->
qualifiedId
->
name
->
asString
()
==
QLatin1String
(
"objectName"
))
continue
;
objectName
=
toString
(
script
->
statement
);
if
(
IdentifierExpression
*
idExp
=
cast
<
IdentifierExpression
*>
(
expStmt
->
expression
))
{
return
idExp
->
name
->
asString
();
}
else
if
(
StringLiteral
*
strExp
=
cast
<
StringLiteral
*>
(
expStmt
->
expression
))
{
return
strExp
->
value
->
asString
();
}
}
}
}
}
}
}
}
}
}
return
QString
()
;
return
objectName
;
}
}
class
Operation
:
public
QmlJSQuickFixOperation
class
Operation
:
public
QmlJSQuickFixOperation
...
@@ -90,7 +99,7 @@ public:
...
@@ -90,7 +99,7 @@ public:
if
(
m_componentName
.
isEmpty
())
{
if
(
m_componentName
.
isEmpty
())
{
setDescription
(
QCoreApplication
::
translate
(
"QmlJSEditor::ComponentFromObjectDef"
,
setDescription
(
QCoreApplication
::
translate
(
"QmlJSEditor::ComponentFromObjectDef"
,
"Move Component into separate file
'
"
));
"Move Component into separate file"
));
}
else
{
}
else
{
m_componentName
[
0
]
=
m_componentName
.
at
(
0
).
toUpper
();
m_componentName
[
0
]
=
m_componentName
.
at
(
0
).
toUpper
();
setDescription
(
QCoreApplication
::
translate
(
"QmlJSEditor::ComponentFromObjectDef"
,
setDescription
(
QCoreApplication
::
translate
(
"QmlJSEditor::ComponentFromObjectDef"
,
...
...
Write
Preview
Supports
Markdown
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