mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Less calls to itemFromIndex
This commit is contained in:
@@ -145,25 +145,32 @@ PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
|
|||||||
bool
|
bool
|
||||||
PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
if ( m_hideDupeItems && !dupeFilterAcceptsRow( sourceRow, sourceParent ) )
|
PlayableItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||||
return false;
|
if ( !pi )
|
||||||
if ( m_maxVisibleItems > 0 && !visibilityFilterAcceptsRow( sourceRow, sourceParent ) )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return nameFilterAcceptsRow( sourceRow, sourceParent );
|
return filterAcceptsRowInternal( sourceRow, pi, sourceParent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlayableProxyModel::dupeFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
PlayableProxyModel::filterAcceptsRowInternal( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const
|
||||||
|
{
|
||||||
|
if ( m_hideDupeItems && !dupeFilterAcceptsRow( sourceRow, pi, sourceParent ) )
|
||||||
|
return false;
|
||||||
|
if ( m_maxVisibleItems > 0 && !visibilityFilterAcceptsRow( sourceRow, sourceParent ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return nameFilterAcceptsRow( sourceRow, pi, sourceParent );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PlayableProxyModel::dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
if ( !m_hideDupeItems )
|
if ( !m_hideDupeItems )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
PlayableItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
|
||||||
if ( !pi )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for ( int i = 0; i < sourceRow; i++ )
|
for ( int i = 0; i < sourceRow; i++ )
|
||||||
{
|
{
|
||||||
PlayableItem* di = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
|
PlayableItem* di = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
|
||||||
@@ -174,7 +181,7 @@ PlayableProxyModel::dupeFilterAcceptsRow( int sourceRow, const QModelIndex& sour
|
|||||||
( pi->album() && pi->album() == di->album() ) ||
|
( pi->album() && pi->album() == di->album() ) ||
|
||||||
( pi->artist() && pi->artist()->name() == di->artist()->name() );
|
( pi->artist() && pi->artist()->name() == di->artist()->name() );
|
||||||
|
|
||||||
if ( b && filterAcceptsRow( i, sourceParent ) )
|
if ( b && filterAcceptsRowInternal( i, di, sourceParent ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +198,8 @@ PlayableProxyModel::visibilityFilterAcceptsRow( int sourceRow, const QModelIndex
|
|||||||
int items = 0;
|
int items = 0;
|
||||||
for ( int i = 0; ( i < sourceRow ) && ( items < m_maxVisibleItems ) ; i++ )
|
for ( int i = 0; ( i < sourceRow ) && ( items < m_maxVisibleItems ) ; i++ )
|
||||||
{
|
{
|
||||||
if ( dupeFilterAcceptsRow( i, sourceParent ) && nameFilterAcceptsRow( i, sourceParent ) )
|
PlayableItem* pi = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
|
||||||
|
if ( pi && dupeFilterAcceptsRow( i, pi, sourceParent ) && nameFilterAcceptsRow( i, pi, sourceParent ) )
|
||||||
{
|
{
|
||||||
items++;
|
items++;
|
||||||
}
|
}
|
||||||
@@ -202,12 +210,8 @@ PlayableProxyModel::visibilityFilterAcceptsRow( int sourceRow, const QModelIndex
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlayableProxyModel::nameFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
PlayableProxyModel::nameFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
PlayableItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
|
||||||
if ( !pi )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( m_hideEmptyParents && pi->source() )
|
if ( m_hideEmptyParents && pi->source() )
|
||||||
{
|
{
|
||||||
if ( !sourceModel()->rowCount( sourceModel()->index( sourceRow, 0, sourceParent ) ) )
|
if ( !sourceModel()->rowCount( sourceModel()->index( sourceRow, 0, sourceParent ) ) )
|
||||||
|
@@ -117,8 +117,9 @@ private slots:
|
|||||||
void onCurrentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex );
|
void onCurrentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool nameFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
bool filterAcceptsRowInternal( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const;
|
||||||
bool dupeFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
bool nameFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const;
|
||||||
|
bool dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const;
|
||||||
bool visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
bool visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||||
bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
|
bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user