Commit 2b0f93c8 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.PropertyEditorView: further cleanup

Cleaning up/renaming the functions used to resolve .qml files.

Change-Id: I80ccb9346d89c0841ad0109147d8a9e07cf20408
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 00eccf6b
......@@ -403,6 +403,10 @@ QString PropertyEditorQmlBackend::templateGeneration(NodeMetaInfo type,
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)
{
......@@ -447,7 +451,12 @@ QString PropertyEditorQmlBackend::fileFromUrl(const QUrl &url)
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()) {
QList<NodeMetaInfo> hierarchy;
......
......@@ -36,6 +36,8 @@
#include "propertyeditorcontextobject.h"
#include "quickpropertyeditorview.h"
#include <nodemetainfo.h>
class PropertyEditorValue;
namespace QmlDesigner {
......@@ -66,13 +68,10 @@ public:
static QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType,
const QmlObjectNode &objectNode);
static QString qmlFileName(const NodeMetaInfo &nodeInfo) ;
static QUrl fileToUrl(const QString &filePath) ;
static QString fileFromUrl(const QUrl &url) ;
static QUrl qmlForNode(const ModelNode &modelNode, TypeName &className) ;
static QString locateQmlFile(const NodeMetaInfo &info, const QString &relativePath) ;
static QUrl getQmlFileUrl(const QString &relativeTypeName, const NodeMetaInfo &info = NodeMetaInfo());
static QUrl getQmlUrlForModelNode(const ModelNode &modelNode, TypeName &className);
static QString fixTypeNameForPanes(const QString &typeName);
static bool checkIfUrlExists(const QUrl &url);
private:
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
......@@ -80,6 +79,12 @@ private:
PropertyEditorView *propertyEditor);
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:
QuickPropertyEditorView *m_view;
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
......
......@@ -100,13 +100,10 @@ void PropertyEditorView::setupPane(const TypeName &typeName)
{
NodeMetaInfo metaInfo = model()->metaInfo(typeName);
QUrl qmlFile = PropertyEditorQmlBackend::fileToUrl(
PropertyEditorQmlBackend::locateQmlFile(metaInfo, QLatin1String("Qt/ItemPane.qml")));
QUrl qmlFile = PropertyEditorQmlBackend::getQmlFileUrl(QLatin1String("Qt/ItemPane"), metaInfo);
QUrl qmlSpecificsFile;
qmlSpecificsFile = PropertyEditorQmlBackend::fileToUrl(PropertyEditorQmlBackend::locateQmlFile(
metaInfo, PropertyEditorQmlBackend::fixTypeNameForPanes(typeName)
+ "Specifics.qml"));
qmlSpecificsFile = PropertyEditorQmlBackend::getQmlFileUrl(typeName + "Specifics", metaInfo);
PropertyEditorQmlBackend *qmlBackend = m_qmlBackendHash.value(qmlFile.toString());
......@@ -364,7 +361,7 @@ void PropertyEditorView::resetView()
m_selectedNode = ModelNode();
TypeName specificsClassName;
QUrl qmlFile(PropertyEditorQmlBackend::qmlForNode(m_selectedNode, specificsClassName));
QUrl qmlFile(PropertyEditorQmlBackend::getQmlUrlForModelNode(m_selectedNode, specificsClassName));
QUrl qmlSpecificsFile;
TypeName diffClassName;
......@@ -374,18 +371,15 @@ void PropertyEditorView::resetView()
hierarchy << m_selectedNode.metaInfo();
hierarchy << m_selectedNode.metaInfo().superClasses();
foreach (const NodeMetaInfo &info, hierarchy) {
if (QFileInfo(PropertyEditorQmlBackend::fileFromUrl(qmlSpecificsFile)).exists())
foreach (const NodeMetaInfo &metaInfo, hierarchy) {
if (PropertyEditorQmlBackend::checkIfUrlExists(qmlSpecificsFile))
break;
qmlSpecificsFile = PropertyEditorQmlBackend::fileToUrl(PropertyEditorQmlBackend::locateQmlFile(
info,
PropertyEditorQmlBackend::fixTypeNameForPanes(info.typeName())
+ "Specifics.qml"));
diffClassName = info.typeName();
qmlSpecificsFile = PropertyEditorQmlBackend::getQmlFileUrl(metaInfo.typeName() + QLatin1String("Specifics"), metaInfo);
diffClassName = metaInfo.typeName();
}
}
if (!QFileInfo(PropertyEditorQmlBackend::fileFromUrl(qmlSpecificsFile)).exists())
if (!PropertyEditorQmlBackend::checkIfUrlExists(qmlSpecificsFile))
diffClassName = specificsClassName;
QString specificQmlData;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment