void colorPickerToolRequested();
void objectCreationRequested(const QString &qml, QObject *parent,
- const QStringList &imports, const QString &filename = QString());
+ const QStringList &imports, const QString &filename = QString(), int order = -1);
void objectReparentRequested(QObject *object, QObject *newParent);
+ void objectDeletionRequested(QObject *object);
// 1 = normal speed,
// 1 < x < 16 = slowdown by some factor
QString filename;
QStringList imports;
ds >> qml >> parentId >> imports >> filename;
- emit objectCreationRequested(qml, objectForId(parentId), imports, filename);
+ int order = -1;
+ if (!ds.atEnd()) {
+ ds >> order;
+ }
+ emit objectCreationRequested(qml, objectForId(parentId), imports, filename, order);
break;
}
case ObserverProtocol::DestroyObject: {
int debugId;
ds >> debugId;
- if (QObject* obj = objectForId(debugId))
- obj->deleteLater();
+ if (QObject* obj = objectForId(debugId)) {
+ emit objectDeletionRequested(obj);
+ }
break;
}
case ObserverProtocol::MoveObject: {
connect(data->debugService, SIGNAL(selectToolRequested()), data.data(), SLOT(_q_changeToSingleSelectTool()));
connect(data->debugService, SIGNAL(zoomToolRequested()), data.data(), SLOT(_q_changeToZoomTool()));
connect(data->debugService,
- SIGNAL(objectCreationRequested(QString,QObject*,QStringList,QString)),
- data.data(), SLOT(_q_createQmlObject(QString,QObject*,QStringList,QString)));
+ SIGNAL(objectCreationRequested(QString,QObject*,QStringList,QString,int)),
+ data.data(), SLOT(_q_createQmlObject(QString,QObject*,QStringList,QString,int)));
+ connect(data->debugService,
+ SIGNAL(objectDeletionRequested(QObject *)), data.data(), SLOT(_q_deleteQmlObject(QObject *)));
connect(data->debugService,
SIGNAL(objectReparentRequested(QObject *, QObject *)),
data.data(), SLOT(_q_reparentQmlObject(QObject *, QObject *)));
return true;
}
+bool insertObjectInListProperty(QDeclarativeListReference &fromList, int position, QObject *object)
+{
+ QList<QObject *> tmpList;
+ int i;
+
+ if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
+ return false;
+
+ if (position == fromList.count()) {
+ fromList.append(object);
+ return true;
+ }
+
+ for (i=0; i<fromList.count(); ++i)
+ tmpList << fromList.at(i);
+
+ fromList.clear();
+ for (i=0; i<position; ++i)
+ fromList.append(tmpList.at(i));
+
+ fromList.append(object);
+ for (; i<tmpList.count(); ++i)
+ fromList.append(tmpList.at(i));
+
+ return true;
+}
+
+bool removeObjectFromListProperty(QDeclarativeListReference &fromList, QObject *object)
+{
+ QList<QObject *> tmpList;
+ int i;
+
+ if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
+ return false;
+
+ for (i=0; i<fromList.count(); ++i)
+ if (object != fromList.at(i))
+ tmpList << fromList.at(i);
+
+ fromList.clear();
+
+ foreach (QObject *item, tmpList)
+ fromList.append(item);
+
+ return true;
+}
+
void QDeclarativeViewObserverPrivate::_q_createQmlObject(const QString &qml, QObject *parent,
const QStringList &importList,
- const QString &filename)
+ const QString &filename, int order)
{
if (!parent)
return;
if (parent->inherits("QDeclarativeAnimationGroup") &&
newObject->inherits("QDeclarativeAbstractAnimation")) {
QDeclarativeListReference animationsList(parent, "animations");
- animationsList.append(newObject);
+ if (order==-1) {
+ animationsList.append(newObject);
+ } else {
+ if (!insertObjectInListProperty(animationsList, order, newObject)) {
+ animationsList.append(newObject);
+ }
+ }
break;
}
// add transition
if (parentItem && newObject->inherits("QDeclarativeTransition")) {
QDeclarativeListReference transitionsList(parentItem,"transitions");
- if (transitionsList.count() == 1 && transitionsList.at(0) == 0)
+ if (transitionsList.count() == 1 && transitionsList.at(0) == 0) {
transitionsList.clear();
+ }
transitionsList.append(newObject);
break;
}
item->setParentItem(newParentItem);
}
+void QDeclarativeViewObserverPrivate::_q_deleteQmlObject(QObject *object)
+{
+ // special cases for transitions/animations
+ if (object->inherits("QDeclarativeAbstractAnimation")) {
+ if (object->parent()) {
+ QDeclarativeListReference animationsList(object->parent(), "animations");
+ if (removeObjectFromListProperty(animationsList, object))
+ object->deleteLater();
+ return;
+ }
+ }
+
+ if (object->inherits("QDeclarativeTransition")) {
+ QDeclarativeListReference transitionsList(object->parent(), "transitions");
+ if (removeObjectFromListProperty(transitionsList, object))
+ object->deleteLater();
+ return;
+ }
+}
+
void QDeclarativeViewObserverPrivate::_q_clearComponentCache()
{
view->engine()->clearComponentCache();
void _q_onCurrentObjectsChanged(QList<QObject*> objects);
void _q_applyChangesFromClient();
void _q_createQmlObject(const QString &qml, QObject *parent,
- const QStringList &imports, const QString &filename = QString());
+ const QStringList &imports, const QString &filename = QString(), int order = 0);
void _q_reparentQmlObject(QObject *, QObject *);
+ void _q_deleteQmlObject(QObject *);
void _q_changeToSingleSelectTool();
void _q_changeToMarqueeSelectTool();
+ QLatin1Char(':') + QString::number(startLine-importList.count());
foreach(DebugId debugId, debugReferences) {
if (debugId != -1) {
- createObject(qmlText, debugId, importList, filename);
+ int order = 0;
+ // skip children which are not objects
+ foreach (const UiObjectMember *child, children(parentMember)) {
+ if (child == member) break;
+ if (child->kind == AST::Node::Kind_UiObjectDefinition)
+ order++;
+ }
+ createObject(qmlText, debugId, importList, filename, order);
}
}
newObjects += member;
}
}
-
void Delta::update(UiObjectMember* oldObject, const QmlJS::Document::Ptr& oldDoc,
UiObjectMember* newObject, const QmlJS::Document::Ptr& newDoc,
const QList<DebugId>& debugReferences)
return m_previousDoc;
}
-void Delta::createObject(const QString &, DebugId, const QStringList &, const QString&)
+void Delta::createObject(const QString &, DebugId, const QStringList &, const QString&, int)
{}
void Delta::removeObject(int)
{}
virtual void removeObject(int debugId);
virtual void reparentObject(int debugId, int newParent);
virtual void createObject(const QString &qmlText, DebugId ref,
- const QStringList &importList, const QString &filename);
+ const QStringList &importList, const QString &filename, int order = 0);
virtual void notifyUnsyncronizableElementChange(AST::UiObjectMember *parent);
private:
}
void ClientProxy::createQmlObject(const QString &qmlText, int parentDebugId,
- const QStringList &imports, const QString &filename)
+ const QStringList &imports, const QString &filename, int order)
{
if (isConnected())
- m_observerClient->createQmlObject(qmlText, parentDebugId, imports, filename);
+ m_observerClient->createQmlObject(qmlText, parentDebugId, imports, filename, order);
}
void ClientProxy::destroyQmlObject(int debugId)
void changeToSelectMarqueeTool();
void showAppOnTop(bool showOnTop);
void createQmlObject(const QString &qmlText, int parentDebugId,
- const QStringList &imports, const QString &filename = QString());
+ const QStringList &imports, const QString &filename = QString(), int order = 0);
void destroyQmlObject(int debugId);
void reparentQmlObject(int debugId, int newParent);
void setContextPathIndex(int contextIndex);
}
virtual void createObject(const QString& qmlText, DebugId ref,
- const QStringList& importList, const QString& filename)
+ const QStringList& importList, const QString& filename, int order)
{
appliedChangesToViewer = true;
referenceRefreshRequired = true;
- m_clientProxy->createQmlObject(qmlText, ref, importList, filename);
+ m_clientProxy->createQmlObject(qmlText, ref, importList, filename, order);
}
virtual void reparentObject(int debugId, int newParent)
}
void QmlJSObserverClient::createQmlObject(const QString &qmlText, int parentDebugId,
- const QStringList &imports, const QString &filename)
+ const QStringList &imports, const QString &filename, int order)
{
if (!m_connection || !m_connection->isConnected())
return;
<< qmlText
<< parentDebugId
<< imports
- << filename;
+ << filename
+ << order;
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText, QString::number(parentDebugId),
imports.join(","), filename));
void showAppOnTop(bool showOnTop);
void createQmlObject(const QString &qmlText, int parentDebugId,
- const QStringList &imports, const QString &filename);
+ const QStringList &imports, const QString &filename, int order);
void destroyQmlObject(int debugId);
void reparentQmlObject(int debugId, int newParent);