mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-01-18 23:17:59 +01:00
* Robustified and cleaned up the PlaylistManager class.
* artist_ptr caching. * Added basic AlbumView. (click the cloud icon in mainwindow's toolbar for now)
This commit is contained in:
parent
e2f6d2891d
commit
fdc5db522d
@ -29,6 +29,7 @@ public:
|
||||
Tomahawk::collection_ptr collection() const { return m_collection; }
|
||||
QList<Tomahawk::query_ptr> tracks();
|
||||
|
||||
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||
virtual int trackCount() const { return m_queries.count(); }
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
|
||||
@ -38,12 +39,15 @@ public:
|
||||
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 );
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "tomahawk/typedefs.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
@ -12,14 +14,23 @@ class Artist : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Artist( const QString& name )
|
||||
: m_name( name )
|
||||
{};
|
||||
static artist_ptr get( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
|
||||
|
||||
Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection );
|
||||
|
||||
unsigned int id() const { return m_id; }
|
||||
QString name() const { return m_name; }
|
||||
|
||||
Tomahawk::collection_ptr collection() const { return m_collection; }
|
||||
|
||||
// QList<Tomahawk::query_ptr> tracks();
|
||||
// virtual int trackCount() const { return 0; }
|
||||
|
||||
private:
|
||||
unsigned int m_id;
|
||||
QString m_name;
|
||||
|
||||
Tomahawk::collection_ptr m_collection;
|
||||
};
|
||||
|
||||
}; // ns
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define PLAYLISTINTERFACE_H
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QWidget>
|
||||
|
||||
#include "tomahawk/typedefs.h"
|
||||
|
||||
@ -10,9 +11,10 @@ class PlaylistInterface
|
||||
public:
|
||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||
|
||||
PlaylistInterface() {}
|
||||
PlaylistInterface( QObject* parent ) : m_widget( 0 ), m_object( parent ) {}
|
||||
virtual ~PlaylistInterface() {}
|
||||
|
||||
virtual int unfilteredTrackCount() const = 0;
|
||||
virtual int trackCount() const = 0;
|
||||
|
||||
virtual Tomahawk::result_ptr previousItem() { return siblingItem( -1 ); }
|
||||
@ -22,6 +24,13 @@ public:
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const = 0;
|
||||
virtual bool shuffled() const = 0;
|
||||
|
||||
virtual void setFilter( const QString& pattern ) = 0;
|
||||
|
||||
QWidget* widget() const { return m_widget; }
|
||||
void setWidget( QWidget* widget ) { m_widget = widget; }
|
||||
|
||||
QObject* object() const { return m_object; }
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) = 0;
|
||||
virtual void setShuffled( bool enabled ) = 0;
|
||||
@ -30,6 +39,11 @@ signals:
|
||||
virtual void repeatModeChanged( PlaylistInterface::RepeatMode mode ) = 0;
|
||||
virtual void shuffleModeChanged( bool enabled ) = 0;
|
||||
virtual void trackCountChanged( unsigned int tracks ) = 0;
|
||||
virtual void sourceTrackCountChanged( unsigned int tracks ) = 0;
|
||||
|
||||
private:
|
||||
QWidget* m_widget;
|
||||
QObject* m_object;
|
||||
};
|
||||
|
||||
#endif // PLAYLISTINTERFACE_H
|
||||
|
@ -27,6 +27,7 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" )
|
||||
#ENDFOREACH( moddir )
|
||||
|
||||
SET( tomahawkSources ${tomahawkSources}
|
||||
artist.cpp
|
||||
album.cpp
|
||||
pipeline.cpp
|
||||
playlist.cpp
|
||||
|
@ -28,7 +28,8 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
|
||||
|
||||
|
||||
Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist, const Tomahawk::collection_ptr& collection )
|
||||
: m_id( id )
|
||||
: PlaylistInterface( this )
|
||||
, m_id( id )
|
||||
, m_name( name )
|
||||
, m_artist( artist )
|
||||
, m_collection( collection )
|
||||
|
35
src/artist.cpp
Normal file
35
src/artist.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "tomahawk/artist.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "tomahawk/collection.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
artist_ptr
|
||||
Artist::get( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
static QHash< unsigned int, artist_ptr > s_artists;
|
||||
|
||||
if ( s_artists.contains( id ) )
|
||||
{
|
||||
return s_artists.value( id );
|
||||
}
|
||||
|
||||
artist_ptr a = artist_ptr( new Artist( id, name, collection ) );
|
||||
s_artists.insert( id, a );
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
Artist::Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection )
|
||||
: m_id( id )
|
||||
, m_name( name )
|
||||
, m_collection( collection )
|
||||
{
|
||||
}
|
@ -41,7 +41,7 @@ DatabaseCommand_AllAlbums::exec( DatabaseImpl* dbi )
|
||||
|
||||
while( query.next() )
|
||||
{
|
||||
Tomahawk::artist_ptr artist = Tomahawk::artist_ptr( new Tomahawk::Artist( query.value( 3 ).toString() ) );
|
||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 2 ).toUInt(), query.value( 3 ).toString(), m_collection );
|
||||
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 0 ).toUInt(), query.value( 1 ).toString(), artist, m_collection );
|
||||
|
||||
al << album;
|
||||
|
@ -170,6 +170,9 @@ DatabaseImpl::file( int fid )
|
||||
m["mimetype"] = query.value( 4 ).toString();
|
||||
m["duration"] = query.value( 5 ).toInt();
|
||||
m["bitrate"] = query.value( 6 ).toInt();
|
||||
m["artistid"] = query.value( 7 ).toInt();
|
||||
m["albumid"] = query.value( 8 ).toInt();
|
||||
m["trackid"] = query.value( 8 ).toInt();
|
||||
m["artist"] = query.value( 10 ).toString();
|
||||
m["album"] = query.value( 11 ).toString();
|
||||
m["track"] = query.value( 12 ).toString();
|
||||
|
@ -211,6 +211,22 @@ AlbumModel::removeIndexes( const QList<QModelIndex>& indexes )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumModel::addCollection( const collection_ptr& collection )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << collection->name()
|
||||
<< collection->source()->id()
|
||||
<< collection->source()->userName();
|
||||
|
||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
||||
|
||||
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ),
|
||||
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ) );
|
||||
|
||||
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order )
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
class QMetaData;
|
||||
|
||||
class AlbumModel : public QAbstractItemModel, public PlaylistInterface
|
||||
class AlbumModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -38,8 +38,6 @@ public:
|
||||
virtual void removeIndex( const QModelIndex& index );
|
||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction ) { return Tomahawk::result_ptr(); }
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
@ -47,6 +45,7 @@ public:
|
||||
virtual QStringList mimeTypes() const;
|
||||
virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
|
||||
|
||||
void addCollection( const Tomahawk::collection_ptr& collection );
|
||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order );
|
||||
|
||||
AlbumItem* itemFromIndex( const QModelIndex& index ) const
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
AlbumProxyModel::AlbumProxyModel( QObject* parent )
|
||||
: QSortFilterProxyModel( parent )
|
||||
, PlaylistInterface( this )
|
||||
, m_model( 0 )
|
||||
{
|
||||
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
||||
@ -26,15 +27,18 @@ AlbumProxyModel::setSourceModel( AlbumModel* sourceModel )
|
||||
{
|
||||
m_model = sourceModel;
|
||||
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
|
||||
|
||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumProxyModel::setFilterRegExp( const QString& pattern )
|
||||
AlbumProxyModel::setFilter( const QString& pattern )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QSortFilterProxyModel::setFilterRegExp( pattern );
|
||||
setFilterRegExp( pattern );
|
||||
|
||||
emit filterChanged( pattern );
|
||||
}
|
||||
@ -53,11 +57,11 @@ AlbumProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen
|
||||
const Tomahawk::album_ptr& q = pi->album();
|
||||
|
||||
QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
|
||||
bool found = true;
|
||||
|
||||
bool found = true;
|
||||
foreach( const QString& s, sl )
|
||||
{
|
||||
if ( !q->name().contains( s, Qt::CaseInsensitive ) )
|
||||
if ( !q->name().contains( s, Qt::CaseInsensitive ) && !q->artist()->name().contains( s, Qt::CaseInsensitive ) )
|
||||
{
|
||||
found = false;
|
||||
}
|
||||
@ -98,5 +102,5 @@ Tomahawk::result_ptr
|
||||
AlbumProxyModel::siblingItem( int itemsAway )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
return Tomahawk::result_ptr();
|
||||
return Tomahawk::result_ptr( 0 );
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ public:
|
||||
virtual AlbumModel* sourceModel() const { return m_model; }
|
||||
virtual void setSourceModel( AlbumModel* sourceModel );
|
||||
|
||||
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||
virtual int albumCount() const { return rowCount( QModelIndex() ); }
|
||||
|
||||
@ -24,7 +25,7 @@ public:
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction );
|
||||
|
||||
void setFilterRegExp( const QString& pattern );
|
||||
virtual void setFilter( const QString& pattern );
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
@ -34,6 +35,7 @@ signals:
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
|
||||
|
@ -51,6 +51,8 @@ void
|
||||
AlbumView::setProxyModel( AlbumProxyModel* model )
|
||||
{
|
||||
m_proxyModel = model;
|
||||
qDebug() << "NOOOOOOOOOOOOOOW CUUUUUUUUUUUUUUUUUR:" << m_proxyModel << (PlaylistInterface*)m_proxyModel;
|
||||
|
||||
setItemDelegate( new AlbumItemDelegate( this, m_proxyModel ) );
|
||||
|
||||
QListView::setModel( m_proxyModel );
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void setProxyModel( AlbumProxyModel* model );
|
||||
|
||||
AlbumModel* model() { return m_model; }
|
||||
AlbumProxyModel* proxyModel() { return (AlbumProxyModel*)m_proxyModel; }
|
||||
AlbumProxyModel* proxyModel() { return m_proxyModel; }
|
||||
// PlaylistItemDelegate* delegate() { return m_delegate; }
|
||||
|
||||
void setModel( AlbumModel* model );
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
class QMetaData;
|
||||
|
||||
class CollectionModel : public QAbstractItemModel, public PlaylistInterface
|
||||
class CollectionModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -37,12 +37,6 @@ public:
|
||||
void addCollection( const Tomahawk::collection_ptr& collection );
|
||||
void removeCollection( const Tomahawk::collection_ptr& collection );
|
||||
|
||||
virtual Tomahawk::result_ptr previousItem() { return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::result_ptr nextItem() { return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction ) { return Tomahawk::result_ptr(); }
|
||||
|
||||
virtual void setCurrentItem( const QModelIndex& index ) {}
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
|
@ -77,7 +77,7 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
||||
|
||||
if ( index.column() == index.model()->columnCount() - 1 )
|
||||
{
|
||||
QRect r = QRect( 3, option.rect.y() + 1, m_view->contentsRect().width() - 6, option.rect.height() - 2 );
|
||||
QRect r = QRect( 3, option.rect.y() + 1, m_view->viewport()->width() - 6, option.rect.height() - 2 );
|
||||
painter->setPen( option.palette.highlight().color() );
|
||||
QPen pen = painter->pen();
|
||||
pen.setWidth( 1.0 );
|
||||
|
@ -13,6 +13,9 @@
|
||||
#include "queueview.h"
|
||||
#include "trackproxymodel.h"
|
||||
#include "trackmodel.h"
|
||||
#include "albumview.h"
|
||||
#include "albumproxymodel.h"
|
||||
#include "albummodel.h"
|
||||
|
||||
#include "infowidgets/sourceinfowidget.h"
|
||||
|
||||
@ -22,9 +25,7 @@
|
||||
PlaylistManager::PlaylistManager( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_widget( new QWidget() )
|
||||
, m_currentProxyModel( 0 )
|
||||
, m_currentModel( 0 )
|
||||
, m_currentView( 0 )
|
||||
, m_currentInterface( 0 )
|
||||
, m_currentMode( 0 )
|
||||
, m_superCollectionVisible( true )
|
||||
{
|
||||
@ -54,7 +55,7 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
||||
m_superCollectionView->setModel( m_superCollectionFlatModel );
|
||||
|
||||
m_stack->addWidget( m_superCollectionView );
|
||||
m_currentView = m_superCollectionView;
|
||||
m_currentInterface = m_superCollectionView->proxyModel();
|
||||
|
||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||
}
|
||||
@ -84,26 +85,20 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
PlaylistModel* model = new PlaylistModel();
|
||||
view->setModel( model );
|
||||
|
||||
m_currentProxyModel = view->proxyModel();
|
||||
m_currentModel = view->model();
|
||||
|
||||
model->loadPlaylist( playlist );
|
||||
playlist->resolve();
|
||||
|
||||
m_currentInterface = view->proxyModel();
|
||||
m_playlistViews.insert( playlist, view );
|
||||
m_views.insert( (PlaylistInterface*)m_currentProxyModel, view );
|
||||
|
||||
m_stack->addWidget( view );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentView = view;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaylistView* view = m_playlistViews.value( playlist );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentProxyModel = view->proxyModel();
|
||||
m_currentModel = view->model();
|
||||
m_currentView = view;
|
||||
m_currentInterface = view->proxyModel();
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
@ -125,26 +120,19 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||
PlaylistView* view = new PlaylistView();
|
||||
PlaylistModel* model = new PlaylistModel();
|
||||
view->setModel( model );
|
||||
|
||||
m_currentProxyModel = view->proxyModel();
|
||||
m_currentModel = view->model();
|
||||
|
||||
model->loadAlbum( album );
|
||||
|
||||
m_currentInterface = view->proxyModel();
|
||||
m_albumViews.insert( album, view );
|
||||
m_views.insert( (PlaylistInterface*)m_currentProxyModel, view );
|
||||
|
||||
m_stack->addWidget( view );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentView = view;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaylistView* view = m_albumViews.value( album );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentProxyModel = view->proxyModel();
|
||||
m_currentModel = view->model();
|
||||
m_currentView = view;
|
||||
m_currentInterface = view->proxyModel();
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
@ -160,31 +148,50 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
unlinkPlaylist();
|
||||
|
||||
if ( !m_collectionViews.contains( collection ) )
|
||||
if ( m_currentMode == 0 )
|
||||
{
|
||||
CollectionView* view = new CollectionView();
|
||||
CollectionFlatModel* model = new CollectionFlatModel();
|
||||
view->setModel( model );
|
||||
if ( !m_collectionViews.contains( collection ) )
|
||||
{
|
||||
CollectionView* view = new CollectionView();
|
||||
CollectionFlatModel* model = new CollectionFlatModel();
|
||||
view->setModel( model );
|
||||
model->addCollection( collection );
|
||||
|
||||
m_currentProxyModel = view->proxyModel();
|
||||
m_currentModel = view->model();
|
||||
m_currentInterface = view->proxyModel();
|
||||
m_collectionViews.insert( collection, view );
|
||||
|
||||
model->addCollection( collection );
|
||||
|
||||
m_collectionViews.insert( collection, view );
|
||||
m_views.insert( (PlaylistInterface*)m_currentProxyModel, view );
|
||||
|
||||
m_stack->addWidget( view );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentView = view;
|
||||
m_stack->addWidget( view );
|
||||
m_stack->setCurrentWidget( view );
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectionView* view = m_collectionViews.value( collection );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentInterface = view->proxyModel();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ( m_currentMode == 2 )
|
||||
{
|
||||
CollectionView* view = m_collectionViews.value( collection );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentProxyModel = view->proxyModel();
|
||||
m_currentModel = view->model();
|
||||
m_currentView = view;
|
||||
if ( !m_collectionAlbumViews.contains( collection ) )
|
||||
{
|
||||
AlbumView* aview = new AlbumView();
|
||||
AlbumModel* amodel = new AlbumModel( aview );
|
||||
aview->setModel( amodel );
|
||||
amodel->addCollection( collection );
|
||||
|
||||
m_currentInterface = aview->proxyModel();
|
||||
m_collectionAlbumViews.insert( collection, aview );
|
||||
|
||||
m_stack->addWidget( aview );
|
||||
m_stack->setCurrentWidget( aview );
|
||||
}
|
||||
else
|
||||
{
|
||||
AlbumView* view = m_collectionAlbumViews.value( collection );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentInterface = view->proxyModel();
|
||||
}
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
@ -200,9 +207,7 @@ PlaylistManager::show( const Tomahawk::source_ptr& source )
|
||||
{
|
||||
unlinkPlaylist();
|
||||
|
||||
m_currentProxyModel = 0;
|
||||
m_currentModel = 0;
|
||||
m_currentView = 0;
|
||||
m_currentInterface = 0;
|
||||
|
||||
if ( !m_sourceViews.contains( source ) )
|
||||
{
|
||||
@ -237,10 +242,7 @@ PlaylistManager::showSuperCollection()
|
||||
}
|
||||
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
m_currentProxyModel = m_superCollectionView->proxyModel();
|
||||
m_currentModel = m_superCollectionView->model();
|
||||
m_currentView = m_superCollectionView;
|
||||
m_views.insert( (PlaylistInterface*)m_currentProxyModel, m_superCollectionView );
|
||||
m_currentInterface = m_superCollectionView->proxyModel();
|
||||
|
||||
m_superCollectionVisible = true;
|
||||
linkPlaylist();
|
||||
@ -250,6 +252,16 @@ PlaylistManager::showSuperCollection()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setTableMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = 0;
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setTreeMode()
|
||||
{
|
||||
@ -263,11 +275,11 @@ PlaylistManager::setTreeMode()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setTableMode()
|
||||
PlaylistManager::setAlbumMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = 0;
|
||||
m_currentMode = 2;
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
}
|
||||
|
||||
@ -319,30 +331,27 @@ PlaylistManager::applyFilter()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( m_currentProxyModel )
|
||||
m_currentProxyModel->setFilterRegExp( m_filter );
|
||||
if ( m_currentInterface )
|
||||
m_currentInterface->setFilter( m_filter );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::unlinkPlaylist()
|
||||
{
|
||||
if ( m_currentModel )
|
||||
if ( m_currentInterface )
|
||||
{
|
||||
disconnect( m_currentModel, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
}
|
||||
disconnect( m_currentInterface->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ),
|
||||
this, SIGNAL( numTracksChanged( unsigned int ) ) );
|
||||
|
||||
if ( m_currentProxyModel )
|
||||
{
|
||||
disconnect( m_currentProxyModel, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
disconnect( m_currentInterface->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
this, SIGNAL( numShownChanged( unsigned int ) ) );
|
||||
|
||||
disconnect( m_currentProxyModel, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
this, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||
disconnect( m_currentInterface->object(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
this, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||
|
||||
disconnect( m_currentProxyModel, SIGNAL( shuffleModeChanged( bool ) ),
|
||||
this, SIGNAL( shuffleModeChanged( bool ) ) );
|
||||
disconnect( m_currentInterface->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
this, SIGNAL( shuffleModeChanged( bool ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,68 +359,62 @@ PlaylistManager::unlinkPlaylist()
|
||||
void
|
||||
PlaylistManager::linkPlaylist()
|
||||
{
|
||||
connect( m_currentModel, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
if ( m_currentInterface )
|
||||
{
|
||||
connect( m_currentInterface->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ),
|
||||
this, SIGNAL( numTracksChanged( unsigned int ) ) );
|
||||
|
||||
connect( m_currentProxyModel, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
connect( m_currentInterface->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
this, SIGNAL( numShownChanged( unsigned int ) ) );
|
||||
|
||||
connect( m_currentProxyModel, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
this, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||
connect( m_currentInterface->object(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
this, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||
|
||||
connect( m_currentProxyModel, SIGNAL( shuffleModeChanged( bool ) ),
|
||||
this, SIGNAL( shuffleModeChanged( bool ) ) );
|
||||
connect( m_currentInterface->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
this, SIGNAL( shuffleModeChanged( bool ) ) );
|
||||
}
|
||||
|
||||
applyFilter();
|
||||
APP->audioEngine()->setPlaylist( (PlaylistInterface*)m_currentProxyModel );
|
||||
APP->audioEngine()->setPlaylist( m_currentInterface );
|
||||
|
||||
emit numTracksChanged( m_currentModel->trackCount() );
|
||||
emit repeatModeChanged( m_currentProxyModel->repeatMode() );
|
||||
emit shuffleModeChanged( m_currentProxyModel->shuffled() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::onTrackCountChanged( unsigned int )
|
||||
{
|
||||
emit numTracksChanged( m_currentModel->trackCount() );
|
||||
emit numShownChanged( m_currentProxyModel->trackCount() );
|
||||
if ( m_currentInterface )
|
||||
{
|
||||
emit numTracksChanged( m_currentInterface->unfilteredTrackCount() );
|
||||
emit numShownChanged( m_currentInterface->trackCount() );
|
||||
emit repeatModeChanged( m_currentInterface->repeatMode() );
|
||||
emit shuffleModeChanged( m_currentInterface->shuffled() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setRepeatMode( PlaylistInterface::RepeatMode mode )
|
||||
{
|
||||
if ( m_currentProxyModel )
|
||||
m_currentProxyModel->setRepeatMode( mode );
|
||||
if ( m_currentInterface )
|
||||
m_currentInterface->setRepeatMode( mode );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setShuffled( bool enabled )
|
||||
{
|
||||
if ( m_currentProxyModel )
|
||||
m_currentProxyModel->setShuffled( enabled );
|
||||
if ( m_currentInterface )
|
||||
m_currentInterface->setShuffled( enabled );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::showCurrentTrack()
|
||||
{
|
||||
PlaylistInterface* playlist = APP->audioEngine()->currentTrackPlaylist();
|
||||
m_currentInterface = APP->audioEngine()->currentTrackPlaylist();
|
||||
|
||||
if ( m_views.contains( playlist ) )
|
||||
{
|
||||
unlinkPlaylist();
|
||||
unlinkPlaylist();
|
||||
|
||||
m_currentView = m_views.value( playlist );
|
||||
m_currentProxyModel = m_currentView->proxyModel();
|
||||
m_currentModel = m_currentView->model();
|
||||
if ( m_currentInterface->widget() )
|
||||
m_stack->setCurrentWidget( m_currentInterface->widget() );
|
||||
|
||||
m_stack->setCurrentWidget( m_currentView );
|
||||
linkPlaylist();
|
||||
}
|
||||
linkPlaylist();
|
||||
|
||||
if ( m_currentView && m_currentProxyModel )
|
||||
m_currentView->scrollTo( m_currentProxyModel->currentItem(), QAbstractItemView::PositionAtCenter );
|
||||
/* if ( m_currentView && m_currentProxyModel )
|
||||
m_currentView->scrollTo( m_currentProxyModel->currentItem(), QAbstractItemView::PositionAtCenter );*/
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "tomahawk/playlistinterface.h"
|
||||
|
||||
class AnimatedSplitter;
|
||||
class AlbumView;
|
||||
class CollectionModel;
|
||||
class CollectionFlatModel;
|
||||
class CollectionView;
|
||||
@ -53,6 +54,7 @@ signals:
|
||||
public slots:
|
||||
void setTreeMode();
|
||||
void setTableMode();
|
||||
void setAlbumMode();
|
||||
|
||||
void showQueue();
|
||||
void hideQueue();
|
||||
@ -64,7 +66,6 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void applyFilter();
|
||||
void onTrackCountChanged( unsigned int );
|
||||
|
||||
private:
|
||||
void unlinkPlaylist();
|
||||
@ -82,15 +83,19 @@ private:
|
||||
|
||||
QList< Tomahawk::collection_ptr > m_superCollections;
|
||||
|
||||
QHash< PlaylistInterface*, TrackView* > m_views;
|
||||
QHash< Tomahawk::collection_ptr, CollectionView* > m_collectionViews;
|
||||
QHash< Tomahawk::collection_ptr, AlbumView* > m_collectionAlbumViews;
|
||||
|
||||
QHash< Tomahawk::playlist_ptr, PlaylistView* > m_playlistViews;
|
||||
QHash< Tomahawk::album_ptr, PlaylistView* > m_albumViews;
|
||||
QHash< Tomahawk::source_ptr, SourceInfoWidget* > m_sourceViews;
|
||||
|
||||
TrackProxyModel* m_currentProxyModel;
|
||||
/*TrackProxyModel* m_currentProxyModel;
|
||||
TrackModel* m_currentModel;
|
||||
TrackView* m_currentView;
|
||||
TrackView* m_currentView;*/
|
||||
|
||||
// QWidget* m_currentView;
|
||||
PlaylistInterface* m_currentInterface;
|
||||
|
||||
QWidget* m_currentInfoWidget;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
class QMetaData;
|
||||
|
||||
class TrackModel : public QAbstractItemModel, public PlaylistInterface
|
||||
class TrackModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -41,8 +41,6 @@ public:
|
||||
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
|
||||
virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction ) { return Tomahawk::result_ptr(); }
|
||||
|
||||
virtual QMimeData* mimeData( const QModelIndexList& indexes ) const;
|
||||
virtual QStringList mimeTypes() const;
|
||||
virtual Qt::DropActions supportedDropActions() const;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
TrackProxyModel::TrackProxyModel( QObject* parent )
|
||||
: QSortFilterProxyModel( parent )
|
||||
, PlaylistInterface( this )
|
||||
, m_model( 0 )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
@ -29,15 +30,19 @@ TrackProxyModel::setSourceModel( TrackModel* sourceModel )
|
||||
{
|
||||
m_model = sourceModel;
|
||||
|
||||
if ( m_model )
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ),
|
||||
SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
|
||||
|
||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackProxyModel::setFilterRegExp( const QString& pattern )
|
||||
TrackProxyModel::setFilter( const QString& pattern )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QSortFilterProxyModel::setFilterRegExp( pattern );
|
||||
setFilterRegExp( pattern );
|
||||
|
||||
emit filterChanged( pattern );
|
||||
emit trackCountChanged( trackCount() );
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
virtual QPersistentModelIndex currentItem() const { return mapFromSource( m_model->currentItem() ); }
|
||||
virtual void setCurrentItem( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||
|
||||
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||
|
||||
virtual void removeIndex( const QModelIndex& index );
|
||||
@ -27,7 +28,7 @@ public:
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
|
||||
void setFilterRegExp( const QString& pattern );
|
||||
virtual void setFilter( const QString& pattern );
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||
virtual bool shuffled() const { return m_shuffled; }
|
||||
@ -39,6 +40,7 @@ signals:
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
|
||||
|
@ -34,6 +34,8 @@ TrackView::TrackView( QWidget* parent )
|
||||
setDragDropOverwriteMode( false );
|
||||
setAllColumnsShowFocus( true );
|
||||
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
||||
setRootIsDecorated( false );
|
||||
setUniformRowHeights( true );
|
||||
setMinimumWidth( 700 );
|
||||
|
||||
setHeader( m_header );
|
||||
@ -58,6 +60,8 @@ void
|
||||
TrackView::setProxyModel( TrackProxyModel* model )
|
||||
{
|
||||
m_proxyModel = model;
|
||||
m_proxyModel->setWidget( this );
|
||||
|
||||
m_delegate = new PlaylistItemDelegate( this, m_proxyModel );
|
||||
setItemDelegate( m_delegate );
|
||||
|
||||
@ -69,17 +73,16 @@ void
|
||||
TrackView::setModel( TrackModel* model )
|
||||
{
|
||||
m_model = model;
|
||||
m_modelInterface = (PlaylistInterface*)model;
|
||||
|
||||
if ( m_proxyModel )
|
||||
{
|
||||
m_proxyModel->setSourceModel( model );
|
||||
}
|
||||
|
||||
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||
|
||||
setAcceptDrops( true );
|
||||
setRootIsDecorated( false );
|
||||
setUniformRowHeights( true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
void setProxyModel( TrackProxyModel* model );
|
||||
|
||||
TrackModel* model() { return m_model; }
|
||||
TrackProxyModel* proxyModel() { return (TrackProxyModel*)m_proxyModel; }
|
||||
TrackProxyModel* proxyModel() { return m_proxyModel; }
|
||||
PlaylistItemDelegate* delegate() { return m_delegate; }
|
||||
TrackHeader* header() { return m_header; }
|
||||
|
||||
@ -59,7 +59,6 @@ private:
|
||||
|
||||
TrackModel* m_model;
|
||||
TrackProxyModel* m_proxyModel;
|
||||
PlaylistInterface* m_modelInterface;
|
||||
PlaylistItemDelegate* m_delegate;
|
||||
TrackHeader* m_header;
|
||||
|
||||
|
@ -11,7 +11,7 @@ Result::Result( const QVariant& v, const collection_ptr& collection )
|
||||
{
|
||||
QVariantMap m = m_v.toMap();
|
||||
|
||||
m_artist = artist_ptr( new Artist( m.value( "artist" ).toString() ) );
|
||||
m_artist = Artist::get( m.value( "artistid" ).toUInt(), m.value( "artist" ).toString(), collection );
|
||||
m_album = Album::get( m.value( "albumid" ).toUInt(), m.value( "album" ).toString(), m_artist, collection );
|
||||
m_track = m.value( "track" ).toString();
|
||||
m_url = m.value( "url" ).toString();
|
||||
|
@ -139,6 +139,9 @@ TomahawkWindow::setupSignals()
|
||||
connect( m_topbar, SIGNAL( artistMode() ),
|
||||
playlistManager(), SLOT( setTreeMode() ) );
|
||||
|
||||
connect( m_topbar, SIGNAL( albumMode() ),
|
||||
playlistManager(), SLOT( setAlbumMode() ) );
|
||||
|
||||
// <From PlaylistManager>
|
||||
connect( playlistManager(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
m_audioControls, SLOT( onRepeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||
|
@ -56,10 +56,13 @@ TopBar::TopBar( QWidget* parent )
|
||||
ui->radioDetailed->setFocusPolicy( Qt::NoFocus );
|
||||
ui->radioCloud->setFocusPolicy( Qt::NoFocus );
|
||||
|
||||
ui->radioDetailed->setEnabled( false );
|
||||
|
||||
connect( ui->radioNormal, SIGNAL( clicked() ), SIGNAL( flatMode() ) );
|
||||
connect( ui->radioDetailed, SIGNAL( clicked() ), SIGNAL( artistMode() ) );
|
||||
connect( ui->radioCloud, SIGNAL( clicked() ), SIGNAL( albumMode() ) );
|
||||
|
||||
ui->widgetRadio->hide(); // FIXME
|
||||
// ui->widgetRadio->hide(); // FIXME
|
||||
|
||||
setNumSources( 0 );
|
||||
setNumTracks( 0 );
|
||||
@ -168,6 +171,7 @@ void
|
||||
TopBar::setNumTracks( unsigned int i )
|
||||
{
|
||||
m_tracks = i;
|
||||
ui->statsLabelNumTracks->setVisible( m_tracks > 0 );
|
||||
ui->statsLabelNumTracks->setVal( i );
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,10 @@ public:
|
||||
|
||||
signals:
|
||||
void filterTextChanged( const QString& newtext );
|
||||
|
||||
void flatMode();
|
||||
void artistMode();
|
||||
void albumMode();
|
||||
|
||||
public slots:
|
||||
void setNumSources( unsigned int );
|
||||
|
Loading…
x
Reference in New Issue
Block a user