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
94270c43
Commit
94270c43
authored
Mar 31, 2010
by
Thomas Hartmann
Browse files
QmlDesigner: propertyEditor - component editing
parent
e0c53622
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
View file @
94270c43
...
...
@@ -601,6 +601,43 @@ void PropertyEditor::timerEvent(QTimerEvent *timerEvent)
}
}
QString
templateGeneration
(
NodeMetaInfo
type
,
NodeMetaInfo
superType
)
{
QString
qmlTemplate
=
QLatin1String
(
"import Qt 4.6
\n
import Bauhaus 1.0
\n
"
);
qmlTemplate
+=
QLatin1String
(
"GroupBox {
\n
"
);
qmlTemplate
+=
QString
(
QLatin1String
(
"caption:
\"
%1
\"\n
"
)).
arg
(
type
.
typeName
());
qmlTemplate
+=
QLatin1String
(
"layout: VerticalLayout {
\n
"
);
foreach
(
const
PropertyMetaInfo
&
propertyMetaInfo
,
type
.
properties
()){
if
(
!
superType
.
hasProperty
(
propertyMetaInfo
.
name
()))
{
if
(
propertyMetaInfo
.
type
()
==
"int"
)
{
qmlTemplate
+=
QString
(
QLatin1String
(
"IntEditor { backendValue: backendValues.%1
\n
caption:
\"
%1
\"\n
baseStateFlag: isBaseState
\n
slider: false
\n
}"
)).
arg
(
propertyMetaInfo
.
name
());
}
if
(
propertyMetaInfo
.
type
()
==
"real"
||
propertyMetaInfo
.
type
()
==
"double"
)
{
qmlTemplate
+=
QString
(
QLatin1String
(
"DoubleSpinBoxAlternate {
\n
text:
\"
%1
\"\n
backendValue: backendValues.%1
\n
baseStateFlag: isBaseState
\n
}
\n
"
)).
arg
(
propertyMetaInfo
.
name
());
}
if
(
propertyMetaInfo
.
type
()
==
"string"
)
{
qmlTemplate
+=
QString
(
QLatin1String
(
"QWidget {
\n
layout: HorizontalLayout {
\n
Label {
\n
text:
\"
%1
\"\n
}
\n
LineEdit {
\n
backendValue: backendValues.%1
\n
baseStateFlag: isBaseState
\n
}
\n
}
\n
}
\n
"
)).
arg
(
propertyMetaInfo
.
name
());
}
if
(
propertyMetaInfo
.
type
()
==
"bool"
)
{
qmlTemplate
+=
QString
(
QLatin1String
(
"CheckBox {
\n
text:
\"
%1
\"\n
backendValue: backendValues.visible
\n
baseStateFlag: isBaseState
\n
checkable: true
\n
}
\n
"
)).
arg
(
propertyMetaInfo
.
name
());
}
}
}
qmlTemplate
+=
QLatin1String
(
"}
\n
"
);
//VerticalLayout
qmlTemplate
+=
QLatin1String
(
"}
\n
"
);
//GroupBox
return
qmlTemplate
;
}
void
PropertyEditor
::
resetView
()
{
if
(
model
()
==
0
)
...
...
@@ -618,14 +655,22 @@ void PropertyEditor::resetView()
if
(
m_selectedNode
.
isValid
()
&&
model
()
!=
m_selectedNode
.
model
())
m_selectedNode
=
ModelNode
();
QUrl
qmlFile
(
qmlForNode
(
m_selectedNode
));
QString
specificsClassName
;
QUrl
qmlFile
(
qmlForNode
(
m_selectedNode
,
specificsClassName
));
QUrl
qmlSpecificsFile
;
if
(
m_selectedNode
.
isValid
())
qmlSpecificsFile
=
fileToUrl
(
locateQmlFile
(
m_selectedNode
.
type
()
+
"Specifics.qml"
));
m_locked
=
true
;
NodeType
*
type
=
m_typeHash
.
value
(
qmlFile
.
toString
());
QString
specificQmlData
;
if
(
m_selectedNode
.
isValid
()
&&
!
QFileInfo
(
qmlSpecificsFile
.
toLocalFile
()).
exists
())
{
//do magic !!
specificQmlData
=
templateGeneration
(
m_selectedNode
.
metaInfo
(),
model
()
->
metaInfo
().
nodeMetaInfo
(
specificsClassName
));
}
NodeType
*
type
=
m_typeHash
.
value
(
qmlFile
.
toString
());
if
(
!
type
)
{
type
=
new
NodeType
(
this
);
...
...
@@ -638,10 +683,13 @@ void PropertyEditor::resetView()
fxObjectNode
=
QmlObjectNode
(
m_selectedNode
);
Q_ASSERT
(
fxObjectNode
.
isValid
());
}
type
->
setup
(
fxObjectNode
,
currentState
().
name
(),
qmlSpecificsFile
,
this
);
QDeclarativeContext
*
ctxt
=
type
->
m_view
->
rootContext
();
ctxt
->
setContextProperty
(
"finishedNotify"
,
QVariant
(
false
));
if
(
specificQmlData
.
isEmpty
())
ctxt
->
setContextProperty
(
"specificQmlData"
,
specificQmlData
);
type
->
setup
(
fxObjectNode
,
currentState
().
name
(),
qmlSpecificsFile
,
this
);
ctxt
->
setContextProperty
(
"globalBaseUrl"
,
QVariant
(
qmlFile
));
ctxt
->
setContextProperty
(
"specificQmlData"
,
specificQmlData
);
type
->
m_view
->
setSource
(
qmlFile
);
ctxt
->
setContextProperty
(
"finishedNotify"
,
QVariant
(
true
));
}
else
{
...
...
@@ -654,7 +702,11 @@ void PropertyEditor::resetView()
ctxt
->
setContextProperty
(
"selectionChanged"
,
QVariant
(
true
));
ctxt
->
setContextProperty
(
"selectionChanged"
,
QVariant
(
false
));
ctxt
->
setContextProperty
(
"finishedNotify"
,
QVariant
(
false
));
if
(
specificQmlData
.
isEmpty
())
ctxt
->
setContextProperty
(
"specificQmlData"
,
specificQmlData
);
type
->
setup
(
fxObjectNode
,
currentState
().
name
(),
qmlSpecificsFile
,
this
);
ctxt
->
setContextProperty
(
"globalBaseUrl"
,
QVariant
(
qmlFile
));
ctxt
->
setContextProperty
(
"specificQmlData"
,
specificQmlData
);
}
m_stackedWidget
->
setCurrentWidget
(
type
->
m_view
);
...
...
@@ -857,7 +909,7 @@ QUrl PropertyEditor::fileToUrl(const QString &filePath) const {
return
fileUrl
;
}
QUrl
PropertyEditor
::
qmlForNode
(
const
ModelNode
&
modelNode
)
const
QUrl
PropertyEditor
::
qmlForNode
(
const
ModelNode
&
modelNode
,
QString
&
className
)
const
{
if
(
modelNode
.
isValid
())
{
QList
<
NodeMetaInfo
>
hierarchy
;
...
...
@@ -866,8 +918,10 @@ QUrl PropertyEditor::qmlForNode(const ModelNode &modelNode) const
foreach
(
const
NodeMetaInfo
&
info
,
hierarchy
)
{
QUrl
fileUrl
=
fileToUrl
(
locateQmlFile
(
qmlFileName
(
info
)));
if
(
fileUrl
.
isValid
())
if
(
fileUrl
.
isValid
())
{
className
=
info
.
typeName
();
return
fileUrl
;
}
}
}
return
fileToUrl
(
QDir
(
m_qmlDir
).
filePath
(
"Qt/emptyPane.qml"
));
...
...
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