Commit 33f5be4c authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.PropertyEditor: Use QmlModelNodeProxy in FileResourcesModel

Before the code was abusing the anchoring backend.

Change-Id: I716c5cfa7a5c72d500cb5ae8c943c52f84c60e91
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent edad809a
......@@ -54,7 +54,7 @@ RowLayout {
FileResourcesModel {
anchorBackendProperty: anchorBackend
modelNodeBackendProperty: modelNodeBackend
filter: urlChooser.filter
id: fileModel
}
......
......@@ -35,7 +35,7 @@
#include <QFileDialog>
#include <QDirIterator>
#include <qmlanchorbindingproxy.h>
#include <qmlmodelnodeproxy.h>
static QString s_lastBrowserPath;
......@@ -44,19 +44,19 @@ FileResourcesModel::FileResourcesModel(QObject *parent) :
{
}
void FileResourcesModel::setAnchorBackend(const QVariant &anchorBackend)
void FileResourcesModel::setModelNodeBackend(const QVariant &modelNodeBackend)
{
QObject* anchorBackendObject = anchorBackend.value<QObject*>();
QObject* modelNodeBackendObject = modelNodeBackend.value<QObject*>();
const QmlDesigner::Internal::QmlAnchorBindingProxy *backendCasted =
qobject_cast<const QmlDesigner::Internal::QmlAnchorBindingProxy *>(anchorBackendObject);
const QmlDesigner::QmlModelNodeProxy *backendObjectCasted =
qobject_cast<const QmlDesigner::QmlModelNodeProxy *>(modelNodeBackendObject);
if (backendCasted)
m_path = backendCasted->getItemNode().modelNode().model()->fileUrl();
if (backendObjectCasted)
m_path = backendObjectCasted->qmlItemNode().modelNode().model()->fileUrl();
setupModel();
emit anchorBackendChanged();
emit modelNodeBackendChanged();
}
QString FileResourcesModel::fileName() const
......@@ -150,6 +150,11 @@ void FileResourcesModel::registerDeclarativeType()
qmlRegisterType<FileResourcesModel>("HelperWidgets",2,0,"FileResourcesModel");
}
QVariant FileResourcesModel::modelNodeBackend() const
{
return QVariant();
}
void FileResourcesModel::setupModel()
{
m_lock = true;
......
......@@ -43,14 +43,14 @@ class FileResourcesModel : public QObject
Q_PROPERTY(QString fileName READ fileName WRITE setFileNameStr NOTIFY fileNameChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter)
Q_PROPERTY(QVariant anchorBackendProperty READ anchorBackend WRITE setAnchorBackend NOTIFY anchorBackendChanged)
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged)
Q_PROPERTY(QUrl path READ path WRITE setPath)
Q_PROPERTY(QStringList fileModel READ fileModel NOTIFY anchorBackendChanged)
Q_PROPERTY(QStringList fileModel READ fileModel NOTIFY modelNodeBackendChanged)
public:
explicit FileResourcesModel(QObject *parent = 0);
void setAnchorBackend(const QVariant &anchorBackend);
void setModelNodeBackend(const QVariant &modelNodeBackend);
QString fileName() const;
void setFileName(const QUrl &fileName);
void setFileNameStr(const QString &fileName);
......@@ -67,12 +67,12 @@ public:
signals:
void fileNameChanged(const QUrl &fileName);
void anchorBackendChanged();
void modelNodeBackendChanged();
public slots:
private:
QVariant anchorBackend() const {return QVariant(); }
QVariant modelNodeBackend() const;
private:
QUrl m_fileName;
......
......@@ -55,4 +55,9 @@ void QmlModelNodeProxy::emitSelectionToBeChanged()
emit selectionToBeChanged();
}
QmlItemNode QmlModelNodeProxy::qmlItemNode() const
{
return m_qmlItemNode;
}
}
......@@ -49,6 +49,8 @@ public:
void emitSelectionToBeChanged();
QmlItemNode qmlItemNode() const;
signals:
void selectionChanged();
void selectionToBeChanged();
......
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