示例#1
0
void SelectionProxyModel::setSourceModel(QAbstractItemModel *model)
{
    if (model == sourceModel()) {
        return;
    }
    KRecursiveFilterProxyModel::setSourceModel(model);
    initializeSelection();
}
示例#2
0
void
SparseSelector::selectVertex(Index parentVertex) {

    initializeSelection();

    //  Don't bother to test-and-set here, just set
    markVertexSelected(parentVertex);
}
示例#3
0
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]);
    }
}
示例#4
0
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]);
        }
    }
}
示例#5
0
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();
}