forked from qt-creator/qt-creator
qmlobserver: Remove the changed() hack to get new object.
There is now a hook in QDeclarative itself for that. Needs commit af2b28f9ca07057 of Qt
This commit is contained in:
@@ -72,7 +72,6 @@ public:
|
|||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void selectedColorChanged(const QColor &color);
|
void selectedColorChanged(const QColor &color);
|
||||||
void contextPathUpdated(const QStringList &contextPath);
|
void contextPathUpdated(const QStringList &contextPath);
|
||||||
void sceneItemCountChanged();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void currentObjectsChanged(const QList<QObject*> &objects);
|
void currentObjectsChanged(const QList<QObject*> &objects);
|
||||||
|
@@ -111,8 +111,6 @@ private:
|
|||||||
Q_PRIVATE_SLOT(d_func(), void _q_changeToColorPickerTool())
|
Q_PRIVATE_SLOT(d_func(), void _q_changeToColorPickerTool())
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_changeContextPathIndex(int index))
|
Q_PRIVATE_SLOT(d_func(), void _q_changeContextPathIndex(int index))
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_clearComponentCache());
|
Q_PRIVATE_SLOT(d_func(), void _q_clearComponentCache());
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_sceneChanged(const QList<QRectF> &areas));
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_checkSceneItemCount());
|
|
||||||
|
|
||||||
inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); }
|
inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); }
|
||||||
QScopedPointer<QDeclarativeDesignViewPrivate> data;
|
QScopedPointer<QDeclarativeDesignViewPrivate> data;
|
||||||
|
@@ -211,16 +211,6 @@ void QDeclarativeDesignDebugServer::contextPathUpdated(const QStringList &contex
|
|||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QDeclarativeDesignDebugServer::sceneItemCountChanged()
|
|
||||||
{
|
|
||||||
QByteArray message;
|
|
||||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
||||||
|
|
||||||
ds << QByteArray("SCENE_ITEM_COUNT_CHANGED");
|
|
||||||
|
|
||||||
sendMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QDeclarativeDesignDebugServer::idStringForObject(QObject *obj) const
|
QString QDeclarativeDesignDebugServer::idStringForObject(QObject *obj) const
|
||||||
{
|
{
|
||||||
int id = idForObject(obj);
|
int id = idForObject(obj);
|
||||||
|
@@ -66,8 +66,6 @@ QDeclarativeDesignViewPrivate::QDeclarativeDesignViewPrivate(QDeclarativeDesignV
|
|||||||
jsDebuggerAgent(0),
|
jsDebuggerAgent(0),
|
||||||
toolbar(0)
|
toolbar(0)
|
||||||
{
|
{
|
||||||
sceneChangedTimer.setInterval(SceneChangeUpdateInterval);
|
|
||||||
sceneChangedTimer.setSingleShot(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDeclarativeDesignViewPrivate::~QDeclarativeDesignViewPrivate()
|
QDeclarativeDesignViewPrivate::~QDeclarativeDesignViewPrivate()
|
||||||
@@ -85,7 +83,6 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
|
|||||||
data->subcomponentEditorTool = new SubcomponentEditorTool(this);
|
data->subcomponentEditorTool = new SubcomponentEditorTool(this);
|
||||||
data->currentTool = data->selectionTool;
|
data->currentTool = data->selectionTool;
|
||||||
|
|
||||||
connect(scene(), SIGNAL(changed(QList<QRectF>)), SLOT(_q_sceneChanged(QList<QRectF>)));
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
connect(qmlDesignDebugServer(), SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool)));
|
connect(qmlDesignDebugServer(), SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool)));
|
||||||
@@ -114,8 +111,6 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
|
|||||||
connect(data->subcomponentEditorTool, SIGNAL(contextPopped()), SIGNAL(inspectorContextPopped()));
|
connect(data->subcomponentEditorTool, SIGNAL(contextPopped()), SIGNAL(inspectorContextPopped()));
|
||||||
connect(data->subcomponentEditorTool, SIGNAL(contextPathChanged(QStringList)), qmlDesignDebugServer(), SLOT(contextPathUpdated(QStringList)));
|
connect(data->subcomponentEditorTool, SIGNAL(contextPathChanged(QStringList)), qmlDesignDebugServer(), SLOT(contextPathUpdated(QStringList)));
|
||||||
|
|
||||||
connect(&(data->sceneChangedTimer), SIGNAL(timeout()), SLOT(_q_checkSceneItemCount()));
|
|
||||||
|
|
||||||
data->createToolbar();
|
data->createToolbar();
|
||||||
|
|
||||||
data->_q_changeToSingleSelectTool();
|
data->_q_changeToSingleSelectTool();
|
||||||
@@ -535,55 +530,6 @@ void QDeclarativeDesignViewPrivate::_q_changeContextPathIndex(int index)
|
|||||||
subcomponentEditorTool->setContext(index);
|
subcomponentEditorTool->setContext(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QDeclarativeDesignViewPrivate::_q_sceneChanged(const QList<QRectF> & /*areas*/)
|
|
||||||
{
|
|
||||||
if (designModeBehavior)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!sceneChangedTimer.isActive())
|
|
||||||
sceneChangedTimer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QDeclarativeDesignViewPrivate::_q_checkSceneItemCount()
|
|
||||||
{
|
|
||||||
bool hasNewItems = hasNewGraphicsObjects(q->rootObject());
|
|
||||||
|
|
||||||
if (hasNewItems) {
|
|
||||||
qmlDesignDebugServer()->sceneItemCountChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool hasNewGraphicsObjectsRecur(QGraphicsObject *object,
|
|
||||||
QSet<QGraphicsObject *> &newItems,
|
|
||||||
const QSet<QGraphicsObject *> &previousItems)
|
|
||||||
{
|
|
||||||
bool hasNew = false;
|
|
||||||
|
|
||||||
newItems << object;
|
|
||||||
|
|
||||||
foreach(QGraphicsItem *item, object->childItems()) {
|
|
||||||
QGraphicsObject *gfxObject = item->toGraphicsObject();
|
|
||||||
if (gfxObject) {
|
|
||||||
newItems << gfxObject;
|
|
||||||
|
|
||||||
hasNew = hasNewGraphicsObjectsRecur(gfxObject, newItems, previousItems) || hasNew;
|
|
||||||
if (!previousItems.contains(gfxObject))
|
|
||||||
hasNew = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasNew;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QDeclarativeDesignViewPrivate::hasNewGraphicsObjects(QGraphicsObject *object)
|
|
||||||
{
|
|
||||||
QSet<QGraphicsObject *> newItems;
|
|
||||||
bool ret = hasNewGraphicsObjectsRecur(object, newItems, sceneGraphicsObjects);
|
|
||||||
sceneGraphicsObjects = newItems;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QDeclarativeDesignView::changeAnimationSpeed(qreal slowdownFactor)
|
void QDeclarativeDesignView::changeAnimationSpeed(qreal slowdownFactor)
|
||||||
{
|
{
|
||||||
data->slowdownFactor = slowdownFactor;
|
data->slowdownFactor = slowdownFactor;
|
||||||
@@ -674,7 +620,6 @@ void QDeclarativeDesignViewPrivate::_q_onStatusChanged(QDeclarativeView::Status
|
|||||||
{
|
{
|
||||||
if (status == QDeclarativeView::Ready) {
|
if (status == QDeclarativeView::Ready) {
|
||||||
if (q->rootObject()) {
|
if (q->rootObject()) {
|
||||||
hasNewGraphicsObjects(q->rootObject());
|
|
||||||
if (subcomponentEditorTool->contextIndex() != -1)
|
if (subcomponentEditorTool->contextIndex() != -1)
|
||||||
subcomponentEditorTool->clear();
|
subcomponentEditorTool->clear();
|
||||||
subcomponentEditorTool->pushContext(q->rootObject());
|
subcomponentEditorTool->pushContext(q->rootObject());
|
||||||
|
@@ -87,8 +87,6 @@ public:
|
|||||||
JSDebuggerAgent *jsDebuggerAgent;
|
JSDebuggerAgent *jsDebuggerAgent;
|
||||||
|
|
||||||
QmlToolbar *toolbar;
|
QmlToolbar *toolbar;
|
||||||
QTimer sceneChangedTimer;
|
|
||||||
QSet<QGraphicsObject *> sceneGraphicsObjects;
|
|
||||||
|
|
||||||
void clearEditorItems();
|
void clearEditorItems();
|
||||||
void createToolbar();
|
void createToolbar();
|
||||||
@@ -100,8 +98,6 @@ public:
|
|||||||
QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
|
QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
|
||||||
QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
|
QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
|
||||||
|
|
||||||
bool hasNewGraphicsObjects(QGraphicsObject *object);
|
|
||||||
|
|
||||||
void setSelectedItemsForTools(QList<QGraphicsItem *> items);
|
void setSelectedItemsForTools(QList<QGraphicsItem *> items);
|
||||||
void setSelectedItems(QList<QGraphicsItem *> items);
|
void setSelectedItems(QList<QGraphicsItem *> items);
|
||||||
QList<QGraphicsItem *> selectedItems();
|
QList<QGraphicsItem *> selectedItems();
|
||||||
@@ -132,9 +128,6 @@ public:
|
|||||||
void _q_changeToColorPickerTool();
|
void _q_changeToColorPickerTool();
|
||||||
void _q_changeContextPathIndex(int index);
|
void _q_changeContextPathIndex(int index);
|
||||||
void _q_clearComponentCache();
|
void _q_clearComponentCache();
|
||||||
void _q_sceneChanged(const QList<QRectF> &areas);
|
|
||||||
void _q_changeDebugObjectCount(int objectCount);
|
|
||||||
void _q_checkSceneItemCount();
|
|
||||||
|
|
||||||
static QDeclarativeDesignViewPrivate *get(QDeclarativeDesignView *v) { return v->d_func(); }
|
static QDeclarativeDesignViewPrivate *get(QDeclarativeDesignView *v) { return v->d_func(); }
|
||||||
};
|
};
|
||||||
|
@@ -85,9 +85,6 @@ void ClientProxy::connectToServer()
|
|||||||
SIGNAL(selectedColorChanged(QColor)));
|
SIGNAL(selectedColorChanged(QColor)));
|
||||||
connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)),
|
connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)),
|
||||||
SIGNAL(contextPathUpdated(QStringList)));
|
SIGNAL(contextPathUpdated(QStringList)));
|
||||||
/* connect(m_designClient, SIGNAL(treeRefreshRequested()),
|
|
||||||
SLOT(refreshObjectTree()));*/
|
|
||||||
|
|
||||||
reloadEngines();
|
reloadEngines();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,4 +451,3 @@ void ClientProxy::newObjects()
|
|||||||
if (!m_requestObjectsTimer.isActive())
|
if (!m_requestObjectsTimer.isActive())
|
||||||
m_requestObjectsTimer.start();
|
m_requestObjectsTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,8 +108,6 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
|
|||||||
QStringList contextPath;
|
QStringList contextPath;
|
||||||
ds >> contextPath;
|
ds >> contextPath;
|
||||||
emit contextPathUpdated(contextPath);
|
emit contextPathUpdated(contextPath);
|
||||||
} else if (type == "SCENE_ITEM_COUNT_CHANGED") {
|
|
||||||
//emit treeRefreshRequested();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,7 +89,6 @@ signals:
|
|||||||
void designModeBehaviorChanged(bool inDesignMode);
|
void designModeBehaviorChanged(bool inDesignMode);
|
||||||
void reloaded(); // the server has reloaded the document
|
void reloaded(); // the server has reloaded the document
|
||||||
void contextPathUpdated(const QStringList &path);
|
void contextPathUpdated(const QStringList &path);
|
||||||
void treeRefreshRequested(); // scene has some new items
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void messageReceived(const QByteArray &);
|
virtual void messageReceived(const QByteArray &);
|
||||||
|
Reference in New Issue
Block a user