Exemplo n.º 1
0
void MshView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
	Q_UNUSED(deselected);
	if (!selected.isEmpty())
	{
		emit removeSelectedMeshComponent();
		const QModelIndex idx = *(selected.indexes().begin());
		const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx);

		const MshItem* list_item = dynamic_cast<const MshItem*>(tree_item);
		if (list_item)
		{
			emit enableSaveButton(true);
			emit enableRemoveButton(true);
			emit meshSelected(list_item->getMesh());
		}
		else
		{
			emit enableSaveButton(false);
			emit enableRemoveButton(false);
			emit elementSelected(dynamic_cast<const MshItem*>(tree_item->parentItem())->vtkSource(), static_cast<unsigned>(tree_item->row()), true);
		}
	}
	//emit itemSelectionChanged(selected, deselected);
	//return QTreeView::selectionChanged(selected, deselected);
}
Exemplo n.º 2
0
void ElementTreeView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
    Q_UNUSED(deselected);
    if (!selected.isEmpty())
    {
        emit removeSelectedMeshComponent();
        const QModelIndex idx = *(selected.indexes().begin());

        if (idx.parent().isValid()) // not root node
            if (idx.parent().parent().isValid()) // not property node
            {
                const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx);
                const unsigned node_index = tree_item->data(0).toString().mid(5).toUInt();
                emit nodeSelected(static_cast<ElementTreeModel*>(this->model())->getSource(), node_index, false);
            }
    }
}