Logo Search packages:      
Sourcecode: qt4-x11 version File versions

bool TreeModel::removeRows ( int  row,
int  count,
const QModelIndex parent = QModelIndex() 
) [virtual]

On models that support this, removes count rows starting with the given row under parent parent from the model. Returns true if the rows were successfully removed; otherwise returns false.

The base class implementation does nothing and returns false.

If you implement your own model, you can reimplement this function if you want to support removing. Alternatively, you can provide you own API for altering the data.

See also:
removeRow(), removeColumns(), insertColumns(), beginRemoveRows(), endRemoveRows()

Reimplemented from QAbstractItemModel.

Definition at line 167 of file treemodel.cpp.

References QAbstractItemModel::beginRemoveRows(), TreeItem::childCount(), QAbstractItemModel::endRemoveRows(), QModelIndex::internalPointer(), QModelIndex::isValid(), and TreeItem::removeChild().

Referenced by removeColumns().

{
    TreeItem *parentItem;

    if (!parent.isValid())
        parentItem = rootItem;
    else
        parentItem = static_cast<TreeItem*>(parent.internalPointer());

    if (position < 0 || position > parentItem->childCount())
        return false;

    beginRemoveRows(parent, position, position + rows - 1);

    for (int row = 0; row < rows; ++row) {
        if (!parentItem->removeChild(position))
            break;
    }

    endRemoveRows();
    return true;
}


Generated by  Doxygen 1.6.0   Back to index