Commit 73356f25 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Cleanup the invisible code in the Navigator

Change-Id: Icc4ccbdc6090234cc9fc081786b2d80b9811ad16
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent b2bb2e3e
......@@ -183,7 +183,6 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data,
}
moveNodesInteractive(parentProperty, nodeList, targetIndex);
propagateInvisible(parentNode, isNodeInvisible(parentNode));
return false; // don't let the view do drag&drop on its own
}
......@@ -344,18 +343,10 @@ void NavigatorTreeModel::handleChangedItem(QStandardItem *item)
} else if (item == itemRow.visibilityItem) {
bool invisible = (item->checkState() == Qt::Unchecked);
node.setAuxiliaryData("invisible", invisible);
propagateInvisible(node,isNodeInvisible(node));
}
}
void NavigatorTreeModel::propagateInvisible(const ModelNode &node, const bool &invisible)
{
QList <ModelNode> children = node.allDirectSubModelNodes();
foreach (ModelNode child, children) {
child.setAuxiliaryData("childOfInvisible",invisible);
if (!child.auxiliaryData("invisible").toBool())
propagateInvisible(child,invisible);
if (invisible)
node.setAuxiliaryData("invisible", invisible);
else
node.removeAuxiliaryData("invisible");
}
}
......@@ -412,12 +403,20 @@ bool NavigatorTreeModel::isNodeInvisible(const QModelIndex &index) const
return isNodeInvisible(nodeForIndex(index));
}
bool NavigatorTreeModel::isNodeInvisible(const ModelNode &node) const
static bool isInvisbleInHierachy(const ModelNode &modelNode)
{
if (modelNode.auxiliaryData("invisible").toBool())
return true;
if (modelNode.hasParentProperty())
return isInvisbleInHierachy(modelNode.parentProperty().parentModelNode());
return false;
}
bool NavigatorTreeModel::isNodeInvisible(const ModelNode &modelNode) const
{
bool nodeInvisible = node.auxiliaryData("invisible").toBool();
if (node.hasAuxiliaryData("childOfInvisible"))
nodeInvisible = nodeInvisible || node.auxiliaryData("childOfInvisible").toBool();
return nodeInvisible;
return isInvisbleInHierachy(modelNode);
}
/**
......
......@@ -102,7 +102,6 @@ public:
ModelNode nodeForIndex(const QModelIndex &index) const;
bool isInTree(const ModelNode &node) const;
void propagateInvisible(const ModelNode &node, const bool &invisible);
bool isNodeInvisible(const QModelIndex &index) const;
bool isNodeInvisible(const ModelNode &node) const;
......
......@@ -220,17 +220,19 @@ void NavigatorView::rootNodeTypeChanged(const QString & /*type*/, int /*majorVer
m_treeModel->updateItemRow(rootModelNode());
}
void NavigatorView::auxiliaryDataChanged(const ModelNode &node, const PropertyName & /*name*/, const QVariant & /*data*/)
void NavigatorView::auxiliaryDataChanged(const ModelNode &modelNode, const PropertyName & name, const QVariant & /*data*/)
{
if (m_treeModel->isInTree(node))
if (name == "invisible" && m_treeModel->isInTree(modelNode))
{
// update model
m_treeModel->updateItemRow(node);
m_treeModel->updateItemRow(modelNode);
// repaint row (id and icon)
QModelIndex index = m_treeModel->indexForNode(node);
treeWidget()->update( index );
treeWidget()->update( index.sibling(index.row(),index.column()+1) );
foreach (const ModelNode &currentModelNode, modelNode.allSubModelNodesAndThisNode()) {
QModelIndex index = m_treeModel->indexForNode(currentModelNode);
treeWidget()->update(index);
treeWidget()->update(index.sibling(index.row(),index.column()+1));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment