Beispiel #1
0
bool ADLSModel::removeItem(const QModelIndex &el){
    if (!el.isValid())
        return false;

    ADLSItem *item = static_cast<ADLSItem*>(el.internalPointer());

    if (!item || !rootItem->childItems.contains(item))
        return false;

    beginRemoveRows(QModelIndex(), item->row(), item->row());
    rootItem->childItems.removeAt(rootItem->childItems.indexOf(item));
    endRemoveRows();

    delete item;

    emit layoutChanged();

    return true;
}
Beispiel #2
0
QModelIndex ADLSModel::parent(const QModelIndex &index) const
{
    if (!index.isValid())
        return QModelIndex();

    ADLSItem *childItem = static_cast<ADLSItem*>(index.internalPointer());
    ADLSItem *parentItem = childItem->parent();

    if (parentItem == rootItem)
        return QModelIndex();

    return createIndex(parentItem->row(), 0, parentItem);
}