void GeoTreeView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected ) { Q_UNUSED(deselected); if (!selected.isEmpty()) { const QModelIndex idx = *(selected.indexes().begin()); const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); emit removeGeoItemSelection(); const GeoObjectListItem* geo_object = dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()); if (geo_object) // geometry object { emit enableSaveButton(false); emit enableRemoveButton(false); emit geoItemSelected(geo_object->vtkSource(), tree_item->row()); } else { if (!idx.parent().isValid()) // geometry item { emit enableSaveButton(true); emit enableRemoveButton(true); } else // line points or surface triangles { emit enableSaveButton(false); const auto* geo_type = dynamic_cast<const GeoObjectListItem*>(tree_item); if (geo_type) // geometry list item emit enableRemoveButton(true); else { // highlight a point for an expanded polyline auto* list_item = dynamic_cast<GeoObjectListItem*>( tree_item->parentItem()->parentItem()); if (list_item && list_item->getType() == GeoLib::GEOTYPE::POLYLINE) geoItemSelected( dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()->parentItem()->parentItem()->child(0))->vtkSource(), tree_item->data(0).toInt()); // highlight a point for an expanded surface list_item = dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()->parentItem()->parentItem()); if (list_item && list_item->getType() == GeoLib::GEOTYPE::SURFACE) geoItemSelected( dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()->parentItem()->parentItem()->parentItem()->child(0))->vtkSource(), tree_item->data(0).toInt()); emit enableRemoveButton(false); } } } } //emit itemSelectionChanged(selected, deselected); //return QTreeView::selectionChanged(selected, deselected); }
void StationTreeView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected ) { Q_UNUSED(deselected); if (!selected.isEmpty()) { const QModelIndex idx = *(selected.indexes().begin()); const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); const ModelTreeItem* list_item = dynamic_cast<const ModelTreeItem*>(tree_item->parentItem()); if (list_item->getItem()) { if (list_item) emit geoItemSelected(list_item->getItem()->vtkSource(), tree_item->row()); emit enableRemoveButton(false); emit enableSaveButton(false); } else { emit removeGeoItemSelection(); emit enableSaveButton(true); emit enableRemoveButton(true); } } //emit itemSelectionChanged(selected, deselected); //return QTreeView::selectionChanged(selected, deselected); }