mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
* Fixed sidebar sorting for items with identical names.
This commit is contained in:
@@ -138,6 +138,18 @@ CollectionItem::text() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
CollectionItem::IDValue() const
|
||||||
|
{
|
||||||
|
if( m_source.isNull() )
|
||||||
|
return -1;
|
||||||
|
if( m_source->isLocal() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return m_source->id();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
CollectionItem::peerSortValue() const
|
CollectionItem::peerSortValue() const
|
||||||
{
|
{
|
||||||
|
@@ -37,6 +37,7 @@ public:
|
|||||||
virtual void activate();
|
virtual void activate();
|
||||||
virtual QIcon icon() const;
|
virtual QIcon icon() const;
|
||||||
virtual int peerSortValue() const;
|
virtual int peerSortValue() const;
|
||||||
|
virtual int IDValue() const;
|
||||||
|
|
||||||
Tomahawk::source_ptr source() const;
|
Tomahawk::source_ptr source() const;
|
||||||
|
|
||||||
|
@@ -87,6 +87,13 @@ PlaylistItem::peerSortValue() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
PlaylistItem::IDValue() const
|
||||||
|
{
|
||||||
|
return m_playlist->createdOn();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Qt::ItemFlags
|
Qt::ItemFlags
|
||||||
PlaylistItem::flags() const
|
PlaylistItem::flags() const
|
||||||
{
|
{
|
||||||
@@ -244,6 +251,13 @@ DynamicPlaylistItem::peerSortValue() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
DynamicPlaylistItem::IDValue() const
|
||||||
|
{
|
||||||
|
return m_dynplaylist->createdOn();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicPlaylistItem::checkReparentHackNeeded( const DynamicPlaylistRevision& revision )
|
DynamicPlaylistItem::checkReparentHackNeeded( const DynamicPlaylistRevision& revision )
|
||||||
{
|
{
|
||||||
|
@@ -38,6 +38,7 @@ public:
|
|||||||
virtual QIcon icon() const;
|
virtual QIcon icon() const;
|
||||||
virtual bool setData(const QVariant& v, bool role);
|
virtual bool setData(const QVariant& v, bool role);
|
||||||
virtual int peerSortValue() const;
|
virtual int peerSortValue() const;
|
||||||
|
virtual int IDValue() const;
|
||||||
|
|
||||||
virtual bool activateCurrent();
|
virtual bool activateCurrent();
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ public:
|
|||||||
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
||||||
virtual void activate();
|
virtual void activate();
|
||||||
virtual int peerSortValue() const;
|
virtual int peerSortValue() const;
|
||||||
|
virtual int IDValue() const;
|
||||||
virtual QIcon icon() const;
|
virtual QIcon icon() const;
|
||||||
|
|
||||||
virtual bool activateCurrent();
|
virtual bool activateCurrent();
|
||||||
|
@@ -55,6 +55,7 @@ public:
|
|||||||
virtual bool dropMimeData( const QMimeData*, Qt::DropAction ) { return false; }
|
virtual bool dropMimeData( const QMimeData*, Qt::DropAction ) { return false; }
|
||||||
virtual bool setData( const QVariant&, bool ) { return false; }
|
virtual bool setData( const QVariant&, bool ) { return false; }
|
||||||
virtual int peerSortValue() const { return 0; } // How to sort relative to peers in the tree.
|
virtual int peerSortValue() const { return 0; } // How to sort relative to peers in the tree.
|
||||||
|
virtual int IDValue() const { return 0; }
|
||||||
|
|
||||||
/// don't call me unless you are a sourcetreeitem. i prefer this to making everyone a friend
|
/// don't call me unless you are a sourcetreeitem. i prefer this to making everyone a friend
|
||||||
void beginRowsAdded( int from, int to ) { emit beginChildRowsAdded( from, to ); }
|
void beginRowsAdded( int from, int to ) { emit beginChildRowsAdded( from, to ); }
|
||||||
|
@@ -106,6 +106,8 @@ SourcesModel::data( const QModelIndex& index, int role ) const
|
|||||||
return itemFromIndex( index )->icon();
|
return itemFromIndex( index )->icon();
|
||||||
case SourcesModel::SortRole:
|
case SourcesModel::SortRole:
|
||||||
return itemFromIndex( index )->peerSortValue();
|
return itemFromIndex( index )->peerSortValue();
|
||||||
|
case SourcesModel::IDRole:
|
||||||
|
return itemFromIndex( index )->IDValue();
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,8 @@ public:
|
|||||||
enum Roles {
|
enum Roles {
|
||||||
SourceTreeItemRole = Qt::UserRole + 10,
|
SourceTreeItemRole = Qt::UserRole + 10,
|
||||||
SourceTreeItemTypeRole = Qt::UserRole + 11,
|
SourceTreeItemTypeRole = Qt::UserRole + 11,
|
||||||
SortRole = Qt::UserRole + 12
|
SortRole = Qt::UserRole + 12,
|
||||||
|
IDRole = Qt::UserRole + 13
|
||||||
};
|
};
|
||||||
|
|
||||||
SourcesModel( QObject* parent = 0 );
|
SourcesModel( QObject* parent = 0 );
|
||||||
|
@@ -94,5 +94,11 @@ SourcesProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right )
|
|||||||
if ( m_model->data( left, SourcesModel::SortRole ) != m_model->data( right, SourcesModel::SortRole ) )
|
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 ( 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;
|
const QString& lefts = left.data().toString().toLower();
|
||||||
|
const QString& rights = right.data().toString().toLower();
|
||||||
|
|
||||||
|
if ( lefts == rights )
|
||||||
|
return ( m_model->data( left, SourcesModel::IDRole ).toInt() < m_model->data( right, SourcesModel::IDRole ).toInt() );
|
||||||
|
else
|
||||||
|
return QString::localeAwareCompare( lefts, rights ) < 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user