forked from qt-creator/qt-creator
QmlDesigner: Use lambdas for transactions
Using lambdas we do not have to repeat the try catch block all over again. This also avoids sublte mistakes when catching the exception. Change-Id: I514fa9b64f43ef08fdc27bf702ec2b173ab1dfd6 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -185,17 +185,16 @@ void LayoutInGridLayout::doIt()
|
|||||||
if (qmlItemNode.hasInstanceParentItem()) {
|
if (qmlItemNode.hasInstanceParentItem()) {
|
||||||
|
|
||||||
ModelNode layoutNode;
|
ModelNode layoutNode;
|
||||||
{
|
|
||||||
RewriterTransaction transaction(m_selectionContext.view(), QByteArrayLiteral("LayoutInGridLayout1"));
|
m_selectionContext.view()->executeInTransaction("LayoutInGridLayout1",[this, &layoutNode, layoutType](){
|
||||||
QTC_ASSERT(m_selectionContext.view()->model()->hasNodeMetaInfo(layoutType), return);
|
QTC_ASSERT(m_selectionContext.view()->model()->hasNodeMetaInfo(layoutType), return);
|
||||||
|
|
||||||
NodeMetaInfo metaInfo = m_selectionContext.view()->model()->metaInfo(layoutType);
|
NodeMetaInfo metaInfo = m_selectionContext.view()->model()->metaInfo(layoutType);
|
||||||
layoutNode = m_selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion());
|
layoutNode = m_selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion());
|
||||||
reparentTo(layoutNode, m_parentNode);
|
reparentTo(layoutNode, m_parentNode);
|
||||||
}
|
});
|
||||||
|
|
||||||
{
|
m_selectionContext.view()->executeInTransaction("LayoutInGridLayout2", [this, layoutNode](){
|
||||||
RewriterTransaction transaction(m_selectionContext.view(), QByteArrayLiteral("LayoutInGridLayout2"));
|
|
||||||
|
|
||||||
fillEmptyCells();
|
fillEmptyCells();
|
||||||
|
|
||||||
@@ -208,7 +207,7 @@ void LayoutInGridLayout::doIt()
|
|||||||
reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes);
|
reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes);
|
||||||
setSizeAsPreferredSize(sortedSelectedNodes);
|
setSizeAsPreferredSize(sortedSelectedNodes);
|
||||||
setSpanning(layoutNode);
|
setSpanning(layoutNode);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,9 +240,7 @@ void changeOrder(const SelectionContext &selectionState, OderAction orderAction)
|
|||||||
if (!modelNode.parentProperty().isNodeListProperty())
|
if (!modelNode.parentProperty().isNodeListProperty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
selectionState.view()->executeInTransaction("DesignerActionManager|raise",[orderAction, selectionState, modelNode](){
|
||||||
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|raise"));
|
|
||||||
|
|
||||||
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
||||||
NodeListProperty parentProperty = modelNode.parentProperty().toNodeListProperty();
|
NodeListProperty parentProperty = modelNode.parentProperty().toNodeListProperty();
|
||||||
const int index = parentProperty.indexOf(modelNode);
|
const int index = parentProperty.indexOf(modelNode);
|
||||||
@@ -255,11 +253,7 @@ void changeOrder(const SelectionContext &selectionState, OderAction orderAction)
|
|||||||
if (index > 0)
|
if (index > 0)
|
||||||
parentProperty.slide(index, index - 1);
|
parentProperty.slide(index, index - 1);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const RewritingException &e) { //better save then sorry
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise(const SelectionContext &selectionState)
|
void raise(const SelectionContext &selectionState)
|
||||||
@@ -328,16 +322,13 @@ void resetSize(const SelectionContext &selectionState)
|
|||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
selectionState.view()->executeInTransaction("DesignerActionManager|resetSize",[selectionState](){
|
||||||
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetSize"));
|
|
||||||
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
||||||
QmlItemNode itemNode(node);
|
QmlItemNode itemNode(node);
|
||||||
itemNode.removeProperty("width");
|
itemNode.removeProperty("width");
|
||||||
itemNode.removeProperty("height");
|
itemNode.removeProperty("height");
|
||||||
}
|
}
|
||||||
} catch (const RewritingException &e) { //better save then sorry
|
});
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetPosition(const SelectionContext &selectionState)
|
void resetPosition(const SelectionContext &selectionState)
|
||||||
@@ -345,17 +336,13 @@ void resetPosition(const SelectionContext &selectionState)
|
|||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
selectionState.view()->executeInTransaction("DesignerActionManager|resetPosition",[selectionState](){
|
||||||
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetPosition"));
|
|
||||||
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
||||||
QmlItemNode itemNode(node);
|
QmlItemNode itemNode(node);
|
||||||
itemNode.removeProperty("x");
|
itemNode.removeProperty("x");
|
||||||
itemNode.removeProperty("y");
|
itemNode.removeProperty("y");
|
||||||
}
|
}
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const RewritingException &e) { //better save then sorry
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void goIntoComponentOperation(const SelectionContext &selectionState)
|
void goIntoComponentOperation(const SelectionContext &selectionState)
|
||||||
@@ -372,11 +359,12 @@ void resetZ(const SelectionContext &selectionState)
|
|||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetZ"));
|
selectionState.view()->executeInTransaction("DesignerActionManager|resetZ",[selectionState](){
|
||||||
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
||||||
QmlItemNode itemNode(node);
|
QmlItemNode itemNode(node);
|
||||||
itemNode.removeProperty("z");
|
itemNode.removeProperty("z");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void backupPropertyAndRemove(const ModelNode &node, const PropertyName &propertyName)
|
static inline void backupPropertyAndRemove(const ModelNode &node, const PropertyName &propertyName)
|
||||||
@@ -404,9 +392,7 @@ void anchorsFill(const SelectionContext &selectionState)
|
|||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
selectionState.view()->executeInTransaction("DesignerActionManager|anchorsFill",[selectionState](){
|
||||||
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsFill"));
|
|
||||||
|
|
||||||
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
||||||
|
|
||||||
QmlItemNode node = modelNode;
|
QmlItemNode node = modelNode;
|
||||||
@@ -417,11 +403,7 @@ void anchorsFill(const SelectionContext &selectionState)
|
|||||||
backupPropertyAndRemove(modelNode, "width");
|
backupPropertyAndRemove(modelNode, "width");
|
||||||
backupPropertyAndRemove(modelNode, "height");
|
backupPropertyAndRemove(modelNode, "height");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const RewritingException &e) { //better save then sorry
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void anchorsReset(const SelectionContext &selectionState)
|
void anchorsReset(const SelectionContext &selectionState)
|
||||||
@@ -429,8 +411,7 @@ void anchorsReset(const SelectionContext &selectionState)
|
|||||||
if (!selectionState.view())
|
if (!selectionState.view())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsReset"));
|
selectionState.view()->executeInTransaction("DesignerActionManager|anchorsReset",[selectionState](){
|
||||||
|
|
||||||
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
||||||
|
|
||||||
QmlItemNode node = modelNode;
|
QmlItemNode node = modelNode;
|
||||||
@@ -442,6 +423,7 @@ void anchorsReset(const SelectionContext &selectionState)
|
|||||||
restoreProperty(node, "width");
|
restoreProperty(node, "width");
|
||||||
restoreProperty(node, "height");
|
restoreProperty(node, "height");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
using LessThan = std::function<bool (const ModelNode &, const ModelNode&)>;
|
using LessThan = std::function<bool (const ModelNode &, const ModelNode&)>;
|
||||||
@@ -481,7 +463,7 @@ bool compareByGrid(const ModelNode &node1, const ModelNode &node2)
|
|||||||
|
|
||||||
static void layoutHelperFunction(const SelectionContext &selectionContext,
|
static void layoutHelperFunction(const SelectionContext &selectionContext,
|
||||||
const TypeName &layoutType,
|
const TypeName &layoutType,
|
||||||
LessThan lessThan)
|
const LessThan &lessThan)
|
||||||
{
|
{
|
||||||
if (!selectionContext.view()
|
if (!selectionContext.view()
|
||||||
|| !selectionContext.hasSingleSelectedModelNode()
|
|| !selectionContext.hasSingleSelectedModelNode()
|
||||||
@@ -492,10 +474,8 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
|
|||||||
const QmlItemNode qmlItemNode = QmlItemNode(selectionContext.firstSelectedModelNode());
|
const QmlItemNode qmlItemNode = QmlItemNode(selectionContext.firstSelectedModelNode());
|
||||||
|
|
||||||
if (qmlItemNode.hasInstanceParentItem()) {
|
if (qmlItemNode.hasInstanceParentItem()) {
|
||||||
|
|
||||||
ModelNode layoutNode;
|
ModelNode layoutNode;
|
||||||
{
|
selectionContext.view()->executeInTransaction("DesignerActionManager|layoutHelperFunction1",[=, &layoutNode](){
|
||||||
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction1"));
|
|
||||||
|
|
||||||
QmlItemNode parentNode = qmlItemNode.instanceParentItem();
|
QmlItemNode parentNode = qmlItemNode.instanceParentItem();
|
||||||
|
|
||||||
@@ -504,10 +484,9 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
|
|||||||
layoutNode = selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion());
|
layoutNode = selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion());
|
||||||
|
|
||||||
reparentTo(layoutNode, parentNode);
|
reparentTo(layoutNode, parentNode);
|
||||||
}
|
});
|
||||||
|
|
||||||
{
|
selectionContext.view()->executeInTransaction("DesignerActionManager|layoutHelperFunction2",[=](){
|
||||||
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction2"));
|
|
||||||
|
|
||||||
QList<ModelNode> sortedSelectedNodes = selectionContext.selectedModelNodes();
|
QList<ModelNode> sortedSelectedNodes = selectionContext.selectedModelNodes();
|
||||||
Utils::sort(sortedSelectedNodes, lessThan);
|
Utils::sort(sortedSelectedNodes, lessThan);
|
||||||
@@ -516,7 +495,7 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
|
|||||||
LayoutInGridLayout::reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes);
|
LayoutInGridLayout::reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes);
|
||||||
if (layoutType.contains("Layout"))
|
if (layoutType.contains("Layout"))
|
||||||
LayoutInGridLayout::setSizeAsPreferredSize(sortedSelectedNodes);
|
LayoutInGridLayout::setSizeAsPreferredSize(sortedSelectedNodes);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,16 +641,9 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
|||||||
|
|
||||||
if (!qmlObjectNode.isRootModelNode()) {
|
if (!qmlObjectNode.isRootModelNode()) {
|
||||||
isModelNodeRoot = false;
|
isModelNodeRoot = false;
|
||||||
try {
|
qmlObjectNode.view()->executeInTransaction("NavigatorTreeModel:exportItem", [&qmlObjectNode](){
|
||||||
RewriterTransaction transaction =
|
|
||||||
qmlObjectNode.view()->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
|
|
||||||
|
|
||||||
QmlObjectNode qmlObjectNode(modelNode);
|
|
||||||
qmlObjectNode.ensureAliasExport();
|
qmlObjectNode.ensureAliasExport();
|
||||||
transaction.commit();
|
});
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
|
||||||
exception.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString itemId = modelNode.id();
|
QString itemId = modelNode.id();
|
||||||
@@ -708,14 +680,10 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
|||||||
if (dialog->signal().isEmpty())
|
if (dialog->signal().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
qmlObjectNode.view()->executeInTransaction("NavigatorTreeModel:exportItem", [=](){
|
||||||
RewriterTransaction transaction =
|
|
||||||
qmlObjectNode.view()->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
|
|
||||||
|
|
||||||
addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot);
|
addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot);
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
});
|
||||||
exception.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot);
|
addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot);
|
||||||
|
|
||||||
@@ -751,9 +719,7 @@ void removeLayout(const SelectionContext &selectionContext)
|
|||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
{
|
selectionContext.view()->executeInTransaction("DesignerActionManager|removeLayout", [selectionContext, &layoutItem, parent](){
|
||||||
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|removeLayout"));
|
|
||||||
|
|
||||||
foreach (const ModelNode &modelNode, selectionContext.currentSingleSelectedNode().directSubModelNodes()) {
|
foreach (const ModelNode &modelNode, selectionContext.currentSingleSelectedNode().directSubModelNodes()) {
|
||||||
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
||||||
|
|
||||||
@@ -772,7 +738,7 @@ void removeLayout(const SelectionContext &selectionContext)
|
|||||||
parent.modelNode().defaultNodeListProperty().reparentHere(modelNode);
|
parent.modelNode().defaultNodeListProperty().reparentHere(modelNode);
|
||||||
}
|
}
|
||||||
layoutItem.destroy();
|
layoutItem.destroy();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void removePositioner(const SelectionContext &selectionContext)
|
void removePositioner(const SelectionContext &selectionContext)
|
||||||
@@ -826,9 +792,7 @@ void addItemToStackedContainer(const SelectionContext &selectionContext)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
view->executeInTransaction("DesignerActionManager:addItemToStackedContainer", [=](){
|
||||||
RewriterTransaction transaction =
|
|
||||||
view->beginRewriterTransaction(QByteArrayLiteral("DesignerActionManager:addItemToStackedContainer"));
|
|
||||||
|
|
||||||
NodeMetaInfo itemMetaInfo = view->model()->metaInfo("QtQuick.Item", -1, -1);
|
NodeMetaInfo itemMetaInfo = view->model()->metaInfo("QtQuick.Item", -1, -1);
|
||||||
QTC_ASSERT(itemMetaInfo.isValid(), return);
|
QTC_ASSERT(itemMetaInfo.isValid(), return);
|
||||||
@@ -853,11 +817,7 @@ void addItemToStackedContainer(const SelectionContext &selectionContext)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
|
||||||
exception.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyName getIndexPropertyName(const ModelNode &modelNode)
|
PropertyName getIndexPropertyName(const ModelNode &modelNode)
|
||||||
@@ -969,9 +929,8 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext)
|
|||||||
const PropertyName indexPropertyName = getIndexPropertyName(container);
|
const PropertyName indexPropertyName = getIndexPropertyName(container);
|
||||||
QTC_ASSERT(container.metaInfo().hasProperty(indexPropertyName), return);
|
QTC_ASSERT(container.metaInfo().hasProperty(indexPropertyName), return);
|
||||||
|
|
||||||
try {
|
view->executeInTransaction("DesignerActionManager:addItemToStackedContainer",
|
||||||
RewriterTransaction transaction =
|
[view, container, containerItemNode, tabBarMetaInfo, tabButtonMetaInfo, indexPropertyName](){
|
||||||
view->beginRewriterTransaction(QByteArrayLiteral("DesignerActionManager:addItemToStackedContainer"));
|
|
||||||
|
|
||||||
ModelNode tabBarNode =
|
ModelNode tabBarNode =
|
||||||
view->createModelNode("QtQuick.Controls.TabBar",
|
view->createModelNode("QtQuick.Controls.TabBar",
|
||||||
@@ -1003,11 +962,8 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext)
|
|||||||
container.removeProperty(indexPropertyName);
|
container.removeProperty(indexPropertyName);
|
||||||
const QString expression = id + "." + QString::fromLatin1(indexPropertyName);
|
const QString expression = id + "." + QString::fromLatin1(indexPropertyName);
|
||||||
container.bindingProperty(indexPropertyName).setExpression(expression);
|
container.bindingProperty(indexPropertyName).setExpression(expression);
|
||||||
|
});
|
||||||
|
|
||||||
transaction.commit();
|
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
|
||||||
exception.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addImageToProject(const QStringList &fileNames, const QString &defaultDirectory)
|
bool addImageToProject(const QStringList &fileNames, const QString &defaultDirectory)
|
||||||
|
|||||||
@@ -365,18 +365,13 @@ void DesignDocument::deleteSelected()
|
|||||||
if (!currentModel())
|
if (!currentModel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
rewriterView()->executeInTransaction("DesignDocument::deleteSelected", [this](){
|
||||||
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::deleteSelected"));
|
|
||||||
QList<ModelNode> toDelete = view()->selectedModelNodes();
|
QList<ModelNode> toDelete = view()->selectedModelNodes();
|
||||||
foreach (ModelNode node, toDelete) {
|
foreach (ModelNode node, toDelete) {
|
||||||
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
|
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
|
||||||
QmlObjectNode(node).destroy();
|
QmlObjectNode(node).destroy();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignDocument::copySelected()
|
void DesignDocument::copySelected()
|
||||||
@@ -465,11 +460,9 @@ void DesignDocument::paste()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, targetNode](){
|
||||||
QList<ModelNode> pastedNodeList;
|
QList<ModelNode> pastedNodeList;
|
||||||
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste1"));
|
|
||||||
|
|
||||||
int offset = double(qrand()) / RAND_MAX * 20 - 10;
|
int offset = double(qrand()) / RAND_MAX * 20 - 10;
|
||||||
|
|
||||||
foreach (const ModelNode &node, selectedNodes) {
|
foreach (const ModelNode &node, selectedNodes) {
|
||||||
@@ -481,14 +474,10 @@ void DesignDocument::paste()
|
|||||||
}
|
}
|
||||||
|
|
||||||
view.setSelectedModelNodes(pastedNodeList);
|
view.setSelectedModelNodes(pastedNodeList);
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
qWarning() << e.description(); //silent error
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste2"));
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, rootNode](){
|
||||||
currentModel()->attachView(&view);
|
currentModel()->attachView(&view);
|
||||||
ModelNode pastedNode(view.insertModel(rootNode));
|
ModelNode pastedNode(view.insertModel(rootNode));
|
||||||
ModelNode targetNode;
|
ModelNode targetNode;
|
||||||
@@ -514,15 +503,9 @@ void DesignDocument::paste()
|
|||||||
} else {
|
} else {
|
||||||
qWarning() << "Cannot reparent to" << targetNode;
|
qWarning() << "Cannot reparent to" << targetNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.commit();
|
|
||||||
NodeMetaInfo::clearCache();
|
|
||||||
|
|
||||||
view.setSelectedModelNodes({pastedNode});
|
view.setSelectedModelNodes({pastedNode});
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const RewritingException &e) {
|
NodeMetaInfo::clearCache();
|
||||||
qWarning() << e.description(); //silent error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -545,10 +545,9 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i
|
|||||||
void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
|
void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_view, return);
|
QTC_ASSERT(m_view, return);
|
||||||
try {
|
|
||||||
const TypeName propertyQmlType = parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name());
|
|
||||||
|
|
||||||
RewriterTransaction transaction = m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel::moveNodesInteractive"));
|
m_view->executeInTransaction("NavigatorTreeModel::moveNodesInteractive",[this, &parentProperty, modelNodes, targetIndex](){
|
||||||
|
const TypeName propertyQmlType = parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name());
|
||||||
foreach (const ModelNode &modelNode, modelNodes) {
|
foreach (const ModelNode &modelNode, modelNodes) {
|
||||||
if (modelNode.isValid()
|
if (modelNode.isValid()
|
||||||
&& modelNode != parentProperty.parentModelNode()
|
&& modelNode != parentProperty.parentModelNode()
|
||||||
@@ -565,10 +564,7 @@ void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
|
||||||
exception.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::DropActions NavigatorTreeModel::supportedDropActions() const
|
Qt::DropActions NavigatorTreeModel::supportedDropActions() const
|
||||||
|
|||||||
@@ -198,16 +198,10 @@ void NavigatorView::handleChangedExport(const ModelNode &modelNode, bool exporte
|
|||||||
if (rootNode.hasProperty(modelNodeId))
|
if (rootNode.hasProperty(modelNodeId))
|
||||||
rootNode.removeProperty(modelNodeId);
|
rootNode.removeProperty(modelNodeId);
|
||||||
if (exported) {
|
if (exported) {
|
||||||
try {
|
executeInTransaction("NavigatorTreeModel:exportItem", [this, modelNode](){
|
||||||
RewriterTransaction transaction =
|
|
||||||
beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
|
|
||||||
|
|
||||||
QmlObjectNode qmlObjectNode(modelNode);
|
QmlObjectNode qmlObjectNode(modelNode);
|
||||||
qmlObjectNode.ensureAliasExport();
|
qmlObjectNode.ensureAliasExport();
|
||||||
transaction.commit();
|
});
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
|
||||||
exception.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include <variantproperty.h>
|
#include <variantproperty.h>
|
||||||
#include <abstractview.h>
|
#include <abstractview.h>
|
||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
#include <rewritertransaction.h>
|
#include <exception.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -147,17 +147,15 @@ void GradientModel::addGradient()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
|
if (!m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
|
||||||
try {
|
|
||||||
|
|
||||||
QColor color = m_itemNode.instanceValue("color").value<QColor>();
|
|
||||||
|
|
||||||
if (!color.isValid())
|
|
||||||
color = QColor(Qt::white);
|
|
||||||
|
|
||||||
if (m_gradientTypeName != "Gradient")
|
if (m_gradientTypeName != "Gradient")
|
||||||
ensureShapesImport();
|
ensureShapesImport();
|
||||||
|
|
||||||
QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient"));
|
view()->executeInTransaction("GradientModel::addGradient", [this](){
|
||||||
|
QColor color = m_itemNode.instanceValue("color").value<QColor>();
|
||||||
|
|
||||||
|
if (!color.isValid())
|
||||||
|
color = QColor(Qt::white);
|
||||||
|
|
||||||
QmlDesigner::ModelNode gradientNode = createGradientNode();
|
QmlDesigner::ModelNode gradientNode = createGradientNode();
|
||||||
|
|
||||||
@@ -172,11 +170,7 @@ void GradientModel::addGradient()
|
|||||||
gradientStopNode.variantProperty("position").setValue(1.0);
|
gradientStopNode.variantProperty("position").setValue(1.0);
|
||||||
gradientStopNode.variantProperty("color").setValue(QColor(Qt::black));
|
gradientStopNode.variantProperty("color").setValue(QColor(Qt::black));
|
||||||
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
|
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
|
||||||
|
});
|
||||||
} catch (const QmlDesigner::Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
setupModel();
|
setupModel();
|
||||||
|
|
||||||
@@ -244,18 +238,18 @@ qreal GradientModel::getPosition(int index) const
|
|||||||
void GradientModel::removeStop(int index)
|
void GradientModel::removeStop(int index)
|
||||||
{
|
{
|
||||||
if (index < rowCount() - 1 && index != 0) {
|
if (index < rowCount() - 1 && index != 0) {
|
||||||
QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop"));
|
view()->executeInTransaction("GradientModel::removeStop", [this, index](){
|
||||||
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
|
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
|
||||||
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
|
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
|
||||||
if (stop.isValid()) {
|
if (stop.isValid()) {
|
||||||
stop.destroy();
|
stop.destroy();
|
||||||
setupModel();
|
setupModel();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
qWarning() << Q_FUNC_INFO << "invalid index";
|
qWarning() << Q_FUNC_INFO << "invalid index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GradientModel::deleteGradient()
|
void GradientModel::deleteGradient()
|
||||||
{
|
{
|
||||||
if (!m_itemNode.isValid())
|
if (!m_itemNode.isValid())
|
||||||
@@ -385,7 +379,11 @@ void GradientModel::ensureShapesImport()
|
|||||||
{
|
{
|
||||||
if (!hasShapesImport()) {
|
if (!hasShapesImport()) {
|
||||||
QmlDesigner::Import timelineImport = QmlDesigner::Import::createLibraryImport("QtQuick.Shapes", "1.0");
|
QmlDesigner::Import timelineImport = QmlDesigner::Import::createLibraryImport("QtQuick.Shapes", "1.0");
|
||||||
|
try {
|
||||||
model()->changeImports({timelineImport}, {});
|
model()->changeImports({timelineImport}, {});
|
||||||
|
} catch (const QmlDesigner::Exception &) {
|
||||||
|
QTC_ASSERT(false, return);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,22 +152,14 @@ void PropertyEditorContextObject::toogleExportAlias()
|
|||||||
PropertyName modelNodeId = selectedNode.id().toUtf8();
|
PropertyName modelNodeId = selectedNode.id().toUtf8();
|
||||||
ModelNode rootModelNode = rewriterView->rootModelNode();
|
ModelNode rootModelNode = rewriterView->rootModelNode();
|
||||||
|
|
||||||
try {
|
rewriterView->executeInTransaction("PropertyEditorContextObject:toogleExportAlias", [&objectNode, &rootModelNode, modelNodeId](){
|
||||||
RewriterTransaction transaction =
|
|
||||||
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:toogleExportAlias"));
|
|
||||||
|
|
||||||
if (!objectNode.isAliasExported())
|
if (!objectNode.isAliasExported())
|
||||||
objectNode.ensureAliasExport();
|
objectNode.ensureAliasExport();
|
||||||
else
|
else
|
||||||
if (rootModelNode.hasProperty(modelNodeId))
|
if (rootModelNode.hasProperty(modelNodeId))
|
||||||
rootModelNode.removeProperty(modelNodeId);
|
rootModelNode.removeProperty(modelNodeId);
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
|
||||||
exception.showException();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorContextObject::changeTypeName(const QString &typeName)
|
void PropertyEditorContextObject::changeTypeName(const QString &typeName)
|
||||||
@@ -181,12 +173,9 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
|
|||||||
|
|
||||||
QTC_ASSERT(!rewriterView->selectedModelNodes().isEmpty(), return);
|
QTC_ASSERT(!rewriterView->selectedModelNodes().isEmpty(), return);
|
||||||
|
|
||||||
|
rewriterView->executeInTransaction("PropertyEditorContextObject:changeTypeName", [this, rewriterView, typeName](){
|
||||||
ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst();
|
ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst();
|
||||||
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction =
|
|
||||||
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:changeTypeName"));
|
|
||||||
|
|
||||||
NodeMetaInfo metaInfo = m_model->metaInfo(typeName.toLatin1());
|
NodeMetaInfo metaInfo = m_model->metaInfo(typeName.toLatin1());
|
||||||
if (!metaInfo.isValid()) {
|
if (!metaInfo.isValid()) {
|
||||||
Core::AsynchronousMessageBox::warning(tr("Invalid Type"), tr("%1 is an invalid type.").arg(typeName));
|
Core::AsynchronousMessageBox::warning(tr("Invalid Type"), tr("%1 is an invalid type.").arg(typeName));
|
||||||
@@ -196,13 +185,7 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
|
|||||||
rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
|
rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
|
||||||
else
|
else
|
||||||
selectedNode.changeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
|
selectedNode.changeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
|
||||||
exception.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorContextObject::insertKeyframe(const QString &propertyName)
|
void PropertyEditorContextObject::insertKeyframe(const QString &propertyName)
|
||||||
|
|||||||
@@ -235,9 +235,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
|
|||||||
if (!m_selectedNode.isValid())
|
if (!m_selectedNode.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression"));
|
executeInTransaction("PropertyEditorView::changeExpression", [this, name](){
|
||||||
|
|
||||||
try {
|
|
||||||
PropertyName underscoreName(name);
|
PropertyName underscoreName(name);
|
||||||
underscoreName.replace('.', '_');
|
underscoreName.replace('.', '_');
|
||||||
|
|
||||||
@@ -253,7 +251,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
|
|||||||
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
|
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
|
||||||
if (QColor(value->expression().remove('"')).isValid()) {
|
if (QColor(value->expression().remove('"')).isValid()) {
|
||||||
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
|
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
|
||||||
transaction.commit(); //committing in the try block
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
|
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
|
||||||
@@ -263,7 +260,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
|
|||||||
qmlObjectNode.setVariantProperty(name, true);
|
qmlObjectNode.setVariantProperty(name, true);
|
||||||
else
|
else
|
||||||
qmlObjectNode.setVariantProperty(name, false);
|
qmlObjectNode.setVariantProperty(name, false);
|
||||||
transaction.commit(); //committing in the try block
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
|
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
|
||||||
@@ -271,7 +267,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
|
|||||||
int intValue = value->expression().toInt(&ok);
|
int intValue = value->expression().toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
qmlObjectNode.setVariantProperty(name, intValue);
|
qmlObjectNode.setVariantProperty(name, intValue);
|
||||||
transaction.commit(); //committing in the try block
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
|
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
|
||||||
@@ -279,7 +274,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
|
|||||||
qreal realValue = value->expression().toDouble(&ok);
|
qreal realValue = value->expression().toDouble(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
qmlObjectNode.setVariantProperty(name, realValue);
|
qmlObjectNode.setVariantProperty(name, realValue);
|
||||||
transaction.commit(); //committing in the try block
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,12 +285,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
|
|||||||
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
|
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
|
||||||
qmlObjectNode.setBindingProperty(name, value->expression());
|
qmlObjectNode.setBindingProperty(name, value->expression());
|
||||||
|
|
||||||
transaction.commit(); //committing in the try block
|
}); /* end of transaction */
|
||||||
}
|
|
||||||
|
|
||||||
catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorView::exportPopertyAsAlias(const QString &name)
|
void PropertyEditorView::exportPopertyAsAlias(const QString &name)
|
||||||
@@ -310,9 +299,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name)
|
|||||||
if (!m_selectedNode.isValid())
|
if (!m_selectedNode.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias"));
|
executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){
|
||||||
|
|
||||||
try {
|
|
||||||
const QString id = m_selectedNode.validId();
|
const QString id = m_selectedNode.validId();
|
||||||
QString upperCasePropertyName = name;
|
QString upperCasePropertyName = name;
|
||||||
upperCasePropertyName.replace(0, 1, upperCasePropertyName.at(0).toUpper());
|
upperCasePropertyName.replace(0, 1, upperCasePropertyName.at(0).toUpper());
|
||||||
@@ -326,11 +313,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rootModelNode().bindingProperty(propertyName).setDynamicTypeNameAndExpression("alias", id + "." + name);
|
rootModelNode().bindingProperty(propertyName).setDynamicTypeNameAndExpression("alias", id + "." + name);
|
||||||
|
});
|
||||||
transaction.commit(); //committing in the try block
|
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorView::removeAliasExport(const QString &name)
|
void PropertyEditorView::removeAliasExport(const QString &name)
|
||||||
@@ -344,9 +327,7 @@ void PropertyEditorView::removeAliasExport(const QString &name)
|
|||||||
if (!m_selectedNode.isValid())
|
if (!m_selectedNode.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias"));
|
executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){
|
||||||
|
|
||||||
try {
|
|
||||||
const QString id = m_selectedNode.validId();
|
const QString id = m_selectedNode.validId();
|
||||||
|
|
||||||
for (const BindingProperty &property : rootModelNode().bindingProperties())
|
for (const BindingProperty &property : rootModelNode().bindingProperties())
|
||||||
@@ -354,10 +335,7 @@ void PropertyEditorView::removeAliasExport(const QString &name)
|
|||||||
rootModelNode().removeProperty(property.name());
|
rootModelNode().removeProperty(property.name());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PropertyEditorView::locked() const
|
bool PropertyEditorView::locked() const
|
||||||
|
|||||||
@@ -292,9 +292,9 @@ void QmlAnchorBindingProxy::setDefaultRelativeRightTarget()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RewriterTransaction QmlAnchorBindingProxy::beginRewriterTransaction(const QByteArray &identifier)
|
bool QmlAnchorBindingProxy::executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda)
|
||||||
{
|
{
|
||||||
return m_qmlItemNode.modelNode().view()->beginRewriterTransaction(identifier);
|
return m_qmlItemNode.modelNode().view()->executeInTransaction(identifier, lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlAnchorBindingProxy::hasParent() const
|
bool QmlAnchorBindingProxy::hasParent() const
|
||||||
@@ -361,20 +361,11 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target)
|
|||||||
if (!newTarget.isValid())
|
if (!newTarget.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setTopTarget", [this, newTarget](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget"));
|
|
||||||
|
|
||||||
m_topTarget = newTarget;
|
m_topTarget = newTarget;
|
||||||
|
|
||||||
setDefaultRelativeTopTarget();
|
setDefaultRelativeTopTarget();
|
||||||
|
|
||||||
anchorTop();
|
anchorTop();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit topTargetChanged();
|
emit topTargetChanged();
|
||||||
}
|
}
|
||||||
@@ -393,18 +384,12 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target)
|
|||||||
if (!newTarget.isValid())
|
if (!newTarget.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setBottomTarget", [this, newTarget](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomTarget"));
|
|
||||||
|
|
||||||
m_bottomTarget = newTarget;
|
m_bottomTarget = newTarget;
|
||||||
setDefaultRelativeBottomTarget();
|
setDefaultRelativeBottomTarget();
|
||||||
anchorBottom();
|
anchorBottom();
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit bottomTargetChanged();
|
emit bottomTargetChanged();
|
||||||
}
|
}
|
||||||
@@ -422,18 +407,11 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target)
|
|||||||
if (!newTarget.isValid())
|
if (!newTarget.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setLeftTarget", [this, newTarget](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftTarget"));
|
|
||||||
|
|
||||||
m_leftTarget = newTarget;
|
m_leftTarget = newTarget;
|
||||||
setDefaultRelativeLeftTarget();
|
setDefaultRelativeLeftTarget();
|
||||||
anchorLeft();
|
anchorLeft();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit leftTargetChanged();
|
emit leftTargetChanged();
|
||||||
}
|
}
|
||||||
@@ -451,18 +429,11 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target)
|
|||||||
if (!newTarget.isValid())
|
if (!newTarget.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setRightTarget", [this, newTarget](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRightTarget"));
|
|
||||||
|
|
||||||
m_rightTarget = newTarget;
|
m_rightTarget = newTarget;
|
||||||
setDefaultRelativeRightTarget();
|
setDefaultRelativeRightTarget();
|
||||||
anchorRight();
|
anchorRight();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit rightTargetChanged();
|
emit rightTargetChanged();
|
||||||
}
|
}
|
||||||
@@ -480,17 +451,10 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target)
|
|||||||
if (!newTarget.isValid())
|
if (!newTarget.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setVerticalTarget", [this, newTarget](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget"));
|
|
||||||
|
|
||||||
m_verticalTarget = newTarget;
|
m_verticalTarget = newTarget;
|
||||||
anchorVertical();
|
anchorVertical();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit verticalTargetChanged();
|
emit verticalTargetChanged();
|
||||||
}
|
}
|
||||||
@@ -508,17 +472,10 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target)
|
|||||||
if (!newTarget.isValid())
|
if (!newTarget.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setHorizontalTarget", [this, newTarget](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget"));
|
|
||||||
|
|
||||||
m_horizontalTarget = newTarget;
|
m_horizontalTarget = newTarget;
|
||||||
anchorHorizontal();\
|
anchorHorizontal();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit horizontalTargetChanged();
|
emit horizontalTargetChanged();
|
||||||
}
|
}
|
||||||
@@ -531,18 +488,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetTop(QmlAnchorBindingProxy::Re
|
|||||||
if (target == m_relativeTopTarget)
|
if (target == m_relativeTopTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetTop", [this, target](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetTop"));
|
|
||||||
|
|
||||||
m_relativeTopTarget = target;
|
m_relativeTopTarget = target;
|
||||||
|
|
||||||
anchorTop();
|
anchorTop();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetTopChanged();
|
emit relativeAnchorTargetTopChanged();
|
||||||
}
|
}
|
||||||
@@ -555,19 +504,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetBottom(QmlAnchorBindingProxy:
|
|||||||
if (target == m_relativeBottomTarget)
|
if (target == m_relativeBottomTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom", [this, target](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom"));
|
|
||||||
|
|
||||||
m_relativeBottomTarget = target;
|
m_relativeBottomTarget = target;
|
||||||
|
|
||||||
|
|
||||||
anchorBottom();
|
anchorBottom();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetBottomChanged();
|
emit relativeAnchorTargetBottomChanged();
|
||||||
}
|
}
|
||||||
@@ -580,18 +520,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetLeft(QmlAnchorBindingProxy::R
|
|||||||
if (target == m_relativeLeftTarget)
|
if (target == m_relativeLeftTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft", [this, target](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft"));
|
|
||||||
|
|
||||||
m_relativeLeftTarget = target;
|
m_relativeLeftTarget = target;
|
||||||
|
|
||||||
anchorLeft();
|
anchorLeft();
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetLeftChanged();
|
emit relativeAnchorTargetLeftChanged();
|
||||||
}
|
}
|
||||||
@@ -604,18 +537,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetRight(QmlAnchorBindingProxy::
|
|||||||
if (target == m_relativeRightTarget)
|
if (target == m_relativeRightTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetRight", [this, target](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetRight"));
|
|
||||||
|
|
||||||
m_relativeRightTarget = target;
|
m_relativeRightTarget = target;
|
||||||
|
|
||||||
anchorRight();
|
anchorRight();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetRightChanged();
|
emit relativeAnchorTargetRightChanged();
|
||||||
|
|
||||||
@@ -629,18 +554,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetVertical(QmlAnchorBindingProx
|
|||||||
if (target == m_relativeVerticalTarget)
|
if (target == m_relativeVerticalTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical"));
|
|
||||||
|
|
||||||
|
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical", [this, target](){
|
||||||
m_relativeVerticalTarget = target;
|
m_relativeVerticalTarget = target;
|
||||||
|
|
||||||
anchorVertical();
|
anchorVertical();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetVerticalChanged();
|
emit relativeAnchorTargetVerticalChanged();
|
||||||
}
|
}
|
||||||
@@ -653,18 +571,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal(QmlAnchorBindingPr
|
|||||||
if (target == m_relativeHorizontalTarget)
|
if (target == m_relativeHorizontalTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal", [this, target](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal"));
|
|
||||||
|
|
||||||
m_relativeHorizontalTarget = target;
|
m_relativeHorizontalTarget = target;
|
||||||
|
|
||||||
anchorHorizontal();
|
anchorHorizontal();
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetHorizontalChanged();
|
emit relativeAnchorTargetHorizontalChanged();
|
||||||
}
|
}
|
||||||
@@ -709,12 +619,10 @@ int QmlAnchorBindingProxy::indexOfPossibleTargetItem(const QString &targetName)
|
|||||||
return possibleTargetItems().indexOf(targetName);
|
return possibleTargetItems().indexOf(targetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchorBindingProxy::resetLayout() {
|
void QmlAnchorBindingProxy::resetLayout()
|
||||||
|
{
|
||||||
try {
|
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::resetLayout"));
|
|
||||||
|
|
||||||
|
executeInTransaction("QmlAnchorBindingProxy::resetLayout", [this](){
|
||||||
m_qmlItemNode.anchors().removeAnchors();
|
m_qmlItemNode.anchors().removeAnchors();
|
||||||
m_qmlItemNode.anchors().removeMargins();
|
m_qmlItemNode.anchors().removeMargins();
|
||||||
|
|
||||||
@@ -722,11 +630,7 @@ void QmlAnchorBindingProxy::resetLayout() {
|
|||||||
restoreProperty(modelNode(), "y");
|
restoreProperty(modelNode(), "y");
|
||||||
restoreProperty(modelNode(), "width");
|
restoreProperty(modelNode(), "width");
|
||||||
restoreProperty(modelNode(), "height");
|
restoreProperty(modelNode(), "height");
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit topAnchorChanged();
|
emit topAnchorChanged();
|
||||||
emit bottomAnchorChanged();
|
emit bottomAnchorChanged();
|
||||||
@@ -743,10 +647,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
|
|||||||
if (bottomAnchored() == anchor)
|
if (bottomAnchored() == anchor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setBottomAnchor", [this, anchor](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomAnchor"));
|
|
||||||
|
|
||||||
if (!anchor) {
|
if (!anchor) {
|
||||||
removeBottomAnchor();
|
removeBottomAnchor();
|
||||||
} else {
|
} else {
|
||||||
@@ -756,10 +657,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
|
|||||||
backupPropertyAndRemove(modelNode(), "height");
|
backupPropertyAndRemove(modelNode(), "height");
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetBottomChanged();
|
emit relativeAnchorTargetBottomChanged();
|
||||||
emit bottomAnchorChanged();
|
emit bottomAnchorChanged();
|
||||||
@@ -776,10 +674,8 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
|
|||||||
if (leftAnchored() == anchor)
|
if (leftAnchored() == anchor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftAnchor"));
|
|
||||||
|
|
||||||
|
executeInTransaction("QmlAnchorBindingProxy::setLeftAnchor", [this, anchor](){
|
||||||
if (!anchor) {
|
if (!anchor) {
|
||||||
removeLeftAnchor();
|
removeLeftAnchor();
|
||||||
} else {
|
} else {
|
||||||
@@ -791,10 +687,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
|
|||||||
backupPropertyAndRemove(modelNode(), "width");
|
backupPropertyAndRemove(modelNode(), "width");
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetLeftChanged();
|
emit relativeAnchorTargetLeftChanged();
|
||||||
emit leftAnchorChanged();
|
emit leftAnchorChanged();
|
||||||
@@ -810,10 +703,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
|
|||||||
if (rightAnchored() == anchor)
|
if (rightAnchored() == anchor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setRightAnchor", [this, anchor](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setRightAnchor"));
|
|
||||||
|
|
||||||
if (!anchor) {
|
if (!anchor) {
|
||||||
removeRightAnchor();
|
removeRightAnchor();
|
||||||
} else {
|
} else {
|
||||||
@@ -824,10 +714,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
|
|||||||
backupPropertyAndRemove(modelNode(), "width");
|
backupPropertyAndRemove(modelNode(), "width");
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetRightChanged();
|
emit relativeAnchorTargetRightChanged();
|
||||||
emit rightAnchorChanged();
|
emit rightAnchorChanged();
|
||||||
@@ -1026,10 +913,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
|
|||||||
if (topAnchored() == anchor)
|
if (topAnchored() == anchor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setTopAnchor", [this, anchor](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setTopAnchor"));
|
|
||||||
|
|
||||||
if (!anchor) {
|
if (!anchor) {
|
||||||
removeTopAnchor();
|
removeTopAnchor();
|
||||||
} else {
|
} else {
|
||||||
@@ -1040,10 +924,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
|
|||||||
if (bottomAnchored())
|
if (bottomAnchored())
|
||||||
backupPropertyAndRemove(modelNode(), "height");
|
backupPropertyAndRemove(modelNode(), "height");
|
||||||
}
|
}
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit relativeAnchorTargetTopChanged();
|
emit relativeAnchorTargetTopChanged();
|
||||||
emit topAnchorChanged();
|
emit topAnchorChanged();
|
||||||
@@ -1052,70 +933,44 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchorBindingProxy::removeTopAnchor() {
|
void QmlAnchorBindingProxy::removeTopAnchor() {
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::removeTopAnchor", [this](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor"));
|
|
||||||
|
|
||||||
m_qmlItemNode.anchors().removeAnchor(AnchorLineTop);
|
m_qmlItemNode.anchors().removeAnchor(AnchorLineTop);
|
||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
|
||||||
|
|
||||||
restoreProperty(modelNode(), "y");
|
restoreProperty(modelNode(), "y");
|
||||||
restoreProperty(modelNode(), "height");
|
restoreProperty(modelNode(), "height");
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchorBindingProxy::removeBottomAnchor() {
|
void QmlAnchorBindingProxy::removeBottomAnchor()
|
||||||
try {
|
{
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
executeInTransaction("QmlAnchorBindingProxy::removeBottomAnchor", [this](){
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor"));
|
|
||||||
|
|
||||||
m_qmlItemNode.anchors().removeAnchor(AnchorLineBottom);
|
m_qmlItemNode.anchors().removeAnchor(AnchorLineBottom);
|
||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
|
||||||
|
|
||||||
|
|
||||||
restoreProperty(modelNode(), "height");
|
restoreProperty(modelNode(), "height");
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchorBindingProxy::removeLeftAnchor() {
|
void QmlAnchorBindingProxy::removeLeftAnchor()
|
||||||
try {
|
{
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
executeInTransaction("QmlAnchorBindingProxy::removeLeftAnchor", [this](){
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor"));
|
|
||||||
|
|
||||||
m_qmlItemNode.anchors().removeAnchor(AnchorLineLeft);
|
m_qmlItemNode.anchors().removeAnchor(AnchorLineLeft);
|
||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineLeft);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineLeft);
|
||||||
|
|
||||||
restoreProperty(modelNode(), "x");
|
restoreProperty(modelNode(), "x");
|
||||||
restoreProperty(modelNode(), "width");
|
restoreProperty(modelNode(), "width");
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchorBindingProxy::removeRightAnchor() {
|
void QmlAnchorBindingProxy::removeRightAnchor()
|
||||||
try {
|
{
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
executeInTransaction("QmlAnchorBindingProxy::removeRightAnchor", [this](){
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor"));
|
|
||||||
|
|
||||||
m_qmlItemNode.anchors().removeAnchor(AnchorLineRight);
|
m_qmlItemNode.anchors().removeAnchor(AnchorLineRight);
|
||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineRight);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineRight);
|
||||||
|
|
||||||
restoreProperty(modelNode(), "width");
|
restoreProperty(modelNode(), "width");
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
|
void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
|
||||||
@@ -1128,10 +983,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
|
|||||||
|
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setVerticalCentered", [this, centered](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered"));
|
|
||||||
|
|
||||||
if (!centered) {
|
if (!centered) {
|
||||||
m_qmlItemNode.anchors().removeAnchor(AnchorLineVerticalCenter);
|
m_qmlItemNode.anchors().removeAnchor(AnchorLineVerticalCenter);
|
||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineVerticalCenter);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineVerticalCenter);
|
||||||
@@ -1141,10 +993,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
|
|||||||
anchorVertical();
|
anchorVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
|
|
||||||
emit relativeAnchorTargetVerticalChanged();
|
emit relativeAnchorTargetVerticalChanged();
|
||||||
@@ -1161,10 +1010,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
|
|||||||
|
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
try {
|
executeInTransaction("QmlAnchorBindingProxy::setHorizontalCentered", [this, centered](){
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered"));
|
|
||||||
|
|
||||||
if (!centered) {
|
if (!centered) {
|
||||||
m_qmlItemNode.anchors().removeAnchor(AnchorLineHorizontalCenter);
|
m_qmlItemNode.anchors().removeAnchor(AnchorLineHorizontalCenter);
|
||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineHorizontalCenter);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineHorizontalCenter);
|
||||||
@@ -1173,11 +1019,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
|
|||||||
|
|
||||||
anchorHorizontal();
|
anchorHorizontal();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
|
|
||||||
emit relativeAnchorTargetHorizontalChanged();
|
emit relativeAnchorTargetHorizontalChanged();
|
||||||
@@ -1256,12 +1098,7 @@ bool QmlAnchorBindingProxy::horizontalCentered()
|
|||||||
|
|
||||||
void QmlAnchorBindingProxy::fill()
|
void QmlAnchorBindingProxy::fill()
|
||||||
{
|
{
|
||||||
|
executeInTransaction("QmlAnchorBindingProxy::fill", [this](){
|
||||||
try {
|
|
||||||
RewriterTransaction transaction = beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("QmlAnchorBindingProxy::fill"));
|
|
||||||
|
|
||||||
|
|
||||||
backupPropertyAndRemove(modelNode(), "x");
|
backupPropertyAndRemove(modelNode(), "x");
|
||||||
backupPropertyAndRemove(modelNode(), "y");
|
backupPropertyAndRemove(modelNode(), "y");
|
||||||
backupPropertyAndRemove(modelNode(), "width");
|
backupPropertyAndRemove(modelNode(), "width");
|
||||||
@@ -1277,10 +1114,7 @@ void QmlAnchorBindingProxy::fill()
|
|||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
|
||||||
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
|
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit topAnchorChanged();
|
emit topAnchorChanged();
|
||||||
emit bottomAnchorChanged();
|
emit bottomAnchorChanged();
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ private:
|
|||||||
void setDefaultRelativeLeftTarget();
|
void setDefaultRelativeLeftTarget();
|
||||||
void setDefaultRelativeRightTarget();
|
void setDefaultRelativeRightTarget();
|
||||||
|
|
||||||
RewriterTransaction beginRewriterTransaction(const QByteArray &identifier);
|
bool executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda);
|
||||||
|
|
||||||
QmlItemNode targetIdToNode(const QString &id) const;
|
QmlItemNode targetIdToNode(const QString &id) const;
|
||||||
QString idForNode(const QmlItemNode &qmlItemNode) const;
|
QString idForNode(const QmlItemNode &qmlItemNode) const;
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QStyle;
|
class QStyle;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
@@ -263,6 +265,9 @@ public:
|
|||||||
void activateTimelineRecording(const ModelNode &timeline);
|
void activateTimelineRecording(const ModelNode &timeline);
|
||||||
void deactivateTimelineRecording();
|
void deactivateTimelineRecording();
|
||||||
|
|
||||||
|
using OperationBlock = std::function<void()>;
|
||||||
|
bool executeInTransaction(const QByteArray &identifier, const OperationBlock &lambda);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setModel(Model * model);
|
void setModel(Model * model);
|
||||||
void removeModel();
|
void removeModel();
|
||||||
|
|||||||
@@ -616,6 +616,20 @@ void AbstractView::deactivateTimelineRecording()
|
|||||||
model()->d->notifyCurrentTimelineChanged(ModelNode());
|
model()->d->notifyCurrentTimelineChanged(ModelNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AbstractView::executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
RewriterTransaction transaction = beginRewriterTransaction(identifier);
|
||||||
|
lambda();
|
||||||
|
transaction.commit();
|
||||||
|
} catch (const Exception &e) {
|
||||||
|
e.showException();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QList<ModelNode> AbstractView::allModelNodes() const
|
QList<ModelNode> AbstractView::allModelNodes() const
|
||||||
{
|
{
|
||||||
return toModelNodeList(model()->d->allNodes());
|
return toModelNodeList(model()->d->allNodes());
|
||||||
|
|||||||
@@ -178,9 +178,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
|
|||||||
view()->model()->changeImports(modelNode.model()->imports(), {});
|
view()->model()->changeImports(modelNode.model()->imports(), {});
|
||||||
view()->model()->setFileUrl(modelNode.model()->fileUrl());
|
view()->model()->setFileUrl(modelNode.model()->fileUrl());
|
||||||
|
|
||||||
try {
|
view()->executeInTransaction("ModelMerger::replaceModel", [this, modelNode](){
|
||||||
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::replaceModel")));
|
|
||||||
|
|
||||||
ModelNode rootNode(view()->rootModelNode());
|
ModelNode rootNode(view()->rootModelNode());
|
||||||
|
|
||||||
foreach (const PropertyName &propertyName, rootNode.propertyNames())
|
foreach (const PropertyName &propertyName, rootNode.propertyNames())
|
||||||
@@ -196,11 +194,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
|
|||||||
syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
|
syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
|
||||||
syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
|
syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
|
||||||
m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
|
m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
qWarning() << e.description(); //silent error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace QmlDesigner
|
} //namespace QmlDesigner
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine,
|
|||||||
const QmlItemNode &targetQmlItemNode,
|
const QmlItemNode &targetQmlItemNode,
|
||||||
AnchorLineType targetAnchorLine)
|
AnchorLineType targetAnchorLine)
|
||||||
{
|
{
|
||||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::setAnchor"));
|
qmlItemNode().view()->executeInTransaction("QmlAnchors::setAnchor", [this, sourceAnchorLine, targetQmlItemNode, targetAnchorLine](){
|
||||||
if (qmlItemNode().isInBaseState()) {
|
if (qmlItemNode().isInBaseState()) {
|
||||||
if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill))
|
if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill))
|
||||||
|| ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)))) {
|
|| ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)))) {
|
||||||
@@ -177,6 +177,7 @@ void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine,
|
|||||||
targetExpression = targetExpression + QLatin1Char('.') + QString::fromLatin1(lineTypeToString(targetAnchorLine));
|
targetExpression = targetExpression + QLatin1Char('.') + QString::fromLatin1(lineTypeToString(targetAnchorLine));
|
||||||
qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression);
|
qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool detectHorizontalCycle(const ModelNode &node, QList<ModelNode> knownNodeList)
|
bool detectHorizontalCycle(const ModelNode &node, QList<ModelNode> knownNodeList)
|
||||||
@@ -315,7 +316,7 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLineType sourceAnchorLine) const
|
|||||||
|
|
||||||
void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine)
|
void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine)
|
||||||
{
|
{
|
||||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchor"));
|
qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchor", [this, sourceAnchorLine](){
|
||||||
if (qmlItemNode().isInBaseState()) {
|
if (qmlItemNode().isInBaseState()) {
|
||||||
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
|
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
|
||||||
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) {
|
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) {
|
||||||
@@ -333,11 +334,12 @@ void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine)
|
|||||||
|
|
||||||
qmlItemNode().modelNode().removeProperty(propertyName);
|
qmlItemNode().modelNode().removeProperty(propertyName);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchors::removeAnchors()
|
void QmlAnchors::removeAnchors()
|
||||||
{
|
{
|
||||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchors"));
|
qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchors", [this](){
|
||||||
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill"))
|
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill"))
|
||||||
qmlItemNode().modelNode().removeProperty("anchors.fill");
|
qmlItemNode().modelNode().removeProperty("anchors.fill");
|
||||||
if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn"))
|
if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn"))
|
||||||
@@ -356,6 +358,7 @@ void QmlAnchors::removeAnchors()
|
|||||||
qmlItemNode().modelNode().removeProperty("anchors.verticalCenter");
|
qmlItemNode().modelNode().removeProperty("anchors.verticalCenter");
|
||||||
if (qmlItemNode().nodeInstance().hasAnchor("anchors.baseline"))
|
if (qmlItemNode().nodeInstance().hasAnchor("anchors.baseline"))
|
||||||
qmlItemNode().modelNode().removeProperty("anchors.baseline");
|
qmlItemNode().modelNode().removeProperty("anchors.baseline");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlAnchors::instanceHasAnchor(AnchorLineType sourceAnchorLine) const
|
bool QmlAnchors::instanceHasAnchor(AnchorLineType sourceAnchorLine) const
|
||||||
@@ -532,13 +535,14 @@ void QmlAnchors::removeMargin(AnchorLineType sourceAnchorLineType)
|
|||||||
|
|
||||||
void QmlAnchors::removeMargins()
|
void QmlAnchors::removeMargins()
|
||||||
{
|
{
|
||||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeMargins"));
|
qmlItemNode().view()->executeInTransaction("QmlAnchors::removeMargins", [this](){
|
||||||
removeMargin(AnchorLineLeft);
|
removeMargin(AnchorLineLeft);
|
||||||
removeMargin(AnchorLineRight);
|
removeMargin(AnchorLineRight);
|
||||||
removeMargin(AnchorLineTop);
|
removeMargin(AnchorLineTop);
|
||||||
removeMargin(AnchorLineBottom);
|
removeMargin(AnchorLineBottom);
|
||||||
removeMargin(AnchorLineHorizontalCenter);
|
removeMargin(AnchorLineHorizontalCenter);
|
||||||
removeMargin(AnchorLineVerticalCenter);
|
removeMargin(AnchorLineVerticalCenter);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAnchors::fill()
|
void QmlAnchors::fill()
|
||||||
|
|||||||
@@ -102,9 +102,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
|
|||||||
{
|
{
|
||||||
QmlItemNode newQmlItemNode;
|
QmlItemNode newQmlItemNode;
|
||||||
|
|
||||||
try {
|
view->executeInTransaction("QmlItemNode::createQmlItemNode", [=, &newQmlItemNode, &parentproperty](){
|
||||||
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNode"));
|
|
||||||
|
|
||||||
NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName());
|
NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName());
|
||||||
|
|
||||||
int minorVersion = metaInfo.minorVersion();
|
int minorVersion = metaInfo.minorVersion();
|
||||||
@@ -139,7 +137,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
|
|||||||
parentproperty.reparentHere(newQmlItemNode);
|
parentproperty.reparentHere(newQmlItemNode);
|
||||||
|
|
||||||
if (!newQmlItemNode.isValid())
|
if (!newQmlItemNode.isValid())
|
||||||
return newQmlItemNode;
|
return;
|
||||||
|
|
||||||
newQmlItemNode.setId(view->generateNewId(itemLibraryEntry.name()));
|
newQmlItemNode.setId(view->generateNewId(itemLibraryEntry.name()));
|
||||||
|
|
||||||
@@ -150,10 +148,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
|
|||||||
newQmlItemNode.modelNode().variantProperty(propertyBindingEntry.first).setEnumeration(propertyBindingEntry.second.toUtf8());
|
newQmlItemNode.modelNode().variantProperty(propertyBindingEntry.first).setEnumeration(propertyBindingEntry.second.toUtf8());
|
||||||
|
|
||||||
Q_ASSERT(newQmlItemNode.isValid());
|
Q_ASSERT(newQmlItemNode.isValid());
|
||||||
}
|
});
|
||||||
catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT(newQmlItemNode.isValid());
|
Q_ASSERT(newQmlItemNode.isValid());
|
||||||
|
|
||||||
@@ -174,10 +169,8 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
|
|||||||
{
|
{
|
||||||
QmlItemNode newQmlItemNode;
|
QmlItemNode newQmlItemNode;
|
||||||
|
|
||||||
if (parentproperty.isValid()) {
|
if (parentproperty.isValid() && view->model()->hasNodeMetaInfo("QtQuick.Image")) {
|
||||||
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNodeFromImage"));
|
view->executeInTransaction("QmlItemNode::createQmlItemNodeFromImage", [=, &newQmlItemNode, &parentproperty](){
|
||||||
|
|
||||||
if (view->model()->hasNodeMetaInfo("QtQuick.Image")) {
|
|
||||||
NodeMetaInfo metaInfo = view->model()->metaInfo("QtQuick.Image");
|
NodeMetaInfo metaInfo = view->model()->metaInfo("QtQuick.Image");
|
||||||
QList<QPair<PropertyName, QVariant> > propertyPairList;
|
QList<QPair<PropertyName, QVariant> > propertyPairList;
|
||||||
propertyPairList.append({PropertyName("x"), QVariant(qRound(position.x()))});
|
propertyPairList.append({PropertyName("x"), QVariant(qRound(position.x()))});
|
||||||
@@ -200,8 +193,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
|
|||||||
newQmlItemNode.modelNode().variantProperty("fillMode").setEnumeration("Image.PreserveAspectFit");
|
newQmlItemNode.modelNode().variantProperty("fillMode").setEnumeration("Image.PreserveAspectFit");
|
||||||
|
|
||||||
Q_ASSERT(newQmlItemNode.isValid());
|
Q_ASSERT(newQmlItemNode.isValid());
|
||||||
}
|
});
|
||||||
Q_ASSERT(newQmlItemNode.isValid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newQmlItemNode;
|
return newQmlItemNode;
|
||||||
|
|||||||
@@ -232,8 +232,6 @@ void BackendModel::addNewBackend()
|
|||||||
|
|
||||||
Import import = Import::createLibraryImport(importSplit.constFirst(), importSplit.constLast());
|
Import import = Import::createLibraryImport(importSplit.constFirst(), importSplit.constLast());
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
/* We cannot add an import and add a node from that import in a single transaction.
|
/* We cannot add an import and add a node from that import in a single transaction.
|
||||||
* We need the import to have the meta info available.
|
* We need the import to have the meta info available.
|
||||||
*/
|
*/
|
||||||
@@ -247,12 +245,11 @@ void BackendModel::addNewBackend()
|
|||||||
|
|
||||||
QTC_ASSERT(metaInfo.isValid(), return);
|
QTC_ASSERT(metaInfo.isValid(), return);
|
||||||
|
|
||||||
int minorVersion = metaInfo.minorVersion();
|
|
||||||
int majorVersion = metaInfo.majorVersion();
|
|
||||||
|
|
||||||
/* Add a property for non singleton types. For singletons just adding the import is enough. */
|
/* Add a property for non singleton types. For singletons just adding the import is enough. */
|
||||||
if (!dialog.isSingleton()) {
|
if (!dialog.isSingleton()) {
|
||||||
RewriterTransaction transaction = m_connectionView->beginRewriterTransaction("BackendModel::addNewBackend");
|
m_connectionView->executeInTransaction("BackendModel::addNewBackend", [=, &dialog](){
|
||||||
|
int minorVersion = metaInfo.minorVersion();
|
||||||
|
int majorVersion = metaInfo.majorVersion();
|
||||||
|
|
||||||
if (dialog.localDefinition()) {
|
if (dialog.localDefinition()) {
|
||||||
ModelNode newNode = m_connectionView->createModelNode(metaInfo.typeName(), majorVersion, minorVersion);
|
ModelNode newNode = m_connectionView->createModelNode(metaInfo.typeName(), majorVersion, minorVersion);
|
||||||
@@ -263,14 +260,9 @@ void BackendModel::addNewBackend()
|
|||||||
m_connectionView->rootModelNode().bindingProperty(
|
m_connectionView->rootModelNode().bindingProperty(
|
||||||
propertyName.toUtf8()).setDynamicTypeNameAndExpression(typeName.toUtf8(), "null");
|
propertyName.toUtf8()).setDynamicTypeNameAndExpression(typeName.toUtf8(), "null");
|
||||||
}
|
}
|
||||||
transaction.commit();
|
});
|
||||||
}
|
|
||||||
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetModel();
|
resetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,11 +271,9 @@ void BackendModel::updatePropertyName(int rowNumber)
|
|||||||
const PropertyName newName = data(index(rowNumber, 1)).toString().toUtf8();
|
const PropertyName newName = data(index(rowNumber, 1)).toString().toUtf8();
|
||||||
const PropertyName oldName = data(index(rowNumber, 0), Qt::UserRole + 1).toString().toUtf8();
|
const PropertyName oldName = data(index(rowNumber, 0), Qt::UserRole + 1).toString().toUtf8();
|
||||||
|
|
||||||
|
m_connectionView->executeInTransaction("BackendModel::updatePropertyName", [this, newName, oldName](){
|
||||||
|
|
||||||
ModelNode rootModelNode = m_connectionView->rootModelNode();
|
ModelNode rootModelNode = m_connectionView->rootModelNode();
|
||||||
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction = m_connectionView->beginRewriterTransaction("BackendModel::updatePropertyName");
|
|
||||||
|
|
||||||
if (rootModelNode.property(oldName).isNodeProperty()) {
|
if (rootModelNode.property(oldName).isNodeProperty()) {
|
||||||
|
|
||||||
const TypeName typeName = rootModelNode.nodeProperty(oldName).dynamicTypeName();
|
const TypeName typeName = rootModelNode.nodeProperty(oldName).dynamicTypeName();
|
||||||
@@ -306,12 +296,7 @@ void BackendModel::updatePropertyName(int rowNumber)
|
|||||||
qWarning() << Q_FUNC_INFO << oldName << newName << "failed...";
|
qWarning() << Q_FUNC_INFO << oldName << newName << "failed...";
|
||||||
QTC_ASSERT(false, return);
|
QTC_ASSERT(false, return);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackendModel::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
void BackendModel::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
|
|||||||
@@ -290,8 +290,6 @@ void BindingModel::addModelNode(const ModelNode &modelNode)
|
|||||||
|
|
||||||
void BindingModel::updateExpression(int row)
|
void BindingModel::updateExpression(int row)
|
||||||
{
|
{
|
||||||
BindingProperty bindingProperty = bindingPropertyForRow(row);
|
|
||||||
|
|
||||||
const QString sourceNode = data(index(row, SourceModelNodeRow)).toString().trimmed();
|
const QString sourceNode = data(index(row, SourceModelNodeRow)).toString().trimmed();
|
||||||
const QString sourceProperty = data(index(row, SourcePropertyNameRow)).toString().trimmed();
|
const QString sourceProperty = data(index(row, SourcePropertyNameRow)).toString().trimmed();
|
||||||
|
|
||||||
@@ -302,15 +300,10 @@ void BindingModel::updateExpression(int row)
|
|||||||
expression = sourceNode + QLatin1String(".") + sourceProperty;
|
expression = sourceNode + QLatin1String(".") + sourceProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
RewriterTransaction transaction =
|
connectionView()->executeInTransaction("BindingModel::updateExpression", [this, row, expression](){
|
||||||
connectionView()->beginRewriterTransaction(QByteArrayLiteral("BindingModel::updateExpression"));
|
BindingProperty bindingProperty = bindingPropertyForRow(row);
|
||||||
try {
|
|
||||||
bindingProperty.setExpression(expression.trimmed());
|
bindingProperty.setExpression(expression.trimmed());
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (Exception &e) {
|
|
||||||
m_exceptionError = e.description();
|
|
||||||
QTimer::singleShot(200, this, &BindingModel::handleException);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BindingModel::updatePropertyName(int rowNumber)
|
void BindingModel::updatePropertyName(int rowNumber)
|
||||||
|
|||||||
@@ -182,26 +182,21 @@ void ConnectionModel::updateSource(int row)
|
|||||||
void ConnectionModel::updateSignalName(int rowNumber)
|
void ConnectionModel::updateSignalName(int rowNumber)
|
||||||
{
|
{
|
||||||
SignalHandlerProperty signalHandlerProperty = signalHandlerPropertyForRow(rowNumber);
|
SignalHandlerProperty signalHandlerProperty = signalHandlerPropertyForRow(rowNumber);
|
||||||
|
|
||||||
const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8();
|
|
||||||
const QString source = signalHandlerProperty.source();
|
|
||||||
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
|
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
|
||||||
|
|
||||||
|
const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8();
|
||||||
if (!newName.isEmpty()) {
|
if (!newName.isEmpty()) {
|
||||||
RewriterTransaction transaction =
|
connectionView()->executeInTransaction("ConnectionModel::updateSignalName", [=, &connectionNode](){
|
||||||
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateSignalName"));
|
|
||||||
try {
|
const QString source = signalHandlerProperty.source();
|
||||||
|
|
||||||
connectionNode.signalHandlerProperty(newName).setSource(source);
|
connectionNode.signalHandlerProperty(newName).setSource(source);
|
||||||
connectionNode.removeProperty(signalHandlerProperty.name());
|
connectionNode.removeProperty(signalHandlerProperty.name());
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (Exception &e) { //better save then sorry
|
|
||||||
QMessageBox::warning(nullptr, tr("Error"), e.description());
|
|
||||||
}
|
|
||||||
|
|
||||||
QStandardItem* idItem = item(rowNumber, 0);
|
QStandardItem* idItem = item(rowNumber, 0);
|
||||||
SignalHandlerProperty newSignalHandlerProperty = connectionNode.signalHandlerProperty(newName);
|
SignalHandlerProperty newSignalHandlerProperty = connectionNode.signalHandlerProperty(newName);
|
||||||
updateCustomData(idItem, newSignalHandlerProperty);
|
updateCustomData(idItem, newSignalHandlerProperty);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "BindingModel::updatePropertyName invalid property name";
|
qWarning() << "BindingModel::updatePropertyName invalid property name";
|
||||||
}
|
}
|
||||||
@@ -214,14 +209,9 @@ void ConnectionModel::updateTargetNode(int rowNumber)
|
|||||||
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
|
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
|
||||||
|
|
||||||
if (!newTarget.isEmpty()) {
|
if (!newTarget.isEmpty()) {
|
||||||
RewriterTransaction transaction =
|
connectionView()->executeInTransaction("ConnectionModel::updateTargetNode", [= ,&connectionNode](){
|
||||||
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateTargetNode"));
|
|
||||||
try {
|
|
||||||
connectionNode.bindingProperty("target").setExpression(newTarget);
|
connectionNode.bindingProperty("target").setExpression(newTarget);
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (Exception &e) { //better save then sorry
|
|
||||||
QMessageBox::warning(nullptr, tr("Error"), e.description());
|
|
||||||
}
|
|
||||||
|
|
||||||
QStandardItem* idItem = item(rowNumber, 0);
|
QStandardItem* idItem = item(rowNumber, 0);
|
||||||
updateCustomData(idItem, signalHandlerProperty);
|
updateCustomData(idItem, signalHandlerProperty);
|
||||||
@@ -259,9 +249,7 @@ void ConnectionModel::addConnection()
|
|||||||
NodeMetaInfo nodeMetaInfo = connectionView()->model()->metaInfo("QtQuick.Connections");
|
NodeMetaInfo nodeMetaInfo = connectionView()->model()->metaInfo("QtQuick.Connections");
|
||||||
|
|
||||||
if (nodeMetaInfo.isValid()) {
|
if (nodeMetaInfo.isValid()) {
|
||||||
RewriterTransaction transaction =
|
connectionView()->executeInTransaction("ConnectionModel::addConnection", [=](){
|
||||||
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::addConnection"));
|
|
||||||
try {
|
|
||||||
ModelNode newNode = connectionView()->createModelNode("QtQuick.Connections",
|
ModelNode newNode = connectionView()->createModelNode("QtQuick.Connections",
|
||||||
nodeMetaInfo.majorVersion(),
|
nodeMetaInfo.majorVersion(),
|
||||||
nodeMetaInfo.minorVersion());
|
nodeMetaInfo.minorVersion());
|
||||||
@@ -276,10 +264,7 @@ void ConnectionModel::addConnection()
|
|||||||
} else {
|
} else {
|
||||||
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
|
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
|
||||||
}
|
}
|
||||||
transaction.commit();
|
});
|
||||||
} catch (Exception &e) { //better save then sorry
|
|
||||||
QMessageBox::warning(nullptr, tr("Error"), e.description());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,19 +464,16 @@ void DynamicPropertiesModel::updatePropertyName(int rowNumber)
|
|||||||
|
|
||||||
BindingProperty bindingProperty = bindingPropertyForRow(rowNumber);
|
BindingProperty bindingProperty = bindingPropertyForRow(rowNumber);
|
||||||
|
|
||||||
if (bindingProperty.isBindingProperty()) {
|
|
||||||
const QString expression = bindingProperty.expression();
|
|
||||||
const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName();
|
|
||||||
ModelNode targetNode = bindingProperty.parentModelNode();
|
ModelNode targetNode = bindingProperty.parentModelNode();
|
||||||
|
|
||||||
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName"));
|
if (bindingProperty.isBindingProperty()) {
|
||||||
try {
|
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [bindingProperty, newName, &targetNode](){
|
||||||
|
const QString expression = bindingProperty.expression();
|
||||||
|
const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName();
|
||||||
|
|
||||||
targetNode.bindingProperty(newName).setDynamicTypeNameAndExpression(dynamicPropertyType, expression);
|
targetNode.bindingProperty(newName).setDynamicTypeNameAndExpression(dynamicPropertyType, expression);
|
||||||
targetNode.removeProperty(bindingProperty.name());
|
targetNode.removeProperty(bindingProperty.name());
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (Exception &e) { //better save then sorry
|
|
||||||
QMessageBox::warning(nullptr, tr("Error"), e.description());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCustomData(rowNumber, targetNode.bindingProperty(newName));
|
updateCustomData(rowNumber, targetNode.bindingProperty(newName));
|
||||||
return;
|
return;
|
||||||
@@ -489,14 +486,10 @@ void DynamicPropertiesModel::updatePropertyName(int rowNumber)
|
|||||||
const PropertyName dynamicPropertyType = variantProperty.dynamicTypeName();
|
const PropertyName dynamicPropertyType = variantProperty.dynamicTypeName();
|
||||||
ModelNode targetNode = variantProperty.parentModelNode();
|
ModelNode targetNode = variantProperty.parentModelNode();
|
||||||
|
|
||||||
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName"));
|
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [=](){
|
||||||
try {
|
|
||||||
targetNode.variantProperty(newName).setDynamicTypeNameAndValue(dynamicPropertyType, value);
|
targetNode.variantProperty(newName).setDynamicTypeNameAndValue(dynamicPropertyType, value);
|
||||||
targetNode.removeProperty(variantProperty.name());
|
targetNode.removeProperty(variantProperty.name());
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (Exception &e) { //better save then sorry
|
|
||||||
QMessageBox::warning(nullptr, tr("Error"), e.description());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCustomData(rowNumber, targetNode.variantProperty(newName));
|
updateCustomData(rowNumber, targetNode.variantProperty(newName));
|
||||||
}
|
}
|
||||||
@@ -519,14 +512,10 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber)
|
|||||||
const PropertyName propertyName = bindingProperty.name();
|
const PropertyName propertyName = bindingProperty.name();
|
||||||
ModelNode targetNode = bindingProperty.parentModelNode();
|
ModelNode targetNode = bindingProperty.parentModelNode();
|
||||||
|
|
||||||
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType"));
|
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){
|
||||||
try {
|
|
||||||
targetNode.removeProperty(bindingProperty.name());
|
targetNode.removeProperty(bindingProperty.name());
|
||||||
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, expression);
|
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, expression);
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (Exception &e) { //better save then sorry
|
|
||||||
QMessageBox::warning(nullptr, tr("Error"), e.description());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCustomData(rowNumber, targetNode.bindingProperty(propertyName));
|
updateCustomData(rowNumber, targetNode.bindingProperty(propertyName));
|
||||||
return;
|
return;
|
||||||
@@ -539,18 +528,14 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber)
|
|||||||
ModelNode targetNode = variantProperty.parentModelNode();
|
ModelNode targetNode = variantProperty.parentModelNode();
|
||||||
const PropertyName propertyName = variantProperty.name();
|
const PropertyName propertyName = variantProperty.name();
|
||||||
|
|
||||||
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType"));
|
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){
|
||||||
try {
|
|
||||||
targetNode.removeProperty(variantProperty.name());
|
targetNode.removeProperty(variantProperty.name());
|
||||||
if (newType == "alias") { //alias properties have to be bindings
|
if (newType == "alias") { //alias properties have to be bindings
|
||||||
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, QLatin1String("none.none"));
|
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, QLatin1String("none.none"));
|
||||||
} else {
|
} else {
|
||||||
targetNode.variantProperty(propertyName).setDynamicTypeNameAndValue(newType, convertVariantForTypeName(value, newType));
|
targetNode.variantProperty(propertyName).setDynamicTypeNameAndValue(newType, convertVariantForTypeName(value, newType));
|
||||||
}
|
}
|
||||||
transaction.commit(); //committing in the try block
|
});
|
||||||
} catch (Exception &e) { //better save then sorry
|
|
||||||
QMessageBox::warning(nullptr, tr("Error"), e.description());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCustomData(rowNumber, targetNode.variantProperty(propertyName));
|
updateCustomData(rowNumber, targetNode.variantProperty(propertyName));
|
||||||
|
|
||||||
|
|||||||
@@ -133,8 +133,7 @@ void PathItem::writePathToProperty()
|
|||||||
|
|
||||||
ModelNode pathNode = pathModelNode(formEditorItem());
|
ModelNode pathNode = pathModelNode(formEditorItem());
|
||||||
|
|
||||||
RewriterTransaction rewriterTransaction = pathNode.view()->beginRewriterTransaction(QByteArrayLiteral("PathItem::writePathToProperty"));
|
pathNode.view()->executeInTransaction("PathItem::writePathToProperty", [this, &pathNode](){
|
||||||
|
|
||||||
QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList();
|
QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList();
|
||||||
|
|
||||||
foreach (ModelNode pathSegment, pathSegmentNodes)
|
foreach (ModelNode pathSegment, pathSegmentNodes)
|
||||||
@@ -159,19 +158,15 @@ void PathItem::writePathToProperty()
|
|||||||
writePathAttributes(pathNode, m_lastAttributes);
|
writePathAttributes(pathNode, m_lastAttributes);
|
||||||
writePathPercent(pathNode, m_lastPercent);
|
writePathPercent(pathNode, m_lastPercent);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
rewriterTransaction.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::writePathAsCubicSegmentsOnly()
|
void PathItem::writePathAsCubicSegmentsOnly()
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
PathUpdateDisabler pathUpdateDisabler(this);
|
PathUpdateDisabler pathUpdateDisabler(this);
|
||||||
|
|
||||||
ModelNode pathNode = pathModelNode(formEditorItem());
|
ModelNode pathNode = pathModelNode(formEditorItem());
|
||||||
|
pathNode.view()->executeInTransaction("PathItem::writePathAsCubicSegmentsOnly", [this, &pathNode](){
|
||||||
RewriterTransaction rewriterTransaction =
|
|
||||||
pathNode.view()->beginRewriterTransaction(QByteArrayLiteral("PathItem::writePathAsCubicSegmentsOnly"));
|
|
||||||
|
|
||||||
QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList();
|
QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList();
|
||||||
|
|
||||||
@@ -192,11 +187,7 @@ void PathItem::writePathAsCubicSegmentsOnly()
|
|||||||
writePathAttributes(pathNode, m_lastAttributes);
|
writePathAttributes(pathNode, m_lastAttributes);
|
||||||
writePathPercent(pathNode, m_lastPercent);
|
writePathPercent(pathNode, m_lastPercent);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
rewriterTransaction.commit();
|
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::setFormEditorItem(FormEditorItem *formEditorItem)
|
void PathItem::setFormEditorItem(FormEditorItem *formEditorItem)
|
||||||
|
|||||||
@@ -202,22 +202,13 @@ bool EasingCurveDialog::apply()
|
|||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
AbstractView *view = m_frames.first().view();
|
AbstractView *view = m_frames.first().view();
|
||||||
RewriterTransaction transaction(view->beginRewriterTransaction("EasingCurveDialog::apply"));
|
|
||||||
|
|
||||||
|
return view->executeInTransaction("EasingCurveDialog::apply", [this, view](){
|
||||||
auto expression = m_splineEditor->easingCurve().toString();
|
auto expression = m_splineEditor->easingCurve().toString();
|
||||||
for (const auto &frame : m_frames)
|
for (const auto &frame : m_frames)
|
||||||
frame.bindingProperty("easing.bezierCurve").setExpression(expression);
|
frame.bindingProperty("easing.bezierCurve").setExpression(expression);
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
return true;
|
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EasingCurveDialog::textChanged()
|
void EasingCurveDialog::textChanged()
|
||||||
|
|||||||
@@ -48,28 +48,18 @@ TimelineActions::TimelineActions() = default;
|
|||||||
void TimelineActions::deleteAllKeyframesForTarget(const ModelNode &targetNode,
|
void TimelineActions::deleteAllKeyframesForTarget(const ModelNode &targetNode,
|
||||||
const QmlTimeline &timeline)
|
const QmlTimeline &timeline)
|
||||||
{
|
{
|
||||||
try {
|
targetNode.view()->executeInTransaction("TimelineActions::deleteAllKeyframesForTarget", [=](){
|
||||||
RewriterTransaction transaction(targetNode.view()->beginRewriterTransaction(
|
|
||||||
"TimelineActions::deleteAllKeyframesForTarget"));
|
|
||||||
|
|
||||||
if (timeline.isValid()) {
|
if (timeline.isValid()) {
|
||||||
for (auto frames : timeline.keyframeGroupsForTarget(targetNode))
|
for (auto frames : timeline.keyframeGroupsForTarget(targetNode))
|
||||||
frames.destroy();
|
frames.destroy();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineActions::insertAllKeyframesForTarget(const ModelNode &targetNode,
|
void TimelineActions::insertAllKeyframesForTarget(const ModelNode &targetNode,
|
||||||
const QmlTimeline &timeline)
|
const QmlTimeline &timeline)
|
||||||
{
|
{
|
||||||
try {
|
targetNode.view()->executeInTransaction("TimelineActions::insertAllKeyframesForTarget", [=](){
|
||||||
RewriterTransaction transaction(targetNode.view()->beginRewriterTransaction(
|
|
||||||
"TimelineGraphicsScene::insertAllKeyframesForTarget"));
|
|
||||||
|
|
||||||
auto object = QmlObjectNode(targetNode);
|
auto object = QmlObjectNode(targetNode);
|
||||||
if (timeline.isValid() && object.isValid()) {
|
if (timeline.isValid() && object.isValid()) {
|
||||||
for (auto frames : timeline.keyframeGroupsForTarget(targetNode)) {
|
for (auto frames : timeline.keyframeGroupsForTarget(targetNode)) {
|
||||||
@@ -78,10 +68,7 @@ void TimelineActions::insertAllKeyframesForTarget(const ModelNode &targetNode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineActions::copyAllKeyframesForTarget(const ModelNode &targetNode,
|
void TimelineActions::copyAllKeyframesForTarget(const ModelNode &targetNode,
|
||||||
@@ -117,11 +104,10 @@ void TimelineActions::pasteKeyframesToTarget(const ModelNode &targetNode,
|
|||||||
|
|
||||||
pasteModel->detachView(&view);
|
pasteModel->detachView(&view);
|
||||||
|
|
||||||
try {
|
view.executeInTransaction("TimelineActions::pasteKeyframesToTarget", [=, &view](){
|
||||||
targetNode.view()->model()->attachView(&view);
|
|
||||||
|
|
||||||
RewriterTransaction transaction(
|
|
||||||
view.beginRewriterTransaction("TimelineActions::pasteKeyframesToTarget"));
|
targetNode.view()->model()->attachView(&view);
|
||||||
|
|
||||||
ModelNode nonConstTargetNode = targetNode;
|
ModelNode nonConstTargetNode = targetNode;
|
||||||
nonConstTargetNode.validId();
|
nonConstTargetNode.validId();
|
||||||
@@ -144,11 +130,7 @@ void TimelineActions::pasteKeyframesToTarget(const ModelNode &targetNode,
|
|||||||
timeline.modelNode().defaultNodeListProperty().reparentHere(newNode);
|
timeline.modelNode().defaultNodeListProperty().reparentHere(newNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,9 +278,7 @@ void TimelineActions::pasteKeyframes(AbstractView *timelineView, const QmlTimeli
|
|||||||
|
|
||||||
ModelNode rootNode = view.rootModelNode();
|
ModelNode rootNode = view.rootModelNode();
|
||||||
|
|
||||||
try {
|
timelineView->executeInTransaction("TimelineActions::pasteKeyframes", [=](){
|
||||||
RewriterTransaction transaction(
|
|
||||||
timelineView->beginRewriterTransaction("TimelineActions::pasteKeyframes"));
|
|
||||||
if (isKeyframe(rootNode))
|
if (isKeyframe(rootNode))
|
||||||
pasteKeyframe(currentTime, rootNode, timelineView, timeline);
|
pasteKeyframe(currentTime, rootNode, timelineView, timeline);
|
||||||
else
|
else
|
||||||
@@ -308,10 +288,7 @@ void TimelineActions::pasteKeyframes(AbstractView *timelineView, const QmlTimeli
|
|||||||
timelineView,
|
timelineView,
|
||||||
timeline);
|
timeline);
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimelineActions::clipboardContainsKeyframes()
|
bool TimelineActions::clipboardContainsKeyframes()
|
||||||
|
|||||||
@@ -663,26 +663,16 @@ void TimelineGraphicsScene::deleteKeyframeGroup(const ModelNode &group)
|
|||||||
if (!QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(group))
|
if (!QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(group))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
timelineView()->executeInTransaction("TimelineGraphicsScene::handleKeyframeGroupDeletion", [group](){
|
||||||
ModelNode nonConst = group;
|
ModelNode nonConst = group;
|
||||||
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction(timelineView()->beginRewriterTransaction(
|
|
||||||
"TimelineGraphicsScene::handleKeyframeGroupDeletion"));
|
|
||||||
|
|
||||||
nonConst.destroy();
|
nonConst.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
transaction.commit();
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames)
|
void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames)
|
||||||
{
|
{
|
||||||
try {
|
timelineView()->executeInTransaction("TimelineGraphicsScene::handleKeyframeDeletion", [frames](){
|
||||||
RewriterTransaction transaction(timelineView()->beginRewriterTransaction(
|
|
||||||
"TimelineGraphicsScene::handleKeyframeDeletion"));
|
|
||||||
|
|
||||||
for (auto keyframe : frames) {
|
for (auto keyframe : frames) {
|
||||||
if (keyframe.isValid()) {
|
if (keyframe.isValid()) {
|
||||||
ModelNode frame = keyframe;
|
ModelNode frame = keyframe;
|
||||||
@@ -692,10 +682,7 @@ void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames)
|
|||||||
parent.destroy();
|
parent.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineGraphicsScene::activateLayout()
|
void TimelineGraphicsScene::activateLayout()
|
||||||
|
|||||||
@@ -136,10 +136,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
scene()->timelineView()->executeInTransaction("TimelineMoveTool::mouseReleaseEvent", [this, current](){
|
||||||
RewriterTransaction transaction(scene()->timelineView()->beginRewriterTransaction(
|
|
||||||
"TimelineMoveTool::mouseReleaseEvent"));
|
|
||||||
|
|
||||||
current->commitPosition(mapToItem(current, current->rect().center()));
|
current->commitPosition(mapToItem(current, current->rect().center()));
|
||||||
|
|
||||||
if (current->asTimelineKeyframeItem()) {
|
if (current->asTimelineKeyframeItem()) {
|
||||||
@@ -152,12 +149,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
|
|||||||
if (keyframe != current)
|
if (keyframe != current)
|
||||||
keyframe->commitPosition(mapToItem(current, keyframe->rect().center()));
|
keyframe->commitPosition(mapToItem(current, keyframe->rect().center()));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
transaction.commit();
|
|
||||||
|
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -534,15 +534,9 @@ void TimelineKeyframeItem::commitPosition(const QPointF &point)
|
|||||||
|
|
||||||
blockUpdates();
|
blockUpdates();
|
||||||
|
|
||||||
try {
|
m_frame.view()->executeInTransaction("TimelineKeyframeItem::commitPosition", [this, frame](){
|
||||||
RewriterTransaction transaction(
|
|
||||||
m_frame.view()->beginRewriterTransaction("TimelineKeyframeItem::commitPosition"));
|
|
||||||
|
|
||||||
m_frame.variantProperty("frame").setValue(frame);
|
m_frame.variantProperty("frame").setValue(frame);
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
enableUpdates();
|
enableUpdates();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -821,20 +821,15 @@ void TimelineBarItem::commitPosition(const QPointF & /*point*/)
|
|||||||
{
|
{
|
||||||
if (sectionItem()->view()) {
|
if (sectionItem()->view()) {
|
||||||
if (m_handle != Location::Undefined) {
|
if (m_handle != Location::Undefined) {
|
||||||
|
sectionItem()->view()->executeInTransaction("TimelineBarItem::commitPosition", [this](){
|
||||||
qreal scaleFactor = rect().width() / m_oldRect.width();
|
qreal scaleFactor = rect().width() / m_oldRect.width();
|
||||||
|
|
||||||
qreal moved = (rect().topLeft().x() - m_oldRect.topLeft().x()) / rulerScaling();
|
qreal moved = (rect().topLeft().x() - m_oldRect.topLeft().x()) / rulerScaling();
|
||||||
qreal supposedFirstFrame = qRound(sectionItem()->firstFrame() + moved);
|
qreal supposedFirstFrame = qRound(sectionItem()->firstFrame() + moved);
|
||||||
|
|
||||||
try {
|
|
||||||
RewriterTransaction transaction(sectionItem()->view()->beginRewriterTransaction(
|
|
||||||
"TimelineBarItem::commitPosition"));
|
|
||||||
sectionItem()->scaleAllFrames(scaleFactor);
|
sectionItem()->scaleAllFrames(scaleFactor);
|
||||||
sectionItem()->moveAllFrames(supposedFirstFrame - sectionItem()->firstFrame());
|
sectionItem()->moveAllFrames(supposedFirstFrame - sectionItem()->firstFrame());
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const RewritingException &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -266,15 +266,13 @@ ModelNode TimelineSettingsModel::animationForTimelineAndState(const QmlTimeline
|
|||||||
|
|
||||||
void TimelineSettingsModel::updateTimeline(int row)
|
void TimelineSettingsModel::updateTimeline(int row)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
timelineView()->executeInTransaction("TimelineSettingsModel::updateTimeline", [this, row](){
|
||||||
QmlModelState modelState(stateForRow(row));
|
QmlModelState modelState(stateForRow(row));
|
||||||
QmlTimeline timeline(timelineForRow(row));
|
QmlTimeline timeline(timelineForRow(row));
|
||||||
ModelNode animation(animationForRow(row));
|
ModelNode animation(animationForRow(row));
|
||||||
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
|
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
|
||||||
|
|
||||||
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("TimelineSettingsModel::updateTimeline"));
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (modelState.isBaseState()) {
|
if (modelState.isBaseState()) {
|
||||||
if (oldTimeline.isValid())
|
if (oldTimeline.isValid())
|
||||||
oldTimeline.modelNode().variantProperty("enabled").setValue(false);
|
oldTimeline.modelNode().variantProperty("enabled").setValue(false);
|
||||||
@@ -301,27 +299,20 @@ void TimelineSettingsModel::updateTimeline(int row)
|
|||||||
propertyChanges.modelNode().variantProperty("enabled").setValue(true);
|
propertyChanges.modelNode().variantProperty("enabled").setValue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} catch (Exception &e) {
|
|
||||||
m_exceptionError = e.description();
|
|
||||||
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
|
|
||||||
}
|
|
||||||
|
|
||||||
resetRow(row);
|
resetRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineSettingsModel::updateAnimation(int row)
|
void TimelineSettingsModel::updateAnimation(int row)
|
||||||
{
|
{
|
||||||
|
timelineView()->executeInTransaction("TimelineSettingsModel::updateAnimation", [this, row](){
|
||||||
QmlModelState modelState(stateForRow(row));
|
QmlModelState modelState(stateForRow(row));
|
||||||
QmlTimeline timeline(timelineForRow(row));
|
QmlTimeline timeline(timelineForRow(row));
|
||||||
ModelNode animation(animationForRow(row));
|
ModelNode animation(animationForRow(row));
|
||||||
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
|
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
|
||||||
ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState);
|
ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState);
|
||||||
|
|
||||||
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("TimelineSettingsModel::updateAnimation"));
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (modelState.isBaseState()) {
|
if (modelState.isBaseState()) {
|
||||||
if (oldAnimation.isValid())
|
if (oldAnimation.isValid())
|
||||||
oldAnimation.variantProperty("running").setValue(false);
|
oldAnimation.variantProperty("running").setValue(false);
|
||||||
@@ -353,27 +344,20 @@ void TimelineSettingsModel::updateAnimation(int row)
|
|||||||
propertyChanges.modelNode().variantProperty("running").setValue(true);
|
propertyChanges.modelNode().variantProperty("running").setValue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception &e) {
|
});
|
||||||
m_exceptionError = e.description();
|
|
||||||
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
|
|
||||||
}
|
|
||||||
|
|
||||||
resetRow(row);
|
resetRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineSettingsModel::updateFixedFrameRow(int row)
|
void TimelineSettingsModel::updateFixedFrameRow(int row)
|
||||||
{
|
{
|
||||||
|
timelineView()->executeInTransaction("TimelineSettingsModel::updateFixedFrameRow", [this, row](){
|
||||||
QmlModelState modelState(stateForRow(row));
|
QmlModelState modelState(stateForRow(row));
|
||||||
QmlTimeline timeline(timelineForRow(row));
|
QmlTimeline timeline(timelineForRow(row));
|
||||||
|
|
||||||
ModelNode animation = animationForTimelineAndState(timeline, modelState);
|
ModelNode animation = animationForTimelineAndState(timeline, modelState);
|
||||||
|
|
||||||
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
|
|
||||||
QByteArrayLiteral("TimelineSettingsModel::updateFixedFrameRow"));
|
|
||||||
|
|
||||||
int fixedFrame = fixedFrameForRow(row);
|
int fixedFrame = fixedFrameForRow(row);
|
||||||
|
|
||||||
try {
|
|
||||||
if (modelState.isBaseState()) {
|
if (modelState.isBaseState()) {
|
||||||
if (animation.isValid())
|
if (animation.isValid())
|
||||||
animation.variantProperty("running").setValue(false);
|
animation.variantProperty("running").setValue(false);
|
||||||
@@ -390,10 +374,8 @@ void TimelineSettingsModel::updateFixedFrameRow(int row)
|
|||||||
if (propertyChanges.isValid())
|
if (propertyChanges.isValid())
|
||||||
propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
|
propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
|
||||||
}
|
}
|
||||||
} catch (Exception &e) {
|
|
||||||
m_exceptionError = e.description();
|
});
|
||||||
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
|
|
||||||
}
|
|
||||||
|
|
||||||
resetRow(row);
|
resetRow(row);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,9 +264,7 @@ const QmlTimeline TimelineView::addNewTimeline()
|
|||||||
|
|
||||||
ModelNode timelineNode;
|
ModelNode timelineNode;
|
||||||
|
|
||||||
try {
|
executeInTransaction("TimelineView::addNewTimeline", [=, &timelineNode](){
|
||||||
RewriterTransaction transaction(beginRewriterTransaction("TimelineView::addNewTimeline"));
|
|
||||||
|
|
||||||
bool hasTimelines = getTimelines().isEmpty();
|
bool hasTimelines = getTimelines().isEmpty();
|
||||||
|
|
||||||
timelineNode = createModelNode(timelineType,
|
timelineNode = createModelNode(timelineType,
|
||||||
@@ -279,10 +277,7 @@ const QmlTimeline TimelineView::addNewTimeline()
|
|||||||
timelineNode.variantProperty("enabled").setValue(hasTimelines);
|
timelineNode.variantProperty("enabled").setValue(hasTimelines);
|
||||||
|
|
||||||
rootModelNode().defaultNodeListProperty().reparentHere(timelineNode);
|
rootModelNode().defaultNodeListProperty().reparentHere(timelineNode);
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QmlTimeline(timelineNode);
|
return QmlTimeline(timelineNode);
|
||||||
}
|
}
|
||||||
@@ -300,10 +295,8 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline)
|
|||||||
QTC_ASSERT(metaInfo.isValid(), return ModelNode());
|
QTC_ASSERT(metaInfo.isValid(), return ModelNode());
|
||||||
|
|
||||||
ModelNode animationNode;
|
ModelNode animationNode;
|
||||||
try {
|
|
||||||
RewriterTransaction transaction(
|
|
||||||
beginRewriterTransaction("TimelineSettingsDialog::addAnimation"));
|
|
||||||
|
|
||||||
|
executeInTransaction("TimelineView::addAnimation", [=, &animationNode](){
|
||||||
animationNode = createModelNode(animationType,
|
animationNode = createModelNode(animationType,
|
||||||
metaInfo.majorVersion(),
|
metaInfo.majorVersion(),
|
||||||
metaInfo.minorVersion());
|
metaInfo.minorVersion());
|
||||||
@@ -321,10 +314,7 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline)
|
|||||||
|
|
||||||
if (timeline.modelNode().hasProperty("currentFrame"))
|
if (timeline.modelNode().hasProperty("currentFrame"))
|
||||||
timeline.modelNode().removeProperty("currentFrame");
|
timeline.modelNode().removeProperty("currentFrame");
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return animationNode;
|
return animationNode;
|
||||||
}
|
}
|
||||||
@@ -391,9 +381,7 @@ void TimelineView::insertKeyframe(const ModelNode &target, const PropertyName &p
|
|||||||
ModelNode targetNode = target;
|
ModelNode targetNode = target;
|
||||||
if (timeline.isValid() && targetNode.isValid()
|
if (timeline.isValid() && targetNode.isValid()
|
||||||
&& QmlObjectNode::isValidQmlObjectNode(targetNode)) {
|
&& QmlObjectNode::isValidQmlObjectNode(targetNode)) {
|
||||||
try {
|
executeInTransaction("TimelineView::insertKeyframe", [=, &timeline, &targetNode](){
|
||||||
RewriterTransaction transaction(
|
|
||||||
beginRewriterTransaction("TimelineView::insertKeyframe"));
|
|
||||||
|
|
||||||
targetNode.validId();
|
targetNode.validId();
|
||||||
|
|
||||||
@@ -408,10 +396,7 @@ void TimelineView::insertKeyframe(const ModelNode &target, const PropertyName &p
|
|||||||
|
|
||||||
timelineFrames.setValue(value, frame);
|
timelineFrames.setValue(value, frame);
|
||||||
|
|
||||||
transaction.commit();
|
});
|
||||||
} catch (const Exception &e) {
|
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user