Commit 5262ca20 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.propertyEditor: use RewriterTransaction to speed things up

parent 0924cb1c
......@@ -91,6 +91,13 @@ QWidget { //This is a special doubleSpinBox that does color coding for states
onMouseOverChanged: {
}
onFocusChanged: {
if (focus)
doubleSpinBox.backendValue.lock();
else
doubleSpinBox.backendValue.unlock();
}
}
}
......
......@@ -55,6 +55,13 @@ QWidget {
if (backendValue != undefined && backendValue != null)
backendValue.value = value;
}
onSliderPressed: {
backendValue.lock();
}
onSliderReleased: {
backendValue.unlock();
}
}
}
}
......
......@@ -20,6 +20,13 @@ QWidget {
onTextEdited: {
backendValue.value = text
}
onFocusChanged: {
if (focus)
backendValue.lock();
else
backendValue.unlock();
}
}
......
......@@ -43,17 +43,22 @@ GroupBox {
text: ""
id: opacitySpinBox;
backendValue: backendValues.opacity === undefined ? null : backendValues.opacity
property var backendValueValue: backendValues.opacity.value;
minimumWidth: 60;
minimum: 0;
maximum: 1;
singleStep: 0.1
baseStateFlag: isBaseState;
onBackendValueValueChanged: {
opacitySlider.value = backendValue.value * 100;
}
}
SliderWidget {
id: opacitySlider
minimum: 0
maximum: 100
singleStep: 5;
value: backendValues.opacity === undefined ? 0 : (backendValues.opacity.value * 100)
backendValue: backendValues.opacity === undefined ? null : backendValues.opacity
onValueChanged: {
if (backendValues.opacity !== undefined)
backendValues.opacity.value = value / 100;
......@@ -110,6 +115,7 @@ GroupBox {
}
SliderWidget {
id: scaleSlider;
backendValue: backendValues.scale;
minimum: 1;
maximum: 100;
singleStep: 1;
......
......@@ -8,6 +8,7 @@ QWidget {
property alias singleStep: localSlider.singleStep
property alias minimum: localSlider.minimum
property alias maximum: localSlider.maximum
property var backendValue
QSlider {
orientation: "Qt::Horizontal";
......@@ -18,6 +19,13 @@ QWidget {
value: sliderWidget.value
onValueChanged: {
sliderWidget.value = value
}
onSliderPressed: {
backendValue.lock();
}
onSliderReleased: {
backendValue.unlock();
}
}
}
......@@ -61,11 +61,14 @@ QWidget { //This is a special spinBox that does color coding for states
onValueChanged: {
if (spinBox.backendValue != null && readingFromBackend == false)
backendValue.value = value;
}
onFocusChanged: {
//extendedSwitches.active = focus;
//extendedSwitches.backendValue = backendValue;
}
}
onFocusChanged: {
if (focus)
spinBox.backendValue.lock();
else
spinBox.backendValue.unlock();
}
}
}
......
......@@ -191,6 +191,24 @@ void PropertyEditorValue::resetValue()
}
}
void PropertyEditorValue::lock()
{
if (!modelNode().isValid())
return;
Q_ASSERT(!m_rewriterTransaction.isValid());
m_rewriterTransaction = modelNode().view()->beginRewriterTransaction();
}
void PropertyEditorValue::unlock()
{
if (!modelNode().isValid())
return;
Q_ASSERT(m_rewriterTransaction.isValid());
m_rewriterTransaction.commit();
}
PropertyEditorNodeWrapper::PropertyEditorNodeWrapper(PropertyEditorValue* parent) : m_valuesPropertyMap(this)
{
m_editorValue = parent;
......
......@@ -34,6 +34,7 @@
#include <QmlPropertyMap>
#include <qml.h>
#include <modelnode.h>
#include <rewritertransaction.h>
class PropertyEditorValue;
......@@ -118,6 +119,8 @@ public:
public slots:
void resetValue();
void lock();
void unlock();
signals:
void valueChanged(const QString &name);
......@@ -140,6 +143,7 @@ private: //variables
bool m_isBound;
bool m_isValid; // if the property value belongs to a non-existing complexProperty it is invalid
PropertyEditorNodeWrapper *m_complexNode;
QmlDesigner::RewriterTransaction m_rewriterTransaction;
};
QML_DECLARE_TYPE(PropertyEditorValue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment