forked from qt-creator/qt-creator
QmlDesigner.NodeInstances: Use dummy data for components too
Reviewed-By: Thomas Hartmann
This commit is contained in:
@@ -124,6 +124,9 @@ QList<ServerNodeInstance> NodeInstanceServer::createInstances(const QVector<Ins
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (QDeclarativeContext* context, allSubContextsForObject(instance.internalObject()))
|
||||||
|
setupDummysForContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return instanceList;
|
return instanceList;
|
||||||
@@ -474,6 +477,43 @@ void NodeInstanceServer::clearChangedPropertyList()
|
|||||||
m_changedPropertyList.clear();
|
m_changedPropertyList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeInstanceServer::setupDummysForContext(QDeclarativeContext *context)
|
||||||
|
{
|
||||||
|
foreach (const DummyPair& dummyPair, m_dummyObjectList) {
|
||||||
|
if (dummyPair.second) {
|
||||||
|
context->setContextProperty(dummyPair.first, dummyPair.second.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QDeclarativeContext*> NodeInstanceServer::allSubContextsForObject(QObject *object)
|
||||||
|
{
|
||||||
|
QList<QDeclarativeContext*> contextList;
|
||||||
|
|
||||||
|
if (object) {
|
||||||
|
foreach (QObject *subObject, allSubObjectsForObject(object)) {
|
||||||
|
QDeclarativeContext *contextOfObject = QDeclarativeEngine::contextForObject(subObject);
|
||||||
|
if (contextOfObject) {
|
||||||
|
if (contextOfObject != context() && !contextList.contains(contextOfObject))
|
||||||
|
contextList.append(contextOfObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return contextList;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> NodeInstanceServer::allSubObjectsForObject(QObject *object)
|
||||||
|
{
|
||||||
|
QList<QObject*> subChildren;
|
||||||
|
if (object) {
|
||||||
|
subChildren = object->findChildren<QObject*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return subChildren;
|
||||||
|
}
|
||||||
|
|
||||||
void NodeInstanceServer::refreshBindings()
|
void NodeInstanceServer::refreshBindings()
|
||||||
{
|
{
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
@@ -1003,6 +1043,7 @@ void NodeInstanceServer::loadDummyDataFile(const QFileInfo& qmlFileInfo)
|
|||||||
qWarning() << "Loaded dummy data:" << qmlFileInfo.filePath();
|
qWarning() << "Loaded dummy data:" << qmlFileInfo.filePath();
|
||||||
m_declarativeView->rootContext()->setContextProperty(qmlFileInfo.completeBaseName(), dummyData);
|
m_declarativeView->rootContext()->setContextProperty(qmlFileInfo.completeBaseName(), dummyData);
|
||||||
dummyData->setParent(this);
|
dummyData->setParent(this);
|
||||||
|
m_dummyObjectList.append(DummyPair(qmlFileInfo.completeBaseName(), dummyData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oldDummyDataObject.isNull())
|
if (!oldDummyDataObject.isNull())
|
||||||
@@ -1010,6 +1051,11 @@ void NodeInstanceServer::loadDummyDataFile(const QFileInfo& qmlFileInfo)
|
|||||||
|
|
||||||
if (!dummydataFileSystemWatcher()->files().contains(qmlFileInfo.filePath()))
|
if (!dummydataFileSystemWatcher()->files().contains(qmlFileInfo.filePath()))
|
||||||
dummydataFileSystemWatcher()->addPath(qmlFileInfo.filePath());
|
dummydataFileSystemWatcher()->addPath(qmlFileInfo.filePath());
|
||||||
|
|
||||||
|
if (rootNodeInstance().isValid() && rootNodeInstance().internalObject()) {
|
||||||
|
foreach (QDeclarativeContext *context, allSubContextsForObject(rootNodeInstance().internalObject()))
|
||||||
|
setupDummysForContext(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeInstanceServer::loadDummyContextObjectFile(const QFileInfo& qmlFileInfo)
|
void NodeInstanceServer::loadDummyContextObjectFile(const QFileInfo& qmlFileInfo)
|
||||||
|
@@ -73,6 +73,8 @@ public:
|
|||||||
typedef QPair<QWeakPointer<QObject>, QString> ObjectPropertyPair;
|
typedef QPair<QWeakPointer<QObject>, QString> ObjectPropertyPair;
|
||||||
typedef QPair<qint32, QString> IdPropertyPair;
|
typedef QPair<qint32, QString> IdPropertyPair;
|
||||||
typedef QPair<ServerNodeInstance, QString> InstancePropertyPair;
|
typedef QPair<ServerNodeInstance, QString> InstancePropertyPair;
|
||||||
|
typedef QPair<QString, QWeakPointer<QObject> > DummyPair;
|
||||||
|
|
||||||
explicit NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
|
explicit NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
|
||||||
~NodeInstanceServer();
|
~NodeInstanceServer();
|
||||||
|
|
||||||
@@ -180,12 +182,18 @@ protected:
|
|||||||
|
|
||||||
void refreshBindings();
|
void refreshBindings();
|
||||||
|
|
||||||
|
void setupDummysForContext(QDeclarativeContext *context);
|
||||||
|
|
||||||
|
QList<QDeclarativeContext*> allSubContextsForObject(QObject *object);
|
||||||
|
static QList<QObject*> allSubObjectsForObject(QObject *object);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ServerNodeInstance m_rootNodeInstance;
|
ServerNodeInstance m_rootNodeInstance;
|
||||||
ServerNodeInstance m_activeStateInstance;
|
ServerNodeInstance m_activeStateInstance;
|
||||||
QHash<qint32, ServerNodeInstance> m_idInstanceHash;
|
QHash<qint32, ServerNodeInstance> m_idInstanceHash;
|
||||||
QHash<QObject*, ServerNodeInstance> m_objectInstanceHash;
|
QHash<QObject*, ServerNodeInstance> m_objectInstanceHash;
|
||||||
QMultiHash<QString, ObjectPropertyPair> m_fileSystemWatcherHash;
|
QMultiHash<QString, ObjectPropertyPair> m_fileSystemWatcherHash;
|
||||||
|
QList<QPair<QString, QWeakPointer<QObject> > > m_dummyObjectList;
|
||||||
QWeakPointer<QFileSystemWatcher> m_fileSystemWatcher;
|
QWeakPointer<QFileSystemWatcher> m_fileSystemWatcher;
|
||||||
QWeakPointer<QFileSystemWatcher> m_dummdataFileSystemWatcher;
|
QWeakPointer<QFileSystemWatcher> m_dummdataFileSystemWatcher;
|
||||||
QWeakPointer<QDeclarativeView> m_declarativeView;
|
QWeakPointer<QDeclarativeView> m_declarativeView;
|
||||||
|
Reference in New Issue
Block a user