forked from qt-creator/qt-creator
QmlDesigner.PropertyEditorView: further cleanup
Cleaning up/renaming the functions used to resolve .qml files. Change-Id: I80ccb9346d89c0841ad0109147d8a9e07cf20408 Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
@@ -403,6 +403,10 @@ QString PropertyEditorQmlBackend::templateGeneration(NodeMetaInfo type,
|
|||||||
return qmlTemplate;
|
return qmlTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUrl PropertyEditorQmlBackend::getQmlFileUrl(const QString &relativeTypeName, const NodeMetaInfo &info)
|
||||||
|
{
|
||||||
|
return fileToUrl(locateQmlFile(info, fixTypeNameForPanes(relativeTypeName) + QLatin1String(".qml")));
|
||||||
|
}
|
||||||
|
|
||||||
QString PropertyEditorQmlBackend::fixTypeNameForPanes(const QString &typeName)
|
QString PropertyEditorQmlBackend::fixTypeNameForPanes(const QString &typeName)
|
||||||
{
|
{
|
||||||
@@ -447,7 +451,12 @@ QString PropertyEditorQmlBackend::fileFromUrl(const QUrl &url)
|
|||||||
return url.toLocalFile();
|
return url.toLocalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl PropertyEditorQmlBackend::qmlForNode(const ModelNode &modelNode, TypeName &className)
|
bool PropertyEditorQmlBackend::checkIfUrlExists(const QUrl &url)
|
||||||
|
{
|
||||||
|
return (QFileInfo(fileFromUrl(url)).exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl PropertyEditorQmlBackend::getQmlUrlForModelNode(const ModelNode &modelNode, TypeName &className)
|
||||||
{
|
{
|
||||||
if (modelNode.isValid()) {
|
if (modelNode.isValid()) {
|
||||||
QList<NodeMetaInfo> hierarchy;
|
QList<NodeMetaInfo> hierarchy;
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
#include "propertyeditorcontextobject.h"
|
#include "propertyeditorcontextobject.h"
|
||||||
#include "quickpropertyeditorview.h"
|
#include "quickpropertyeditorview.h"
|
||||||
|
|
||||||
|
#include <nodemetainfo.h>
|
||||||
|
|
||||||
class PropertyEditorValue;
|
class PropertyEditorValue;
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -66,13 +68,10 @@ public:
|
|||||||
static QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType,
|
static QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType,
|
||||||
const QmlObjectNode &objectNode);
|
const QmlObjectNode &objectNode);
|
||||||
|
|
||||||
static QString qmlFileName(const NodeMetaInfo &nodeInfo) ;
|
static QUrl getQmlFileUrl(const QString &relativeTypeName, const NodeMetaInfo &info = NodeMetaInfo());
|
||||||
static QUrl fileToUrl(const QString &filePath) ;
|
static QUrl getQmlUrlForModelNode(const ModelNode &modelNode, TypeName &className);
|
||||||
static QString fileFromUrl(const QUrl &url) ;
|
|
||||||
static QUrl qmlForNode(const ModelNode &modelNode, TypeName &className) ;
|
|
||||||
static QString locateQmlFile(const NodeMetaInfo &info, const QString &relativePath) ;
|
|
||||||
|
|
||||||
static QString fixTypeNameForPanes(const QString &typeName);
|
static bool checkIfUrlExists(const QUrl &url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
|
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
|
||||||
@@ -80,6 +79,12 @@ private:
|
|||||||
PropertyEditorView *propertyEditor);
|
PropertyEditorView *propertyEditor);
|
||||||
void setupPropertyEditorValue(const PropertyName &name, PropertyEditorView *propertyEditor, const QString &type);
|
void setupPropertyEditorValue(const PropertyName &name, PropertyEditorView *propertyEditor, const QString &type);
|
||||||
|
|
||||||
|
static QString qmlFileName(const NodeMetaInfo &nodeInfo);
|
||||||
|
static QUrl fileToUrl(const QString &filePath);
|
||||||
|
static QString fileFromUrl(const QUrl &url);
|
||||||
|
static QString locateQmlFile(const NodeMetaInfo &info, const QString &relativePath);
|
||||||
|
static QString fixTypeNameForPanes(const QString &typeName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QuickPropertyEditorView *m_view;
|
QuickPropertyEditorView *m_view;
|
||||||
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
|
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
|
||||||
|
@@ -100,13 +100,10 @@ void PropertyEditorView::setupPane(const TypeName &typeName)
|
|||||||
{
|
{
|
||||||
NodeMetaInfo metaInfo = model()->metaInfo(typeName);
|
NodeMetaInfo metaInfo = model()->metaInfo(typeName);
|
||||||
|
|
||||||
QUrl qmlFile = PropertyEditorQmlBackend::fileToUrl(
|
QUrl qmlFile = PropertyEditorQmlBackend::getQmlFileUrl(QLatin1String("Qt/ItemPane"), metaInfo);
|
||||||
PropertyEditorQmlBackend::locateQmlFile(metaInfo, QLatin1String("Qt/ItemPane.qml")));
|
|
||||||
QUrl qmlSpecificsFile;
|
QUrl qmlSpecificsFile;
|
||||||
|
|
||||||
qmlSpecificsFile = PropertyEditorQmlBackend::fileToUrl(PropertyEditorQmlBackend::locateQmlFile(
|
qmlSpecificsFile = PropertyEditorQmlBackend::getQmlFileUrl(typeName + "Specifics", metaInfo);
|
||||||
metaInfo, PropertyEditorQmlBackend::fixTypeNameForPanes(typeName)
|
|
||||||
+ "Specifics.qml"));
|
|
||||||
|
|
||||||
PropertyEditorQmlBackend *qmlBackend = m_qmlBackendHash.value(qmlFile.toString());
|
PropertyEditorQmlBackend *qmlBackend = m_qmlBackendHash.value(qmlFile.toString());
|
||||||
|
|
||||||
@@ -364,7 +361,7 @@ void PropertyEditorView::resetView()
|
|||||||
m_selectedNode = ModelNode();
|
m_selectedNode = ModelNode();
|
||||||
|
|
||||||
TypeName specificsClassName;
|
TypeName specificsClassName;
|
||||||
QUrl qmlFile(PropertyEditorQmlBackend::qmlForNode(m_selectedNode, specificsClassName));
|
QUrl qmlFile(PropertyEditorQmlBackend::getQmlUrlForModelNode(m_selectedNode, specificsClassName));
|
||||||
QUrl qmlSpecificsFile;
|
QUrl qmlSpecificsFile;
|
||||||
|
|
||||||
TypeName diffClassName;
|
TypeName diffClassName;
|
||||||
@@ -374,18 +371,15 @@ void PropertyEditorView::resetView()
|
|||||||
hierarchy << m_selectedNode.metaInfo();
|
hierarchy << m_selectedNode.metaInfo();
|
||||||
hierarchy << m_selectedNode.metaInfo().superClasses();
|
hierarchy << m_selectedNode.metaInfo().superClasses();
|
||||||
|
|
||||||
foreach (const NodeMetaInfo &info, hierarchy) {
|
foreach (const NodeMetaInfo &metaInfo, hierarchy) {
|
||||||
if (QFileInfo(PropertyEditorQmlBackend::fileFromUrl(qmlSpecificsFile)).exists())
|
if (PropertyEditorQmlBackend::checkIfUrlExists(qmlSpecificsFile))
|
||||||
break;
|
break;
|
||||||
qmlSpecificsFile = PropertyEditorQmlBackend::fileToUrl(PropertyEditorQmlBackend::locateQmlFile(
|
qmlSpecificsFile = PropertyEditorQmlBackend::getQmlFileUrl(metaInfo.typeName() + QLatin1String("Specifics"), metaInfo);
|
||||||
info,
|
diffClassName = metaInfo.typeName();
|
||||||
PropertyEditorQmlBackend::fixTypeNameForPanes(info.typeName())
|
|
||||||
+ "Specifics.qml"));
|
|
||||||
diffClassName = info.typeName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!QFileInfo(PropertyEditorQmlBackend::fileFromUrl(qmlSpecificsFile)).exists())
|
if (!PropertyEditorQmlBackend::checkIfUrlExists(qmlSpecificsFile))
|
||||||
diffClassName = specificsClassName;
|
diffClassName = specificsClassName;
|
||||||
|
|
||||||
QString specificQmlData;
|
QString specificQmlData;
|
||||||
|
Reference in New Issue
Block a user