Commit 9a0abef1 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Add more selection methodes in the AbstractView

Change-Id: I91afb480d65908e962e912b241d07a4f66e67a3a
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent d54be468
......@@ -146,11 +146,16 @@ public:
ModelNode rootModelNode();
void setSelectedModelNodes(const QList<ModelNode> &selectedNodeList);
void setSelectedModelNode(const ModelNode &modelNode);
void selectModelNode(const ModelNode &node);
void deselectModelNode(const ModelNode &node);
void clearSelectedModelNodes();
bool hasSelectedModelNodes() const;
bool hasSingleSelectedModelNode() const;
QList<ModelNode> selectedModelNodes() const;
ModelNode firstSelectedModelNode() const;
ModelNode singleSelectedModelNode() const;
ModelNode modelNodeForId(const QString &id);
bool hasId(const QString &id) const;
......
......@@ -299,6 +299,11 @@ void AbstractView::setSelectedModelNodes(const QList<ModelNode> &selectedNodeLis
model()->d->setSelectedNodes(toInternalNodeList(selectedNodeList));
}
void AbstractView::setSelectedModelNode(const ModelNode &modelNode)
{
setSelectedModelNodes(QList<ModelNode>() << modelNode);
}
/*!
\brief clears the selection
*/
......@@ -307,6 +312,16 @@ void AbstractView::clearSelectedModelNodes()
model()->d->clearSelectedNodes();
}
bool AbstractView::hasSelectedModelNodes() const
{
return !model()->d->selectedNodes().isEmpty();
}
bool AbstractView::hasSingleSelectedModelNode() const
{
return model()->d->selectedNodes().count() == 1;
}
/*!
\brief set this list nodes to the actual selected nodes
\return list the selected nodes
......@@ -316,6 +331,22 @@ QList<ModelNode> AbstractView::selectedModelNodes() const
return toModelNodeList(model()->d->selectedNodes());
}
ModelNode AbstractView::firstSelectedModelNode() const
{
if (hasSelectedModelNodes())
return ModelNode(model()->d->selectedNodes().first(), model(), this);
return ModelNode();
}
ModelNode AbstractView::singleSelectedModelNode() const
{
if (hasSingleSelectedModelNode())
return ModelNode(model()->d->selectedNodes().first(), model(), this);
return ModelNode();
}
/*!
\brief adds a node to the selection list
\param node to be added to the selection list
......
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