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
Marco Bubke
flatpak-qt-creator
Commits
478907e5
Commit
478907e5
authored
Jan 26, 2010
by
Roberto Raggi
Browse files
Added method defaultValueForBuiltinType(typeName) to the QML/JS interpreter.
parent
84d72107
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsinterpreter.cpp
View file @
478907e5
...
...
@@ -1680,6 +1680,19 @@ const ObjectValue *Engine::qmlKeysObject()
return
_qmlKeysObject
;
}
const
Value
*
Engine
::
defaultValueForBuiltinType
(
const
QString
&
typeName
)
const
{
if
(
typeName
==
QLatin1String
(
"string"
)
||
typeName
==
QLatin1String
(
"url"
))
return
stringValue
();
else
if
(
typeName
==
QLatin1String
(
"bool"
))
return
booleanValue
();
else
if
(
typeName
==
QLatin1String
(
"int"
)
||
typeName
==
QLatin1String
(
"real"
))
return
numberValue
();
// ### more types...
return
undefinedValue
();
}
ObjectValue
*
Engine
::
newQmlObject
(
const
QString
&
name
)
{
#ifndef NO_DECLARATIVE_BACKEND
...
...
src/libs/qmljs/qmljsinterpreter.h
View file @
478907e5
...
...
@@ -442,6 +442,7 @@ public:
// QML objects
ObjectValue
*
newQmlObject
(
const
QString
&
name
);
const
ObjectValue
*
qmlKeysObject
();
const
Value
*
defaultValueForBuiltinType
(
const
QString
&
typeName
)
const
;
// global object
ObjectValue
*
globalObject
()
const
;
...
...
src/plugins/qmljseditor/qmlcodecompletion.cpp
View file @
478907e5
...
...
@@ -134,15 +134,7 @@ static Interpreter::ObjectValue *newComponent(Interpreter::Engine *engine, const
const
QString
propName
=
prop
->
name
->
asString
();
const
QString
propType
=
prop
->
memberType
->
asString
();
// ### generalize
if
(
propType
==
QLatin1String
(
"string"
)
||
propType
==
QLatin1String
(
"url"
))
object
->
setProperty
(
propName
,
engine
->
stringValue
());
else
if
(
propType
==
QLatin1String
(
"bool"
))
object
->
setProperty
(
propName
,
engine
->
booleanValue
());
else
if
(
propType
==
QLatin1String
(
"int"
)
||
propType
==
QLatin1String
(
"real"
))
object
->
setProperty
(
propName
,
engine
->
numberValue
());
else
object
->
setProperty
(
propName
,
engine
->
undefinedValue
());
object
->
setProperty
(
propName
,
engine
->
defaultValueForBuiltinType
(
propType
));
}
}
}
...
...
@@ -867,13 +859,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
const
QString
propName
=
prop
->
name
->
asString
();
const
QString
propType
=
prop
->
memberType
->
asString
();
// ### TODO: generalize
if
(
propType
==
QLatin1String
(
"string"
)
||
propType
==
QLatin1String
(
"url"
))
interp
.
globalObject
()
->
setProperty
(
propName
,
interp
.
stringValue
());
else
if
(
propType
==
QLatin1String
(
"bool"
))
interp
.
globalObject
()
->
setProperty
(
propName
,
interp
.
booleanValue
());
else
if
(
propType
==
QLatin1String
(
"int"
)
||
propType
==
QLatin1String
(
"real"
))
interp
.
globalObject
()
->
setProperty
(
propName
,
interp
.
numberValue
());
interp
.
globalObject
()
->
setProperty
(
propName
,
interp
.
defaultValueForBuiltinType
(
propType
));
}
// Get the name of the declaring item.
...
...
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