mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-15 05:22:35 +02:00
* Fixed sidebar sorting.
This commit is contained in:
parent
4c5d34ceb7
commit
4d012b156a
@ -82,7 +82,8 @@ PlaylistItem::onPlaylistChanged()
|
||||
int
|
||||
PlaylistItem::peerSortValue() const
|
||||
{
|
||||
return m_playlist->createdOn();
|
||||
// return m_playlist->createdOn();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -238,7 +239,8 @@ DynamicPlaylistItem::onDynamicPlaylistLoaded( DynamicPlaylistRevision revision )
|
||||
int
|
||||
DynamicPlaylistItem::peerSortValue() const
|
||||
{
|
||||
return m_dynplaylist->createdOn();
|
||||
// return m_dynplaylist->createdOn();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
#include "sourcelist.h"
|
||||
#include "sourcesmodel.h"
|
||||
#include "sourcetree/items/collectionitem.h"
|
||||
|
||||
@ -51,13 +52,13 @@ SourcesProxyModel::showOfflineSources( bool offlineSourcesShown )
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||
{
|
||||
if ( !m_filtered )
|
||||
return true;
|
||||
|
||||
|
||||
CollectionItem* sti = qobject_cast< CollectionItem* >( m_model->data( sourceModel()->index( sourceRow, 0, sourceParent ), SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
||||
if ( sti )
|
||||
{
|
||||
@ -70,6 +71,7 @@ SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePar
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourcesProxyModel::selectRequested( const QModelIndex& idx )
|
||||
{
|
||||
@ -77,6 +79,7 @@ SourcesProxyModel::selectRequested( const QModelIndex& idx )
|
||||
emit selectRequest( mapFromSource( idx ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourcesProxyModel::expandRequested( const QModelIndex& idx )
|
||||
{
|
||||
@ -84,3 +87,28 @@ SourcesProxyModel::expandRequested( const QModelIndex& idx )
|
||||
emit expandRequest( mapFromSource( idx ) );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SourcesProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
|
||||
{
|
||||
CollectionItem* ciL = qobject_cast< CollectionItem* >( m_model->data( left, SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
||||
CollectionItem* ciR = qobject_cast< CollectionItem* >( m_model->data( right, SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
||||
|
||||
if ( ciL && ciR )
|
||||
{
|
||||
if ( ciL->source().isNull() )
|
||||
return true;
|
||||
if ( ciR->source().isNull() )
|
||||
return false;
|
||||
|
||||
if ( ciL->source() == SourceList::instance()->getLocal() )
|
||||
return true;
|
||||
if ( ciR->source() == SourceList::instance()->getLocal() )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_model->data( left, SourcesModel::SortRole ) != m_model->data( right, SourcesModel::SortRole ) )
|
||||
return ( m_model->data( left, SourcesModel::SortRole ).toInt() < m_model->data( right, SourcesModel::SortRole ).toInt() );
|
||||
|
||||
return QString::localeAwareCompare( left.data().toString().toLower(), right.data().toString().toLower() ) < 0;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ signals:
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||
|
||||
private:
|
||||
SourcesModel* m_model;
|
||||
|
Loading…
x
Reference in New Issue
Block a user