mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-14 18:14:50 +02:00
Merge remote branch 'origin/master' into dynamic
Conflicts: src/libtomahawk/artist.cpp src/libtomahawk/artist.h src/playlist/playlistmanager.cpp src/playlist/playlistmodel.cpp
This commit is contained in:
@@ -30,8 +30,9 @@ public:
|
|||||||
Tomahawk::collection_ptr collection() const { return m_collection; }
|
Tomahawk::collection_ptr collection() const { return m_collection; }
|
||||||
QList<Tomahawk::query_ptr> tracks();
|
QList<Tomahawk::query_ptr> tracks();
|
||||||
|
|
||||||
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
|
||||||
virtual int trackCount() const { return m_queries.count(); }
|
virtual int trackCount() const { return m_queries.count(); }
|
||||||
|
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||||
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
|
@@ -30,9 +30,11 @@ Artist::get( unsigned int id, const QString& name, const Tomahawk::collection_pt
|
|||||||
|
|
||||||
|
|
||||||
Artist::Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection )
|
Artist::Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection )
|
||||||
: m_id( id )
|
: PlaylistInterface( this )
|
||||||
|
, m_id( id )
|
||||||
, m_name( name )
|
, m_name( name )
|
||||||
, m_collection( collection )
|
, m_collection( collection )
|
||||||
|
, m_currentTrack( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,3 +44,48 @@ Artist::collection() const
|
|||||||
{
|
{
|
||||||
return m_collection;
|
return m_collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
m_queries << tracks;
|
||||||
|
emit tracksAdded( tracks, collection );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
Artist::siblingItem( int itemsAway )
|
||||||
|
{
|
||||||
|
int p = m_currentTrack;
|
||||||
|
p += itemsAway;
|
||||||
|
|
||||||
|
if ( p < 0 )
|
||||||
|
return Tomahawk::result_ptr();
|
||||||
|
|
||||||
|
if ( p >= m_queries.count() )
|
||||||
|
return Tomahawk::result_ptr();
|
||||||
|
|
||||||
|
m_currentTrack = p;
|
||||||
|
return m_queries.at( p )->results().first();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<Tomahawk::query_ptr>
|
||||||
|
Artist::tracks()
|
||||||
|
{
|
||||||
|
if ( m_queries.isEmpty() )
|
||||||
|
{
|
||||||
|
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
|
||||||
|
cmd->setArtist( this );
|
||||||
|
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
|
||||||
|
|
||||||
|
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||||
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_queries;
|
||||||
|
}
|
||||||
|
@@ -5,19 +5,23 @@
|
|||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
|
||||||
|
#include "playlistinterface.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
class DLLEXPORT Artist : public QObject
|
class DLLEXPORT Artist : public QObject, public PlaylistInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static artist_ptr get( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
|
static artist_ptr get( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
|
||||||
Artist();
|
|
||||||
Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
|
Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
|
||||||
|
|
||||||
|
Artist();
|
||||||
virtual ~Artist();
|
virtual ~Artist();
|
||||||
|
|
||||||
unsigned int id() const { return m_id; }
|
unsigned int id() const { return m_id; }
|
||||||
@@ -25,13 +29,38 @@ public:
|
|||||||
|
|
||||||
Tomahawk::collection_ptr collection() const;
|
Tomahawk::collection_ptr collection() const;
|
||||||
|
|
||||||
// QList<Tomahawk::query_ptr> tracks();
|
QList<Tomahawk::query_ptr> tracks();
|
||||||
// virtual int trackCount() const { return 0; }
|
|
||||||
|
virtual int trackCount() const { return 0; }
|
||||||
|
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||||
|
|
||||||
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
|
||||||
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
|
virtual bool shuffled() const { return false; }
|
||||||
|
|
||||||
|
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||||
|
virtual void setShuffled( bool ) {}
|
||||||
|
|
||||||
|
virtual void setFilter( const QString& pattern ) {}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& );
|
||||||
|
void trackCountChanged( unsigned int tracks );
|
||||||
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
|
QList<Tomahawk::query_ptr> m_queries;
|
||||||
|
unsigned int m_currentTrack;
|
||||||
Tomahawk::collection_ptr m_collection;
|
Tomahawk::collection_ptr m_collection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -18,6 +18,10 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Album:
|
||||||
|
m_orderToken = "album.name, file_join.albumpos";
|
||||||
|
break;
|
||||||
|
|
||||||
case ModificationTime:
|
case ModificationTime:
|
||||||
m_orderToken = "file.mtime";
|
m_orderToken = "file.mtime";
|
||||||
break;
|
break;
|
||||||
@@ -37,9 +41,10 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
"AND file_join.artist = artist.id "
|
"AND file_join.artist = artist.id "
|
||||||
"AND file_join.track = track.id "
|
"AND file_join.track = track.id "
|
||||||
"AND file.source %1 "
|
"AND file.source %1 "
|
||||||
"%2 "
|
"%2 %3 "
|
||||||
"%3 %4 %5"
|
"%4 %5 %6"
|
||||||
).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) )
|
).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) )
|
||||||
|
.arg( !m_artist ? QString() : QString( "AND artist.id = %1" ).arg( m_artist->id() ) )
|
||||||
.arg( !m_album ? QString() : QString( "AND album.id = %1" ).arg( m_album->id() ) )
|
.arg( !m_album ? QString() : QString( "AND album.id = %1" ).arg( m_album->id() ) )
|
||||||
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( m_orderToken ) : QString() )
|
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( m_orderToken ) : QString() )
|
||||||
.arg( m_sortDescending ? "DESC" : QString() )
|
.arg( m_sortDescending ? "DESC" : QString() )
|
||||||
|
@@ -17,13 +17,15 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
enum SortOrder {
|
enum SortOrder {
|
||||||
None = 0,
|
None = 0,
|
||||||
ModificationTime = 1,
|
Album = 1,
|
||||||
AlbumPosition = 2
|
ModificationTime = 2,
|
||||||
|
AlbumPosition = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit DatabaseCommand_AllTracks( const Tomahawk::collection_ptr& collection, QObject* parent = 0 )
|
explicit DatabaseCommand_AllTracks( const Tomahawk::collection_ptr& collection, QObject* parent = 0 )
|
||||||
: DatabaseCommand( parent )
|
: DatabaseCommand( parent )
|
||||||
, m_collection( collection )
|
, m_collection( collection )
|
||||||
|
, m_artist( 0 )
|
||||||
, m_album( 0 )
|
, m_album( 0 )
|
||||||
, m_amount( 0 )
|
, m_amount( 0 )
|
||||||
, m_sortOrder( DatabaseCommand_AllTracks::None )
|
, m_sortOrder( DatabaseCommand_AllTracks::None )
|
||||||
@@ -35,7 +37,9 @@ public:
|
|||||||
virtual bool doesMutates() const { return false; }
|
virtual bool doesMutates() const { return false; }
|
||||||
virtual QString commandname() const { return "alltracks"; }
|
virtual QString commandname() const { return "alltracks"; }
|
||||||
|
|
||||||
|
void setArtist( Tomahawk::Artist* artist ) { m_artist = artist; }
|
||||||
void setAlbum( Tomahawk::Album* album ) { m_album = album; }
|
void setAlbum( Tomahawk::Album* album ) { m_album = album; }
|
||||||
|
|
||||||
void setLimit( unsigned int amount ) { m_amount = amount; }
|
void setLimit( unsigned int amount ) { m_amount = amount; }
|
||||||
void setSortOrder( DatabaseCommand_AllTracks::SortOrder order ) { m_sortOrder = order; }
|
void setSortOrder( DatabaseCommand_AllTracks::SortOrder order ) { m_sortOrder = order; }
|
||||||
void setSortDescending( bool descending ) { m_sortDescending = descending; }
|
void setSortDescending( bool descending ) { m_sortDescending = descending; }
|
||||||
@@ -46,7 +50,10 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Tomahawk::collection_ptr m_collection;
|
Tomahawk::collection_ptr m_collection;
|
||||||
|
|
||||||
|
Tomahawk::Artist* m_artist;
|
||||||
Tomahawk::Album* m_album;
|
Tomahawk::Album* m_album;
|
||||||
|
|
||||||
unsigned int m_amount;
|
unsigned int m_amount;
|
||||||
DatabaseCommand_AllTracks::SortOrder m_sortOrder;
|
DatabaseCommand_AllTracks::SortOrder m_sortOrder;
|
||||||
bool m_sortDescending;
|
bool m_sortDescending;
|
||||||
|
@@ -13,7 +13,7 @@ class DLLEXPORT PlaylistInterface
|
|||||||
public:
|
public:
|
||||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||||
|
|
||||||
PlaylistInterface( QObject* parent ) : m_widget( 0 ), m_object( parent ) {}
|
PlaylistInterface( QObject* parent = 0 ) : m_widget( 0 ), m_object( parent ) {}
|
||||||
virtual ~PlaylistInterface() {}
|
virtual ~PlaylistInterface() {}
|
||||||
|
|
||||||
virtual int unfilteredTrackCount() const = 0;
|
virtual int unfilteredTrackCount() const = 0;
|
||||||
|
@@ -154,11 +154,12 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
|||||||
qDebug() << Q_FUNC_INFO << &album << album.data();
|
qDebug() << Q_FUNC_INFO << &album << album.data();
|
||||||
unlinkPlaylist();
|
unlinkPlaylist();
|
||||||
|
|
||||||
m_playlistModel->loadAlbum( album );
|
m_playlistModel->appendAlbum( album );
|
||||||
m_stack->setCurrentWidget( m_playlistView );
|
m_stack->setCurrentWidget( m_playlistView );
|
||||||
|
|
||||||
m_currentInterface = m_playlistView->proxyModel();
|
m_currentInterface = m_playlistView->proxyModel();
|
||||||
|
|
||||||
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = false;
|
m_statsAvailable = false;
|
||||||
m_modesAvailable = false;
|
m_modesAvailable = false;
|
||||||
|
@@ -95,22 +95,11 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistModel::loadAlbum( const Tomahawk::album_ptr& album )
|
PlaylistModel::appendAlbum( const Tomahawk::album_ptr& album )
|
||||||
{
|
{
|
||||||
if ( album.isNull() )
|
if ( album.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( rowCount( QModelIndex() ) )
|
|
||||||
{
|
|
||||||
emit beginRemoveRows( QModelIndex(), 0, rowCount( QModelIndex() ) - 1 );
|
|
||||||
delete m_rootItem;
|
|
||||||
emit endRemoveRows();
|
|
||||||
m_rootItem = new PlItem( 0, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_playlist.clear();
|
|
||||||
setReadOnly( false );
|
|
||||||
|
|
||||||
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
@@ -118,6 +107,19 @@ PlaylistModel::loadAlbum( const Tomahawk::album_ptr& album )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistModel::appendArtist( const Tomahawk::artist_ptr& artist )
|
||||||
|
{
|
||||||
|
if ( artist.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
connect( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||||
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
|
onTracksAdded( artist->tracks(), artist->collection() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amount )
|
PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amount )
|
||||||
{
|
{
|
||||||
|
@@ -31,10 +31,12 @@ public:
|
|||||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
||||||
|
|
||||||
void loadPlaylist( const Tomahawk::playlist_ptr& playlist );
|
void loadPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||||
void loadAlbum( const Tomahawk::album_ptr& album );
|
|
||||||
void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 );
|
void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 );
|
||||||
|
|
||||||
void appendTrack( const Tomahawk::query_ptr& query );
|
void appendTrack( const Tomahawk::query_ptr& query );
|
||||||
|
void appendAlbum( const Tomahawk::album_ptr& album );
|
||||||
|
void appendArtist( const Tomahawk::artist_ptr& artist );
|
||||||
|
|
||||||
void insertTrack( unsigned int row, const Tomahawk::query_ptr& query );
|
void insertTrack( unsigned int row, const Tomahawk::query_ptr& query );
|
||||||
|
|
||||||
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
||||||
|
@@ -296,8 +296,14 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
|||||||
p.save();
|
p.save();
|
||||||
p.setRenderHint( QPainter::Antialiasing );
|
p.setRenderHint( QPainter::Antialiasing );
|
||||||
|
|
||||||
if ( elidedText == s && m_hoverArea.width() )
|
if ( m_hoverArea.width() )
|
||||||
{
|
{
|
||||||
|
if ( elidedText != s )
|
||||||
|
{
|
||||||
|
m_hoverArea.setLeft( 0 );
|
||||||
|
m_hoverArea.setRight( fontMetrics().width( elidedText ) + contentsMargins().left() * 2 );
|
||||||
|
}
|
||||||
|
|
||||||
p.setPen( palette().mid().color() );
|
p.setPen( palette().mid().color() );
|
||||||
p.setBrush( palette().highlight() );
|
p.setBrush( palette().highlight() );
|
||||||
p.drawRoundedRect( m_hoverArea, 4.0, 4.0 );
|
p.drawRoundedRect( m_hoverArea, 4.0, 4.0 );
|
||||||
|
Reference in New Issue
Block a user