コード例 #1
0
ファイル: PlayableProxyModel.cpp プロジェクト: Teriq/tomahawk
bool
PlayableProxyModel::visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const
{
    if ( m_maxVisibleItems <= 0 )
        return true;

    if ( static_cast<size_t>( sourceRow ) < memo.visibilty.size() )
    {
        // We have already memoized the return value.
        return memo.visibilty[sourceRow] < m_maxVisibleItems;
    }
    // else: We do not have memoized the value, so compute it.

    int items = memo.visibilty.back();
    for ( int i = memo.visibilty.size() - 1; ( i < sourceRow ) && ( items < m_maxVisibleItems ) ; i++ )
    {
        PlayableItem* pi = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
        // We will not change memo in these calls as all values needed in them are already memoized.
        if ( pi && dupeFilterAcceptsRow( i, pi, sourceParent, memo ) && nameFilterAcceptsRow( i, pi, sourceParent ) )
        {
            items++;
            memo.visibilty.push_back( items ); // Sets memo.visibilty[i + 1] to items
        }
    }

    return ( items < m_maxVisibleItems );
}
コード例 #2
0
bool BtBookshelfFilterModel::filterAcceptsRow(int row,
        const QModelIndex &parent) const
{
    if (!m_enabled) return true;

    if (!hiddenFilterAcceptsRow(row, parent)) return false;
    if (!nameFilterAcceptsRow(row, parent)) return false;
    if (!categoryFilterAcceptsRow(row, parent)) return false;
    return true;
}
コード例 #3
0
ファイル: PlayableProxyModel.cpp プロジェクト: Teriq/tomahawk
bool
PlayableProxyModel::filterAcceptsRowInternal( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const
{
    if ( m_maxVisibleItems > 0 && !visibilityFilterAcceptsRow( sourceRow, sourceParent, memo ) )
        return false;
    if ( m_hideDupeItems && !dupeFilterAcceptsRow( sourceRow, pi, sourceParent, memo ) )
        return false;

    return nameFilterAcceptsRow( sourceRow, pi, sourceParent );
}