forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Kai Koehne
parent
aa4c3f2332
commit
305ebd9fcc
@@ -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)));
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user