QModelIndexList
PartitionLabelsView::getIndexesToDraw( const QModelIndex& parent ) const
{
    QModelIndexList list;

    QAbstractItemModel* modl = model();
    if ( !modl )
        return list;

    for ( int row = 0; row < modl->rowCount( parent ); ++row )
    {
        QModelIndex index = modl->index( row, 0, parent );

        //HACK: horrible special casing follows.
        //      To save vertical space, we choose to hide short instances of free space.
        //      Arbitrary limit: 10MB.
        const qint64 maxHiddenB = 10000000;
        if ( index.data( PartitionModel::IsFreeSpaceRole ).toBool() &&
             index.data( PartitionModel::SizeRole ).toLongLong() <  maxHiddenB )
            continue;

        if ( !modl->hasChildren( index ) || !m_extendedPartitionHidden )
            list.append( index );

        if ( modl->hasChildren( index ) )
            list.append( getIndexesToDraw( index ) );
    }
    return list;
}
示例#2
0
void PropertyBrowser::expandAllGroups()
{
    QAbstractItemModel * model = this->model();

    QModelIndexList indexes = model->match(model->index(0,0), Qt::DisplayRole, "*", -1, Qt::MatchWildcard|Qt::MatchRecursive);
    for (QModelIndex index : indexes)
    {
        if (!index.isValid())
            continue;

        AbstractProperty * property = retrieveProperty(index);

        if (property->isGroup() && model->hasChildren(index))
            expand(index);
    }
}
示例#3
0
void PropertyBrowser::onRowsInserted(const QModelIndex & parentIndex, int first, int last)
{
    QAbstractItemModel * model = this->model();

    for (int i = first; i <= last; ++i)
    {
        QModelIndex index = model->index(i, 0, parentIndex);

        if (!index.isValid())
            continue;

        AbstractProperty * property = retrieveProperty(index);

        if (property->isGroup() && model->hasChildren(index))
            expand(index);
    }
}