forked from qt-creator/qt-creator
Change signature of AbstractView::nodeSlidedToIndex in QmlDesigner
The usage of 'int newIndex' was ambiguous in the case of oldIndex < newIndex. Solved by directly passing the ModelNode that was moved around. 'nodeSlidedToIndex' was also renamed to 'nodeOrderChanged', since 'Slided' is no proper English.
This commit is contained in:
@@ -167,7 +167,7 @@ void ComponentView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeL
|
|||||||
|
|
||||||
void ComponentView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &/*newUrl*/) {}
|
void ComponentView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &/*newUrl*/) {}
|
||||||
|
|
||||||
void ComponentView::nodeSlidedToIndex(const NodeListProperty &/*listProperty*/, int /*newIndex*/, int /*oldIndex*/) {}
|
void ComponentView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, const ModelNode & /*movedNode*/, int /*oldIndex*/) {}
|
||||||
|
|
||||||
void ComponentView::importsChanged() {}
|
void ComponentView::importsChanged() {}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
|
|
||||||
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
||||||
|
|
||||||
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
void importsChanged();
|
void importsChanged();
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void DesignDocumentControllerView::nodeTypeChanged(const ModelNode & /*node*/,co
|
|||||||
void DesignDocumentControllerView::selectedNodesChanged(const QList<ModelNode> & /*selectedNodeList*/,
|
void DesignDocumentControllerView::selectedNodesChanged(const QList<ModelNode> & /*selectedNodeList*/,
|
||||||
const QList<ModelNode> & /*lastSelectedNodeList*/) {};
|
const QList<ModelNode> & /*lastSelectedNodeList*/) {};
|
||||||
|
|
||||||
void DesignDocumentControllerView::nodeSlidedToIndex(const NodeListProperty & /*listProperty*/, int /*newIndex*/, int /*oldIndex*/) {};
|
void DesignDocumentControllerView::nodeOrderChanged(const NodeListProperty & /*listProperty*/, const ModelNode & /*movedNode*/, int /*oldIndex*/) {};
|
||||||
|
|
||||||
static QStringList arrayToStringList(const QByteArray &byteArray)
|
static QStringList arrayToStringList(const QByteArray &byteArray)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||||
const QList<ModelNode> &lastSelectedNodeList);
|
const QList<ModelNode> &lastSelectedNodeList);
|
||||||
|
|
||||||
virtual void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
|
virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
ModelNode insertModel(const ModelNode &modelNode)
|
ModelNode insertModel(const ModelNode &modelNode)
|
||||||
{ return m_modelMerger.insertModel(modelNode); }
|
{ return m_modelMerger.insertModel(modelNode); }
|
||||||
|
|||||||
@@ -122,20 +122,18 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data,
|
|||||||
if (parentIndex.model() != this)
|
if (parentIndex.model() != this)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int beginRow = 0;
|
|
||||||
|
|
||||||
QModelIndex parentIdIndex = parentIndex;
|
QModelIndex parentIdIndex = parentIndex;
|
||||||
parentIdIndex = parentIdIndex.sibling(parentIdIndex.row(), 0);
|
parentIdIndex = parentIdIndex.sibling(parentIdIndex.row(), 0);
|
||||||
|
|
||||||
Q_ASSERT(parentIdIndex.isValid());
|
Q_ASSERT(parentIdIndex.isValid());
|
||||||
|
|
||||||
if (row > -1)
|
int targetIndex = 0;
|
||||||
beginRow = row;
|
if (row > -1) {
|
||||||
else if (parentIdIndex.isValid())
|
targetIndex = row;
|
||||||
beginRow = rowCount(parentIdIndex);
|
} else {
|
||||||
else
|
targetIndex = rowCount(parentIdIndex);
|
||||||
beginRow = rowCount(QModelIndex());
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray encodedData = data->data("application/vnd.modelnode.list");
|
QByteArray encodedData = data->data("application/vnd.modelnode.list");
|
||||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||||
@@ -159,13 +157,19 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data,
|
|||||||
if (!isAnchestorInList(node, nodeList)) {
|
if (!isAnchestorInList(node, nodeList)) {
|
||||||
if (node.parentProperty().parentModelNode() != parentItemNode) {
|
if (node.parentProperty().parentModelNode() != parentItemNode) {
|
||||||
QmlItemNode itemNode(node);
|
QmlItemNode itemNode(node);
|
||||||
if (node != parentItemNode)
|
if (node != parentItemNode) {
|
||||||
itemNode.setParent(parentItemNode);
|
itemNode.setParent(parentItemNode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (node.parentProperty().isNodeListProperty()) {
|
if (node.parentProperty().isNodeListProperty()) {
|
||||||
int index = node.parentProperty().toNodeListProperty().toModelNodeList().indexOf(node);
|
int index = node.parentProperty().toNodeListProperty().toModelNodeList().indexOf(node);
|
||||||
node.parentProperty().toNodeListProperty().slide(index, beginRow);
|
if (index < targetIndex) { // item is first removed from oldIndex, then inserted at new index
|
||||||
|
--targetIndex;
|
||||||
|
}
|
||||||
|
if (index != targetIndex) {
|
||||||
|
node.parentProperty().toNodeListProperty().slide(index, targetIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,14 +133,10 @@ void NavigatorView::auxiliaryDataChanged(const ModelNode &node, const QString &n
|
|||||||
m_treeModel->updateItemRow(node);
|
m_treeModel->updateItemRow(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigatorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex)
|
void NavigatorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &node, int oldIndex)
|
||||||
{
|
{
|
||||||
QmlModelView::nodeSlidedToIndex(listProperty, newIndex, oldIndex);
|
QmlModelView::nodeOrderChanged(listProperty, node, oldIndex);
|
||||||
|
|
||||||
int nodeIndex = newIndex;
|
|
||||||
if (oldIndex < newIndex)
|
|
||||||
--nodeIndex;
|
|
||||||
ModelNode node = listProperty.toModelNodeList().at(nodeIndex);
|
|
||||||
if (m_treeModel->isInTree(node))
|
if (m_treeModel->isInTree(node))
|
||||||
m_treeModel->updateItemRowOrder(node);
|
m_treeModel->updateItemRowOrder(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ public:
|
|||||||
|
|
||||||
void nodeAboutToBeRemoved(const ModelNode &removedNode);
|
void nodeAboutToBeRemoved(const ModelNode &removedNode);
|
||||||
void nodeReparented(const ModelNode &node, const ModelNode &oldParent, const ModelNode &newParent);
|
void nodeReparented(const ModelNode &node, const ModelNode &oldParent, const ModelNode &newParent);
|
||||||
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
void nodeSlidedToIndex(const ModelNode &node, int newIndex, int oldIndex);
|
|
||||||
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion);
|
void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion);
|
||||||
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
|
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
|
||||||
@@ -70,7 +70,6 @@ public:
|
|||||||
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||||
const QList<ModelNode> &lastSelectedNodeList);
|
const QList<ModelNode> &lastSelectedNodeList);
|
||||||
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
|
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
|
||||||
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
|
|
||||||
|
|
||||||
void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState);
|
void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState);
|
||||||
|
|
||||||
|
|||||||
@@ -274,15 +274,16 @@ void StatesEditorView::nodeReparented(const ModelNode &node, const NodeAbstractP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex)
|
void StatesEditorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex)
|
||||||
{
|
{
|
||||||
QmlModelView::nodeSlidedToIndex(listProperty, newIndex, oldIndex);
|
QmlModelView::nodeOrderChanged(listProperty, movedNode, oldIndex);
|
||||||
if (listProperty.parentModelNode() == m_stateRootNode
|
if (listProperty.parentModelNode() == m_stateRootNode
|
||||||
&& listProperty.name() == "states") {
|
&& listProperty.name() == "states") {
|
||||||
int index = newIndex;
|
|
||||||
if (oldIndex < newIndex)
|
int newIndex = listProperty.toModelNodeList().indexOf(movedNode);
|
||||||
--index;
|
Q_ASSERT(newIndex >= 0);
|
||||||
QmlModelState state = listProperty.toModelNodeList().at(index);
|
|
||||||
|
QmlModelState state = QmlModelState(movedNode);
|
||||||
if (state.isValid()) {
|
if (state.isValid()) {
|
||||||
Q_ASSERT(oldIndex == modelStateIndex(state));
|
Q_ASSERT(oldIndex == modelStateIndex(state));
|
||||||
removeModelState(state);
|
removeModelState(state);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
|
|
||||||
void nodeAboutToBeRemoved(const ModelNode &removedNode);
|
void nodeAboutToBeRemoved(const ModelNode &removedNode);
|
||||||
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
// QmlModelView
|
// QmlModelView
|
||||||
void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState);
|
void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public:
|
|||||||
|
|
||||||
virtual void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
virtual void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
||||||
|
|
||||||
virtual void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex) = 0;
|
virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) = 0;
|
||||||
|
|
||||||
virtual void importsChanged();
|
virtual void importsChanged();
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
|
|
||||||
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
||||||
|
|
||||||
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
void importsChanged();
|
void importsChanged();
|
||||||
|
|
||||||
@@ -210,10 +210,11 @@ void ForwardView<ViewType>::fileUrlChanged(const QUrl &oldUrl, const QUrl &newUr
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class ViewType>
|
template <class ViewType>
|
||||||
void ForwardView<ViewType>::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex)
|
void ForwardView<ViewType>::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex)
|
||||||
{
|
{
|
||||||
foreach (const ViewTypePointer &view, m_targetViewList)
|
foreach (const ViewTypePointer &view, m_targetViewList)
|
||||||
view->nodeSlidedToIndex(NodeListProperty(listProperty, view.data()), newIndex, oldIndex);
|
view->nodeOrderChanged(NodeListProperty(listProperty, view.data()),
|
||||||
|
ModelNode(movedNode, view.data()), oldIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ViewType>
|
template <class ViewType>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
void nodeStatesAboutToBeRemoved(const QList<ModelNode> &nodeStateList);
|
void nodeStatesAboutToBeRemoved(const QList<ModelNode> &nodeStateList);
|
||||||
void nodeStatesAdded(const QList<ModelNode> &nodeStateList);
|
void nodeStatesAdded(const QList<ModelNode> &nodeStateList);
|
||||||
|
|
||||||
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
NodeInstance rootNodeInstance() const;
|
NodeInstance rootNodeInstance() const;
|
||||||
NodeInstance viewNodeInstance() const;
|
NodeInstance viewNodeInstance() const;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public:
|
|||||||
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
|
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
|
||||||
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
|
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
|
||||||
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int /*oldIndex*/);
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion);
|
void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion);
|
||||||
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
|
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
|
||||||
|
|
||||||
|
|||||||
@@ -293,10 +293,10 @@ void NodeInstanceView::nodeIdChanged(const ModelNode& node, const QString& newId
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeInstanceView::nodeSlidedToIndex(const NodeListProperty &listProperty, int /*newIndex*/, int /*oldIndex*/)
|
void NodeInstanceView::nodeOrderChanged(const NodeListProperty & listProperty,
|
||||||
|
const ModelNode & /*movedNode*/, int /*oldIndex*/)
|
||||||
{
|
{
|
||||||
QList<ModelNode> newOrderModelNodeList = listProperty.toModelNodeList();
|
foreach(const ModelNode &node, listProperty.toModelNodeList()) {
|
||||||
foreach(const ModelNode &node, newOrderModelNodeList) {
|
|
||||||
NodeInstance instance = instanceForNode(node);
|
NodeInstance instance = instanceForNode(node);
|
||||||
instance.reparent(instance.parent(), listProperty.name(), instance.parent(), listProperty.name());
|
instance.reparent(instance.parent(), listProperty.name(), instance.parent(), listProperty.name());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -438,12 +438,15 @@ void ModelPrivate::notifyNodeReparent(const InternalNode::Pointer &internalNodeP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelPrivate::notifyNodeSlidedToIndex(const InternalNodeListProperty::Pointer &internalNodeListproperty, int newIndex, int oldIndex)
|
void ModelPrivate::notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer,
|
||||||
|
const InternalNode::Pointer &internalNodePointer,
|
||||||
|
int oldIndex)
|
||||||
{
|
{
|
||||||
foreach (const QWeakPointer<AbstractView> &view, m_viewList) {
|
foreach (const QWeakPointer<AbstractView> &view, m_viewList) {
|
||||||
Q_ASSERT(view != 0);
|
Q_ASSERT(!view.isNull());
|
||||||
NodeListProperty nodeListproperty(internalNodeListproperty, model(), view.data());
|
view->nodeOrderChanged(NodeListProperty(internalListPropertyPointer, model(), view.data()),
|
||||||
view->nodeSlidedToIndex(nodeListproperty, newIndex, oldIndex);
|
ModelNode(internalNodePointer, model(), view.data()),
|
||||||
|
oldIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,14 +681,15 @@ void ModelPrivate::changeType(const InternalNodePointer &internalNode, const QSt
|
|||||||
notifyNodeTypeChanged(internalNode, type, majorVersion, minorVersion);
|
notifyNodeTypeChanged(internalNode, type, majorVersion, minorVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelPrivate::slideNodeList(const InternalNode::Pointer &internalNode, const QString &name, int from, int to)
|
void ModelPrivate::changeNodeOrder(const InternalNode::Pointer &internalParentNode, const QString &listPropertyName, int from, int to)
|
||||||
{
|
{
|
||||||
InternalNodeListProperty::Pointer nodeList(internalNode->nodeListProperty(name));
|
InternalNodeListProperty::Pointer nodeList(internalParentNode->nodeListProperty(listPropertyName));
|
||||||
Q_ASSERT(!nodeList.isNull());
|
Q_ASSERT(!nodeList.isNull());
|
||||||
nodeList->slide(from, to);
|
nodeList->slide(from, to);
|
||||||
notifyNodeSlidedToIndex(nodeList, to, from);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const InternalNodePointer internalNode = nodeList->nodeList().at(to);
|
||||||
|
notifyNodeOrderChanged(nodeList, internalNode, from);
|
||||||
|
}
|
||||||
|
|
||||||
void ModelPrivate::setRootNode(const InternalNode::Pointer& newRootNode)
|
void ModelPrivate::setRootNode(const InternalNode::Pointer& newRootNode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public:
|
|||||||
void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange);
|
void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const QStringList& propertyNameList, AbstractView::PropertyChangeFlags propertyChange);
|
void notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const QStringList& propertyNameList, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
|
|
||||||
void notifyNodeSlidedToIndex(const InternalNodeListPropertyPointer &internalNode, int newIndex, int oldIndex);
|
void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, const InternalNodePointer &internalNodePointer, int oldIndex);
|
||||||
void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const QString &name, const QVariant &data);
|
void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const QString &name, const QVariant &data);
|
||||||
|
|
||||||
void notifyNodeTypeChanged(const InternalNodePointer &internalNode, const QString &type, int majorVersion, int minorVersion);
|
void notifyNodeTypeChanged(const InternalNodePointer &internalNode, const QString &type, int majorVersion, int minorVersion);
|
||||||
@@ -156,7 +156,7 @@ public:
|
|||||||
void setDynamicVariantProperty(const InternalNodePointer &internalNode, const QString &name, const QString &propertyType, const QVariant &value);
|
void setDynamicVariantProperty(const InternalNodePointer &internalNode, const QString &name, const QString &propertyType, const QVariant &value);
|
||||||
void setDynamicBindingProperty(const InternalNodePointer &internalNode, const QString &name, const QString &dynamicPropertyType, const QString &expression);
|
void setDynamicBindingProperty(const InternalNodePointer &internalNode, const QString &name, const QString &dynamicPropertyType, const QString &expression);
|
||||||
void reparentNode(const InternalNodePointer &internalNode, const QString &name, const InternalNodePointer &internalNodeToBeAppended, bool list = true);
|
void reparentNode(const InternalNodePointer &internalNode, const QString &name, const InternalNodePointer &internalNodeToBeAppended, bool list = true);
|
||||||
void slideNodeList(const InternalNodePointer &internalNode, const QString &name, int from, int to);
|
void changeNodeOrder(const InternalNodePointer &internalParentNode, const QString &listPropertyName, int from, int to);
|
||||||
void checkPropertyName(const QString &propertyName);
|
void checkPropertyName(const QString &propertyName);
|
||||||
void clearParent(const InternalNodePointer &internalNode);
|
void clearParent(const InternalNodePointer &internalNode);
|
||||||
void changeType(const InternalNodePointer & internalNode, const QString &type, int majorVersion, int minorVersion);
|
void changeType(const InternalNodePointer & internalNode, const QString &type, int majorVersion, int minorVersion);
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ void NodeListProperty::slide(int from, int to) const
|
|||||||
{
|
{
|
||||||
if (!isValid())
|
if (!isValid())
|
||||||
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<invalid node list property>");
|
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<invalid node list property>");
|
||||||
if (to > toModelNodeList().count())
|
if (to > toModelNodeList().count() - 1)
|
||||||
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<invalid node list sliding>");
|
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<invalid node list sliding>");
|
||||||
|
|
||||||
model()->m_d->slideNodeList(internalNode(), name(), from, to);
|
model()->m_d->changeNodeOrder(internalNode(), name(), from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeListProperty::reparentHere(const ModelNode &modelNode)
|
void NodeListProperty::reparentHere(const ModelNode &modelNode)
|
||||||
|
|||||||
@@ -258,18 +258,19 @@ void RewriterView::nodeIdChanged(const ModelNode& node, const QString& newId, co
|
|||||||
modelToTextMerger()->applyChanges();
|
modelToTextMerger()->applyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RewriterView::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int /*oldIndex*/)
|
void RewriterView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int /*oldIndex*/)
|
||||||
{ // FIXME: "slided" ain't no English, probably "slid" or "sliding" is meant...
|
{
|
||||||
Q_ASSERT(textModifier());
|
Q_ASSERT(textModifier());
|
||||||
if (textToModelMerger()->isActive())
|
if (textToModelMerger()->isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QList<ModelNode> nodes = listProperty.toModelNodeList();
|
const QList<ModelNode> nodes = listProperty.toModelNodeList();
|
||||||
const ModelNode movingNode = nodes.at(newIndex);
|
|
||||||
ModelNode trailingNode;
|
ModelNode trailingNode;
|
||||||
|
int newIndex = nodes.indexOf(movedNode);
|
||||||
if (newIndex + 1 < nodes.size())
|
if (newIndex + 1 < nodes.size())
|
||||||
trailingNode = nodes.at(newIndex + 1);
|
trailingNode = nodes.at(newIndex + 1);
|
||||||
modelToTextMerger()->nodeSlidAround(movingNode, trailingNode);
|
modelToTextMerger()->nodeSlidAround(movedNode, trailingNode);
|
||||||
|
|
||||||
if (!isModificationGroupActive())
|
if (!isModificationGroupActive())
|
||||||
modelToTextMerger()->applyChanges();
|
modelToTextMerger()->applyChanges();
|
||||||
|
|||||||
@@ -171,9 +171,9 @@ void ViewLogger::fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl)
|
|||||||
m_output << time() << indent("fileUrlChanged:") << oldUrl.toString() << "\t" << newUrl.toString() << endl;
|
m_output << time() << indent("fileUrlChanged:") << oldUrl.toString() << "\t" << newUrl.toString() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewLogger::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex)
|
void ViewLogger::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex)
|
||||||
{
|
{
|
||||||
m_output << time() << indent("nodeSlidedToIndex:") << listProperty << newIndex << oldIndex << endl;
|
m_output << time() << indent("nodeOrderChanged:") << listProperty << movedNode << oldIndex << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewLogger::importsChanged()
|
void ViewLogger::importsChanged()
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
||||||
|
|
||||||
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
void importsChanged();
|
void importsChanged();
|
||||||
|
|
||||||
|
|||||||
@@ -1381,14 +1381,12 @@ void TestCore::testModelReorderSiblings()
|
|||||||
|
|
||||||
NodeListProperty listProperty(rootModelNode.nodeListProperty("data"));
|
NodeListProperty listProperty(rootModelNode.nodeListProperty("data"));
|
||||||
|
|
||||||
listProperty.slide(listProperty.toModelNodeList().indexOf(a), 3); //a.slideToIndex(3);
|
listProperty.slide(listProperty.toModelNodeList().indexOf(a), 2); //a.slideToIndex(2);
|
||||||
|
|
||||||
|
|
||||||
QVERIFY(a.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(a), 2);
|
QVERIFY(a.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(a), 2);
|
||||||
QVERIFY(b.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(b), 0);
|
QVERIFY(b.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(b), 0);
|
||||||
QVERIFY(c.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(c), 1);
|
QVERIFY(c.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(c), 1);
|
||||||
|
|
||||||
|
|
||||||
listProperty.slide(listProperty.toModelNodeList().indexOf(c), 0); //c.slideToIndex(0);
|
listProperty.slide(listProperty.toModelNodeList().indexOf(c), 0); //c.slideToIndex(0);
|
||||||
|
|
||||||
QVERIFY(a.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(a), 2);
|
QVERIFY(a.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(a), 2);
|
||||||
|
|||||||
@@ -140,10 +140,11 @@ void TestView::selectedNodesChanged(const QList<QmlDesigner::ModelNode> &selecte
|
|||||||
m_methodCalls += MethodCall("selectedNodesChanged", QStringList() << selectedNodes.join(", ") << lastSelectedNodes.join(", "));
|
m_methodCalls += MethodCall("selectedNodesChanged", QStringList() << selectedNodes.join(", ") << lastSelectedNodes.join(", "));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestView::nodeSlidedToIndex(const QmlDesigner::NodeListProperty &listProperty, int newIndex, int oldIndex)
|
|
||||||
|
void TestView::nodeOrderChanged(const QmlDesigner::NodeListProperty &listProperty, const QmlDesigner::ModelNode &movedNode, int oldIndex)
|
||||||
{
|
{
|
||||||
QmlDesigner::QmlModelView::nodeSlidedToIndex(listProperty, newIndex, oldIndex);
|
QmlDesigner::QmlModelView::nodeOrderChanged(listProperty, movedNode, oldIndex);
|
||||||
m_methodCalls += MethodCall("nodeSlidedToIndex", QStringList() << listProperty.name() << QString::number(newIndex) << QString::number(oldIndex));
|
m_methodCalls += MethodCall("nodeOrderChanged", QStringList() << listProperty.name() << movedNode.id() << QString::number(oldIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestView::stateChanged(const QmlDesigner::QmlModelState &newQmlModelState, const QmlDesigner::QmlModelState &oldQmlModelState)
|
void TestView::stateChanged(const QmlDesigner::QmlModelState &newQmlModelState, const QmlDesigner::QmlModelState &oldQmlModelState)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
void selectedNodesChanged(const QList<QmlDesigner::ModelNode> &selectedNodeList,
|
void selectedNodesChanged(const QList<QmlDesigner::ModelNode> &selectedNodeList,
|
||||||
const QList<QmlDesigner::ModelNode> &lastSelectedNodeList);
|
const QList<QmlDesigner::ModelNode> &lastSelectedNodeList);
|
||||||
|
|
||||||
void nodeSlidedToIndex(const QmlDesigner::NodeListProperty &listProperty, int newIndex, int oldIndex);
|
void nodeOrderChanged(const QmlDesigner::NodeListProperty &listProperty, const QmlDesigner::ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
void stateChanged(const QmlDesigner::QmlModelState &newQmlModelState, const QmlDesigner::QmlModelState &oldQmlModelState);
|
void stateChanged(const QmlDesigner::QmlModelState &newQmlModelState, const QmlDesigner::QmlModelState &oldQmlModelState);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user