mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* PlayableProxyModel now supports setting a maximum amount of visible items.
This commit is contained in:
@@ -34,6 +34,7 @@ PlayableProxyModel::PlayableProxyModel( QObject* parent )
|
|||||||
: QSortFilterProxyModel( parent )
|
: QSortFilterProxyModel( parent )
|
||||||
, m_model( 0 )
|
, m_model( 0 )
|
||||||
, m_showOfflineResults( true )
|
, m_showOfflineResults( true )
|
||||||
|
, m_maxVisibleItems( -1 )
|
||||||
{
|
{
|
||||||
setFilterCaseSensitivity( Qt::CaseInsensitive );
|
setFilterCaseSensitivity( Qt::CaseInsensitive );
|
||||||
setSortCaseSensitivity( Qt::CaseInsensitive );
|
setSortCaseSensitivity( Qt::CaseInsensitive );
|
||||||
@@ -98,6 +99,9 @@ PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePa
|
|||||||
if ( !pi )
|
if ( !pi )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ( m_maxVisibleItems >= 0 && sourceRow > m_maxVisibleItems - 1 )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( pi->query() )
|
if ( pi->query() )
|
||||||
{
|
{
|
||||||
const Tomahawk::query_ptr& q = pi->query()->displayQuery();
|
const Tomahawk::query_ptr& q = pi->query()->displayQuery();
|
||||||
@@ -211,6 +215,17 @@ PlayableProxyModel::remove( const QList< QPersistentModelIndex >& indexes )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlayableProxyModel::setMaxVisibleItems( int items )
|
||||||
|
{
|
||||||
|
if ( m_maxVisibleItems == items )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_maxVisibleItems = items;
|
||||||
|
invalidateFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const Tomahawk::query_ptr& q2 ) const
|
PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const Tomahawk::query_ptr& q2 ) const
|
||||||
{
|
{
|
||||||
|
@@ -51,6 +51,9 @@ public:
|
|||||||
virtual bool showOfflineResults() const { return m_showOfflineResults; }
|
virtual bool showOfflineResults() const { return m_showOfflineResults; }
|
||||||
virtual void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
virtual void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
||||||
|
|
||||||
|
virtual int maxVisibleItems() const { return m_maxVisibleItems; }
|
||||||
|
virtual void setMaxVisibleItems( int items );
|
||||||
|
|
||||||
virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); }
|
virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); }
|
||||||
|
|
||||||
virtual PlayableItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
virtual PlayableItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||||
@@ -76,7 +79,9 @@ private:
|
|||||||
virtual bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
|
virtual bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
|
||||||
|
|
||||||
PlayableModel* m_model;
|
PlayableModel* m_model;
|
||||||
|
|
||||||
bool m_showOfflineResults;
|
bool m_showOfflineResults;
|
||||||
|
int m_maxVisibleItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACKPROXYMODEL_H
|
#endif // TRACKPROXYMODEL_H
|
||||||
|
Reference in New Issue
Block a user