QmlDesigner.documentController: adding instance()

Also exposing changeCurrentModelTo() as public API.

Change-Id: I7c9ed3679ef5859b1349f1d1fe3088e78bccc7ad
Reviewed-on: http://codereview.qt.nokia.com/787
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
Thomas Hartmann
2011-06-27 17:46:44 +02:00
parent 88ac3daa7f
commit 386974c943
4 changed files with 35 additions and 1 deletions

View File

@@ -72,6 +72,11 @@ ModelNode ComponentView::modelNode(int index) const
return ModelNode();
}
void ComponentView::setComponentNode(const ModelNode &node)
{
m_componentAction->setCurrentIndex(indexForNode(node));
}
void ComponentView::appendWholeDocumentAsComponent()
{
QStandardItem *item = new QStandardItem(tr("whole document"));
@@ -88,6 +93,16 @@ void ComponentView::removeSingleNodeFromList(const ModelNode &node)
}
}
int ComponentView::indexForNode(const ModelNode &node)
{
for (int row = 0; row < m_standardItemModel->rowCount(); row++) {
if (m_standardItemModel->item(row)->data(ModelNodeRole).value<ModelNode>() == node)
return row;
}
return -1;
}
void ComponentView::modelAttached(Model *model)
{
if (AbstractView::model() == model)