mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 23:41:51 +02:00
* Little PlaylistModel cleanup.
This commit is contained in:
parent
47d9311df0
commit
c0f87542b7
@ -54,7 +54,7 @@ SourceInfoWidget::~SourceInfoWidget()
|
||||
void
|
||||
SourceInfoWidget::onPlaybackFinished( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
m_historyModel->insertTrack( 0, query );
|
||||
m_historyModel->insert( 0, query );
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order );
|
||||
|
||||
virtual void appendTrack( const Tomahawk::query_ptr& query ) {}
|
||||
virtual void append( const Tomahawk::query_ptr& query ) {}
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
#include "infowidgets/sourceinfowidget.h"
|
||||
|
||||
#include "widgets/welcomewidget.h"
|
||||
|
||||
#define FILTER_TIMEOUT 280
|
||||
|
||||
|
||||
@ -67,7 +65,10 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
||||
m_stack->addWidget( m_superCollectionView );
|
||||
m_stack->addWidget( m_superAlbumView );
|
||||
|
||||
show( new WelcomeWidget() );
|
||||
m_stack->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_widget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_widget->layout()->setMargin( 0 );
|
||||
|
||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||
}
|
||||
@ -125,6 +126,42 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::artist_ptr& artist )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << &artist << artist.data();
|
||||
unlinkPlaylist();
|
||||
|
||||
if ( !m_artistViews.contains( artist ) )
|
||||
{
|
||||
PlaylistView* view = new PlaylistView();
|
||||
PlaylistModel* model = new PlaylistModel();
|
||||
view->setModel( model );
|
||||
model->append( artist );
|
||||
|
||||
m_currentInterface = view->proxyModel();
|
||||
m_artistViews.insert( artist, view );
|
||||
|
||||
m_stack->addWidget( view );
|
||||
m_stack->setCurrentWidget( view );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaylistView* view = m_artistViews.value( artist );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentInterface = view->proxyModel();
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
m_statsAvailable = false;
|
||||
m_modesAvailable = false;
|
||||
linkPlaylist();
|
||||
|
||||
emit numSourcesChanged( 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||
{
|
||||
@ -136,7 +173,7 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||
PlaylistView* view = new PlaylistView();
|
||||
PlaylistModel* model = new PlaylistModel();
|
||||
view->setModel( model );
|
||||
model->appendAlbum( album );
|
||||
model->append( album );
|
||||
|
||||
m_currentInterface = view->proxyModel();
|
||||
m_albumViews.insert( album, view );
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
bool isSuperCollectionVisible() const { return true; }
|
||||
|
||||
bool show( const Tomahawk::playlist_ptr& playlist );
|
||||
bool show( const Tomahawk::artist_ptr& artist );
|
||||
bool show( const Tomahawk::album_ptr& album );
|
||||
bool show( const Tomahawk::collection_ptr& collection );
|
||||
bool show( const Tomahawk::source_ptr& source );
|
||||
@ -97,6 +98,7 @@ private:
|
||||
QHash< Tomahawk::collection_ptr, AlbumView* > m_collectionAlbumViews;
|
||||
|
||||
QHash< Tomahawk::playlist_ptr, PlaylistView* > m_playlistViews;
|
||||
QHash< Tomahawk::artist_ptr, PlaylistView* > m_artistViews;
|
||||
QHash< Tomahawk::album_ptr, PlaylistView* > m_albumViews;
|
||||
QHash< Tomahawk::source_ptr, SourceInfoWidget* > m_sourceViews;
|
||||
|
||||
|
@ -94,32 +94,6 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::appendAlbum( const Tomahawk::album_ptr& album )
|
||||
{
|
||||
if ( album.isNull() )
|
||||
return;
|
||||
|
||||
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||
|
||||
onTracksAdded( album->tracks(), album->collection() );
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amount )
|
||||
{
|
||||
@ -145,7 +119,7 @@ PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amo
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::appendTrack( const Tomahawk::query_ptr& query )
|
||||
PlaylistModel::append( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
@ -158,7 +132,33 @@ PlaylistModel::appendTrack( const Tomahawk::query_ptr& query )
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::insertTrack( unsigned int row, const Tomahawk::query_ptr& query )
|
||||
PlaylistModel::append( const Tomahawk::album_ptr& album )
|
||||
{
|
||||
if ( album.isNull() )
|
||||
return;
|
||||
|
||||
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||
|
||||
onTracksAdded( album->tracks(), album->collection() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::append( 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
|
||||
PlaylistModel::insert( unsigned int row, const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
|
@ -33,11 +33,11 @@ public:
|
||||
void loadPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 );
|
||||
|
||||
void appendTrack( const Tomahawk::query_ptr& query );
|
||||
void appendAlbum( const Tomahawk::album_ptr& album );
|
||||
void appendArtist( const Tomahawk::artist_ptr& artist );
|
||||
void append( const Tomahawk::query_ptr& query );
|
||||
void append( const Tomahawk::album_ptr& album );
|
||||
void append( const Tomahawk::artist_ptr& artist );
|
||||
|
||||
void insertTrack( unsigned int row, const Tomahawk::query_ptr& query );
|
||||
void insert( unsigned int row, const Tomahawk::query_ptr& query );
|
||||
|
||||
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void appendTrack( const Tomahawk::query_ptr& query ) = 0;
|
||||
virtual void append( const Tomahawk::query_ptr& query ) = 0;
|
||||
|
||||
PlItem* itemFromIndex( const QModelIndex& index ) const;
|
||||
|
||||
|
@ -141,7 +141,7 @@ TrackView::addItemsToQueue()
|
||||
PlItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
||||
if ( item && item->query()->numResults() )
|
||||
{
|
||||
APP->playlistManager()->queue()->model()->appendTrack( item->query() );
|
||||
APP->playlistManager()->queue()->model()->append( item->query() );
|
||||
APP->playlistManager()->showQueue();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "sip/SipHandler.h"
|
||||
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "widgets/welcomewidget.h"
|
||||
|
||||
#include "audiocontrols.h"
|
||||
#include "network/controlconnection.h"
|
||||
@ -56,13 +57,6 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
|
||||
ui->setupUi( this );
|
||||
|
||||
#ifndef Q_WS_MAC
|
||||
ui->centralWidget->layout()->setContentsMargins( 4, 4, 4, 2 );
|
||||
#else
|
||||
// ui->playlistView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
ui->sourceTreeView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
#endif
|
||||
|
||||
delete ui->playlistWidget;
|
||||
ui->splitter->addWidget( m_playlistManager->widget() );
|
||||
ui->splitter->setStretchFactor( 0, 1 );
|
||||
@ -86,6 +80,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
|
||||
loadSettings();
|
||||
setupSignals();
|
||||
|
||||
m_playlistManager->show( new WelcomeWidget() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,17 +15,20 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="statusButton">
|
||||
<property name="text">
|
||||
<string></string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -100,7 +100,7 @@ NewPlaylistWidget::suggestionsFound()
|
||||
QList<Tomahawk::query_ptr> ql;
|
||||
foreach( const Tomahawk::plentry_ptr& entry, m_entries )
|
||||
{
|
||||
m_suggestionsModel->appendTrack( entry->query() );
|
||||
m_suggestionsModel->append( entry->query() );
|
||||
ql.append( entry->query() );
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||
void
|
||||
WelcomeWidget::onPlaybackFinished( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
m_tracksModel->insertTrack( 0, query );
|
||||
m_tracksModel->insert( 0, query );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user