Skip to content
GitLab
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
a8a99534
Commit
a8a99534
authored
Oct 13, 2010
by
Marco Bubke
Browse files
QmlDesigner.MetaInfo: Cleanup
parent
def8944f
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
View file @
a8a99534
...
...
@@ -573,16 +573,14 @@ QStringList NavigatorTreeModel::visibleProperties(const ModelNode &node) const
{
QStringList
propertyList
;
foreach
(
PropertyMetaInfo
propertyMetaInfo
,
node
.
metaInfo
().
properties
().
values
())
{
if
(
!
m_hiddenProperties
.
contains
(
propertyMetaInfo
.
name
())
&&
propertyMetaInfo
.
name
()
!=
node
.
metaInfo
().
defaultProperty
()
&&
propertyMetaInfo
.
isReadable
()
&&
propertyMetaInfo
.
isWriteable
())
{
foreach
(
const
QString
&
propertyName
,
node
.
metaInfo
().
propertyNamesOnlyContainer
())
{
if
(
!
m_hiddenProperties
.
contains
(
propertyName
)
&&
propertyName
!=
node
.
metaInfo
().
defaultProperty
())
{
// TODO: ask the node instances
QString
qmlType
=
qmlTypeInQtContainer
(
propertyMetaInfo
.
type
(
));
QString
qmlType
=
qmlTypeInQtContainer
(
node
.
metaInfo
().
propertyType
(
propertyName
));
if
(
node
.
metaInfo
().
metaInfo
().
hasNodeMetaInfo
(
qmlType
)
&&
node
.
metaInfo
().
metaInfo
().
nodeMetaInfo
(
qmlType
).
isSubclassOf
(
"Q
Graphics
Object"
,
-
1
,
-
1
))
{
propertyList
<<
propertyMetaInfo
.
n
ame
(
);
node
.
metaInfo
().
metaInfo
().
nodeMetaInfo
(
qmlType
).
isSubclassOf
(
"Q
t/Qt
Object"
,
4
,
7
))
{
propertyList
.
append
(
propertyN
ame
);
}
}
}
...
...
src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
View file @
a8a99534
...
...
@@ -175,7 +175,7 @@ void PropertyEditor::NodeType::setup(const QmlObjectNode &fxObjectNode, const QS
QDeclarativeContext
*
ctxt
=
m_view
->
rootContext
();
if
(
fxObjectNode
.
isValid
())
{
foreach
(
const
QString
&
propertyName
,
fxObjectNode
.
modelNode
().
metaInfo
().
propert
ies
(
true
).
key
s
())
foreach
(
const
QString
&
propertyName
,
fxObjectNode
.
modelNode
().
metaInfo
().
propert
yName
s
())
createPropertyEditorValue
(
fxObjectNode
,
propertyName
,
fxObjectNode
.
instanceValue
(
propertyName
),
&
m_backendValuesPropertyMap
,
propertyEditor
);
// className
...
...
@@ -227,8 +227,8 @@ void PropertyEditor::NodeType::initialSetup(const QString &typeName, const QUrl
NodeMetaInfo
metaInfo
=
propertyEditor
->
model
()
->
metaInfo
().
nodeMetaInfo
(
typeName
,
4
,
7
);
foreach
(
const
QString
&
propertyName
,
metaInfo
.
propert
ies
(
true
).
key
s
())
setupPropertyEditorValue
(
propertyName
,
&
m_backendValuesPropertyMap
,
propertyEditor
,
metaInfo
.
property
(
propertyName
,
true
).
type
(
));
foreach
(
const
QString
&
propertyName
,
metaInfo
.
propert
yName
s
())
setupPropertyEditorValue
(
propertyName
,
&
m_backendValuesPropertyMap
,
propertyEditor
,
metaInfo
.
property
Type
(
propertyName
));
PropertyEditorValue
*
valueObject
=
qobject_cast
<
PropertyEditorValue
*>
(
QDeclarativeMetaType
::
toQObject
(
m_backendValuesPropertyMap
.
value
(
"className"
)));
if
(
!
valueObject
)
...
...
@@ -386,8 +386,8 @@ void PropertyEditor::changeValue(const QString &propertyName)
QVariant
castedValue
;
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
isValid
()
&&
fxObjectNode
.
modelNode
().
metaInfo
().
p
roperty
(
propertyName
,
true
).
isValid
(
))
{
castedValue
=
fxObjectNode
.
modelNode
().
metaInfo
().
p
roperty
(
propertyName
,
true
).
castedValue
(
value
->
value
());
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
isValid
()
&&
fxObjectNode
.
modelNode
().
metaInfo
().
hasP
roperty
(
propertyName
))
{
castedValue
=
fxObjectNode
.
modelNode
().
metaInfo
().
nativeP
roperty
Value
(
propertyName
,
value
->
value
());
}
else
{
qWarning
()
<<
"PropertyEditor:"
<<
propertyName
<<
"cannot be casted (metainfo)"
;
return
;
...
...
@@ -398,8 +398,8 @@ void PropertyEditor::changeValue(const QString &propertyName)
return
;
}
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
isValid
()
&&
fxObjectNode
.
modelNode
().
metaInfo
().
p
roperty
(
propertyName
)
.
isValid
()
)
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
(
propertyName
)
.
type
()
==
QLatin1String
(
"QUrl"
))
{
//turn absolute local file paths into relative paths
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
isValid
()
&&
fxObjectNode
.
modelNode
().
metaInfo
().
hasP
roperty
(
propertyName
))
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
Type
(
propertyName
)
==
QLatin1String
(
"QUrl"
))
{
//turn absolute local file paths into relative paths
QString
filePath
=
castedValue
.
toUrl
().
toString
();
if
(
QFileInfo
(
filePath
).
exists
()
&&
QFileInfo
(
filePath
).
isAbsolute
())
{
QDir
fileDir
(
QFileInfo
(
model
()
->
fileUrl
().
toLocalFile
()).
absolutePath
());
...
...
@@ -446,13 +446,13 @@ void PropertyEditor::changeExpression(const QString &name)
QmlObjectNode
fxObjectNode
(
m_selectedNode
);
PropertyEditorValue
*
value
=
qobject_cast
<
PropertyEditorValue
*>
(
QDeclarativeMetaType
::
toQObject
(
m_currentType
->
m_backendValuesPropertyMap
.
value
(
underscoreName
)));
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
isValid
()
&&
fxObjectNode
.
modelNode
().
metaInfo
().
p
roperty
(
name
)
.
isValid
()
)
{
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
(
name
)
.
type
()
==
QLatin1String
(
"QColor"
))
{
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
isValid
()
&&
fxObjectNode
.
modelNode
().
metaInfo
().
hasP
roperty
(
name
))
{
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
Type
(
name
)
==
QLatin1String
(
"QColor"
))
{
if
(
QColor
(
value
->
expression
().
remove
(
'"'
)).
isValid
())
{
fxObjectNode
.
setVariantProperty
(
name
,
QColor
(
value
->
expression
().
remove
(
'"'
)));
return
;
}
}
else
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
(
name
)
.
type
()
==
QLatin1String
(
"bool"
))
{
}
else
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
Type
(
name
)
==
QLatin1String
(
"bool"
))
{
if
(
value
->
expression
().
compare
(
"false"
,
Qt
::
CaseInsensitive
)
==
0
||
value
->
expression
().
compare
(
"true"
,
Qt
::
CaseInsensitive
)
==
0
)
{
if
(
value
->
expression
().
compare
(
"true"
,
Qt
::
CaseInsensitive
)
==
0
)
fxObjectNode
.
setVariantProperty
(
name
,
true
);
...
...
@@ -460,14 +460,14 @@ void PropertyEditor::changeExpression(const QString &name)
fxObjectNode
.
setVariantProperty
(
name
,
false
);
return
;
}
}
else
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
(
name
)
.
type
()
==
QLatin1String
(
"int"
))
{
}
else
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
Type
(
name
)
==
QLatin1String
(
"int"
))
{
bool
ok
;
int
intValue
=
value
->
expression
().
toInt
(
&
ok
);
if
(
ok
)
{
fxObjectNode
.
setVariantProperty
(
name
,
intValue
);
return
;
}
}
else
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
(
name
)
.
type
()
==
QLatin1String
(
"qreal"
))
{
}
else
if
(
fxObjectNode
.
modelNode
().
metaInfo
().
property
Type
(
name
)
==
QLatin1String
(
"qreal"
))
{
bool
ok
;
qreal
realValue
=
value
->
expression
().
toFloat
(
&
ok
);
if
(
ok
)
{
...
...
@@ -561,20 +561,19 @@ QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType, const QmlO
qmlTemplate
+=
QLatin1String
(
"layout: VerticalLayout {
\n
"
);
QList
<
QString
>
orderedList
;
orderedList
=
type
.
propert
ies
(
true
).
key
s
();
orderedList
=
type
.
propert
yName
s
();
qSort
(
orderedList
);
foreach
(
const
QString
&
name
,
orderedList
)
{
const
PropertyMetaInfo
propertyMetaInfo
(
type
.
property
(
name
,
true
));
QString
properName
=
name
;
properName
.
replace
(
"."
,
"_"
);
QString
typeName
=
property
MetaInfo
.
type
(
);
QString
typeName
=
type
.
property
Type
(
name
);
//alias resolution only possible with instance
if
(
typeName
==
QLatin1String
(
"alias"
)
&&
objectNode
.
isValid
())
typeName
=
objectNode
.
instanceType
(
name
);
if
(
!
superType
.
hasProperty
(
name
,
true
))
{
if
(
!
superType
.
hasProperty
(
name
))
{
if
(
typeName
==
"int"
)
{
qmlTemplate
+=
QString
(
QLatin1String
(
"IntEditor { backendValue: backendValues.%2
\n
caption:
\"
%1
\"\n
baseStateFlag: isBaseState
\n
slider: false
\n
}"
...
...
src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp
View file @
a8a99534
...
...
@@ -53,8 +53,8 @@ PropertyEditorValue::PropertyEditorValue(QObject *parent)
QVariant
PropertyEditorValue
::
value
()
const
{
QVariant
returnValue
=
m_value
;
if
(
modelNode
().
isValid
()
&&
modelNode
().
metaInfo
().
isValid
()
&&
modelNode
().
metaInfo
().
p
roperty
(
name
())
.
isValid
()
)
if
(
modelNode
().
metaInfo
().
property
(
name
())
.
type
()
==
QLatin1String
(
"QUrl"
))
{
if
(
modelNode
().
isValid
()
&&
modelNode
().
metaInfo
().
isValid
()
&&
modelNode
().
metaInfo
().
hasP
roperty
(
name
()))
if
(
modelNode
().
metaInfo
().
property
Type
(
name
())
==
QLatin1String
(
"QUrl"
))
{
returnValue
=
returnValue
.
toUrl
().
toString
();
}
return
returnValue
;
...
...
@@ -97,8 +97,8 @@ void PropertyEditorValue::setValueWithEmit(const QVariant &value)
{
if
(
m_value
!=
value
)
{
QVariant
newValue
=
value
;
if
(
modelNode
().
isValid
()
&&
modelNode
().
metaInfo
().
isValid
()
&&
modelNode
().
metaInfo
().
p
roperty
(
name
())
.
isValid
()
)
if
(
modelNode
().
metaInfo
().
property
(
name
())
.
type
()
==
QLatin1String
(
"QUrl"
))
{
if
(
modelNode
().
isValid
()
&&
modelNode
().
metaInfo
().
isValid
()
&&
modelNode
().
metaInfo
().
hasP
roperty
(
name
()))
if
(
modelNode
().
metaInfo
().
property
Type
(
name
())
==
QLatin1String
(
"QUrl"
))
{
newValue
=
QUrl
(
newValue
.
toString
());
}
...
...
@@ -272,7 +272,7 @@ void PropertyEditorNodeWrapper::add(const QString &type)
if
((
m_editorValue
&&
m_editorValue
->
modelNode
().
isValid
()))
{
if
(
propertyType
.
isEmpty
())
propertyType
=
m_editorValue
->
modelNode
().
metaInfo
().
property
(
m_editorValue
->
name
())
.
type
()
;
propertyType
=
m_editorValue
->
modelNode
().
metaInfo
().
property
Type
(
m_editorValue
->
name
());
while
(
propertyType
.
contains
(
'*'
))
//strip star
propertyType
.
chop
(
1
);
m_modelNode
=
m_editorValue
->
modelNode
().
view
()
->
createModelNode
(
propertyType
,
4
,
7
);
...
...
@@ -332,7 +332,7 @@ void PropertyEditorNodeWrapper::setup()
foreach
(
QObject
*
object
,
m_valuesPropertyMap
.
children
())
delete
object
;
foreach
(
const
QString
&
propertyName
,
m_modelNode
.
metaInfo
().
propert
ies
().
key
s
())
{
foreach
(
const
QString
&
propertyName
,
m_modelNode
.
metaInfo
().
propert
yName
s
())
{
if
(
fxObjectNode
.
isValid
())
{
PropertyEditorValue
*
valueObject
=
new
PropertyEditorValue
(
&
m_valuesPropertyMap
);
valueObject
->
setName
(
propertyName
);
...
...
src/plugins/qmldesigner/designercore/include/nodemetainfo.h
View file @
a8a99534
...
...
@@ -77,11 +77,14 @@ public:
bool
isValid
()
const
;
MetaInfo
metaInfo
()
const
;
PropertyMetaInfo
property
(
const
QString
&
propertyName
,
bool
resolveDotSyntax
=
false
)
const
;
QList
<
NodeMetaInfo
>
superClasses
()
const
;
NodeMetaInfo
directSuperClass
()
const
;
QHash
<
QString
,
PropertyMetaInfo
>
properties
(
bool
resolveDotSyntax
=
false
)
const
;
QStringList
propertyNames
()
const
;
QStringList
propertyNamesOnlyContainer
()
const
;
QString
propertyType
(
const
QString
&
propertyName
)
const
;
QVariant
nativePropertyValue
(
const
QString
&
propertyName
,
const
QVariant
&
value
)
const
;
QString
typeName
()
const
;
int
majorVersion
()
const
;
...
...
@@ -92,7 +95,7 @@ public:
bool
hasDefaultProperty
()
const
;
QString
defaultProperty
()
const
;
bool
hasProperty
(
const
QString
&
propertyName
,
bool
resolveDotSyntax
=
false
)
const
;
bool
hasProperty
(
const
QString
&
propertyName
)
const
;
bool
isContainer
()
const
;
bool
isComponent
()
const
;
bool
isSubclassOf
(
const
QString
&
type
,
int
majorVersion
,
int
minorVersio
)
const
;
...
...
@@ -113,8 +116,11 @@ private:
void
setDefaultProperty
(
const
QString
&
defaultProperty
);
void
setSuperClass
(
const
QString
&
typeName
,
int
majorVersion
=
-
1
,
int
minorVersion
=
-
1
);
bool
hasLocalProperty
(
const
QString
&
propertyName
,
bool
resolveDotSyntax
=
fals
e
)
const
;
bool
hasLocalProperty
(
const
QString
&
propertyName
,
bool
resolveDotSyntax
=
tru
e
)
const
;
QHash
<
QString
,
PropertyMetaInfo
>
dotProperties
()
const
;
QHash
<
QString
,
PropertyMetaInfo
>
properties
(
bool
resolveDotSyntax
=
true
)
const
;
PropertyMetaInfo
property
(
const
QString
&
propertyName
,
bool
resolveDotSyntax
=
true
)
const
;
private:
QExplicitlySharedDataPointer
<
Internal
::
NodeMetaInfoData
>
m_data
;
...
...
src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
View file @
a8a99534
...
...
@@ -255,9 +255,9 @@ QHash<QString,PropertyMetaInfo> NodeMetaInfo::dotProperties() const
QHash
<
QString
,
PropertyMetaInfo
>
propertiesInfo
;
foreach
(
const
QString
&
propertyName
,
properties
().
keys
())
{
foreach
(
const
QString
&
propertyName
,
properties
(
false
).
keys
())
{
if
(
property
(
propertyName
).
hasDotSubProperties
())
{
QString
propertyType
=
property
(
propertyName
).
type
();
QString
propertyType
=
property
(
propertyName
,
false
).
type
();
if
(
propertyType
.
right
(
1
)
==
"*"
)
propertyType
=
propertyType
.
left
(
propertyType
.
size
()
-
1
).
trimmed
();
...
...
@@ -377,17 +377,17 @@ bool NodeMetaInfo::hasLocalProperty(const QString &propertyName, bool resolveDot
\throws InvalidMetaInfoException if the object is not valid
*/
bool
NodeMetaInfo
::
hasProperty
(
const
QString
&
propertyName
,
bool
resolveDotSyntax
)
const
bool
NodeMetaInfo
::
hasProperty
(
const
QString
&
propertyName
)
const
{
if
(
!
isValid
())
{
qWarning
()
<<
"NodeMetaInfo is invalid"
;
return
false
;
}
if
(
hasLocalProperty
(
propertyName
,
resolveDotSyntax
))
if
(
hasLocalProperty
(
propertyName
,
true
))
return
true
;
if
(
directSuperClass
().
isValid
()
&&
directSuperClass
().
hasProperty
(
propertyName
,
resolveDotSyntax
))
if
(
directSuperClass
().
isValid
()
&&
directSuperClass
().
hasProperty
(
propertyName
))
return
true
;
return
false
;
...
...
@@ -610,6 +610,38 @@ bool NodeMetaInfo::isSubclassOf(const QString &type, int majorVersion, int minor
return
false
;
}
QStringList
NodeMetaInfo
::
propertyNames
()
const
{
return
properties
(
true
).
keys
();
}
QStringList
NodeMetaInfo
::
propertyNamesOnlyContainer
()
const
{
QStringList
nameList
;
foreach
(
const
PropertyMetaInfo
&
propertyMetaInfo
,
properties
(
true
).
values
())
{
if
(
propertyMetaInfo
.
isReadable
()
&&
propertyMetaInfo
.
isWriteable
())
nameList
.
append
(
propertyMetaInfo
.
name
());
}
return
nameList
;
}
QString
NodeMetaInfo
::
propertyType
(
const
QString
&
propertyName
)
const
{
if
(
!
hasProperty
(
propertyName
))
return
QString
();
return
property
(
propertyName
).
type
();
}
QVariant
NodeMetaInfo
::
nativePropertyValue
(
const
QString
&
propertyName
,
const
QVariant
&
value
)
const
{
if
(
!
hasProperty
(
propertyName
))
return
value
;
return
property
(
propertyName
).
castedValue
(
value
);
}
void
NodeMetaInfo
::
setQmlFile
(
const
QString
&
filePath
)
{
if
(
!
isValid
())
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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