mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 15:16:34 +02:00
* Fixed sidebar sorting.
This commit is contained in:
@@ -82,7 +82,8 @@ PlaylistItem::onPlaylistChanged()
|
|||||||
int
|
int
|
||||||
PlaylistItem::peerSortValue() const
|
PlaylistItem::peerSortValue() const
|
||||||
{
|
{
|
||||||
return m_playlist->createdOn();
|
// return m_playlist->createdOn();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -238,7 +239,8 @@ DynamicPlaylistItem::onDynamicPlaylistLoaded( DynamicPlaylistRevision revision )
|
|||||||
int
|
int
|
||||||
DynamicPlaylistItem::peerSortValue() const
|
DynamicPlaylistItem::peerSortValue() const
|
||||||
{
|
{
|
||||||
return m_dynplaylist->createdOn();
|
// return m_dynplaylist->createdOn();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
|
#include "sourcelist.h"
|
||||||
#include "sourcesmodel.h"
|
#include "sourcesmodel.h"
|
||||||
#include "sourcetree/items/collectionitem.h"
|
#include "sourcetree/items/collectionitem.h"
|
||||||
|
|
||||||
@@ -51,13 +52,13 @@ SourcesProxyModel::showOfflineSources( bool offlineSourcesShown )
|
|||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
if ( !m_filtered )
|
if ( !m_filtered )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
CollectionItem* sti = qobject_cast< CollectionItem* >( m_model->data( sourceModel()->index( sourceRow, 0, sourceParent ), SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
CollectionItem* sti = qobject_cast< CollectionItem* >( m_model->data( sourceModel()->index( sourceRow, 0, sourceParent ), SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
||||||
if ( sti )
|
if ( sti )
|
||||||
{
|
{
|
||||||
@@ -70,6 +71,7 @@ SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePar
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourcesProxyModel::selectRequested( const QModelIndex& idx )
|
SourcesProxyModel::selectRequested( const QModelIndex& idx )
|
||||||
{
|
{
|
||||||
@@ -77,6 +79,7 @@ SourcesProxyModel::selectRequested( const QModelIndex& idx )
|
|||||||
emit selectRequest( mapFromSource( idx ) );
|
emit selectRequest( mapFromSource( idx ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourcesProxyModel::expandRequested( const QModelIndex& idx )
|
SourcesProxyModel::expandRequested( const QModelIndex& idx )
|
||||||
{
|
{
|
||||||
@@ -84,3 +87,28 @@ SourcesProxyModel::expandRequested( const QModelIndex& idx )
|
|||||||
emit expandRequest( mapFromSource( 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:
|
protected:
|
||||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||||
|
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SourcesModel* m_model;
|
SourcesModel* m_model;
|
||||||
|
Reference in New Issue
Block a user