forked from qt-creator/qt-creator
QmlJSInspector: Fix line length
Change-Id: I483a970551e1747d037c9e0e4ec9332fe68cb49c Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -118,7 +118,8 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
|
|||||||
{
|
{
|
||||||
QString serviceName;
|
QString serviceName;
|
||||||
float version = 0;
|
float version = 0;
|
||||||
if (QDeclarativeDebugClient *client = qobject_cast<QDeclarativeDebugClient*>(sender())) {
|
if (QDeclarativeDebugClient *client
|
||||||
|
= qobject_cast<QDeclarativeDebugClient*>(sender())) {
|
||||||
serviceName = client->name();
|
serviceName = client->name();
|
||||||
version = client->serviceVersion();
|
version = client->serviceVersion();
|
||||||
}
|
}
|
||||||
@@ -134,7 +135,8 @@ QDeclarativeDebugClient *ClientProxy::qmlDebugger() const
|
|||||||
return m_engineClient;
|
return m_engineClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status)
|
void ClientProxy::engineClientStatusChanged(
|
||||||
|
QDeclarativeDebugClient::Status status)
|
||||||
{
|
{
|
||||||
if (status == QDeclarativeDebugClient::Enabled) {
|
if (status == QDeclarativeDebugClient::Enabled) {
|
||||||
m_engineClient = qobject_cast<QmlEngineDebugClient *>(sender());
|
m_engineClient = qobject_cast<QmlEngineDebugClient *>(sender());
|
||||||
@@ -167,8 +169,8 @@ void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds,
|
|||||||
if (ref.debugId() != -1 && !ref.needsMoreData()) {
|
if (ref.debugId() != -1 && !ref.needsMoreData()) {
|
||||||
selectedItems << ref;
|
selectedItems << ref;
|
||||||
} else if (requestIfNeeded) {
|
} else if (requestIfNeeded) {
|
||||||
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
m_fetchCurrentObjectsQueryIds
|
||||||
QmlDebugObjectReference(debugId));
|
<< fetchContextObject(QmlDebugObjectReference(debugId));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,10 +178,12 @@ void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds,
|
|||||||
emit selectedItemsChanged(selectedItems);
|
emit selectedItemsChanged(selectedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::onCurrentObjectsFetched(quint32 queryId, const QVariant &result)
|
void ClientProxy::onCurrentObjectsFetched(quint32 queryId,
|
||||||
|
const QVariant &result)
|
||||||
{
|
{
|
||||||
m_fetchCurrentObjectsQueryIds.removeOne(queryId);
|
m_fetchCurrentObjectsQueryIds.removeOne(queryId);
|
||||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
QmlDebugObjectReference obj
|
||||||
|
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||||
m_fetchCurrentObjects.push_front(obj);
|
m_fetchCurrentObjects.push_front(obj);
|
||||||
|
|
||||||
if (!getObjectHierarchy(obj))
|
if (!getObjectHierarchy(obj))
|
||||||
@@ -200,8 +204,8 @@ bool ClientProxy::getObjectHierarchy(const QmlDebugObjectReference &obj)
|
|||||||
|
|
||||||
//for other objects
|
//for other objects
|
||||||
if (parent.debugId() == -1 || parent.needsMoreData()) {
|
if (parent.debugId() == -1 || parent.needsMoreData()) {
|
||||||
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
m_fetchCurrentObjectsQueryIds
|
||||||
QmlDebugObjectReference(obj.parentId()));
|
<< fetchContextObject(QmlDebugObjectReference(obj.parentId()));
|
||||||
} else {
|
} else {
|
||||||
return getObjectHierarchy(parent);
|
return getObjectHierarchy(parent);
|
||||||
}
|
}
|
||||||
@@ -230,7 +234,8 @@ void ClientProxy::setSelectedItemsByObjectId(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::addObjectToTree(const QmlDebugObjectReference &obj, bool notify)
|
void ClientProxy::addObjectToTree(const QmlDebugObjectReference &obj,
|
||||||
|
bool notify)
|
||||||
{
|
{
|
||||||
int count = m_rootObjects.count();
|
int count = m_rootObjects.count();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
@@ -245,7 +250,7 @@ void ClientProxy::addObjectToTree(const QmlDebugObjectReference &obj, bool notif
|
|||||||
|
|
||||||
QmlDebugObjectReference ClientProxy::objectReferenceForId(int debugId) const
|
QmlDebugObjectReference ClientProxy::objectReferenceForId(int debugId) const
|
||||||
{
|
{
|
||||||
foreach (const QmlDebugObjectReference& it, m_rootObjects) {
|
foreach (const QmlDebugObjectReference &it, m_rootObjects) {
|
||||||
QmlDebugObjectReference result = objectReferenceForId(debugId, it);
|
QmlDebugObjectReference result = objectReferenceForId(debugId, it);
|
||||||
if (result.debugId() == debugId)
|
if (result.debugId() == debugId)
|
||||||
return result;
|
return result;
|
||||||
@@ -274,7 +279,8 @@ QmlJSInspector::Internal::ClientProxy::rootObjectReference() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QmlDebugObjectReference
|
QmlDebugObjectReference
|
||||||
ClientProxy::objectReferenceForId(int debugId,
|
ClientProxy::objectReferenceForId(
|
||||||
|
int debugId,
|
||||||
const QmlDebugObjectReference &objectRef) const
|
const QmlDebugObjectReference &objectRef) const
|
||||||
{
|
{
|
||||||
if (objectRef.debugId() == debugId)
|
if (objectRef.debugId() == debugId)
|
||||||
@@ -307,7 +313,8 @@ QmlDebugObjectReference ClientProxy::objectReferenceForLocation(
|
|||||||
{
|
{
|
||||||
const QList<QmlDebugObjectReference> refs = objectReferences();
|
const QList<QmlDebugObjectReference> refs = objectReferences();
|
||||||
foreach (const QmlDebugObjectReference &ref, refs) {
|
foreach (const QmlDebugObjectReference &ref, refs) {
|
||||||
if (ref.source().lineNumber() == line && ref.source().columnNumber() == column)
|
if (ref.source().lineNumber() == line
|
||||||
|
&& ref.source().columnNumber() == column)
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +396,7 @@ quint32 ClientProxy::setMethodBodyForObject(int objectDebugId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
quint32 ClientProxy::resetBindingForObject(int objectDebugId,
|
quint32 ClientProxy::resetBindingForObject(int objectDebugId,
|
||||||
const QString& propertyName)
|
const QString &propertyName)
|
||||||
{
|
{
|
||||||
if (objectDebugId == -1)
|
if (objectDebugId == -1)
|
||||||
return false;
|
return false;
|
||||||
@@ -424,7 +431,8 @@ quint32 ClientProxy::queryExpressionResult(int objectDebugId,
|
|||||||
|
|
||||||
log(LogSend, QString("EVAL_EXPRESSION %1 %2").arg(
|
log(LogSend, QString("EVAL_EXPRESSION %1 %2").arg(
|
||||||
QString::number(objectDebugId), expr));
|
QString::number(objectDebugId), expr));
|
||||||
quint32 queryId = m_engineClient->queryExpressionResult(objectDebugId, expr);
|
quint32 queryId
|
||||||
|
= m_engineClient->queryExpressionResult(objectDebugId, expr);
|
||||||
|
|
||||||
if (m_adapter)
|
if (m_adapter)
|
||||||
m_adapter.data()->disableJsDebugging(block);
|
m_adapter.data()->disableJsDebugging(block);
|
||||||
@@ -510,7 +518,8 @@ void ClientProxy::queryEngineContext(int id)
|
|||||||
|
|
||||||
log(LogSend, QString("LIST_OBJECTS %1").arg(QString::number(id)));
|
log(LogSend, QString("LIST_OBJECTS %1").arg(QString::number(id)));
|
||||||
|
|
||||||
m_contextQueryId = m_engineClient->queryRootContexts(QmlDebugEngineReference(id));
|
m_contextQueryId
|
||||||
|
= m_engineClient->queryRootContexts(QmlDebugEngineReference(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::contextChanged(const QVariant &value)
|
void ClientProxy::contextChanged(const QVariant &value)
|
||||||
@@ -522,7 +531,7 @@ void ClientProxy::contextChanged(const QVariant &value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 ClientProxy::fetchContextObject(const QmlDebugObjectReference& obj)
|
quint32 ClientProxy::fetchContextObject(const QmlDebugObjectReference &obj)
|
||||||
{
|
{
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -532,7 +541,7 @@ quint32 ClientProxy::fetchContextObject(const QmlDebugObjectReference& obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::fetchRootObjects(
|
void ClientProxy::fetchRootObjects(
|
||||||
const QmlDebugContextReference& context, bool clear)
|
const QmlDebugContextReference &context, bool clear)
|
||||||
{
|
{
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
return;
|
return;
|
||||||
@@ -555,25 +564,28 @@ void ClientProxy::fetchRootObjects(
|
|||||||
if (queryId)
|
if (queryId)
|
||||||
m_objectTreeQueryIds << queryId;
|
m_objectTreeQueryIds << queryId;
|
||||||
}
|
}
|
||||||
foreach (const QmlDebugContextReference& child, context.contexts()) {
|
foreach (const QmlDebugContextReference &child, context.contexts()) {
|
||||||
fetchRootObjects(child, false);
|
fetchRootObjects(child, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::insertObjectInTreeIfNeeded(const QmlDebugObjectReference &object)
|
void ClientProxy::insertObjectInTreeIfNeeded(
|
||||||
|
const QmlDebugObjectReference &object)
|
||||||
{
|
{
|
||||||
if (!m_rootObjects.contains(object))
|
if (!m_rootObjects.contains(object))
|
||||||
return;
|
return;
|
||||||
int count = m_rootObjects.count();
|
int count = m_rootObjects.count();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (m_rootObjects[i].parentId() < 0 && m_rootObjects[i].insertObjectInTree(object)) {
|
if (m_rootObjects[i].parentId() < 0
|
||||||
|
&& m_rootObjects[i].insertObjectInTree(object)) {
|
||||||
m_rootObjects.removeOne(object);
|
m_rootObjects.removeOne(object);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::onResult(quint32 queryId, const QVariant &value, const QByteArray &type)
|
void ClientProxy::onResult(quint32 queryId, const QVariant &value,
|
||||||
|
const QByteArray &type)
|
||||||
{
|
{
|
||||||
if (type == "FETCH_OBJECT_R") {
|
if (type == "FETCH_OBJECT_R") {
|
||||||
log(LogReceive, QString("FETCH_OBJECT_R %1").arg(
|
log(LogReceive, QString("FETCH_OBJECT_R %1").arg(
|
||||||
@@ -596,7 +608,8 @@ void ClientProxy::onResult(quint32 queryId, const QVariant &value, const QByteAr
|
|||||||
|
|
||||||
void ClientProxy::objectTreeFetched(quint32 queryId, const QVariant &result)
|
void ClientProxy::objectTreeFetched(quint32 queryId, const QVariant &result)
|
||||||
{
|
{
|
||||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
QmlDebugObjectReference obj
|
||||||
|
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||||
m_rootObjects.append(obj);
|
m_rootObjects.append(obj);
|
||||||
|
|
||||||
m_objectTreeQueryIds.removeOne(queryId);
|
m_objectTreeQueryIds.removeOne(queryId);
|
||||||
@@ -610,14 +623,15 @@ void ClientProxy::objectTreeFetched(quint32 queryId, const QVariant &result)
|
|||||||
|
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
if (!m_inspectorClient->currentObjects().isEmpty())
|
if (!m_inspectorClient->currentObjects().isEmpty())
|
||||||
onCurrentObjectsChanged(m_inspectorClient->currentObjects(), false);
|
onCurrentObjectsChanged(m_inspectorClient->currentObjects(),
|
||||||
|
false);
|
||||||
|
|
||||||
m_inspectorClient->setObjectIdList(m_rootObjects);
|
m_inspectorClient->setObjectIdList(m_rootObjects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference& ref)
|
void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference &ref)
|
||||||
{
|
{
|
||||||
QUrl fileUrl = ref.source().url();
|
QUrl fileUrl = ref.source().url();
|
||||||
int lineNum = ref.source().lineNumber();
|
int lineNum = ref.source().lineNumber();
|
||||||
@@ -633,7 +647,8 @@ void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference& ref)
|
|||||||
lineNum += rx.cap(3).toInt() - 1;
|
lineNum += rx.cap(3).toInt() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString filePath = InspectorUi::instance()->findFileInProject(fileUrl);
|
const QString filePath
|
||||||
|
= InspectorUi::instance()->findFileInProject(fileUrl);
|
||||||
|
|
||||||
// append the debug ids in the hash
|
// append the debug ids in the hash
|
||||||
m_debugIdHash[qMakePair<QString, int>(filePath, rev)][qMakePair<int, int>(
|
m_debugIdHash[qMakePair<QString, int>(filePath, rev)][qMakePair<int, int>(
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ class QmlAdapter;
|
|||||||
namespace QmlJSInspector {
|
namespace QmlJSInspector {
|
||||||
|
|
||||||
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugIds
|
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugIds
|
||||||
typedef QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
|
typedef
|
||||||
|
QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -67,8 +68,10 @@ public:
|
|||||||
QString source,
|
QString source,
|
||||||
int line);
|
int line);
|
||||||
|
|
||||||
quint32 setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody);
|
quint32 setMethodBodyForObject(int objectDebugId, const QString &methodName,
|
||||||
quint32 resetBindingForObject(int objectDebugId, const QString &propertyName);
|
const QString &methodBody);
|
||||||
|
quint32 resetBindingForObject(int objectDebugId,
|
||||||
|
const QString &propertyName);
|
||||||
quint32 queryExpressionResult(int objectDebugId, const QString &expr);
|
quint32 queryExpressionResult(int objectDebugId, const QString &expr);
|
||||||
void clearComponentCache();
|
void clearComponentCache();
|
||||||
|
|
||||||
@@ -81,14 +84,16 @@ public:
|
|||||||
QList<QmlDebugObjectReference> objectReferences() const;
|
QList<QmlDebugObjectReference> objectReferences() const;
|
||||||
QmlDebugObjectReference objectReferenceForId(int debugId) const;
|
QmlDebugObjectReference objectReferenceForId(int debugId) const;
|
||||||
QmlDebugObjectReference objectReferenceForId(const QString &objectId) const;
|
QmlDebugObjectReference objectReferenceForId(const QString &objectId) const;
|
||||||
QmlDebugObjectReference objectReferenceForLocation(int line, int column) const;
|
QmlDebugObjectReference objectReferenceForLocation(int line,
|
||||||
|
int column) const;
|
||||||
QList<QmlDebugObjectReference> rootObjectReference() const;
|
QList<QmlDebugObjectReference> rootObjectReference() const;
|
||||||
DebugIdHash debugIdHash() const { return m_debugIdHash; }
|
DebugIdHash debugIdHash() const { return m_debugIdHash; }
|
||||||
|
|
||||||
bool isConnected() const;
|
bool isConnected() const;
|
||||||
|
|
||||||
void setSelectedItemsByDebugId(const QList<int> &debugIds);
|
void setSelectedItemsByDebugId(const QList<int> &debugIds);
|
||||||
void setSelectedItemsByObjectId(const QList<QmlDebugObjectReference> &objectRefs);
|
void setSelectedItemsByObjectId(
|
||||||
|
const QList<QmlDebugObjectReference> &objectRefs);
|
||||||
|
|
||||||
QList<QmlDebugEngineReference> engines() const;
|
QList<QmlDebugEngineReference> engines() const;
|
||||||
|
|
||||||
@@ -108,7 +113,8 @@ signals:
|
|||||||
void aboutToReloadEngines();
|
void aboutToReloadEngines();
|
||||||
void enginesChanged();
|
void enginesChanged();
|
||||||
|
|
||||||
void selectedItemsChanged(const QList<QmlDebugObjectReference> &selectedItems);
|
void selectedItemsChanged(
|
||||||
|
const QList<QmlDebugObjectReference> &selectedItems);
|
||||||
|
|
||||||
void connected();
|
void connected();
|
||||||
void disconnected();
|
void disconnected();
|
||||||
@@ -121,7 +127,8 @@ signals:
|
|||||||
void designModeBehaviorChanged(bool inDesignMode);
|
void designModeBehaviorChanged(bool inDesignMode);
|
||||||
void showAppOnTopChanged(bool showAppOnTop);
|
void showAppOnTopChanged(bool showAppOnTop);
|
||||||
void serverReloaded();
|
void serverReloaded();
|
||||||
void propertyChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
void propertyChanged(int debugId, const QByteArray &propertyName,
|
||||||
|
const QVariant &propertyValue);
|
||||||
|
|
||||||
void result(quint32 queryId, const QVariant &result);
|
void result(quint32 queryId, const QVariant &result);
|
||||||
void rootContext(const QVariant &context);
|
void rootContext(const QVariant &context);
|
||||||
@@ -139,7 +146,8 @@ public slots:
|
|||||||
void changeToSelectMarqueeTool();
|
void changeToSelectMarqueeTool();
|
||||||
void showAppOnTop(bool showOnTop);
|
void showAppOnTop(bool showOnTop);
|
||||||
void createQmlObject(const QString &qmlText, int parentDebugId,
|
void createQmlObject(const QString &qmlText, int parentDebugId,
|
||||||
const QStringList &imports, const QString &filename = QString(), int order = 0);
|
const QStringList &imports,
|
||||||
|
const QString &filename = QString(), int order = 0);
|
||||||
void destroyQmlObject(int debugId);
|
void destroyQmlObject(int debugId);
|
||||||
void reparentQmlObject(int debugId, int newParent);
|
void reparentQmlObject(int debugId, int newParent);
|
||||||
|
|
||||||
@@ -148,10 +156,13 @@ private slots:
|
|||||||
void clientStatusChanged(QDeclarativeDebugClient::Status status);
|
void clientStatusChanged(QDeclarativeDebugClient::Status status);
|
||||||
void engineClientStatusChanged(QDeclarativeDebugClient::Status status);
|
void engineClientStatusChanged(QDeclarativeDebugClient::Status status);
|
||||||
|
|
||||||
void onCurrentObjectsChanged(const QList<int> &debugIds, bool requestIfNeeded = true);
|
void onCurrentObjectsChanged(const QList<int> &debugIds,
|
||||||
|
bool requestIfNeeded = true);
|
||||||
void newObjects();
|
void newObjects();
|
||||||
void objectWatchTriggered(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
void objectWatchTriggered(int debugId, const QByteArray &propertyName,
|
||||||
void onResult(quint32 queryId, const QVariant &value, const QByteArray &type);
|
const QVariant &propertyValue);
|
||||||
|
void onResult(quint32 queryId, const QVariant &value,
|
||||||
|
const QByteArray &type);
|
||||||
void onCurrentObjectsFetched(quint32 queryId, const QVariant &result);
|
void onCurrentObjectsFetched(quint32 queryId, const QVariant &result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -162,8 +173,11 @@ private:
|
|||||||
void reloadEngines();
|
void reloadEngines();
|
||||||
bool getObjectHierarchy(const QmlDebugObjectReference &obj);
|
bool getObjectHierarchy(const QmlDebugObjectReference &obj);
|
||||||
|
|
||||||
QList<QmlDebugObjectReference> objectReferences(const QmlDebugObjectReference &objectRef) const;
|
QList<QmlDebugObjectReference> objectReferences(
|
||||||
QmlDebugObjectReference objectReferenceForId(int debugId, const QmlDebugObjectReference &ref) const;
|
const QmlDebugObjectReference &objectRef) const;
|
||||||
|
QmlDebugObjectReference objectReferenceForId(
|
||||||
|
int debugId,
|
||||||
|
const QmlDebugObjectReference &ref) const;
|
||||||
|
|
||||||
enum LogDirection {
|
enum LogDirection {
|
||||||
LogSend,
|
LogSend,
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ ContextCrumblePath::ContextCrumblePath(QWidget *parent)
|
|||||||
updateContextPath(QStringList(), QList<int>());
|
updateContextPath(QStringList(), QList<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextCrumblePath::updateContextPath(const QStringList &path, const QList<int> &debugIds)
|
void ContextCrumblePath::updateContextPath(const QStringList &path,
|
||||||
|
const QList<int> &debugIds)
|
||||||
{
|
{
|
||||||
Q_ASSERT(path.count() == debugIds.count());
|
Q_ASSERT(path.count() == debugIds.count());
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ void ContextCrumblePath::updateContextPath(const QStringList &path, const QList<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextCrumblePath::addChildren(const QStringList &childrenNames, const QList<int> &childrenDebugIds)
|
void ContextCrumblePath::addChildren(const QStringList &childrenNames,
|
||||||
|
const QList<int> &childrenDebugIds)
|
||||||
{
|
{
|
||||||
Q_ASSERT(childrenNames.count() == childrenDebugIds.count());
|
Q_ASSERT(childrenNames.count() == childrenDebugIds.count());
|
||||||
for (int i = 0; i < childrenNames.count(); i++)
|
for (int i = 0; i < childrenNames.count(); i++)
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateContextPath(const QStringList &path, const QList<int> &debugIds);
|
void updateContextPath(const QStringList &path, const QList<int> &debugIds);
|
||||||
void addChildren(const QStringList &childrenNames, const QList<int> &childrenDebugIds);
|
void addChildren(const QStringList &childrenNames,
|
||||||
|
const QList<int> &childrenDebugIds);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ InspectorUi *InspectorUi::m_instance = 0;
|
|||||||
|
|
||||||
QmlJS::ModelManagerInterface *modelManager()
|
QmlJS::ModelManagerInterface *modelManager()
|
||||||
{
|
{
|
||||||
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
ExtensionSystem::PluginManager *pm
|
||||||
|
= ExtensionSystem::PluginManager::instance();
|
||||||
|
return pm->getObject<QmlJS::ModelManagerInterface>();
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectorUi::InspectorUi(QObject *parent)
|
InspectorUi::InspectorUi(QObject *parent)
|
||||||
@@ -175,8 +177,10 @@ void InspectorUi::setDebuggerEngine(QObject *engine)
|
|||||||
if (qmlEngine->isSlaveEngine())
|
if (qmlEngine->isSlaveEngine())
|
||||||
masterEngine = qmlEngine->masterEngine();
|
masterEngine = qmlEngine->masterEngine();
|
||||||
|
|
||||||
connect(qmlEngine, SIGNAL(tooltipRequested(QPoint,TextEditor::ITextEditor*,int)),
|
connect(qmlEngine,
|
||||||
this, SLOT(showDebuggerTooltip(QPoint,TextEditor::ITextEditor*,int)));
|
SIGNAL(tooltipRequested(QPoint,TextEditor::ITextEditor*,int)),
|
||||||
|
this,
|
||||||
|
SLOT(showDebuggerTooltip(QPoint,TextEditor::ITextEditor*,int)));
|
||||||
connect(masterEngine, SIGNAL(stateChanged(Debugger::DebuggerState)),
|
connect(masterEngine, SIGNAL(stateChanged(Debugger::DebuggerState)),
|
||||||
this, SLOT(onEngineStateChanged(Debugger::DebuggerState)));
|
this, SLOT(onEngineStateChanged(Debugger::DebuggerState)));
|
||||||
}
|
}
|
||||||
@@ -202,20 +206,25 @@ QmlJSTools::SemanticInfo getSemanticInfo(QPlainTextEdit *qmlJSTextEdit)
|
|||||||
QTC_ASSERT(QLatin1String(qmlJSTextEdit->metaObject()->className())
|
QTC_ASSERT(QLatin1String(qmlJSTextEdit->metaObject()->className())
|
||||||
== QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
|
== QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
|
||||||
return info);
|
return info);
|
||||||
QTC_ASSERT(qmlJSTextEdit->metaObject()->indexOfProperty("semanticInfo") != -1, return info);
|
QTC_ASSERT(qmlJSTextEdit->metaObject()->indexOfProperty("semanticInfo")
|
||||||
|
!= -1, return info);
|
||||||
|
|
||||||
info = qmlJSTextEdit->property("semanticInfo").value<QmlJSTools::SemanticInfo>();
|
info = qmlJSTextEdit->property("semanticInfo")
|
||||||
|
.value<QmlJSTools::SemanticInfo>();
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor,
|
void InspectorUi::showDebuggerTooltip(const QPoint &mousePos,
|
||||||
|
TextEditor::ITextEditor *editor,
|
||||||
int cursorPos)
|
int cursorPos)
|
||||||
{
|
{
|
||||||
Q_UNUSED(mousePos);
|
Q_UNUSED(mousePos);
|
||||||
if (m_clientProxy && editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
if (m_clientProxy && editor->id()
|
||||||
|
== QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||||
TextEditor::BaseTextEditor *baseTextEditor =
|
TextEditor::BaseTextEditor *baseTextEditor =
|
||||||
static_cast<TextEditor::BaseTextEditor*>(editor);
|
static_cast<TextEditor::BaseTextEditor*>(editor);
|
||||||
QPlainTextEdit *editWidget = qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
QPlainTextEdit *editWidget
|
||||||
|
= qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
||||||
|
|
||||||
QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
|
QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
|
||||||
|
|
||||||
@@ -235,7 +244,8 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE
|
|||||||
QmlDebugObjectReference ref;
|
QmlDebugObjectReference ref;
|
||||||
if (QmlJS::AST::Node *node
|
if (QmlJS::AST::Node *node
|
||||||
= semanticInfo.declaringMemberNoProperties(cursorPos)) {
|
= semanticInfo.declaringMemberNoProperties(cursorPos)) {
|
||||||
if (QmlJS::AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
|
if (QmlJS::AST::UiObjectMember *objMember
|
||||||
|
= node->uiObjectMemberCast()) {
|
||||||
ref = m_clientProxy->objectReferenceForLocation(
|
ref = m_clientProxy->objectReferenceForLocation(
|
||||||
objMember->firstSourceLocation().startLine,
|
objMember->firstSourceLocation().startLine,
|
||||||
objMember->firstSourceLocation().startColumn);
|
objMember->firstSourceLocation().startColumn);
|
||||||
@@ -248,33 +258,41 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE
|
|||||||
if (wordAtCursor == QString("id")) {
|
if (wordAtCursor == QString("id")) {
|
||||||
query = QString("\"id:") + ref.idString() + doubleQuote;
|
query = QString("\"id:") + ref.idString() + doubleQuote;
|
||||||
} else {
|
} else {
|
||||||
if ((qmlNode->kind == QmlJS::AST::Node::Kind_IdentifierExpression) ||
|
using namespace QmlJS::AST;
|
||||||
(qmlNode->kind == QmlJS::AST::Node::Kind_FieldMemberExpression)) {
|
if ((qmlNode->kind == Node::Kind_IdentifierExpression) ||
|
||||||
tc.setPosition(qmlNode->expressionCast()->firstSourceLocation().begin());
|
(qmlNode->kind == Node::Kind_FieldMemberExpression)) {
|
||||||
tc.setPosition(qmlNode->expressionCast()->lastSourceLocation().end(),
|
ExpressionNode *expressionNode = qmlNode->expressionCast();
|
||||||
|
tc.setPosition(expressionNode->firstSourceLocation().begin());
|
||||||
|
tc.setPosition(expressionNode->lastSourceLocation().end(),
|
||||||
QTextCursor::KeepAnchor);
|
QTextCursor::KeepAnchor);
|
||||||
QString refToLook = tc.selectedText();
|
QString refToLook = tc.selectedText();
|
||||||
if ((qmlNode->kind == QmlJS::AST::Node::Kind_IdentifierExpression) &&
|
if ((qmlNode->kind == ::Node::Kind_IdentifierExpression) &&
|
||||||
(m_clientProxy->objectReferenceForId(refToLook).debugId() == -1)) {
|
(m_clientProxy->objectReferenceForId(refToLook).debugId()
|
||||||
query = doubleQuote + QString("local: ") + refToLook + doubleQuote;
|
== -1)) {
|
||||||
foreach (const QmlDebugPropertyReference &property, ref.properties()) {
|
query = doubleQuote + QString("local: ") + refToLook
|
||||||
|
+ doubleQuote;
|
||||||
|
foreach (const QmlDebugPropertyReference &property,
|
||||||
|
ref.properties()) {
|
||||||
if (property.name() == wordAtCursor
|
if (property.name() == wordAtCursor
|
||||||
&& !property.valueTypeName().isEmpty()) {
|
&& !property.valueTypeName().isEmpty()) {
|
||||||
query = doubleQuote + property.name() + QLatin1Char(':')
|
query = doubleQuote + property.name()
|
||||||
+ doubleQuote + QLatin1Char('+') + property.name();
|
+ QLatin1Char(':') + doubleQuote
|
||||||
|
+ QLatin1Char('+') + property.name();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
query = doubleQuote + refToLook + QLatin1Char(':') + doubleQuote
|
query = doubleQuote + refToLook + QLatin1Char(':')
|
||||||
+ QLatin1Char('+') + refToLook;
|
+ doubleQuote + QLatin1Char('+') + refToLook;
|
||||||
} else {
|
} else {
|
||||||
// show properties
|
// show properties
|
||||||
foreach (const QmlDebugPropertyReference &property, ref.properties()) {
|
foreach (const QmlDebugPropertyReference &property, ref.properties()) {
|
||||||
if (property.name() == wordAtCursor && !property.valueTypeName().isEmpty()) {
|
if (property.name() == wordAtCursor
|
||||||
|
&& !property.valueTypeName().isEmpty()) {
|
||||||
query = doubleQuote + property.name() + QLatin1Char(':')
|
query = doubleQuote + property.name() + QLatin1Char(':')
|
||||||
+ doubleQuote + QLatin1Char('+') + property.name();
|
+ doubleQuote + QLatin1Char('+')
|
||||||
|
+ property.name();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,7 +300,8 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!query.isEmpty()) {
|
if (!query.isEmpty()) {
|
||||||
m_debugQuery = m_clientProxy->queryExpressionResult(ref.debugId(), query);
|
m_debugQuery
|
||||||
|
= m_clientProxy->queryExpressionResult(ref.debugId(), query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +310,8 @@ void InspectorUi::onResult(quint32 queryId, const QVariant &result)
|
|||||||
{
|
{
|
||||||
if (m_showObjectQueryId == queryId) {
|
if (m_showObjectQueryId == queryId) {
|
||||||
m_showObjectQueryId = 0;
|
m_showObjectQueryId = 0;
|
||||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
QmlDebugObjectReference obj
|
||||||
|
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||||
m_clientProxy->addObjectToTree(obj);
|
m_clientProxy->addObjectToTree(obj);
|
||||||
if (m_onCrumblePathClicked) {
|
if (m_onCrumblePathClicked) {
|
||||||
m_onCrumblePathClicked = false;
|
m_onCrumblePathClicked = false;
|
||||||
@@ -302,7 +322,8 @@ void InspectorUi::onResult(quint32 queryId, const QVariant &result)
|
|||||||
|
|
||||||
if (m_updateObjectQueryIds.contains(queryId)) {
|
if (m_updateObjectQueryIds.contains(queryId)) {
|
||||||
m_updateObjectQueryIds.removeOne(queryId);
|
m_updateObjectQueryIds.removeOne(queryId);
|
||||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
QmlDebugObjectReference obj
|
||||||
|
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||||
m_clientProxy->addObjectToTree(obj);
|
m_clientProxy->addObjectToTree(obj);
|
||||||
if (m_updateObjectQueryIds.empty())
|
if (m_updateObjectQueryIds.empty())
|
||||||
showObject(obj);
|
showObject(obj);
|
||||||
@@ -333,21 +354,26 @@ void InspectorUi::connected(ClientProxy *clientProxy)
|
|||||||
connect(m_clientProxy, SIGNAL(result(quint32,QVariant)),
|
connect(m_clientProxy, SIGNAL(result(quint32,QVariant)),
|
||||||
SLOT(onResult(quint32,QVariant)));
|
SLOT(onResult(quint32,QVariant)));
|
||||||
using namespace QmlJsDebugClient::Constants;
|
using namespace QmlJsDebugClient::Constants;
|
||||||
if (m_clientProxy->qmlDebugger()->objectName() == QML_DEBUGGER &&
|
if (m_clientProxy->qmlDebugger()->objectName() == QML_DEBUGGER
|
||||||
m_clientProxy->qmlDebugger()->serviceVersion() >= CURRENT_SUPPORTED_VERSION)
|
&& m_clientProxy->qmlDebugger()->serviceVersion()
|
||||||
|
>= CURRENT_SUPPORTED_VERSION)
|
||||||
m_toolBar->setZoomToolEnabled(false);
|
m_toolBar->setZoomToolEnabled(false);
|
||||||
else
|
else
|
||||||
m_toolBar->setZoomToolEnabled(true);
|
m_toolBar->setZoomToolEnabled(true);
|
||||||
QmlJS::Snapshot snapshot = modelManager()->snapshot();
|
QmlJS::Snapshot snapshot = modelManager()->snapshot();
|
||||||
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it = m_textPreviews.constBegin();
|
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it
|
||||||
|
= m_textPreviews.constBegin();
|
||||||
it != m_textPreviews.constEnd(); ++it) {
|
it != m_textPreviews.constEnd(); ++it) {
|
||||||
Document::Ptr doc = snapshot.document(it.key());
|
Document::Ptr doc = snapshot.document(it.key());
|
||||||
it.value()->resetInitialDoc(doc);
|
it.value()->resetInitialDoc(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Debugger::DebuggerEngine *debuggerEngine = clientProxy->qmlAdapter()->debuggerEngine()) {
|
if (Debugger::DebuggerEngine *debuggerEngine
|
||||||
m_projectFinder.setProjectDirectory(debuggerEngine->startParameters().projectSourceDirectory);
|
= clientProxy->qmlAdapter()->debuggerEngine()) {
|
||||||
m_projectFinder.setProjectFiles(debuggerEngine->startParameters().projectSourceFiles);
|
m_projectFinder.setProjectDirectory(
|
||||||
|
debuggerEngine->startParameters().projectSourceDirectory);
|
||||||
|
m_projectFinder.setProjectFiles(
|
||||||
|
debuggerEngine->startParameters().projectSourceFiles);
|
||||||
m_projectFinder.setSysroot(debuggerEngine->startParameters().sysroot);
|
m_projectFinder.setSysroot(debuggerEngine->startParameters().sysroot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +418,8 @@ void InspectorUi::onRootContext(const QVariant &value)
|
|||||||
value), true);
|
value), true);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 1; i < m_crumblePath->length(); i++) {
|
for (int i = 1; i < m_crumblePath->length(); i++) {
|
||||||
m_updateObjectQueryIds << m_clientProxy->fetchContextObject(
|
m_updateObjectQueryIds
|
||||||
|
<< m_clientProxy->fetchContextObject(
|
||||||
m_crumblePath->dataForIndex(i).toInt());
|
m_crumblePath->dataForIndex(i).toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,7 +450,8 @@ void InspectorUi::updateEngineList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::changeSelectedItems(const QList<QmlDebugObjectReference> &objects)
|
void InspectorUi::changeSelectedItems(
|
||||||
|
const QList<QmlDebugObjectReference> &objects)
|
||||||
{
|
{
|
||||||
if (!m_propertyInspector->contentsValid())
|
if (!m_propertyInspector->contentsValid())
|
||||||
return;
|
return;
|
||||||
@@ -433,10 +461,12 @@ void InspectorUi::changeSelectedItems(const QList<QmlDebugObjectReference> &obje
|
|||||||
}
|
}
|
||||||
m_cursorPositionChangedExternally = true;
|
m_cursorPositionChangedExternally = true;
|
||||||
|
|
||||||
// QmlJSLiveTextPreview doesn't provide valid references, only correct debugIds. We need to remap them
|
// QmlJSLiveTextPreview doesn't provide valid references, only correct
|
||||||
|
// debugIds. We need to remap them
|
||||||
QList <QmlDebugObjectReference> realList;
|
QList <QmlDebugObjectReference> realList;
|
||||||
foreach (const QmlDebugObjectReference &obj, objects) {
|
foreach (const QmlDebugObjectReference &obj, objects) {
|
||||||
QmlDebugObjectReference clientRef = m_clientProxy->objectReferenceForId(obj.debugId());
|
QmlDebugObjectReference clientRef
|
||||||
|
= m_clientProxy->objectReferenceForId(obj.debugId());
|
||||||
realList << clientRef;
|
realList << clientRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +505,8 @@ void InspectorUi::serverReloaded()
|
|||||||
{
|
{
|
||||||
QmlJS::Snapshot snapshot = modelManager()->snapshot();
|
QmlJS::Snapshot snapshot = modelManager()->snapshot();
|
||||||
m_loadedSnapshot = snapshot;
|
m_loadedSnapshot = snapshot;
|
||||||
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it = m_textPreviews.constBegin();
|
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it
|
||||||
|
= m_textPreviews.constBegin();
|
||||||
it != m_textPreviews.constEnd(); ++it) {
|
it != m_textPreviews.constEnd(); ++it) {
|
||||||
Document::Ptr doc = snapshot.document(it.key());
|
Document::Ptr doc = snapshot.document(it.key());
|
||||||
it.value()->resetInitialDoc(doc);
|
it.value()->resetInitialDoc(doc);
|
||||||
@@ -486,12 +517,14 @@ void InspectorUi::serverReloaded()
|
|||||||
|
|
||||||
void InspectorUi::removePreviewForEditor(Core::IEditor *oldEditor)
|
void InspectorUi::removePreviewForEditor(Core::IEditor *oldEditor)
|
||||||
{
|
{
|
||||||
if (QmlJSLiveTextPreview *preview = m_textPreviews.value(oldEditor->document()->fileName())) {
|
if (QmlJSLiveTextPreview *preview
|
||||||
|
= m_textPreviews.value(oldEditor->document()->fileName())) {
|
||||||
preview->unassociateEditor(oldEditor);
|
preview->unassociateEditor(oldEditor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(Core::IEditor *newEditor)
|
QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(
|
||||||
|
Core::IEditor *newEditor)
|
||||||
{
|
{
|
||||||
QmlJSLiveTextPreview *preview = 0;
|
QmlJSLiveTextPreview *preview = 0;
|
||||||
|
|
||||||
@@ -522,13 +555,16 @@ QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(Core::IEditor *newEdit
|
|||||||
preview = m_textPreviews.value(filename);
|
preview = m_textPreviews.value(filename);
|
||||||
preview->associateEditor(newEditor);
|
preview->associateEditor(newEditor);
|
||||||
} else {
|
} else {
|
||||||
preview = new QmlJSLiveTextPreview(doc, initdoc, m_clientProxy, this);
|
preview = new QmlJSLiveTextPreview(doc, initdoc, m_clientProxy,
|
||||||
|
this);
|
||||||
connect(preview,
|
connect(preview,
|
||||||
SIGNAL(selectedItemsChanged(QList<QmlDebugObjectReference>)),
|
SIGNAL(selectedItemsChanged(QList<QmlDebugObjectReference>)),
|
||||||
SLOT(changeSelectedItems(QList<QmlDebugObjectReference>)));
|
SLOT(changeSelectedItems(QList<QmlDebugObjectReference>)));
|
||||||
connect(preview, SIGNAL(reloadQmlViewerRequested()),
|
connect(preview, SIGNAL(reloadQmlViewerRequested()),
|
||||||
m_clientProxy, SLOT(reloadQmlViewer()));
|
m_clientProxy, SLOT(reloadQmlViewer()));
|
||||||
connect(preview, SIGNAL(disableLivePreviewRequested()), SLOT(disableLivePreview()));
|
connect(preview,
|
||||||
|
SIGNAL(disableLivePreviewRequested()),
|
||||||
|
SLOT(disableLivePreview()));
|
||||||
|
|
||||||
m_textPreviews.insert(newEditor->document()->fileName(), preview);
|
m_textPreviews.insert(newEditor->document()->fileName(), preview);
|
||||||
preview->associateEditor(newEditor);
|
preview->associateEditor(newEditor);
|
||||||
@@ -559,11 +595,13 @@ QmlDebugObjectReference InspectorUi::findParentRecursive(
|
|||||||
|
|
||||||
foreach (const QmlDebugObjectReference &possibleParent, objectsToSearch) {
|
foreach (const QmlDebugObjectReference &possibleParent, objectsToSearch) {
|
||||||
// Am I a root object? No parent
|
// Am I a root object? No parent
|
||||||
if ( possibleParent.debugId() == goalDebugId && possibleParent.parentId() < 0)
|
if ( possibleParent.debugId() == goalDebugId
|
||||||
|
&& possibleParent.parentId() < 0)
|
||||||
return QmlDebugObjectReference();
|
return QmlDebugObjectReference();
|
||||||
|
|
||||||
// Is the goal one of my children?
|
// Is the goal one of my children?
|
||||||
foreach (const QmlDebugObjectReference &child, possibleParent.children())
|
foreach (const QmlDebugObjectReference &child,
|
||||||
|
possibleParent.children())
|
||||||
if ( child.debugId() == goalDebugId ) {
|
if ( child.debugId() == goalDebugId ) {
|
||||||
m_clientProxy->insertObjectInTreeIfNeeded(child);
|
m_clientProxy->insertObjectInTreeIfNeeded(child);
|
||||||
return possibleParent;
|
return possibleParent;
|
||||||
@@ -597,12 +635,14 @@ inline QString displayName(const QmlDebugObjectReference &obj)
|
|||||||
QString objTypeName = obj.className();
|
QString objTypeName = obj.className();
|
||||||
QString declarativeString("QDeclarative");
|
QString declarativeString("QDeclarative");
|
||||||
if (objTypeName.startsWith(declarativeString)) {
|
if (objTypeName.startsWith(declarativeString)) {
|
||||||
objTypeName = objTypeName.mid(declarativeString.length()).section('_',0,0);
|
objTypeName
|
||||||
|
= objTypeName.mid(declarativeString.length()).section('_',0,0);
|
||||||
}
|
}
|
||||||
return QString("<%1>").arg(objTypeName);
|
return QString("<%1>").arg(objTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::selectItems(const QList<QmlDebugObjectReference> &objectReferences)
|
void InspectorUi::selectItems(
|
||||||
|
const QList<QmlDebugObjectReference> &objectReferences)
|
||||||
{
|
{
|
||||||
foreach (const QmlDebugObjectReference &objref, objectReferences) {
|
foreach (const QmlDebugObjectReference &objref, objectReferences) {
|
||||||
int debugId = objref.debugId();
|
int debugId = objref.debugId();
|
||||||
@@ -636,7 +676,8 @@ void InspectorUi::showObject(const QmlDebugObjectReference &obj)
|
|||||||
|
|
||||||
bool InspectorUi::isRoot(const QmlDebugObjectReference &obj) const
|
bool InspectorUi::isRoot(const QmlDebugObjectReference &obj) const
|
||||||
{
|
{
|
||||||
foreach (const QmlDebugObjectReference &rootObj, m_clientProxy->rootObjectReference())
|
foreach (const QmlDebugObjectReference &rootObj,
|
||||||
|
m_clientProxy->rootObjectReference())
|
||||||
if (obj.debugId() == rootObj.debugId() && obj.parentId() < 0)
|
if (obj.debugId() == rootObj.debugId() && obj.parentId() < 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@@ -653,7 +694,8 @@ void InspectorUi::populateCrumblePath(const QmlDebugObjectReference &objRef)
|
|||||||
crumbleStrings << displayName(objRef);
|
crumbleStrings << displayName(objRef);
|
||||||
|
|
||||||
while ((!isRoot(ref)) && (ref.debugId()!=-1)) {
|
while ((!isRoot(ref)) && (ref.debugId()!=-1)) {
|
||||||
ref = findParentRecursive(ref.debugId(), m_clientProxy->rootObjectReference());
|
ref = findParentRecursive(ref.debugId(),
|
||||||
|
m_clientProxy->rootObjectReference());
|
||||||
crumbleData.push_front( ref.debugId() );
|
crumbleData.push_front( ref.debugId() );
|
||||||
crumbleStrings.push_front( displayName(ref) );
|
crumbleStrings.push_front( displayName(ref) );
|
||||||
}
|
}
|
||||||
@@ -687,7 +729,8 @@ void InspectorUi::showRoot()
|
|||||||
crumbleData.clear();
|
crumbleData.clear();
|
||||||
|
|
||||||
// now append the children
|
// now append the children
|
||||||
foreach (const QmlDebugObjectReference &child, m_clientProxy->rootObjectReference()) {
|
foreach (const QmlDebugObjectReference &child,
|
||||||
|
m_clientProxy->rootObjectReference()) {
|
||||||
if (child.parentId() != -1)
|
if (child.parentId() != -1)
|
||||||
continue;
|
continue;
|
||||||
crumbleData.push_back(child.debugId());
|
crumbleData.push_back(child.debugId());
|
||||||
@@ -706,7 +749,8 @@ void InspectorUi::selectItems(const QList<int> &objectIds)
|
|||||||
QList<QmlDebugObjectReference> objectReferences;
|
QList<QmlDebugObjectReference> objectReferences;
|
||||||
foreach (int objectId, objectIds)
|
foreach (int objectId, objectIds)
|
||||||
{
|
{
|
||||||
QmlDebugObjectReference ref = m_clientProxy->objectReferenceForId(objectId);
|
QmlDebugObjectReference ref
|
||||||
|
= m_clientProxy->objectReferenceForId(objectId);
|
||||||
if (ref.debugId() == objectId)
|
if (ref.debugId() == objectId)
|
||||||
objectReferences.append(ref);
|
objectReferences.append(ref);
|
||||||
}
|
}
|
||||||
@@ -715,11 +759,13 @@ void InspectorUi::selectItems(const QList<int> &objectIds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::changePropertyValue(int debugId, const QString &propertyName,
|
void InspectorUi::changePropertyValue(int debugId, const QString &propertyName,
|
||||||
const QString &valueExpression, bool isLiteral)
|
const QString &valueExpression,
|
||||||
|
bool isLiteral)
|
||||||
{
|
{
|
||||||
QmlDebugObjectReference obj = m_clientProxy->objectReferenceForId(debugId);
|
QmlDebugObjectReference obj = m_clientProxy->objectReferenceForId(debugId);
|
||||||
m_clientProxy->setBindingForObject(debugId, propertyName, valueExpression, isLiteral,
|
m_clientProxy->setBindingForObject(debugId, propertyName, valueExpression,
|
||||||
obj.source().url().toString(), obj.source().lineNumber());
|
isLiteral, obj.source().url().toString(),
|
||||||
|
obj.source().lineNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::enable()
|
void InspectorUi::enable()
|
||||||
@@ -736,24 +782,29 @@ void InspectorUi::disable()
|
|||||||
m_propertyInspector->clear();
|
m_propertyInspector->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &fileName, int cursorPosition) const
|
QmlDebugObjectReference InspectorUi::objectReferenceForLocation(
|
||||||
|
const QString &fileName, int cursorPosition) const
|
||||||
{
|
{
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
Core::IEditor *editor = editorManager->openEditor(fileName);
|
Core::IEditor *editor = editorManager->openEditor(fileName);
|
||||||
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
TextEditor::ITextEditor *textEditor
|
||||||
|
= qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||||
|
|
||||||
if (textEditor && m_clientProxy && textEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
if (textEditor && m_clientProxy
|
||||||
|
&& textEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||||
if (cursorPosition == -1)
|
if (cursorPosition == -1)
|
||||||
cursorPosition = textEditor->position();
|
cursorPosition = textEditor->position();
|
||||||
TextEditor::BaseTextEditor *baseTextEditor =
|
TextEditor::BaseTextEditor *baseTextEditor =
|
||||||
static_cast<TextEditor::BaseTextEditor*>(editor);
|
static_cast<TextEditor::BaseTextEditor*>(editor);
|
||||||
QPlainTextEdit *editWidget = qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
QPlainTextEdit *editWidget
|
||||||
|
= qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
||||||
|
|
||||||
QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
|
QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
|
||||||
|
|
||||||
if (QmlJS::AST::Node *node
|
if (QmlJS::AST::Node *node
|
||||||
= semanticInfo.declaringMemberNoProperties(cursorPosition)) {
|
= semanticInfo.declaringMemberNoProperties(cursorPosition)) {
|
||||||
if (QmlJS::AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
|
if (QmlJS::AST::UiObjectMember *objMember
|
||||||
|
= node->uiObjectMemberCast()) {
|
||||||
return m_clientProxy->objectReferenceForLocation(
|
return m_clientProxy->objectReferenceForLocation(
|
||||||
objMember->firstSourceLocation().startLine,
|
objMember->firstSourceLocation().startLine,
|
||||||
objMember->firstSourceLocation().startColumn);
|
objMember->firstSourceLocation().startColumn);
|
||||||
@@ -763,7 +814,8 @@ QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &f
|
|||||||
return QmlDebugObjectReference();
|
return QmlDebugObjectReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::gotoObjectReferenceDefinition(const QmlDebugObjectReference &obj)
|
void InspectorUi::gotoObjectReferenceDefinition(
|
||||||
|
const QmlDebugObjectReference &obj)
|
||||||
{
|
{
|
||||||
if (m_cursorPositionChangedExternally) {
|
if (m_cursorPositionChangedExternally) {
|
||||||
m_cursorPositionChangedExternally = false;
|
m_cursorPositionChangedExternally = false;
|
||||||
@@ -777,7 +829,8 @@ void InspectorUi::gotoObjectReferenceDefinition(const QmlDebugObjectReference &o
|
|||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
Core::IEditor *currentEditor = editorManager->currentEditor();
|
Core::IEditor *currentEditor = editorManager->currentEditor();
|
||||||
Core::IEditor *editor = editorManager->openEditor(fileName);
|
Core::IEditor *editor = editorManager->openEditor(fileName);
|
||||||
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
TextEditor::ITextEditor *textEditor
|
||||||
|
= qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||||
|
|
||||||
if (currentEditor != editor)
|
if (currentEditor != editor)
|
||||||
m_selectionCallbackExpected = true;
|
m_selectionCallbackExpected = true;
|
||||||
@@ -805,7 +858,8 @@ void InspectorUi::setupDockWidgets()
|
|||||||
m_crumblePath->setStyleSheet(QLatin1String("background: #9B9B9B"));
|
m_crumblePath->setStyleSheet(QLatin1String("background: #9B9B9B"));
|
||||||
m_crumblePath->setObjectName("QmlContextPath");
|
m_crumblePath->setObjectName("QmlContextPath");
|
||||||
m_crumblePath->setWindowTitle(tr("Context Path"));
|
m_crumblePath->setWindowTitle(tr("Context Path"));
|
||||||
connect(m_crumblePath, SIGNAL(elementClicked(QVariant)), SLOT(crumblePathElementClicked(QVariant)));
|
connect(m_crumblePath, SIGNAL(elementClicked(QVariant)),
|
||||||
|
SLOT(crumblePathElementClicked(QVariant)));
|
||||||
|
|
||||||
m_propertyInspector = new QmlJSPropertyInspector;
|
m_propertyInspector = new QmlJSPropertyInspector;
|
||||||
|
|
||||||
@@ -830,7 +884,8 @@ void InspectorUi::setupDockWidgets()
|
|||||||
wlay->addWidget(m_propertyInspector);
|
wlay->addWidget(m_propertyInspector);
|
||||||
wlay->addWidget(new Core::FindToolBarPlaceHolder(inspectorWidget));
|
wlay->addWidget(new Core::FindToolBarPlaceHolder(inspectorWidget));
|
||||||
|
|
||||||
QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, inspectorWidget);
|
QDockWidget *dock
|
||||||
|
= mw->createDockWidget(Debugger::QmlLanguage, inspectorWidget);
|
||||||
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
||||||
dock->setTitleBarWidget(new QWidget(dock));
|
dock->setTitleBarWidget(new QWidget(dock));
|
||||||
|
|
||||||
@@ -901,8 +956,9 @@ void InspectorUi::updatePendingPreviewDocuments(QmlJS::Document::Ptr doc)
|
|||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
QList<Core::IEditor *> editors
|
QList<Core::IEditor *> editors
|
||||||
= Core::EditorManager::instance()->editorsForFileName(doc->fileName());
|
= em->editorsForFileName(doc->fileName());
|
||||||
|
|
||||||
if (editors.isEmpty())
|
if (editors.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -923,13 +979,17 @@ void InspectorUi::disableLivePreview()
|
|||||||
|
|
||||||
void InspectorUi::connectSignals()
|
void InspectorUi::connectSignals()
|
||||||
{
|
{
|
||||||
connect(m_propertyInspector, SIGNAL(changePropertyValue(int,QString,QString,bool)),
|
connect(m_propertyInspector,
|
||||||
|
SIGNAL(changePropertyValue(int,QString,QString,bool)),
|
||||||
this, SLOT(changePropertyValue(int,QString,QString,bool)));
|
this, SLOT(changePropertyValue(int,QString,QString,bool)));
|
||||||
|
|
||||||
connect(m_clientProxy, SIGNAL(propertyChanged(int,QByteArray,QVariant)),
|
connect(m_clientProxy,
|
||||||
m_propertyInspector, SLOT(propertyValueChanged(int,QByteArray,QVariant)));
|
SIGNAL(propertyChanged(int,QByteArray,QVariant)),
|
||||||
|
m_propertyInspector,
|
||||||
|
SLOT(propertyValueChanged(int,QByteArray,QVariant)));
|
||||||
|
|
||||||
connect(m_clientProxy, SIGNAL(selectedItemsChanged(QList<QmlDebugObjectReference>)),
|
connect(m_clientProxy,
|
||||||
|
SIGNAL(selectedItemsChanged(QList<QmlDebugObjectReference>)),
|
||||||
this, SLOT(selectItems(QList<QmlDebugObjectReference>)));
|
this, SLOT(selectItems(QList<QmlDebugObjectReference>)));
|
||||||
connect(m_clientProxy, SIGNAL(enginesChanged()),
|
connect(m_clientProxy, SIGNAL(enginesChanged()),
|
||||||
this, SLOT(updateEngineList()));
|
this, SLOT(updateEngineList()));
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ private slots:
|
|||||||
void crumblePathElementClicked(const QVariant &data);
|
void crumblePathElementClicked(const QVariant &data);
|
||||||
|
|
||||||
void updatePendingPreviewDocuments(QmlJS::Document::Ptr doc);
|
void updatePendingPreviewDocuments(QmlJS::Document::Ptr doc);
|
||||||
void showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
|
void showDebuggerTooltip(const QPoint &mousePos,
|
||||||
|
TextEditor::ITextEditor *editor, int cursorPos);
|
||||||
void onEngineStateChanged(Debugger::DebuggerState state);
|
void onEngineStateChanged(Debugger::DebuggerState state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -147,7 +148,8 @@ private:
|
|||||||
QString filenameForShadowBuildFile(const QString &filename) const;
|
QString filenameForShadowBuildFile(const QString &filename) const;
|
||||||
void populateCrumblePath(const QmlDebugObjectReference &objRef);
|
void populateCrumblePath(const QmlDebugObjectReference &objRef);
|
||||||
bool isRoot(const QmlDebugObjectReference &obj) const;
|
bool isRoot(const QmlDebugObjectReference &obj) const;
|
||||||
QmlDebugObjectReference objectReferenceForLocation(const QString &fileName, int cursorPosition=-1) const;
|
QmlDebugObjectReference objectReferenceForLocation(
|
||||||
|
const QString &fileName, int cursorPosition = -1) const;
|
||||||
|
|
||||||
void connectSignals();
|
void connectSignals();
|
||||||
void disconnectSignals();
|
void disconnectSignals();
|
||||||
@@ -155,7 +157,8 @@ private:
|
|||||||
void showObject(const QmlDebugObjectReference &obj);
|
void showObject(const QmlDebugObjectReference &obj);
|
||||||
|
|
||||||
QmlDebugObjectReference findParentRecursive(
|
QmlDebugObjectReference findParentRecursive(
|
||||||
int goalDebugId, const QList<QmlDebugObjectReference > &objectsToSearch);
|
int goalDebugId,
|
||||||
|
const QList<QmlDebugObjectReference > &objectsToSearch);
|
||||||
private:
|
private:
|
||||||
bool m_listeningToEditorManager;
|
bool m_listeningToEditorManager;
|
||||||
QmlJsInspectorToolBar *m_toolBar;
|
QmlJsInspectorToolBar *m_toolBar;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace Internal {
|
|||||||
|
|
||||||
QmlJSInspectorClient::QmlJSInspectorClient(QDeclarativeDebugConnection *client,
|
QmlJSInspectorClient::QmlJSInspectorClient(QDeclarativeDebugConnection *client,
|
||||||
QObject * /*parent*/)
|
QObject * /*parent*/)
|
||||||
: QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), client) ,
|
: QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), client),
|
||||||
m_connection(client)
|
m_connection(client)
|
||||||
{
|
{
|
||||||
setObjectName(name());
|
setObjectName(name());
|
||||||
@@ -105,7 +105,8 @@ void QmlJSInspectorClient::messageReceived(const QByteArray &message)
|
|||||||
bool paused;
|
bool paused;
|
||||||
ds >> paused;
|
ds >> paused;
|
||||||
|
|
||||||
log(LogReceive, type, paused ? QLatin1String("true") : QLatin1String("false"));
|
log(LogReceive, type, paused ? QLatin1String("true")
|
||||||
|
: QLatin1String("false"));
|
||||||
|
|
||||||
emit animationPausedChanged(paused);
|
emit animationPausedChanged(paused);
|
||||||
break;
|
break;
|
||||||
@@ -169,7 +170,8 @@ void QmlJSInspectorClient::setCurrentObjects(const QList<int> &debugIds)
|
|||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void recurseObjectIdList(const QmlDebugObjectReference &ref, QList<int> &debugIds, QList<QString> &objectIds)
|
void recurseObjectIdList(const QmlDebugObjectReference &ref,
|
||||||
|
QList<int> &debugIds, QList<QString> &objectIds)
|
||||||
{
|
{
|
||||||
debugIds << ref.debugId();
|
debugIds << ref.debugId();
|
||||||
objectIds << ref.idString();
|
objectIds << ref.idString();
|
||||||
@@ -177,7 +179,8 @@ void recurseObjectIdList(const QmlDebugObjectReference &ref, QList<int> &debugId
|
|||||||
recurseObjectIdList(child, debugIds, objectIds);
|
recurseObjectIdList(child, debugIds, objectIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSInspectorClient::setObjectIdList(const QList<QmlDebugObjectReference> &objectRoots)
|
void QmlJSInspectorClient::setObjectIdList(
|
||||||
|
const QList<QmlDebugObjectReference> &objectRoots)
|
||||||
{
|
{
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||||
@@ -198,7 +201,8 @@ void QmlJSInspectorClient::setObjectIdList(const QList<QmlDebugObjectReference>
|
|||||||
ds << debugIds[i] << objectIds[i];
|
ds << debugIds[i] << objectIds[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
log(LogSend, cmd, QString("%1 %2 [list of debug / object ids]").arg(debugIds.length()));
|
log(LogSend, cmd,
|
||||||
|
QString("%1 %2 [list of debug / object ids]").arg(debugIds.length()));
|
||||||
|
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
@@ -357,8 +361,10 @@ void QmlJSInspectorClient::showAppOnTop(bool showOnTop)
|
|||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSInspectorClient::createQmlObject(const QString &qmlText, int parentDebugId,
|
void QmlJSInspectorClient::createQmlObject(const QString &qmlText,
|
||||||
const QStringList &imports, const QString &filename, int order)
|
int parentDebugId,
|
||||||
|
const QStringList &imports,
|
||||||
|
const QString &filename, int order)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isConnected())
|
||||||
return;
|
return;
|
||||||
@@ -374,7 +380,8 @@ void QmlJSInspectorClient::createQmlObject(const QString &qmlText, int parentDeb
|
|||||||
<< filename
|
<< filename
|
||||||
<< order;
|
<< order;
|
||||||
|
|
||||||
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText, QString::number(parentDebugId),
|
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText,
|
||||||
|
QString::number(parentDebugId),
|
||||||
imports.join(","), filename));
|
imports.join(","), filename));
|
||||||
|
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
@@ -430,7 +437,8 @@ void QmlJSInspectorClient::applyChangesFromQmlFile()
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSInspectorClient::log(LogDirection direction, InspectorProtocol::Message message,
|
void QmlJSInspectorClient::log(LogDirection direction,
|
||||||
|
InspectorProtocol::Message message,
|
||||||
const QString &extra)
|
const QString &extra)
|
||||||
{
|
{
|
||||||
QString msg;
|
QString msg;
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ public:
|
|||||||
void showAppOnTop(bool showOnTop);
|
void showAppOnTop(bool showOnTop);
|
||||||
|
|
||||||
void createQmlObject(const QString &qmlText, int parentDebugId,
|
void createQmlObject(const QString &qmlText, int parentDebugId,
|
||||||
const QStringList &imports, const QString &filename, int order);
|
const QStringList &imports, const QString &filename,
|
||||||
|
int order);
|
||||||
void destroyQmlObject(int debugId);
|
void destroyQmlObject(int debugId);
|
||||||
void reparentQmlObject(int debugId, int newParent);
|
void reparentQmlObject(int debugId, int newParent);
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ InspectorPlugin::~InspectorPlugin()
|
|||||||
|
|
||||||
QmlJS::ModelManagerInterface *InspectorPlugin::modelManager() const
|
QmlJS::ModelManagerInterface *InspectorPlugin::modelManager() const
|
||||||
{
|
{
|
||||||
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
ExtensionSystem::PluginManager *pluginManager
|
||||||
|
= ExtensionSystem::PluginManager::instance();
|
||||||
|
return pluginManager->getObject<QmlJS::ModelManagerInterface>();
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectorUi *InspectorPlugin::inspector() const
|
InspectorUi *InspectorPlugin::inspector() const
|
||||||
@@ -86,7 +88,8 @@ ExtensionSystem::IPlugin::ShutdownFlag InspectorPlugin::aboutToShutdown()
|
|||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InspectorPlugin::initialize(const QStringList &arguments, QString *errorString)
|
bool InspectorPlugin::initialize(const QStringList &arguments,
|
||||||
|
QString *errorString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments);
|
Q_UNUSED(arguments);
|
||||||
Q_UNUSED(errorString);
|
Q_UNUSED(errorString);
|
||||||
@@ -96,10 +99,13 @@ bool InspectorPlugin::initialize(const QStringList &arguments, QString *errorStr
|
|||||||
|
|
||||||
void InspectorPlugin::extensionsInitialized()
|
void InspectorPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pluginManager
|
||||||
|
= ExtensionSystem::PluginManager::instance();
|
||||||
|
|
||||||
connect(pluginManager, SIGNAL(objectAdded(QObject*)), SLOT(objectAdded(QObject*)));
|
connect(pluginManager, SIGNAL(objectAdded(QObject*)),
|
||||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
SLOT(objectAdded(QObject*)));
|
||||||
|
connect(Core::ModeManager::instance(),
|
||||||
|
SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
||||||
this, SLOT(modeAboutToChange(Core::IMode*)));
|
this, SLOT(modeAboutToChange(Core::IMode*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +119,8 @@ void InspectorPlugin::objectAdded(QObject *object)
|
|||||||
if (m_clientProxy->isConnected()) {
|
if (m_clientProxy->isConnected()) {
|
||||||
clientProxyConnected();
|
clientProxyConnected();
|
||||||
} else {
|
} else {
|
||||||
connect(m_clientProxy, SIGNAL(connected()), this, SLOT(clientProxyConnected()));
|
connect(m_clientProxy, SIGNAL(connected()),
|
||||||
|
this, SLOT(clientProxyConnected()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -144,7 +151,8 @@ void InspectorPlugin::modeAboutToChange(Core::IMode *newMode)
|
|||||||
m_inspectorUi->setupUi();
|
m_inspectorUi->setupUi();
|
||||||
|
|
||||||
// Make sure we're not called again.
|
// Make sure we're not called again.
|
||||||
QObject::disconnect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
QObject::disconnect(Core::ModeManager::instance(),
|
||||||
|
SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
||||||
this, SLOT(modeAboutToChange(Core::IMode*)));
|
this, SLOT(modeAboutToChange(Core::IMode*)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ class InspectorUi;
|
|||||||
class InspectorPlugin : public ExtensionSystem::IPlugin
|
class InspectorPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlJSInspector.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin"
|
||||||
|
FILE "QmlJSInspector.json")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InspectorPlugin();
|
InspectorPlugin();
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
namespace QmlJSInspector {
|
namespace QmlJSInspector {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
using namespace QmlJSInspector::Constants;
|
||||||
|
|
||||||
InspectorSettings::InspectorSettings(QObject *parent)
|
InspectorSettings::InspectorSettings(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_showLivePreviewWarning(true)
|
m_showLivePreviewWarning(true)
|
||||||
@@ -45,15 +47,18 @@ InspectorSettings::InspectorSettings(QObject *parent)
|
|||||||
|
|
||||||
void InspectorSettings::restoreSettings(QSettings *settings)
|
void InspectorSettings::restoreSettings(QSettings *settings)
|
||||||
{
|
{
|
||||||
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
settings->beginGroup(QLatin1String(S_QML_INSPECTOR));
|
||||||
m_showLivePreviewWarning = settings->value(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), true).toBool();
|
m_showLivePreviewWarning
|
||||||
|
= settings->value(QLatin1String(S_LIVE_PREVIEW_WARNING_KEY),
|
||||||
|
true).toBool();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorSettings::saveSettings(QSettings *settings) const
|
void InspectorSettings::saveSettings(QSettings *settings) const
|
||||||
{
|
{
|
||||||
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
settings->beginGroup(QLatin1String(S_QML_INSPECTOR));
|
||||||
settings->setValue(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), m_showLivePreviewWarning);
|
settings->setValue(QLatin1String(S_LIVE_PREVIEW_WARNING_KEY),
|
||||||
|
m_showLivePreviewWarning);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,21 +171,23 @@ void QmlJsInspectorToolBar::setZoomToolEnabled(bool enable)
|
|||||||
|
|
||||||
void QmlJsInspectorToolBar::createActions()
|
void QmlJsInspectorToolBar::createActions()
|
||||||
{
|
{
|
||||||
|
using namespace Constants;
|
||||||
|
|
||||||
Core::Context context(Debugger::Constants::C_QMLDEBUGGER);
|
Core::Context context(Debugger::Constants::C_QMLDEBUGGER);
|
||||||
Core::ActionManager *am = Core::ICore::actionManager();
|
Core::ActionManager *am = Core::ICore::actionManager();
|
||||||
|
|
||||||
m_fromQmlAction = new Utils::SavedAction(this);
|
m_fromQmlAction = new Utils::SavedAction(this);
|
||||||
m_fromQmlAction->setDefaultValue(false);
|
m_fromQmlAction->setDefaultValue(false);
|
||||||
m_fromQmlAction->setSettingsKey(QLatin1String(Constants::S_QML_INSPECTOR),
|
m_fromQmlAction->setSettingsKey(QLatin1String(S_QML_INSPECTOR),
|
||||||
QLatin1String(Constants::FROM_QML_ACTION));
|
QLatin1String(FROM_QML_ACTION));
|
||||||
m_fromQmlAction->setText(tr("Apply Changes on Save"));
|
m_fromQmlAction->setText(tr("Apply Changes on Save"));
|
||||||
m_fromQmlAction->setCheckable(true);
|
m_fromQmlAction->setCheckable(true);
|
||||||
m_fromQmlAction->setIcon(QIcon(QLatin1String(":/qml/images/from-qml-small.png")));
|
m_fromQmlAction->setIcon(QIcon(QLatin1String(":/qml/images/from-qml-small.png")));
|
||||||
|
|
||||||
m_showAppOnTopAction = new Utils::SavedAction(this);
|
m_showAppOnTopAction = new Utils::SavedAction(this);
|
||||||
m_showAppOnTopAction->setDefaultValue(false);
|
m_showAppOnTopAction->setDefaultValue(false);
|
||||||
m_showAppOnTopAction->setSettingsKey(QLatin1String(Constants::S_QML_INSPECTOR),
|
m_showAppOnTopAction->setSettingsKey(QLatin1String(S_QML_INSPECTOR),
|
||||||
QLatin1String(Constants::SHOW_APP_ON_TOP_ACTION));
|
QLatin1String(SHOW_APP_ON_TOP_ACTION));
|
||||||
m_showAppOnTopAction->setText(tr("Show application on top"));
|
m_showAppOnTopAction->setText(tr("Show application on top"));
|
||||||
m_showAppOnTopAction->setCheckable(true);
|
m_showAppOnTopAction->setCheckable(true);
|
||||||
m_showAppOnTopAction->setIcon(QIcon(QLatin1String(":/qml/images/app-on-top.png")));
|
m_showAppOnTopAction->setIcon(QIcon(QLatin1String(":/qml/images/app-on-top.png")));
|
||||||
@@ -202,40 +204,46 @@ void QmlJsInspectorToolBar::createActions()
|
|||||||
m_selectAction->setCheckable(true);
|
m_selectAction->setCheckable(true);
|
||||||
m_zoomAction->setCheckable(true);
|
m_zoomAction->setCheckable(true);
|
||||||
|
|
||||||
Core::Command *command = am->registerAction(m_playAction, Constants::PLAY_ACTION, context);
|
Core::Command *command
|
||||||
|
= am->registerAction(m_playAction, PLAY_ACTION, context);
|
||||||
command->setAttribute(Core::Command::CA_UpdateIcon);
|
command->setAttribute(Core::Command::CA_UpdateIcon);
|
||||||
am->registerAction(m_selectAction, Constants::SELECT_ACTION, context);
|
am->registerAction(m_selectAction, SELECT_ACTION, context);
|
||||||
am->registerAction(m_zoomAction, Constants::ZOOM_ACTION, context);
|
am->registerAction(m_zoomAction, ZOOM_ACTION, context);
|
||||||
am->registerAction(m_fromQmlAction, Constants::FROM_QML_ACTION, context);
|
am->registerAction(m_fromQmlAction, FROM_QML_ACTION, context);
|
||||||
am->registerAction(m_showAppOnTopAction, Constants::SHOW_APP_ON_TOP_ACTION, context);
|
am->registerAction(m_showAppOnTopAction, SHOW_APP_ON_TOP_ACTION, context);
|
||||||
|
|
||||||
m_barWidget = new QWidget;
|
m_barWidget = new QWidget;
|
||||||
|
|
||||||
QMenu *playSpeedMenu = new QMenu(m_barWidget);
|
QMenu *playSpeedMenu = new QMenu(m_barWidget);
|
||||||
m_playSpeedMenuActions = new QActionGroup(this);
|
m_playSpeedMenuActions = new QActionGroup(this);
|
||||||
m_playSpeedMenuActions->setExclusive(true);
|
m_playSpeedMenuActions->setExclusive(true);
|
||||||
QAction *speedAction = playSpeedMenu->addAction(tr("1x"), this, SLOT(changeAnimationSpeed()));
|
QAction *speedAction = playSpeedMenu->addAction(tr("1x"),
|
||||||
|
this, SLOT(changeAnimationSpeed()));
|
||||||
speedAction->setCheckable(true);
|
speedAction->setCheckable(true);
|
||||||
speedAction->setChecked(true);
|
speedAction->setChecked(true);
|
||||||
speedAction->setData(1.0f);
|
speedAction->setData(1.0f);
|
||||||
m_playSpeedMenuActions->addAction(speedAction);
|
m_playSpeedMenuActions->addAction(speedAction);
|
||||||
|
|
||||||
speedAction = playSpeedMenu->addAction(tr("0.5x"), this, SLOT(changeAnimationSpeed()));
|
speedAction = playSpeedMenu->addAction(tr("0.5x"),
|
||||||
|
this, SLOT(changeAnimationSpeed()));
|
||||||
speedAction->setCheckable(true);
|
speedAction->setCheckable(true);
|
||||||
speedAction->setData(2.0f);
|
speedAction->setData(2.0f);
|
||||||
m_playSpeedMenuActions->addAction(speedAction);
|
m_playSpeedMenuActions->addAction(speedAction);
|
||||||
|
|
||||||
speedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeAnimationSpeed()));
|
speedAction = playSpeedMenu->addAction(tr("0.25x"),
|
||||||
|
this, SLOT(changeAnimationSpeed()));
|
||||||
speedAction->setCheckable(true);
|
speedAction->setCheckable(true);
|
||||||
speedAction->setData(4.0f);
|
speedAction->setData(4.0f);
|
||||||
m_playSpeedMenuActions->addAction(speedAction);
|
m_playSpeedMenuActions->addAction(speedAction);
|
||||||
|
|
||||||
speedAction = playSpeedMenu->addAction(tr("0.125x"), this, SLOT(changeAnimationSpeed()));
|
speedAction = playSpeedMenu->addAction(tr("0.125x"),
|
||||||
|
this, SLOT(changeAnimationSpeed()));
|
||||||
speedAction->setCheckable(true);
|
speedAction->setCheckable(true);
|
||||||
speedAction->setData(8.0f);
|
speedAction->setData(8.0f);
|
||||||
m_playSpeedMenuActions->addAction(speedAction);
|
m_playSpeedMenuActions->addAction(speedAction);
|
||||||
|
|
||||||
speedAction = playSpeedMenu->addAction(tr("0.1x"), this, SLOT(changeAnimationSpeed()));
|
speedAction = playSpeedMenu->addAction(tr("0.1x"),
|
||||||
|
this, SLOT(changeAnimationSpeed()));
|
||||||
speedAction->setCheckable(true);
|
speedAction->setCheckable(true);
|
||||||
speedAction->setData(10.0f);
|
speedAction->setData(10.0f);
|
||||||
m_playSpeedMenuActions->addAction(speedAction);
|
m_playSpeedMenuActions->addAction(speedAction);
|
||||||
@@ -245,23 +253,29 @@ void QmlJsInspectorToolBar::createActions()
|
|||||||
toolBarLayout->setSpacing(0);
|
toolBarLayout->setSpacing(0);
|
||||||
|
|
||||||
// QML Helpers
|
// QML Helpers
|
||||||
toolBarLayout->addWidget(toolButton(am->command(Constants::FROM_QML_ACTION)->action()));
|
toolBarLayout->addWidget(toolButton(am->command(FROM_QML_ACTION)->action()));
|
||||||
toolBarLayout->addWidget(toolButton(am->command(Constants::SHOW_APP_ON_TOP_ACTION)->action()));
|
toolBarLayout->addWidget(
|
||||||
m_playButton = toolButton(am->command(Constants::PLAY_ACTION)->action());
|
toolButton(am->command(SHOW_APP_ON_TOP_ACTION)->action()));
|
||||||
|
m_playButton = toolButton(am->command(PLAY_ACTION)->action());
|
||||||
m_playButton->setMenu(playSpeedMenu);
|
m_playButton->setMenu(playSpeedMenu);
|
||||||
toolBarLayout->addWidget(m_playButton);
|
toolBarLayout->addWidget(m_playButton);
|
||||||
|
|
||||||
// Inspector
|
// Inspector
|
||||||
toolBarLayout->addWidget(new Utils::StyledSeparator);
|
toolBarLayout->addWidget(new Utils::StyledSeparator);
|
||||||
toolBarLayout->addWidget(toolButton(am->command(Constants::SELECT_ACTION)->action()));
|
toolBarLayout->addWidget(toolButton(am->command(SELECT_ACTION)->action()));
|
||||||
toolBarLayout->addWidget(toolButton(am->command(Constants::ZOOM_ACTION)->action()));
|
toolBarLayout->addWidget(toolButton(am->command(ZOOM_ACTION)->action()));
|
||||||
toolBarLayout->addWidget(new Utils::StyledSeparator);
|
toolBarLayout->addWidget(new Utils::StyledSeparator);
|
||||||
|
|
||||||
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
|
connect(m_fromQmlAction, SIGNAL(triggered()),
|
||||||
connect(m_showAppOnTopAction, SIGNAL(triggered()), SLOT(showAppOnTopClick()));
|
SLOT(activateFromQml()));
|
||||||
connect(m_playAction, SIGNAL(triggered()), SLOT(activatePlayOnClick()));
|
connect(m_showAppOnTopAction, SIGNAL(triggered()),
|
||||||
connect(m_selectAction, SIGNAL(triggered(bool)), SLOT(selectToolTriggered(bool)));
|
SLOT(showAppOnTopClick()));
|
||||||
connect(m_zoomAction, SIGNAL(triggered(bool)), SLOT(zoomToolTriggered(bool)));
|
connect(m_playAction, SIGNAL(triggered()),
|
||||||
|
SLOT(activatePlayOnClick()));
|
||||||
|
connect(m_selectAction, SIGNAL(triggered(bool)),
|
||||||
|
SLOT(selectToolTriggered(bool)));
|
||||||
|
connect(m_zoomAction, SIGNAL(triggered(bool)),
|
||||||
|
SLOT(zoomToolTriggered(bool)));
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
connect(Core::ICore::instance(),
|
connect(Core::ICore::instance(),
|
||||||
@@ -350,8 +364,10 @@ void QmlJsInspectorToolBar::activateFromQml()
|
|||||||
void QmlJsInspectorToolBar::updateDesignModeActions(DesignTool activeTool)
|
void QmlJsInspectorToolBar::updateDesignModeActions(DesignTool activeTool)
|
||||||
{
|
{
|
||||||
m_activeTool = activeTool;
|
m_activeTool = activeTool;
|
||||||
m_selectAction->setChecked(m_designModeActive && (m_activeTool == SelectionToolMode));
|
m_selectAction->setChecked(m_designModeActive
|
||||||
m_zoomAction->setChecked(m_designModeActive && (m_activeTool == ZoomMode));
|
&& (m_activeTool == SelectionToolMode));
|
||||||
|
m_zoomAction->setChecked(m_designModeActive
|
||||||
|
&& (m_activeTool == ZoomMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -88,49 +88,51 @@ private:
|
|||||||
int activated;
|
int activated;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool MapObjectWithDebugReference::visit(UiObjectDefinition* ast)
|
bool MapObjectWithDebugReference::visit(UiObjectDefinition *ast)
|
||||||
{
|
{
|
||||||
if (lookupObjects.contains(ast))
|
if (lookupObjects.contains(ast))
|
||||||
activated++;
|
activated++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapObjectWithDebugReference::visit(UiObjectBinding* ast)
|
bool MapObjectWithDebugReference::visit(UiObjectBinding *ast)
|
||||||
{
|
{
|
||||||
if (lookupObjects.contains(ast))
|
if (lookupObjects.contains(ast))
|
||||||
activated++;
|
activated++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapObjectWithDebugReference::endVisit(UiObjectDefinition* ast)
|
void MapObjectWithDebugReference::endVisit(UiObjectDefinition *ast)
|
||||||
{
|
{
|
||||||
process(ast);
|
process(ast);
|
||||||
if (lookupObjects.contains(ast))
|
if (lookupObjects.contains(ast))
|
||||||
activated--;
|
activated--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapObjectWithDebugReference::endVisit(UiObjectBinding* ast)
|
void MapObjectWithDebugReference::endVisit(UiObjectBinding *ast)
|
||||||
{
|
{
|
||||||
process(ast);
|
process(ast);
|
||||||
if (lookupObjects.contains(ast))
|
if (lookupObjects.contains(ast))
|
||||||
activated--;
|
activated--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapObjectWithDebugReference::process(UiObjectMember* ast)
|
void MapObjectWithDebugReference::process(UiObjectMember *ast)
|
||||||
{
|
{
|
||||||
if (lookupObjects.isEmpty() || activated) {
|
if (lookupObjects.isEmpty() || activated) {
|
||||||
SourceLocation loc = ast->firstSourceLocation();
|
SourceLocation loc = ast->firstSourceLocation();
|
||||||
QHash<QPair<int, int>, DebugIdList>::const_iterator it = ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
QHash<QPair<int, int>, DebugIdList>::const_iterator it
|
||||||
|
= ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
||||||
if (it != ids.constEnd())
|
if (it != ids.constEnd())
|
||||||
result[ast].append(*it);
|
result[ast].append(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapObjectWithDebugReference::process(UiObjectBinding* ast)
|
void MapObjectWithDebugReference::process(UiObjectBinding *ast)
|
||||||
{
|
{
|
||||||
if (lookupObjects.isEmpty() || activated) {
|
if (lookupObjects.isEmpty() || activated) {
|
||||||
SourceLocation loc = ast->qualifiedTypeNameId->identifierToken;
|
SourceLocation loc = ast->qualifiedTypeNameId->identifierToken;
|
||||||
QHash<QPair<int, int>, DebugIdList>::const_iterator it = ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
QHash<QPair<int, int>, DebugIdList>::const_iterator it
|
||||||
|
= ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
||||||
if (it != ids.constEnd())
|
if (it != ids.constEnd())
|
||||||
result[ast].append(*it);
|
result[ast].append(*it);
|
||||||
}
|
}
|
||||||
@@ -138,7 +140,9 @@ void MapObjectWithDebugReference::process(UiObjectBinding* ast)
|
|||||||
|
|
||||||
QmlJS::ModelManagerInterface *QmlJSLiveTextPreview::modelManager()
|
QmlJS::ModelManagerInterface *QmlJSLiveTextPreview::modelManager()
|
||||||
{
|
{
|
||||||
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
ExtensionSystem::PluginManager *pm
|
||||||
|
= ExtensionSystem::PluginManager::instance();
|
||||||
|
return pm->getObject<QmlJS::ModelManagerInterface>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
|
void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
|
||||||
@@ -149,13 +153,15 @@ void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
|
|||||||
QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
|
QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
|
||||||
return);
|
return);
|
||||||
|
|
||||||
BaseTextEditorWidget *editWidget = qobject_cast<BaseTextEditorWidget*>(editor->widget());
|
BaseTextEditorWidget *editWidget
|
||||||
|
= qobject_cast<BaseTextEditorWidget*>(editor->widget());
|
||||||
QTC_ASSERT(editWidget, return);
|
QTC_ASSERT(editWidget, return);
|
||||||
|
|
||||||
if (!m_editors.contains(editWidget)) {
|
if (!m_editors.contains(editWidget)) {
|
||||||
m_editors << editWidget;
|
m_editors << editWidget;
|
||||||
if (m_clientProxy.data())
|
if (m_clientProxy.data())
|
||||||
connect(editWidget, SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
connect(editWidget,
|
||||||
|
SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||||
SLOT(changeSelectedElements(QList<int>,QString)));
|
SLOT(changeSelectedElements(QList<int>,QString)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,8 +170,10 @@ void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
|
|||||||
void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
|
void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
|
||||||
{
|
{
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
if (oldEditor && oldEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
if (oldEditor && oldEditor->id()
|
||||||
BaseTextEditorWidget *editWidget = qobject_cast<BaseTextEditorWidget*>(oldEditor->widget());
|
== QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||||
|
BaseTextEditorWidget *editWidget
|
||||||
|
= qobject_cast<BaseTextEditorWidget*>(oldEditor->widget());
|
||||||
QTC_ASSERT(editWidget, return);
|
QTC_ASSERT(editWidget, return);
|
||||||
|
|
||||||
if (m_editors.contains(editWidget)) {
|
if (m_editors.contains(editWidget)) {
|
||||||
@@ -178,7 +186,7 @@ void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
|
|||||||
QmlJSLiveTextPreview::QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc,
|
QmlJSLiveTextPreview::QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc,
|
||||||
const QmlJS::Document::Ptr &initDoc,
|
const QmlJS::Document::Ptr &initDoc,
|
||||||
ClientProxy *clientProxy,
|
ClientProxy *clientProxy,
|
||||||
QObject* parent)
|
QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_previousDoc(doc)
|
, m_previousDoc(doc)
|
||||||
, m_initialDoc(initDoc)
|
, m_initialDoc(initDoc)
|
||||||
@@ -194,7 +202,8 @@ QmlJSLiveTextPreview::QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc,
|
|||||||
SLOT(documentChanged(QmlJS::Document::Ptr)));
|
SLOT(documentChanged(QmlJS::Document::Ptr)));
|
||||||
|
|
||||||
if (m_clientProxy.data()) {
|
if (m_clientProxy.data()) {
|
||||||
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()), SLOT(updateDebugIds()));
|
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()),
|
||||||
|
SLOT(updateDebugIds()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +247,8 @@ QList<int> QmlJSLiveTextPreview::objectReferencesForOffset(quint32 offset)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QString &wordAtCursor)
|
void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets,
|
||||||
|
const QString &wordAtCursor)
|
||||||
{
|
{
|
||||||
if (m_editors.isEmpty() || !m_previousDoc || !m_clientProxy)
|
if (m_editors.isEmpty() || !m_previousDoc || !m_clientProxy)
|
||||||
return;
|
return;
|
||||||
@@ -246,7 +256,8 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
|
|||||||
m_updateNodeForOffset = false;
|
m_updateNodeForOffset = false;
|
||||||
m_lastOffsets = offsets;
|
m_lastOffsets = offsets;
|
||||||
QmlDebugObjectReference objectRefUnderCursor;
|
QmlDebugObjectReference objectRefUnderCursor;
|
||||||
objectRefUnderCursor = m_clientProxy.data()->objectReferenceForId(wordAtCursor);
|
objectRefUnderCursor
|
||||||
|
= m_clientProxy.data()->objectReferenceForId(wordAtCursor);
|
||||||
|
|
||||||
QList<int> selectedReferences;
|
QList<int> selectedReferences;
|
||||||
bool containsReferenceUnderCursor = false;
|
bool containsReferenceUnderCursor = false;
|
||||||
@@ -255,7 +266,8 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
|
|||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
QList<int> list = objectReferencesForOffset(offset);
|
QList<int> list = objectReferencesForOffset(offset);
|
||||||
|
|
||||||
if (!containsReferenceUnderCursor && objectRefUnderCursor.debugId() != -1) {
|
if (!containsReferenceUnderCursor
|
||||||
|
&& objectRefUnderCursor.debugId() != -1) {
|
||||||
foreach(int id, list) {
|
foreach(int id, list) {
|
||||||
if (id == objectRefUnderCursor.debugId()) {
|
if (id == objectRefUnderCursor.debugId()) {
|
||||||
containsReferenceUnderCursor = true;
|
containsReferenceUnderCursor = true;
|
||||||
@@ -284,7 +296,8 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<int> findRootObjectRecursive(const QmlDebugObjectReference &object, const Document::Ptr &doc)
|
static QList<int> findRootObjectRecursive(const QmlDebugObjectReference &object,
|
||||||
|
const Document::Ptr &doc)
|
||||||
{
|
{
|
||||||
QList<int> result;
|
QList<int> result;
|
||||||
if (object.className() == doc->componentName())
|
if (object.className() == doc->componentName())
|
||||||
@@ -301,13 +314,16 @@ void QmlJSLiveTextPreview::updateDebugIds()
|
|||||||
if (!m_initialDoc->qmlProgram())
|
if (!m_initialDoc->qmlProgram())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ClientProxy* clientProxy = m_clientProxy.data();
|
ClientProxy *clientProxy = m_clientProxy.data();
|
||||||
if (!clientProxy)
|
if (!clientProxy)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DebugIdHash::const_iterator it = clientProxy->debugIdHash().constFind(qMakePair<QString, int>(m_initialDoc->fileName(), 0));
|
DebugIdHash::const_iterator it
|
||||||
|
= clientProxy->debugIdHash().constFind(
|
||||||
|
qMakePair<QString, int>(m_initialDoc->fileName(), 0));
|
||||||
if (it != clientProxy->debugIdHash().constEnd()) {
|
if (it != clientProxy->debugIdHash().constEnd()) {
|
||||||
// Map all the object that comes from the document as it has been loaded by the server.
|
// Map all the object that comes from the document as it has been loaded
|
||||||
|
// by the server.
|
||||||
const QmlJS::Document::Ptr &doc = m_initialDoc;
|
const QmlJS::Document::Ptr &doc = m_initialDoc;
|
||||||
|
|
||||||
MapObjectWithDebugReference visitor;
|
MapObjectWithDebugReference visitor;
|
||||||
@@ -328,16 +344,19 @@ void QmlJSLiveTextPreview::updateDebugIds()
|
|||||||
|
|
||||||
// Map the root nodes of the document.
|
// Map the root nodes of the document.
|
||||||
if(doc->qmlProgram()->members && doc->qmlProgram()->members->member) {
|
if(doc->qmlProgram()->members && doc->qmlProgram()->members->member) {
|
||||||
UiObjectMember* root = doc->qmlProgram()->members->member;
|
UiObjectMember *root = doc->qmlProgram()->members->member;
|
||||||
QList<int> r;
|
QList<int> r;
|
||||||
foreach (const QmlDebugObjectReference& it, clientProxy->rootObjectReference())
|
foreach (const QmlDebugObjectReference& it,
|
||||||
|
clientProxy->rootObjectReference()) {
|
||||||
r += findRootObjectRecursive(it, doc);
|
r += findRootObjectRecursive(it, doc);
|
||||||
|
}
|
||||||
if (!r.isEmpty())
|
if (!r.isEmpty())
|
||||||
m_debugIds[root] += r;
|
m_debugIds[root] += r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map the node of the later created objects.
|
// Map the node of the later created objects.
|
||||||
for(QHash<Document::Ptr,QSet<UiObjectMember*> >::const_iterator it = m_createdObjects.constBegin();
|
for (QHash<Document::Ptr,QSet<UiObjectMember*> >::const_iterator it
|
||||||
|
= m_createdObjects.constBegin();
|
||||||
it != m_createdObjects.constEnd(); ++it) {
|
it != m_createdObjects.constEnd(); ++it) {
|
||||||
|
|
||||||
const QmlJS::Document::Ptr &doc = it.key();
|
const QmlJS::Document::Ptr &doc = it.key();
|
||||||
@@ -373,7 +392,8 @@ private:
|
|||||||
static inline QString stripQuotes(const QString &str)
|
static inline QString stripQuotes(const QString &str)
|
||||||
{
|
{
|
||||||
if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
|
if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
|
||||||
|| (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
|
|| (str.startsWith(QLatin1Char('\''))
|
||||||
|
&& str.endsWith(QLatin1Char('\''))))
|
||||||
return str.mid(1, str.length() - 2);
|
return str.mid(1, str.length() - 2);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
@@ -392,11 +412,13 @@ private:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString cleanExpression(const QString &expression, UiScriptBinding *scriptBinding)
|
static QString cleanExpression(const QString &expression,
|
||||||
|
UiScriptBinding *scriptBinding)
|
||||||
{
|
{
|
||||||
QString trimmedExpression = expression.trimmed();
|
QString trimmedExpression = expression.trimmed();
|
||||||
|
|
||||||
if (ExpressionStatement *expStatement = cast<ExpressionStatement*>(scriptBinding->statement)) {
|
if (ExpressionStatement *expStatement
|
||||||
|
= cast<ExpressionStatement*>(scriptBinding->statement)) {
|
||||||
if (expStatement->semicolonToken.isValid())
|
if (expStatement->semicolonToken.isValid())
|
||||||
trimmedExpression.chop(1);
|
trimmedExpression.chop(1);
|
||||||
}
|
}
|
||||||
@@ -410,9 +432,11 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
else if (cast<StringLiteral*>(expr))
|
else if (cast<StringLiteral*>(expr))
|
||||||
return true;
|
return true;
|
||||||
else if (UnaryPlusExpression *plusExpr = cast<UnaryPlusExpression*>(expr))
|
else if (UnaryPlusExpression *plusExpr
|
||||||
|
= cast<UnaryPlusExpression*>(expr))
|
||||||
return isLiteralValue(plusExpr->expression);
|
return isLiteralValue(plusExpr->expression);
|
||||||
else if (UnaryMinusExpression *minusExpr = cast<UnaryMinusExpression*>(expr))
|
else if (UnaryMinusExpression *minusExpr
|
||||||
|
= cast<UnaryMinusExpression*>(expr))
|
||||||
return isLiteralValue(minusExpr->expression);
|
return isLiteralValue(minusExpr->expression);
|
||||||
else if (cast<TrueLiteral*>(expr))
|
else if (cast<TrueLiteral*>(expr))
|
||||||
return true;
|
return true;
|
||||||
@@ -427,19 +451,22 @@ private:
|
|||||||
if (!script || !script->statement)
|
if (!script || !script->statement)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ExpressionStatement *exprStmt = cast<ExpressionStatement *>(script->statement);
|
ExpressionStatement *exprStmt
|
||||||
|
= cast<ExpressionStatement *>(script->statement);
|
||||||
if (exprStmt)
|
if (exprStmt)
|
||||||
return isLiteralValue(exprStmt->expression);
|
return isLiteralValue(exprStmt->expression);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant castToLiteral(const QString &expression, UiScriptBinding *scriptBinding)
|
static QVariant castToLiteral(const QString &expression,
|
||||||
|
UiScriptBinding *scriptBinding)
|
||||||
{
|
{
|
||||||
const QString cleanedValue = cleanExpression(expression, scriptBinding);
|
const QString cleanedValue = cleanExpression(expression, scriptBinding);
|
||||||
QVariant castedExpression;
|
QVariant castedExpression;
|
||||||
|
|
||||||
ExpressionStatement *expStatement = cast<ExpressionStatement*>(scriptBinding->statement);
|
ExpressionStatement *expStatement
|
||||||
|
= cast<ExpressionStatement*>(scriptBinding->statement);
|
||||||
|
|
||||||
switch(expStatement->expression->kind) {
|
switch(expStatement->expression->kind) {
|
||||||
case Node::Kind_NumericLiteral:
|
case Node::Kind_NumericLiteral:
|
||||||
@@ -464,8 +491,10 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateMethodBody(DebugId debugId,
|
virtual void updateMethodBody(DebugId debugId,
|
||||||
UiObjectMember *parentDefinition, UiScriptBinding* scriptBinding,
|
UiObjectMember *parentDefinition,
|
||||||
const QString& methodName, const QString& methodBody)
|
UiScriptBinding *scriptBinding,
|
||||||
|
const QString &methodName,
|
||||||
|
const QString &methodBody)
|
||||||
{
|
{
|
||||||
Q_UNUSED(scriptBinding);
|
Q_UNUSED(scriptBinding);
|
||||||
Q_UNUSED(parentDefinition);
|
Q_UNUSED(parentDefinition);
|
||||||
@@ -474,15 +503,21 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void updateScriptBinding(DebugId debugId,
|
virtual void updateScriptBinding(DebugId debugId,
|
||||||
UiObjectMember *parentDefinition, UiScriptBinding* scriptBinding,
|
UiObjectMember *parentDefinition,
|
||||||
const QString& propertyName, const QString& scriptCode)
|
UiScriptBinding *scriptBinding,
|
||||||
|
const QString &propertyName,
|
||||||
|
const QString &scriptCode)
|
||||||
{
|
{
|
||||||
if (unsyncronizableChanges == QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
|
if (unsyncronizableChanges
|
||||||
|
== QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
|
||||||
if (propertyName == QLatin1String("id")) {
|
if (propertyName == QLatin1String("id")) {
|
||||||
unsyncronizableElementName = propertyName;
|
unsyncronizableElementName = propertyName;
|
||||||
unsyncronizableChanges = QmlJSLiveTextPreview::AttributeChangeWarning;
|
unsyncronizableChanges
|
||||||
unsyncronizableChangeLine = parentDefinition->firstSourceLocation().startLine;
|
= QmlJSLiveTextPreview::AttributeChangeWarning;
|
||||||
unsyncronizableChangeColumn = parentDefinition->firstSourceLocation().startColumn;
|
unsyncronizableChangeLine
|
||||||
|
= parentDefinition->firstSourceLocation().startLine;
|
||||||
|
unsyncronizableChangeColumn
|
||||||
|
= parentDefinition->firstSourceLocation().startColumn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,8 +544,10 @@ protected:
|
|||||||
m_clientProxy->destroyQmlObject(debugId);
|
m_clientProxy->destroyQmlObject(debugId);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void createObject(const QString& qmlText, DebugId ref,
|
virtual void createObject(const QString &qmlText, DebugId ref,
|
||||||
const QStringList& importList, const QString& filename, int order)
|
const QStringList &importList,
|
||||||
|
const QString &filename,
|
||||||
|
int order)
|
||||||
{
|
{
|
||||||
appliedChangesToViewer = true;
|
appliedChangesToViewer = true;
|
||||||
referenceRefreshRequired = true;
|
referenceRefreshRequired = true;
|
||||||
@@ -530,10 +567,14 @@ protected:
|
|||||||
if (parentDefinition && parentDefinition->qualifiedTypeNameId
|
if (parentDefinition && parentDefinition->qualifiedTypeNameId
|
||||||
&& !parentDefinition->qualifiedTypeNameId->name.isEmpty())
|
&& !parentDefinition->qualifiedTypeNameId->name.isEmpty())
|
||||||
{
|
{
|
||||||
unsyncronizableElementName = parentDefinition->qualifiedTypeNameId->name.toString();
|
unsyncronizableElementName
|
||||||
unsyncronizableChanges = QmlJSLiveTextPreview::ElementChangeWarning;
|
= parentDefinition->qualifiedTypeNameId->name.toString();
|
||||||
unsyncronizableChangeLine = parentDefinition->firstSourceLocation().startLine;
|
unsyncronizableChanges
|
||||||
unsyncronizableChangeColumn = parentDefinition->firstSourceLocation().startColumn;
|
= QmlJSLiveTextPreview::ElementChangeWarning;
|
||||||
|
unsyncronizableChangeLine
|
||||||
|
= parentDefinition->firstSourceLocation().startLine;
|
||||||
|
unsyncronizableChangeColumn
|
||||||
|
= parentDefinition->firstSourceLocation().startColumn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -576,15 +617,19 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
|||||||
if (delta.referenceRefreshRequired)
|
if (delta.referenceRefreshRequired)
|
||||||
m_clientProxy.data()->refreshObjectTree();
|
m_clientProxy.data()->refreshObjectTree();
|
||||||
|
|
||||||
if (InspectorUi::instance()->showExperimentalWarning() && delta.appliedChangesToViewer) {
|
if (InspectorUi::instance()->showExperimentalWarning()
|
||||||
|
&& delta.appliedChangesToViewer) {
|
||||||
showExperimentalWarning();
|
showExperimentalWarning();
|
||||||
experimentalWarningShown = true;
|
experimentalWarningShown = true;
|
||||||
InspectorUi::instance()->setShowExperimentalWarning(false);
|
InspectorUi::instance()->setShowExperimentalWarning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta.unsyncronizableChanges != NoUnsyncronizableChanges && !experimentalWarningShown)
|
if (delta.unsyncronizableChanges != NoUnsyncronizableChanges
|
||||||
showSyncWarning(delta.unsyncronizableChanges, delta.unsyncronizableElementName,
|
&& !experimentalWarningShown)
|
||||||
delta.unsyncronizableChangeLine, delta.unsyncronizableChangeColumn);
|
showSyncWarning(delta.unsyncronizableChanges,
|
||||||
|
delta.unsyncronizableElementName,
|
||||||
|
delta.unsyncronizableChangeLine,
|
||||||
|
delta.unsyncronizableChangeColumn);
|
||||||
|
|
||||||
m_previousDoc = doc;
|
m_previousDoc = doc;
|
||||||
if (!delta.newObjects.isEmpty())
|
if (!delta.newObjects.isEmpty())
|
||||||
@@ -603,24 +648,30 @@ void QmlJSLiveTextPreview::showExperimentalWarning()
|
|||||||
if (editor) {
|
if (editor) {
|
||||||
Core::InfoBarEntry info(
|
Core::InfoBarEntry info(
|
||||||
Constants::INFO_EXPERIMENTAL,
|
Constants::INFO_EXPERIMENTAL,
|
||||||
tr("You changed a QML file in Live Preview mode, which modifies the running QML application. "
|
tr("You changed a QML file in Live Preview mode, which "
|
||||||
"In case of unexpected behavior, please reload the QML application."));
|
"modifies the running QML application. In case of "
|
||||||
info.setCustomButtonInfo(tr("Disable Live Preview"), this, SLOT(disableLivePreview()));
|
"unexpected behavior, please reload the QML "
|
||||||
|
"application."));
|
||||||
|
info.setCustomButtonInfo(tr("Disable Live Preview"), this,
|
||||||
|
SLOT(disableLivePreview()));
|
||||||
editor.data()->editorDocument()->infoBar()->addInfo(info);
|
editor.data()->editorDocument()->infoBar()->addInfo(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSLiveTextPreview::showSyncWarning(UnsyncronizableChangeType unsyncronizableChangeType,
|
void QmlJSLiveTextPreview::showSyncWarning(
|
||||||
|
UnsyncronizableChangeType unsyncronizableChangeType,
|
||||||
const QString &elementName, unsigned line, unsigned column)
|
const QString &elementName, unsigned line, unsigned column)
|
||||||
{
|
{
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
switch (unsyncronizableChangeType) {
|
switch (unsyncronizableChangeType) {
|
||||||
case AttributeChangeWarning:
|
case AttributeChangeWarning:
|
||||||
errorMessage = tr("The %1 attribute at line %2, column %3 cannot be changed without reloading the QML application. ")
|
errorMessage = tr("The %1 attribute at line %2, column %3 cannot be "
|
||||||
|
"changed without reloading the QML application. ")
|
||||||
.arg(elementName, QString::number(line), QString::number(column));
|
.arg(elementName, QString::number(line), QString::number(column));
|
||||||
break;
|
break;
|
||||||
case ElementChangeWarning:
|
case ElementChangeWarning:
|
||||||
errorMessage = tr("The %1 element at line %2, column %3 cannot be changed without reloading the QML application. ")
|
errorMessage = tr("The %1 element at line %2, column %3 cannot be "
|
||||||
|
"changed without reloading the QML application. ")
|
||||||
.arg(elementName, QString::number(line), QString::number(column));
|
.arg(elementName, QString::number(line), QString::number(column));
|
||||||
break;
|
break;
|
||||||
case QmlJSLiveTextPreview::NoUnsyncronizableChanges:
|
case QmlJSLiveTextPreview::NoUnsyncronizableChanges:
|
||||||
@@ -630,25 +681,35 @@ void QmlJSLiveTextPreview::showSyncWarning(UnsyncronizableChangeType unsyncroniz
|
|||||||
|
|
||||||
errorMessage.append(tr("You can continue debugging, but behavior can be unexpected."));
|
errorMessage.append(tr("You can continue debugging, but behavior can be unexpected."));
|
||||||
|
|
||||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
|
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors) {
|
||||||
if (editor)
|
if (editor) {
|
||||||
editor.data()->editorDocument()->infoBar()->addInfo(Core::InfoBarEntry(
|
Core::InfoBar *infoBar = editor.data()->editorDocument()->infoBar();
|
||||||
QLatin1String(Constants::INFO_OUT_OF_SYNC), errorMessage));
|
infoBar->addInfo(Core::InfoBarEntry(
|
||||||
|
QLatin1String(Constants::INFO_OUT_OF_SYNC),
|
||||||
|
errorMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSLiveTextPreview::reloadQmlViewer()
|
void QmlJSLiveTextPreview::reloadQmlViewer()
|
||||||
{
|
{
|
||||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
|
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors) {
|
||||||
if (editor)
|
if (editor) {
|
||||||
editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
Core::InfoBar *infoBar = editor.data()->editorDocument()->infoBar();
|
||||||
|
infoBar->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
||||||
|
}
|
||||||
|
}
|
||||||
emit reloadQmlViewerRequested();
|
emit reloadQmlViewerRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSLiveTextPreview::disableLivePreview()
|
void QmlJSLiveTextPreview::disableLivePreview()
|
||||||
{
|
{
|
||||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
|
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors) {
|
||||||
if (editor)
|
if (editor) {
|
||||||
editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
Core::InfoBar *infoBar = editor.data()->editorDocument()->infoBar();
|
||||||
|
infoBar->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
||||||
|
}
|
||||||
|
}
|
||||||
emit disableLivePreviewRequested();
|
emit disableLivePreviewRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,15 +738,21 @@ void QmlJSLiveTextPreview::setClientProxy(ClientProxy *clientProxy)
|
|||||||
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()),
|
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()),
|
||||||
SLOT(updateDebugIds()));
|
SLOT(updateDebugIds()));
|
||||||
|
|
||||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget, m_editors)
|
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget,
|
||||||
|
m_editors)
|
||||||
if (editWidget)
|
if (editWidget)
|
||||||
connect(editWidget.data(), SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
connect(editWidget.data(),
|
||||||
this, SLOT(changeSelectedElements(QList<int>,QString)));
|
SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||||
|
this,
|
||||||
|
SLOT(changeSelectedElements(QList<int>,QString)));
|
||||||
} else {
|
} else {
|
||||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget, m_editors)
|
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget,
|
||||||
|
m_editors)
|
||||||
if (editWidget)
|
if (editWidget)
|
||||||
disconnect(editWidget.data(), SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
disconnect(editWidget.data(),
|
||||||
this, SLOT(changeSelectedElements(QList<int>,QString)));
|
SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||||
|
this,
|
||||||
|
SLOT(changeSelectedElements(QList<int>,QString)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,8 +99,10 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
static QmlJS::ModelManagerInterface *modelManager();
|
static QmlJS::ModelManagerInterface *modelManager();
|
||||||
QList<int> objectReferencesForOffset(quint32 offset);
|
QList<int> objectReferencesForOffset(quint32 offset);
|
||||||
QVariant castToLiteral(const QString &expression, QmlJS::AST::UiScriptBinding *scriptBinding);
|
QVariant castToLiteral(const QString &expression,
|
||||||
void showSyncWarning(UnsyncronizableChangeType unsyncronizableChangeType, const QString &elementName,
|
QmlJS::AST::UiScriptBinding *scriptBinding);
|
||||||
|
void showSyncWarning(UnsyncronizableChangeType unsyncronizableChangeType,
|
||||||
|
const QString &elementName,
|
||||||
unsigned line, unsigned column);
|
unsigned line, unsigned column);
|
||||||
void showExperimentalWarning();
|
void showExperimentalWarning();
|
||||||
|
|
||||||
|
|||||||
@@ -76,10 +76,19 @@ public:
|
|||||||
|
|
||||||
case QmlJSPropertyInspector::BooleanType: {
|
case QmlJSPropertyInspector::BooleanType: {
|
||||||
// invert the bool, skip editor
|
// invert the bool, skip editor
|
||||||
int objectId = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
int objectId = m_treeWidget->getData(index.row(),
|
||||||
QString propertyName = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
PROPERTY_NAME_COLUMN,
|
||||||
bool propertyValue = m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN, Qt::DisplayRole).toBool();
|
Qt::UserRole).toInt();
|
||||||
m_treeWidget->propertyValueEdited(objectId, propertyName, !propertyValue?"true":"false", true);
|
QString propertyName
|
||||||
|
= m_treeWidget->getData(index.row(),
|
||||||
|
PROPERTY_NAME_COLUMN,
|
||||||
|
Qt::DisplayRole).toString();
|
||||||
|
bool propertyValue
|
||||||
|
= m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN,
|
||||||
|
Qt::DisplayRole).toBool();
|
||||||
|
m_treeWidget->propertyValueEdited(objectId, propertyName,
|
||||||
|
!propertyValue?"true":"false",
|
||||||
|
true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,23 +108,29 @@ public:
|
|||||||
|
|
||||||
void setEditorData(QWidget *editor, const QModelIndex &index) const
|
void setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QVariant data = m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN, Qt::DisplayRole);
|
QVariant data = m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN,
|
||||||
|
Qt::DisplayRole);
|
||||||
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
|
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
|
||||||
lineEdit->setText(data.toString());
|
lineEdit->setText(data.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(model);
|
Q_UNUSED(model);
|
||||||
|
|
||||||
int objectId = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
int objectId = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN,
|
||||||
|
Qt::UserRole).toInt();
|
||||||
if (objectId == -1)
|
if (objectId == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString propertyName = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
QString propertyName = m_treeWidget->getData(index.row(),
|
||||||
|
PROPERTY_NAME_COLUMN,
|
||||||
|
Qt::DisplayRole).toString();
|
||||||
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
|
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
|
||||||
QString propertyValue = lineEdit->text();
|
QString propertyValue = lineEdit->text();
|
||||||
m_treeWidget->propertyValueEdited(objectId, propertyName, propertyValue, true);
|
m_treeWidget->propertyValueEdited(objectId, propertyName, propertyValue,
|
||||||
|
true);
|
||||||
lineEdit->clearFocus();
|
lineEdit->clearFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +153,8 @@ private:
|
|||||||
|
|
||||||
ExpressionEdit::ExpressionEdit(const QString &title, QDialog *parent)
|
ExpressionEdit::ExpressionEdit(const QString &title, QDialog *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel))
|
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok
|
||||||
|
| QDialogButtonBox::Cancel))
|
||||||
, m_exprInput(new QLineEdit(this))
|
, m_exprInput(new QLineEdit(this))
|
||||||
{
|
{
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
@@ -179,7 +195,9 @@ inline QString extendedNameFromColor(QColor color)
|
|||||||
{
|
{
|
||||||
int alphaValue = color.alpha();
|
int alphaValue = color.alpha();
|
||||||
if (alphaValue < 255)
|
if (alphaValue < 255)
|
||||||
return QLatin1String("#") + QString("%1").arg(alphaValue, 2, 16, QChar('0')) + color.name().right(6) ;
|
return QLatin1String("#")
|
||||||
|
+ QString("%1").arg(alphaValue, 2, 16, QChar('0'))
|
||||||
|
+ color.name().right(6) ;
|
||||||
else
|
else
|
||||||
return color.name();
|
return color.name();
|
||||||
}
|
}
|
||||||
@@ -214,7 +232,8 @@ ColorChooserDialog::ColorChooserDialog(const QString &title, QDialog *parent)
|
|||||||
connect(m_mainFrame,SIGNAL(rejected()),this,SLOT(reject()));
|
connect(m_mainFrame,SIGNAL(rejected()),this,SLOT(reject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorChooserDialog::setItemData(int objectId, const QString &propertyName, const QString& colorName)
|
void ColorChooserDialog::setItemData(int objectId, const QString &propertyName,
|
||||||
|
const QString &colorName)
|
||||||
{
|
{
|
||||||
m_debugId = objectId;
|
m_debugId = objectId;
|
||||||
m_paramName = propertyName;
|
m_paramName = propertyName;
|
||||||
@@ -224,7 +243,8 @@ void ColorChooserDialog::setItemData(int objectId, const QString &propertyName,
|
|||||||
void ColorChooserDialog::acceptColor(const QColor &color)
|
void ColorChooserDialog::acceptColor(const QColor &color)
|
||||||
{
|
{
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
emit dataChanged(m_debugId, m_paramName, QChar('\"')+color.name()+QChar('\"'));
|
emit dataChanged(m_debugId, m_paramName,
|
||||||
|
QChar('\"') + color.name() + QChar('\"'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
@@ -253,7 +273,8 @@ Qt::ItemFlags QmlJSPropertyInspectorModel::flags(const QModelIndex &index) const
|
|||||||
return m_contentsValid ? QStandardItemModel::flags(index) : Qt::ItemFlags();
|
return m_contentsValid ? QStandardItemModel::flags(index) : Qt::ItemFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QmlJSPropertyInspectorModel::headerData(int section, Qt::Orientation orient, int role) const
|
QVariant QmlJSPropertyInspectorModel::headerData(
|
||||||
|
int section, Qt::Orientation orient, int role) const
|
||||||
{
|
{
|
||||||
if (orient == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orient == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
@@ -278,7 +299,8 @@ bool QmlJSPropertyInspectorModel::contentsValid() const
|
|||||||
QmlJSPropertyInspector::QmlJSPropertyInspector(QWidget *parent)
|
QmlJSPropertyInspector::QmlJSPropertyInspector(QWidget *parent)
|
||||||
: Utils::BaseTreeView(parent)
|
: Utils::BaseTreeView(parent)
|
||||||
{
|
{
|
||||||
setItemDelegateForColumn(PROPERTY_VALUE_COLUMN, new PropertyEditDelegate(this));
|
setItemDelegateForColumn(PROPERTY_VALUE_COLUMN,
|
||||||
|
new PropertyEditDelegate(this));
|
||||||
|
|
||||||
setModel(&m_model);
|
setModel(&m_model);
|
||||||
//Add an empty Row to make the headers visible!
|
//Add an empty Row to make the headers visible!
|
||||||
@@ -301,7 +323,8 @@ bool QmlJSPropertyInspector::contentsValid() const
|
|||||||
return m_model.contentsValid();
|
return m_model.contentsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::setCurrentObjects(const QList<QmlDebugObjectReference> &objectList)
|
void QmlJSPropertyInspector::setCurrentObjects(
|
||||||
|
const QList<QmlDebugObjectReference> &objectList)
|
||||||
{
|
{
|
||||||
if (objectList.isEmpty())
|
if (objectList.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -319,26 +342,35 @@ QVariant QmlJSPropertyInspector::getData(int row, int column, int role) const
|
|||||||
return m_model.data(m_model.index(row, column), role);
|
return m_model.data(m_model.index(row, column), role);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSPropertyInspector::PropertyType QmlJSPropertyInspector::getTypeFor(int row) const
|
QmlJSPropertyInspector::PropertyType
|
||||||
|
QmlJSPropertyInspector::getTypeFor(int row) const
|
||||||
{
|
{
|
||||||
return static_cast<QmlJSPropertyInspector::PropertyType>(m_model.data(m_model.index(row, PROPERTY_TYPE_COLUMN), Qt::UserRole).toInt());
|
return static_cast<QmlJSPropertyInspector::PropertyType>(
|
||||||
|
m_model.data(m_model.index(row, PROPERTY_TYPE_COLUMN),
|
||||||
|
Qt::UserRole).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue)
|
void QmlJSPropertyInspector::propertyValueChanged(int debugId,
|
||||||
|
const QByteArray &propertyName,
|
||||||
|
const QVariant &propertyValue)
|
||||||
{
|
{
|
||||||
if (m_model.rowCount() == 0)
|
if (m_model.rowCount() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString propertyNameS = QString(propertyName);
|
QString propertyNameS = QString(propertyName);
|
||||||
for (int i = 0; i < m_model.rowCount(); i++) {
|
for (int i = 0; i < m_model.rowCount(); i++) {
|
||||||
if (m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN), Qt::DisplayRole).toString() == propertyNameS &&
|
if (m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN),
|
||||||
m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN), Qt::UserRole).toInt() == debugId) {
|
Qt::DisplayRole).toString() == propertyNameS &&
|
||||||
QString oldData = m_model.data(m_model.index(i, PROPERTY_VALUE_COLUMN), Qt::DisplayRole).toString();
|
m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN),
|
||||||
|
Qt::UserRole).toInt() == debugId) {
|
||||||
|
QString oldData = m_model.data(m_model.index(i, PROPERTY_VALUE_COLUMN),
|
||||||
|
Qt::DisplayRole).toString();
|
||||||
QString newData = propertyValue.toString();
|
QString newData = propertyValue.toString();
|
||||||
if (QString(propertyValue.typeName()) == "QColor")
|
if (QString(propertyValue.typeName()) == "QColor")
|
||||||
newData = extendedNameFromColor(propertyValue);
|
newData = extendedNameFromColor(propertyValue);
|
||||||
if (oldData != newData) {
|
if (oldData != newData) {
|
||||||
m_model.setData(m_model.index(i, PROPERTY_VALUE_COLUMN), newData, Qt::DisplayRole);
|
m_model.setData(m_model.index(i, PROPERTY_VALUE_COLUMN), newData,
|
||||||
|
Qt::DisplayRole);
|
||||||
m_model.item(i, PROPERTY_VALUE_COLUMN)->setToolTip(newData);
|
m_model.item(i, PROPERTY_VALUE_COLUMN)->setToolTip(newData);
|
||||||
m_model.item(i, PROPERTY_NAME_COLUMN)->setForeground(QBrush(Qt::red));
|
m_model.item(i, PROPERTY_NAME_COLUMN)->setForeground(QBrush(Qt::red));
|
||||||
m_model.item(i, PROPERTY_VALUE_COLUMN)->setForeground(QBrush(Qt::red));
|
m_model.item(i, PROPERTY_VALUE_COLUMN)->setForeground(QBrush(Qt::red));
|
||||||
@@ -352,8 +384,8 @@ void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::propertyValueEdited(const int objectId,
|
void QmlJSPropertyInspector::propertyValueEdited(const int objectId,
|
||||||
const QString& propertyName,
|
const QString &propertyName,
|
||||||
const QString& propertyValue,
|
const QString &propertyValue,
|
||||||
bool isLiteral)
|
bool isLiteral)
|
||||||
{
|
{
|
||||||
emit changePropertyValue(objectId, propertyName, propertyValue, isLiteral);
|
emit changePropertyValue(objectId, propertyName, propertyValue, isLiteral);
|
||||||
@@ -365,7 +397,8 @@ void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &ob
|
|||||||
QString objTypeName = obj.className();
|
QString objTypeName = obj.className();
|
||||||
QString declarativeString("QDeclarative");
|
QString declarativeString("QDeclarative");
|
||||||
if (objTypeName.startsWith(declarativeString)) {
|
if (objTypeName.startsWith(declarativeString)) {
|
||||||
objTypeName = objTypeName.mid(declarativeString.length()).section('_',0,0);
|
objTypeName = objTypeName.mid(declarativeString.length()).section('_',
|
||||||
|
0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class
|
// class
|
||||||
@@ -395,7 +428,8 @@ void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &ob
|
|||||||
propertyValue = extendedNameFromColor(prop.value());
|
propertyValue = extendedNameFromColor(prop.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
addRow(propertyName, propertyValue, prop.valueTypeName(), obj.debugId(), prop.hasNotifySignal());
|
addRow(propertyName, propertyValue, prop.valueTypeName(), obj.debugId(),
|
||||||
|
prop.hasNotifySignal());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_model.setHeaderData(PROPERTY_NAME_COLUMN, Qt::Horizontal,QVariant("name"));
|
m_model.setHeaderData(PROPERTY_NAME_COLUMN, Qt::Horizontal,QVariant("name"));
|
||||||
@@ -404,8 +438,9 @@ void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &ob
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::addRow(const QString &name,const QString &value, const QString &type,
|
void QmlJSPropertyInspector::addRow(const QString &name,const QString &value,
|
||||||
const int debugId, bool editable)
|
const QString &type, const int debugId,
|
||||||
|
bool editable)
|
||||||
{
|
{
|
||||||
QStandardItem *nameColumn = new QStandardItem(name);
|
QStandardItem *nameColumn = new QStandardItem(name);
|
||||||
nameColumn->setToolTip(name);
|
nameColumn->setToolTip(name);
|
||||||
@@ -422,7 +457,8 @@ void QmlJSPropertyInspector::addRow(const QString &name,const QString &value, co
|
|||||||
typeColumn->setEditable(false);
|
typeColumn->setEditable(false);
|
||||||
|
|
||||||
// encode type for easy lookup
|
// encode type for easy lookup
|
||||||
QmlJSPropertyInspector::PropertyType typeCode = QmlJSPropertyInspector::OtherType;
|
QmlJSPropertyInspector::PropertyType typeCode
|
||||||
|
= QmlJSPropertyInspector::OtherType;
|
||||||
if (type == "bool")
|
if (type == "bool")
|
||||||
typeCode = QmlJSPropertyInspector::BooleanType;
|
typeCode = QmlJSPropertyInspector::BooleanType;
|
||||||
else if (type == "qreal")
|
else if (type == "qreal")
|
||||||
@@ -492,9 +528,11 @@ void QmlJSPropertyInspector::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
|
|
||||||
void QmlJSPropertyInspector::openExpressionEditor(const QModelIndex &itemIndex)
|
void QmlJSPropertyInspector::openExpressionEditor(const QModelIndex &itemIndex)
|
||||||
{
|
{
|
||||||
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||||
|
Qt::DisplayRole).toString();
|
||||||
const QString dialogText = tr("JavaScript expression for %1").arg(propertyName);
|
const QString dialogText = tr("JavaScript expression for %1").arg(propertyName);
|
||||||
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||||
|
Qt::UserRole).toInt();
|
||||||
|
|
||||||
ExpressionEdit *expressionDialog = new ExpressionEdit(dialogText);
|
ExpressionEdit *expressionDialog = new ExpressionEdit(dialogText);
|
||||||
expressionDialog->setItemData(objectId, propertyName);
|
expressionDialog->setItemData(objectId, propertyName);
|
||||||
@@ -507,10 +545,13 @@ void QmlJSPropertyInspector::openExpressionEditor(const QModelIndex &itemIndex)
|
|||||||
|
|
||||||
void QmlJSPropertyInspector::openColorSelector(const QModelIndex &itemIndex)
|
void QmlJSPropertyInspector::openColorSelector(const QModelIndex &itemIndex)
|
||||||
{
|
{
|
||||||
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||||
|
Qt::DisplayRole).toString();
|
||||||
const QString dialogText = tr("Color selection for %1").arg(propertyName);
|
const QString dialogText = tr("Color selection for %1").arg(propertyName);
|
||||||
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||||
const QString propertyValue = getData(itemIndex.row(), PROPERTY_VALUE_COLUMN, Qt::DisplayRole).toString();
|
Qt::UserRole).toInt();
|
||||||
|
const QString propertyValue = getData(itemIndex.row(), PROPERTY_VALUE_COLUMN,
|
||||||
|
Qt::DisplayRole).toString();
|
||||||
|
|
||||||
ColorChooserDialog *colorDialog = new ColorChooserDialog(dialogText);
|
ColorChooserDialog *colorDialog = new ColorChooserDialog(dialogText);
|
||||||
colorDialog->setItemData(objectId, propertyName, propertyValue);
|
colorDialog->setItemData(objectId, propertyName, propertyValue);
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ public:
|
|||||||
virtual void accept();
|
virtual void accept();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged(int debugId, const QString ¶mName, const QString &newExpression);
|
void dataChanged(int debugId, const QString ¶mName,
|
||||||
|
const QString &newExpression);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDialogButtonBox *m_buttonBox;
|
QDialogButtonBox *m_buttonBox;
|
||||||
@@ -77,13 +78,15 @@ class ColorChooserDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit ColorChooserDialog(const QString &title, QDialog *parent = 0);
|
explicit ColorChooserDialog(const QString &title, QDialog *parent = 0);
|
||||||
|
|
||||||
void setItemData(int objectId,const QString &propertyName, const QString &colorName);
|
void setItemData(int objectId,const QString &propertyName,
|
||||||
|
const QString &colorName);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void acceptColor(const QColor &color);
|
void acceptColor(const QColor &color);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged(int debugId, const QString ¶mName, const QString &newExpression);
|
void dataChanged(int debugId, const QString ¶mName,
|
||||||
|
const QString &newExpression);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -127,15 +130,16 @@ public:
|
|||||||
bool contentsValid() const;
|
bool contentsValid() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changePropertyValue(int debugId, QString propertyName, QString valueExpression,
|
void changePropertyValue(int debugId, QString propertyName,
|
||||||
bool isLiteral);
|
QString valueExpression, bool isLiteral);
|
||||||
void customContextMenuRequested(const QPoint &pos);
|
void customContextMenuRequested(const QPoint &pos);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentObjects(const QList<QmlDebugObjectReference> &);
|
void setCurrentObjects(const QList<QmlDebugObjectReference> &);
|
||||||
void propertyValueEdited(const int objectId,const QString &propertyName, const QString &propertyValue,
|
void propertyValueEdited(const int objectId,const QString &propertyName,
|
||||||
bool isLiteral = false);
|
const QString &propertyValue, bool isLiteral = false);
|
||||||
void propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
void propertyValueChanged(int debugId, const QByteArray &propertyName,
|
||||||
|
const QVariant &propertyValue);
|
||||||
|
|
||||||
void openExpressionEditor(const QModelIndex &itemIndex);
|
void openExpressionEditor(const QModelIndex &itemIndex);
|
||||||
void openColorSelector(const QModelIndex &itemIndex);
|
void openColorSelector(const QModelIndex &itemIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user