diff options
author | Aurindam Jana <aurindam.jana@nokia.com> | 2012-04-13 13:18:45 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2012-04-13 14:10:49 +0200 |
commit | 305ebd9fcc9c84d122284e1f58b00bd390c3db37 (patch) | |
tree | 9170d974b519993a4779dc3b79be311b5e0a9157 | |
parent | aa4c3f23320c99b7e3863362dfd2a96a74837dae (diff) |
QmlJSPropertyInspector: Change property value
Check if the expression is a literal when calling setBinding()
Change-Id: Iab9d8d090a232a836c5929ac4cadc50310a20aa1
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
-rw-r--r-- | src/plugins/qmljsinspector/qmljsinspector.cpp | 9 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljsinspector.h | 3 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljspropertyinspector.cpp | 27 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljspropertyinspector.h | 6 |
4 files changed, 18 insertions, 27 deletions
diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index df2f658b01..95049e71b2 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -696,10 +696,11 @@ void InspectorUi::selectItems(const QList<int> &objectIds) selectItems(objectReferences); } -void InspectorUi::changePropertyValue(int debugId,const QString &propertyName, const QString &valueExpression) +void InspectorUi::changePropertyValue(int debugId, const QString &propertyName, + const QString &valueExpression, bool isLiteral) { QmlDebugObjectReference obj = m_clientProxy->objectReferenceForId(debugId); - m_clientProxy->setBindingForObject(debugId, propertyName, valueExpression, false, + m_clientProxy->setBindingForObject(debugId, propertyName, valueExpression, isLiteral, obj.source().url().toString(), obj.source().lineNumber()); } @@ -901,8 +902,8 @@ void InspectorUi::disableLivePreview() void InspectorUi::connectSignals() { - connect(m_propertyInspector, SIGNAL(changePropertyValue(int,QString,QString)), - this, SLOT(changePropertyValue(int,QString,QString))); + connect(m_propertyInspector, SIGNAL(changePropertyValue(int,QString,QString,bool)), + this, SLOT(changePropertyValue(int,QString,QString,bool))); connect(m_clientProxy, SIGNAL(propertyChanged(int,QByteArray,QVariant)), m_propertyInspector, SLOT(propertyValueChanged(int,QByteArray,QVariant))); diff --git a/src/plugins/qmljsinspector/qmljsinspector.h b/src/plugins/qmljsinspector/qmljsinspector.h index 20bad0a36d..8f5e17798b 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.h +++ b/src/plugins/qmljsinspector/qmljsinspector.h @@ -120,7 +120,8 @@ private slots: void selectItems(const QList<QmlDebugObjectReference> &objectReferences); void selectItems(const QList<int> &objectIds); void changeSelectedItems(const QList<QmlDebugObjectReference> &objects); - void changePropertyValue(int debugId,const QString &propertyName, const QString &valueExpression); + void changePropertyValue(int debugId,const QString &propertyName, + const QString &valueExpression, bool isLiteral); void objectTreeReady(); void onRootContext(const QVariant &value); diff --git a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp index 9f4c325c48..86c0e5804f 100644 --- a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp +++ b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp @@ -79,7 +79,7 @@ class PropertyEditDelegate : public QItemDelegate int objectId = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt(); 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"); + m_treeWidget->propertyValueEdited(objectId, propertyName, !propertyValue?"true":"false", true); return 0; } @@ -113,25 +113,9 @@ class PropertyEditDelegate : public QItemDelegate return; QString propertyName = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString(); - QLineEdit *lineEdit = static_cast<QLineEdit*>(editor); QString propertyValue = lineEdit->text(); - - // add quotes if it's a string - QmlJSPropertyInspector::PropertyType propertyType = m_treeWidget->getTypeFor(index.row()); - const QChar quote(QLatin1Char('\"')); - - if (propertyType == QmlJSPropertyInspector::StringType) { - const QChar backslash(QLatin1Char('\\')); - propertyValue = propertyValue.replace(quote, QString(backslash) + quote); - } - - if (propertyType == QmlJSPropertyInspector::StringType || propertyType == QmlJSPropertyInspector::ColorType) { - propertyValue = quote + propertyValue + quote; - } - - m_treeWidget->propertyValueEdited(objectId, propertyName, propertyValue); - + m_treeWidget->propertyValueEdited(objectId, propertyName, propertyValue, true); lineEdit->clearFocus(); } @@ -367,9 +351,12 @@ void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray } } -void QmlJSPropertyInspector::propertyValueEdited(const int objectId,const QString& propertyName, const QString& propertyValue) +void QmlJSPropertyInspector::propertyValueEdited(const int objectId, + const QString& propertyName, + const QString& propertyValue, + bool isLiteral) { - emit changePropertyValue(objectId, propertyName, propertyValue); + emit changePropertyValue(objectId, propertyName, propertyValue, isLiteral); } void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &obj) diff --git a/src/plugins/qmljsinspector/qmljspropertyinspector.h b/src/plugins/qmljsinspector/qmljspropertyinspector.h index 3080c64652..4f42177a49 100644 --- a/src/plugins/qmljsinspector/qmljspropertyinspector.h +++ b/src/plugins/qmljsinspector/qmljspropertyinspector.h @@ -127,12 +127,14 @@ public: bool contentsValid() const; signals: - void changePropertyValue(int debugId, QString propertyName, QString valueExpression); + void changePropertyValue(int debugId, QString propertyName, QString valueExpression, + bool isLiteral); void customContextMenuRequested(const QPoint &pos); public slots: void setCurrentObjects(const QList<QmlDebugObjectReference> &); - void propertyValueEdited(const int objectId,const QString &propertyName, const QString &propertyValue); + void propertyValueEdited(const int objectId,const QString &propertyName, const QString &propertyValue, + bool isLiteral = false); void propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue); void openExpressionEditor(const QModelIndex &itemIndex); |