void SelectionProxyModel::setSourceModel(QAbstractItemModel *model) { if (model == sourceModel()) { return; } KRecursiveFilterProxyModel::setSourceModel(model); initializeSelection(); }
void SparseSelector::selectVertex(Index parentVertex) { initializeSelection(); // Don't bother to test-and-set here, just set markVertexSelected(parentVertex); }
void SparseSelector::selectEdge(Index parentEdge) { initializeSelection(); if (!wasEdgeSelected(parentEdge)) { markEdgeSelected(parentEdge); // Mark the two end vertices: ConstIndexArray eVerts = _refine->parent().getEdgeVertices(parentEdge); markVertexSelected(eVerts[0]); markVertexSelected(eVerts[1]); } }
void SparseSelector::selectFace(Index parentFace) { initializeSelection(); if (!wasFaceSelected(parentFace)) { markFaceSelected(parentFace); // Mark the face's incident verts and edges as selected: ConstIndexArray fEdges = _refine->parent().getFaceEdges(parentFace), fVerts = _refine->parent().getFaceVertices(parentFace); for (int i = 0; i < fVerts.size(); ++i) { markEdgeSelected(fEdges[i]); markVertexSelected(fVerts[i]); } } }
void SelectionProxyModel::setSelectionModel(QItemSelectionModel *selectionModel) { if (m_selectionModel == selectionModel) { return; } if (m_selectionModel) { disconnect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); disconnect(m_selectionModel->model(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); } m_selectionModel = selectionModel; if (selectionModel) { connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(onSelectionChanged(QItemSelection,QItemSelection))); connect(selectionModel->model(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(onSourceRemoveRows(QModelIndex,int,int))); } initializeSelection(); invalidate(); }