Commit 4b3e3aaa authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Remove operator from properties

To improve the readability of the source methods should be used.

Change-Id: I839e448369a03dc42b3649baed033daa20c4d49a
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent f12a8644
......@@ -239,7 +239,7 @@ void setVisible(const SelectionContext &selectionState)
return;
try {
selectionState.selectedModelNodes().first().variantProperty("visible") = selectionState.toggled();
selectionState.selectedModelNodes().first().variantProperty("visible").setValue(selectionState.toggled());
} catch (RewritingException &e) { //better save then sorry
QMessageBox::warning(0, "Error", e.description());
}
......@@ -252,7 +252,7 @@ void setFillWidth(const SelectionContext &selectionState)
return;
try {
selectionState.selectedModelNodes().first().variantProperty("Layout.fillWidth") = selectionState.toggled();
selectionState.selectedModelNodes().first().variantProperty("Layout.fillWidth").setValue(selectionState.toggled());
} catch (RewritingException &e) { //better save then sorry
QMessageBox::warning(0, "Error", e.description());
}
......@@ -265,7 +265,7 @@ void setFillHeight(const SelectionContext &selectionState)
return;
try {
selectionState.selectedModelNodes().first().variantProperty("Layout.fillHeight") = selectionState.toggled();
selectionState.selectedModelNodes().first().variantProperty("Layout.fillHeight").setValue(selectionState.toggled());
} catch (RewritingException &e) { //better save then sorry
QMessageBox::warning(0, "Error", e.description());
}
......@@ -340,7 +340,7 @@ static inline void backupPropertyAndRemove(ModelNode node, const PropertyName &p
static inline void restoreProperty(ModelNode node, const PropertyName &propertyName)
{
if (node.hasAuxiliaryData(auxDataString + propertyName))
node.variantProperty(propertyName) = node.auxiliaryData(auxDataString + propertyName);
node.variantProperty(propertyName).setValue(node.auxiliaryData(auxDataString + propertyName));
}
void anchorsFill(const SelectionContext &selectionState)
......@@ -476,8 +476,8 @@ void layoutRowPositioner(const SelectionContext &selectionState)
RewriterTransaction transaction(selectionState.view());
QPoint pos = getUpperLeftPosition(modelNodeList);
row.variantProperty("x") = pos.x();
row.variantProperty("y") = pos.y();
row.variantProperty("x").setValue(pos.x());
row.variantProperty("y").setValue(pos.y());
QList<ModelNode> sortedList = modelNodeList;
qSort(sortedList.begin(), sortedList.end(), compareByX);
......@@ -519,8 +519,8 @@ void layoutColumnPositioner(const SelectionContext &selectionState)
RewriterTransaction transaction(selectionState.view());
QPoint pos = getUpperLeftPosition(modelNodeList);
column.variantProperty("x") = pos.x();
column.variantProperty("y") = pos.y();
column.variantProperty("x").setValue(pos.x());
column.variantProperty("y").setValue(pos.y());
QList<ModelNode> sortedList = modelNodeList;
qSort(sortedList.begin(), sortedList.end(), compareByY);
......@@ -554,7 +554,7 @@ void layoutGridPositioner(const SelectionContext &selectionState)
return;
grid = selectionState.view()->createModelNode("QtQuick.Grid", gridMetaInfo.majorVersion(), gridMetaInfo.minorVersion());
grid.variantProperty("columns") = int(sqrt(double(modelNodeList.count())));
grid.variantProperty("columns").setValue(int(sqrt(double(modelNodeList.count()))));
reparentTo(grid, parent);
}
......@@ -563,8 +563,8 @@ void layoutGridPositioner(const SelectionContext &selectionState)
RewriterTransaction transaction(selectionState.view());
QPoint pos = getUpperLeftPosition(modelNodeList);
grid.variantProperty("x") = pos.x();
grid.variantProperty("y") = pos.y();
grid.variantProperty("x").setValue(pos.x());
grid.variantProperty("y").setValue(pos.y());
QList<ModelNode> sortedList = modelNodeList;
qSort(sortedList.begin(), sortedList.end(), compareByGrid);
......@@ -606,8 +606,8 @@ void layoutFlowPositioner(const SelectionContext &selectionState)
RewriterTransaction transaction(selectionState.view());
QPoint pos = getUpperLeftPosition(modelNodeList);
flow.variantProperty("x") = pos.x();
flow.variantProperty("y") = pos.y();
flow.variantProperty("x").setValue(pos.x());
flow.variantProperty("y").setValue(pos.y());
QList<ModelNode> sortedList = modelNodeList;
qSort(sortedList.begin(), sortedList.end(), compareByGrid);
......@@ -653,8 +653,8 @@ void layoutRowLayout(const SelectionContext &selectionState)
RewriterTransaction transaction(selectionState.view());
QPoint upperLeftPosition = getUpperLeftPosition(selectedNodeList);
rowNode.variantProperty("x") = upperLeftPosition.x();
rowNode.variantProperty("y") = upperLeftPosition.y();
rowNode.variantProperty("x").setValue(upperLeftPosition.x());
rowNode.variantProperty("y").setValue(upperLeftPosition.y());
QList<ModelNode> sortedSelectedNodes = selectedNodeList;
qSort(sortedSelectedNodes.begin(), sortedSelectedNodes.end(), compareByX);
......@@ -701,8 +701,8 @@ void layoutColumnLayout(const SelectionContext &selectionState)
RewriterTransaction transaction(selectionState.view());
QPoint upperLeftPosition = getUpperLeftPosition(selectedNodeList);
columnNode.variantProperty("x") = upperLeftPosition.x();
columnNode.variantProperty("y") = upperLeftPosition.y();
columnNode.variantProperty("x").setValue(upperLeftPosition.x());
columnNode.variantProperty("y").setValue(upperLeftPosition.y());
QList<ModelNode> sortedSelectedNodes = selectedNodeList;
qSort(sortedSelectedNodes.begin(), sortedSelectedNodes.end(), compareByY);
......@@ -741,7 +741,7 @@ void layoutGridLayout(const SelectionContext &selectionState)
QmlItemNode parentNode = qmlItemNode.instanceParentItem();
gridNode = selectionState.view()->createModelNode(gridLayoutType, gridMetaInfo.majorVersion(), gridMetaInfo.minorVersion());
gridNode.variantProperty("columns") = int(sqrt(double(selectedNodeList.count())));
gridNode.variantProperty("columns").setValue(int(sqrt(double(selectedNodeList.count()))));
reparentTo(gridNode, parentNode);
}
......@@ -750,8 +750,8 @@ void layoutGridLayout(const SelectionContext &selectionState)
RewriterTransaction transaction(selectionState.view());
QPoint upperLeftPosition = getUpperLeftPosition(selectedNodeList);
gridNode.variantProperty("x") = upperLeftPosition.x();
gridNode.variantProperty("y") = upperLeftPosition.y();
gridNode.variantProperty("x").setValue(upperLeftPosition.x());
gridNode.variantProperty("y") .setValue(upperLeftPosition.y());
QList<ModelNode> sortedSelectedNodes = selectedNodeList;
qSort(sortedSelectedNodes.begin(), sortedSelectedNodes.end(), compareByGrid);
......
......@@ -471,15 +471,15 @@ static void scatterItem(ModelNode pastedNode, const ModelNode targetNode, int of
double targetHeight = 20;
x = x + double(qrand()) / RAND_MAX * targetWidth - targetWidth / 2;
y = y + double(qrand()) / RAND_MAX * targetHeight - targetHeight / 2;
pastedNode.variantProperty("x") = int(x);
pastedNode.variantProperty("y") = int(y);
pastedNode.variantProperty("x").setValue(int(x));
pastedNode.variantProperty("y").setValue(int(y));
} else {
double x = pastedNode.variantProperty("x").value().toDouble();
double y = pastedNode.variantProperty("y").value().toDouble();
x = x + offset;
y = y + offset;
pastedNode.variantProperty("x") = int(x);
pastedNode.variantProperty("y") = int(y);
pastedNode.variantProperty("x").setValue(int(x));
pastedNode.variantProperty("y").setValue(int(y));
}
}
......
......@@ -50,8 +50,8 @@ static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPo
if (modelNode.hasParentProperty() && QmlDesigner::QmlItemNode::isValidQmlItemNode(modelNode.parentProperty().parentModelNode())) {
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
QPointF localPos = parentNode.instanceSceneTransform().inverted().map(pos);
modelNode.variantProperty("x") = localPos.toPoint().x();
modelNode.variantProperty("y") = localPos.toPoint().y();
modelNode.variantProperty("x").setValue(localPos.toPoint().x());
modelNode.variantProperty("y").setValue(localPos.toPoint().y());
}
}
......
......@@ -45,8 +45,8 @@ static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPo
if (modelNode.hasParentProperty() && QmlDesigner::QmlItemNode::isValidQmlItemNode(modelNode.parentProperty().parentModelNode())) {
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
QPointF localPos = parentNode.instanceSceneTransform().inverted().map(pos);
modelNode.variantProperty("x") = localPos.toPoint().x();
modelNode.variantProperty("y") = localPos.toPoint().y();
modelNode.variantProperty("x").setValue(localPos.toPoint().x());
modelNode.variantProperty("y").setValue(localPos.toPoint().y());
}
}
......
......@@ -143,17 +143,17 @@ void BehaviorDialog::accept()
ModelNode Behavior = m_modelNode.view()->createModelNode("Qt/Behavior", 4, 7);
m_modelNode.nodeProperty(m_propertyName).reparentHere(Behavior);
ModelNode animation = m_modelNode.view()->createModelNode("Qt/NumberAnimation", 4, 7);
animation.variantProperty("duration") = m_ui->duration->value();
animation.variantProperty("easing") = m_ui->curve->currentText();
animation.variantProperty("duration").setValue(m_ui->duration->value());
animation.variantProperty("easing").setValue(m_ui->curve->currentText());
Behavior.nodeProperty("animation").reparentHere(animation);
} else {
RewriterTransaction transaction(m_modelNode.view()->beginRewriterTransaction());
ModelNode springFollow = m_modelNode.view()->createModelNode("Qt/SpringFollow", 4, 7);
m_modelNode.nodeProperty(m_propertyName).reparentHere(springFollow);
springFollow.variantProperty("velocity") = m_ui->velocity->value();
springFollow.variantProperty("spring") = m_ui->spring->value();
springFollow.variantProperty("damping") = m_ui->damping->value();
springFollow.bindingProperty("source") = m_ui->source->text();
springFollow.variantProperty("velocity").setValue(m_ui->velocity->value());
springFollow.variantProperty("spring").setValue(m_ui->spring->value());
springFollow.variantProperty("damping").setValue(m_ui->damping->value());
springFollow.bindingProperty("source").setExpression(m_ui->source->text());
}
}
......
......@@ -138,8 +138,8 @@ void GradientLineQmlAdaptor::writeGradient()
for (int i = 0;i < stops.size(); i++) {
ModelNode gradientStopNode = modelNode.view()->createModelNode("QtQuick.GradientStop", modelNode.majorQtQuickVersion(), 0);
gradientStopNode.variantProperty("position") = roundReal(stops.at(i).first);
gradientStopNode.variantProperty("color") = normalizeColor(stops.at(i).second);
gradientStopNode.variantProperty("position").setValue(roundReal(stops.at(i).first));
gradientStopNode.variantProperty("color").setValue(normalizeColor(stops.at(i).second));
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
}
} else { //state
......
......@@ -58,7 +58,7 @@ static inline void backupPropertyAndRemove(ModelNode node, const PropertyName &p
static inline void restoreProperty(ModelNode node, const PropertyName &propertyName)
{
if (node.hasAuxiliaryData(auxDataString + propertyName))
node.variantProperty(propertyName) = node.auxiliaryData(auxDataString + propertyName);
node.variantProperty(propertyName).setValue(node.auxiliaryData(auxDataString + propertyName));
}
namespace Internal {
......
......@@ -44,7 +44,6 @@ class QMLDESIGNERCORE_EXPORT BindingProperty : public QmlDesigner::AbstractPrope
public:
void setExpression(const QString &expression);
QString expression() const;
BindingProperty& operator= (const QString &expression);
BindingProperty();
BindingProperty(const BindingProperty &property, AbstractView *view);
......
......@@ -51,8 +51,6 @@ class QMLDESIGNERCORE_EXPORT NodeListProperty : public NodeAbstractProperty
friend class QmlDesigner::AbstractProperty;
friend class QmlDesigner::Internal::ModelPrivate;
public:
NodeListProperty& operator= (const QVariant &value);
NodeListProperty();
NodeListProperty(const NodeListProperty &nodeListProperty, AbstractView *view);
const QList<ModelNode> toModelNodeList() const;
......
......@@ -44,7 +44,6 @@ class QMLDESIGNERCORE_EXPORT SignalHandlerProperty : public QmlDesigner::Abstrac
public:
void setSource(const QString &source);
QString source() const;
SignalHandlerProperty& operator= (const QString &source);
SignalHandlerProperty();
SignalHandlerProperty(const SignalHandlerProperty &property, AbstractView *view);
......
......@@ -54,7 +54,6 @@ class QMLDESIGNERCORE_EXPORT VariantProperty : public AbstractProperty
public:
void setValue(const QVariant &value);
QVariant value() const;
VariantProperty& operator= (const QVariant &value);
void setDynamicTypeNameAndValue(const TypeName &type, const QVariant &value);
......
......@@ -93,13 +93,6 @@ QString BindingProperty::expression() const
return QString();
}
BindingProperty& BindingProperty::operator= (const QString &expression)
{
setExpression(expression);
return *this;
}
static ModelNode resolveBinding(const QString &binding, ModelNode currentNode, AbstractView* view)
{
int i = 0;
......
......@@ -60,7 +60,7 @@ static QString fixExpression(const QString &expression, const QHash<QString, QSt
static void syncVariantProperties(ModelNode &outputNode, const ModelNode &inputNode)
{
foreach (const VariantProperty &variantProperty, inputNode.variantProperties()) {
outputNode.variantProperty(variantProperty.name()) = variantProperty.value();
outputNode.variantProperty(variantProperty.name()).setValue(variantProperty.value());
}
}
......
......@@ -140,7 +140,7 @@ QmlItemNode QmlModelView::createQmlItemNodeFromImage(const QString &imageName, c
newQmlItemNode.setId(id);
if (!currentState().isBaseState()) {
newQmlItemNode.modelNode().variantProperty("opacity") = 0;
newQmlItemNode.modelNode().variantProperty("opacity").setValue(0);
newQmlItemNode.setVariantProperty("opacity", 1);
}
......@@ -224,8 +224,8 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
ModelNode rootModelNode = rewriterView->rootModelNode();
inputModel->detachView(rewriterView.data());
rootModelNode.variantProperty("x") = propertyPairList.first().second;
rootModelNode.variantProperty("y") = propertyPairList.at(1).second;
rootModelNode.variantProperty("x").setValue(propertyPairList.first().second);
rootModelNode.variantProperty("y").setValue(propertyPairList.at(1).second);
ModelMerger merger(this);
newQmlItemNode = merger.insertModel(rootModelNode);
......@@ -251,7 +251,7 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
newQmlItemNode.setId(id);
if (!currentState().isBaseState()) {
newQmlItemNode.modelNode().variantProperty("opacity") = 0;
newQmlItemNode.modelNode().variantProperty("opacity").setValue(0);
newQmlItemNode.setVariantProperty("opacity", 1);
}
......
......@@ -53,7 +53,7 @@ void QmlObjectNode::setVariantProperty(const PropertyName &name, const QVariant
QmlPropertyChanges changeSet(currentState().propertyChanges(modelNode()));
Q_ASSERT(changeSet.isValid());
changeSet.modelNode().variantProperty(name) = value;
changeSet.modelNode().variantProperty(name).setValue(value);
}
}
......@@ -63,13 +63,13 @@ void QmlObjectNode::setBindingProperty(const PropertyName &name, const QString &
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (isInBaseState()) {
modelNode().bindingProperty(name) = expression; //basestate
modelNode().bindingProperty(name).setExpression(expression); //basestate
} else {
modelNode().validId();
QmlPropertyChanges changeSet(currentState().propertyChanges(modelNode()));
Q_ASSERT(changeSet.isValid());
changeSet.modelNode().bindingProperty(name) = expression;
changeSet.modelNode().bindingProperty(name).setExpression(expression);
}
}
......
......@@ -301,7 +301,7 @@ QmlModelState QmlModelState::duplicate(const QString &name) const
foreach (const BindingProperty &bindingProperty, childNode.bindingProperties())
newModelNode.bindingProperty(bindingProperty.name()).setExpression(bindingProperty.expression());
foreach (const VariantProperty &variantProperty, childNode.variantProperties())
newModelNode.variantProperty(variantProperty.name()) = variantProperty.value();
newModelNode.variantProperty(variantProperty.name()).setValue(variantProperty.value());
newState.modelNode().nodeListProperty("changes").reparentHere(newModelNode);
}
......
......@@ -89,11 +89,4 @@ QString SignalHandlerProperty::source() const
return QString();
}
SignalHandlerProperty& SignalHandlerProperty::operator= (const QString &source)
{
setSource(source);
return *this;
}
} // namespace QmlDesigner
......@@ -89,13 +89,6 @@ QVariant VariantProperty::value() const
return QVariant();
}
VariantProperty& VariantProperty::operator= (const QVariant &value)
{
setValue(value);
return *this;
}
void VariantProperty::setDynamicTypeNameAndValue(const TypeName &type, const QVariant &value)
{
Internal::WriteLocker locker(model());
......
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