mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-17 04:21:22 +02:00
do lots of stuff.
rename playlistmanager to viewmanager. link pages in the viewmanager to indexes in the sourcetree, so it is never out of sync. yay!
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "utils/imagebutton.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
@@ -408,21 +408,21 @@ AudioControls::onRepeatClicked()
|
||||
case PlaylistInterface::NoRepeat:
|
||||
{
|
||||
// switch to RepeatOne
|
||||
PlaylistManager::instance()->setRepeatMode( PlaylistInterface::RepeatOne );
|
||||
ViewManager::instance()->setRepeatMode( PlaylistInterface::RepeatOne );
|
||||
}
|
||||
break;
|
||||
|
||||
case PlaylistInterface::RepeatOne:
|
||||
{
|
||||
// switch to RepeatAll
|
||||
PlaylistManager::instance()->setRepeatMode( PlaylistInterface::RepeatAll );
|
||||
ViewManager::instance()->setRepeatMode( PlaylistInterface::RepeatAll );
|
||||
}
|
||||
break;
|
||||
|
||||
case PlaylistInterface::RepeatAll:
|
||||
{
|
||||
// switch to NoRepeat
|
||||
PlaylistManager::instance()->setRepeatMode( PlaylistInterface::NoRepeat );
|
||||
ViewManager::instance()->setRepeatMode( PlaylistInterface::NoRepeat );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -457,26 +457,26 @@ AudioControls::onShuffleModeChanged( bool enabled )
|
||||
void
|
||||
AudioControls::onShuffleClicked()
|
||||
{
|
||||
PlaylistManager::instance()->setShuffled( m_shuffled ^ true );
|
||||
ViewManager::instance()->setShuffled( m_shuffled ^ true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onArtistClicked()
|
||||
{
|
||||
PlaylistManager::instance()->show( m_currentTrack->artist() );
|
||||
ViewManager::instance()->show( m_currentTrack->artist() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onAlbumClicked()
|
||||
{
|
||||
PlaylistManager::instance()->show( m_currentTrack->album() );
|
||||
ViewManager::instance()->show( m_currentTrack->album() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onTrackClicked()
|
||||
{
|
||||
PlaylistManager::instance()->showCurrentTrack();
|
||||
ViewManager::instance()->showCurrentTrack();
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ set( libSources
|
||||
result.cpp
|
||||
source.cpp
|
||||
viewpage.cpp
|
||||
viewmanager.cpp
|
||||
|
||||
sip/SipPlugin.cpp
|
||||
|
||||
@@ -90,7 +91,6 @@ set( libSources
|
||||
playlist/collectionproxymodel.cpp
|
||||
playlist/collectionflatmodel.cpp
|
||||
playlist/collectionview.cpp
|
||||
playlist/playlistmanager.cpp
|
||||
playlist/playlistmodel.cpp
|
||||
playlist/playlistproxymodel.cpp
|
||||
playlist/playlistview.cpp
|
||||
@@ -180,6 +180,7 @@ set( libHeaders
|
||||
result.h
|
||||
source.h
|
||||
viewpage.h
|
||||
viewmanager.h
|
||||
|
||||
artist.h
|
||||
album.h
|
||||
@@ -257,7 +258,6 @@ set( libHeaders
|
||||
playlist/collectionproxymodel.h
|
||||
playlist/collectionflatmodel.h
|
||||
playlist/collectionview.h
|
||||
playlist/playlistmanager.h
|
||||
playlist/playlistmodel.h
|
||||
playlist/playlistproxymodel.h
|
||||
playlist/playlistview.h
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
|
||||
#include "network/servent.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -92,7 +92,7 @@ DatabaseCommand_CreateDynamicPlaylist::postCommitHook()
|
||||
qDebug() << Q_FUNC_INFO << "..reporting..";
|
||||
if( m_playlist.isNull() ) {
|
||||
source_ptr src = source();
|
||||
QMetaObject::invokeMethod( PlaylistManager::instance(),
|
||||
QMetaObject::invokeMethod( ViewManager::instance(),
|
||||
"createDynamicPlaylist",
|
||||
Qt::BlockingQueuedConnection,
|
||||
QGenericArgument( "Tomahawk::source_ptr", (const void*)&src ),
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "network/servent.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -66,7 +66,7 @@ DatabaseCommand_CreatePlaylist::postCommitHook()
|
||||
qDebug() << Q_FUNC_INFO << "..reporting..";
|
||||
if( m_playlist.isNull() ) {
|
||||
source_ptr src = source();
|
||||
QMetaObject::invokeMethod( PlaylistManager::instance(),
|
||||
QMetaObject::invokeMethod( ViewManager::instance(),
|
||||
"createPlaylist",
|
||||
Qt::BlockingQueuedConnection,
|
||||
QGenericArgument( "Tomahawk::source_ptr", (const void*)&src ),
|
||||
|
@@ -184,6 +184,7 @@ playlist_ptr
|
||||
Playlist::load( const QString& guid )
|
||||
{
|
||||
playlist_ptr p;
|
||||
qDebug() << "asked to load playlist:" << guid;
|
||||
|
||||
foreach( const Tomahawk::source_ptr& source, SourceList::instance()->sources() )
|
||||
{
|
||||
|
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "tomahawksettings.h"
|
||||
#include "albumitemdelegate.h"
|
||||
#include "playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -106,7 +106,7 @@ AlbumView::onItemActivated( const QModelIndex& index )
|
||||
// qDebug() << "Result activated:" << item->album()->tracks().first()->toString() << item->album()->tracks().first()->results().first()->url();
|
||||
// APP->audioEngine()->playItem( item->album().data(), item->album()->tracks().first()->results().first() );
|
||||
|
||||
PlaylistManager::instance()->show( item->album() );
|
||||
ViewManager::instance()->show( item->album() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include "tomahawksettings.h"
|
||||
#include "treeheader.h"
|
||||
#include "treeitemdelegate.h"
|
||||
#include "playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
static QString s_tmInfoIdentifier = QString( "TREEMODEL" );
|
||||
|
||||
@@ -121,9 +121,9 @@ ArtistView::onItemActivated( const QModelIndex& index )
|
||||
if ( item )
|
||||
{
|
||||
if ( !item->artist().isNull() )
|
||||
PlaylistManager::instance()->show( item->artist() );
|
||||
ViewManager::instance()->show( item->artist() );
|
||||
else if ( !item->album().isNull() )
|
||||
PlaylistManager::instance()->show( item->album() );
|
||||
ViewManager::instance()->show( item->album() );
|
||||
else if ( !item->result().isNull() )
|
||||
AudioEngine::instance()->playItem( 0, item->result() );
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include "ReadOrWriteWidget.h"
|
||||
#include "CollapsibleControls.h"
|
||||
#include "DynamicControlWrapper.h"
|
||||
#include "playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "dynamic/DynamicView.h"
|
||||
#include <qevent.h>
|
||||
#include "DynamicSetupWidget.h"
|
||||
|
@@ -70,6 +70,7 @@ signals:
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void itemSizeChanged( const QModelIndex& index );
|
||||
void playlistDeleted();
|
||||
|
||||
private slots:
|
||||
void onDataChanged();
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -47,7 +47,7 @@ QueueProxyModel::siblingItem( int itemsAway )
|
||||
|
||||
qDebug() << "new rowcount:" << rowCount( QModelIndex() );
|
||||
if ( rowCount( QModelIndex() ) == 1 )
|
||||
PlaylistManager::instance()->hideQueue();
|
||||
ViewManager::instance()->hideQueue();
|
||||
|
||||
removeIndex( currentItem() );
|
||||
|
||||
|
@@ -83,25 +83,25 @@ TopBar::TopBar( QWidget* parent )
|
||||
|
||||
onFlatMode();
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( numSourcesChanged( unsigned int ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( numSourcesChanged( unsigned int ) ),
|
||||
SLOT( setNumSources( unsigned int ) ) );
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( numTracksChanged( unsigned int ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( numTracksChanged( unsigned int ) ),
|
||||
SLOT( setNumTracks( unsigned int ) ) );
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( numArtistsChanged( unsigned int ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( numArtistsChanged( unsigned int ) ),
|
||||
SLOT( setNumArtists( unsigned int ) ) );
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( numShownChanged( unsigned int ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( numShownChanged( unsigned int ) ),
|
||||
SLOT( setNumShown( unsigned int ) ) );
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( statsAvailable( bool ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( statsAvailable( bool ) ),
|
||||
SLOT( setStatsVisible( bool ) ) );
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( modesAvailable( bool ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( modesAvailable( bool ) ),
|
||||
SLOT( setModesVisible( bool ) ) );
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( modeChanged( PlaylistInterface::ViewMode ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( modeChanged( PlaylistInterface::ViewMode ) ),
|
||||
SLOT( onModeChanged( PlaylistInterface::ViewMode ) ) );
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include <QLabel>
|
||||
#include <QList>
|
||||
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "sourcelist.h"
|
||||
#include "dllmacro.h"
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include "dynamic/widgets/LoadingSpinner.h"
|
||||
|
||||
#include "trackheader.h"
|
||||
#include "playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "queueview.h"
|
||||
#include "trackmodel.h"
|
||||
#include "trackproxymodel.h"
|
||||
@@ -192,8 +192,8 @@ TrackView::addItemsToQueue()
|
||||
TrackModelItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
||||
if ( item && item->query()->numResults() )
|
||||
{
|
||||
PlaylistManager::instance()->queue()->model()->append( item->query() );
|
||||
PlaylistManager::instance()->showQueue();
|
||||
ViewManager::instance()->queue()->model()->append( item->query() );
|
||||
ViewManager::instance()->showQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QMetaMethod>
|
||||
@@ -47,23 +47,23 @@
|
||||
|
||||
#include "widgets/welcomewidget.h"
|
||||
#include "widgets/infowidgets/sourceinfowidget.h"
|
||||
#include <widgets/newplaylistwidget.h>
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
|
||||
#define FILTER_TIMEOUT 280
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
PlaylistManager* PlaylistManager::s_instance = 0;
|
||||
ViewManager* ViewManager::s_instance = 0;
|
||||
|
||||
|
||||
PlaylistManager*
|
||||
PlaylistManager::instance()
|
||||
ViewManager*
|
||||
ViewManager::instance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
|
||||
PlaylistManager::PlaylistManager( QObject* parent )
|
||||
ViewManager::ViewManager( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_widget( new QWidget() )
|
||||
, m_welcomeWidget( new WelcomeWidget() )
|
||||
@@ -137,21 +137,21 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
||||
}
|
||||
|
||||
|
||||
PlaylistManager::~PlaylistManager()
|
||||
ViewManager::~ViewManager()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
|
||||
PlaylistView*
|
||||
PlaylistManager::queue() const
|
||||
ViewManager::queue() const
|
||||
{
|
||||
return m_queueView->queue();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
{
|
||||
PlaylistView* view;
|
||||
if ( !m_playlistViews.contains( playlist ) )
|
||||
@@ -175,12 +175,12 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
||||
emit numSourcesChanged( SourceList::instance()->count() );
|
||||
|
||||
return true;
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
{
|
||||
if ( !m_dynamicWidgets.contains( playlist ) )
|
||||
{
|
||||
@@ -201,12 +201,12 @@ PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
||||
emit numSourcesChanged( SourceList::instance()->count() );
|
||||
|
||||
return true;
|
||||
return m_dynamicWidgets.value( playlist );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::artist_ptr& artist )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::artist_ptr& artist )
|
||||
{
|
||||
PlaylistView* view;
|
||||
|
||||
@@ -229,12 +229,12 @@ PlaylistManager::show( const Tomahawk::artist_ptr& artist )
|
||||
setPage( view );
|
||||
emit numSourcesChanged( 1 );
|
||||
|
||||
return true;
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::album_ptr& album )
|
||||
{
|
||||
PlaylistView* view;
|
||||
if ( !m_albumViews.contains( album ) )
|
||||
@@ -256,15 +256,16 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||
setPage( view );
|
||||
emit numSourcesChanged( 1 );
|
||||
|
||||
return true;
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << m_currentMode;
|
||||
m_currentCollection = collection;
|
||||
ViewPage* shown = 0;
|
||||
if ( m_currentMode == 0 )
|
||||
{
|
||||
CollectionView* view;
|
||||
@@ -285,6 +286,7 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||
view = m_collectionViews.value( collection );
|
||||
}
|
||||
|
||||
shown = view;
|
||||
setPage( view );
|
||||
}
|
||||
|
||||
@@ -308,6 +310,7 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||
view = m_treeViews.value( collection );
|
||||
}
|
||||
|
||||
shown = view;
|
||||
setPage( view );
|
||||
}
|
||||
|
||||
@@ -330,17 +333,18 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||
aview = m_collectionAlbumViews.value( collection );
|
||||
}
|
||||
|
||||
shown = aview;
|
||||
setPage( aview );
|
||||
}
|
||||
|
||||
emit numSourcesChanged( 1 );
|
||||
|
||||
return true;
|
||||
return shown;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( const Tomahawk::source_ptr& source )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::source_ptr& source )
|
||||
{
|
||||
SourceInfoWidget* swidget;
|
||||
if ( !m_sourceViews.contains( source ) )
|
||||
@@ -356,21 +360,21 @@ PlaylistManager::show( const Tomahawk::source_ptr& source )
|
||||
setPage( swidget );
|
||||
emit numSourcesChanged( 1 );
|
||||
|
||||
return true;
|
||||
return swidget;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show( ViewPage* page )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( ViewPage* page )
|
||||
{
|
||||
setPage( page );
|
||||
|
||||
return true;
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::showSuperCollection()
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::showSuperCollection()
|
||||
{
|
||||
if ( m_superCollections.isEmpty() )
|
||||
m_superCollectionModel->addAllCollections();
|
||||
@@ -387,34 +391,37 @@ PlaylistManager::showSuperCollection()
|
||||
m_superCollectionModel->setTitle( tr( "All available tracks" ) );
|
||||
m_superAlbumModel->setTitle( tr( "All available albums" ) );
|
||||
|
||||
ViewPage* shown = 0;
|
||||
if ( m_currentMode == 0 )
|
||||
{
|
||||
shown = m_superCollectionView;
|
||||
setPage( m_superCollectionView );
|
||||
}
|
||||
else if ( m_currentMode == 1 )
|
||||
{
|
||||
shown = m_superCollectionView;
|
||||
setPage( m_superCollectionView );
|
||||
}
|
||||
else if ( m_currentMode == 2 )
|
||||
{
|
||||
shown = m_superAlbumView;
|
||||
setPage( m_superAlbumView );
|
||||
}
|
||||
|
||||
emit numSourcesChanged( m_superCollections.count() );
|
||||
|
||||
return true;
|
||||
return shown;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::showWelcomePage()
|
||||
ViewManager::showWelcomePage()
|
||||
{
|
||||
show( m_welcomeWidget );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setTableMode()
|
||||
ViewManager::setTableMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@@ -428,7 +435,7 @@ PlaylistManager::setTableMode()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setTreeMode()
|
||||
ViewManager::setTreeMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@@ -442,7 +449,7 @@ PlaylistManager::setTreeMode()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setAlbumMode()
|
||||
ViewManager::setAlbumMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@@ -456,7 +463,7 @@ PlaylistManager::setAlbumMode()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::showQueue()
|
||||
ViewManager::showQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
@@ -470,7 +477,7 @@ PlaylistManager::showQueue()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::hideQueue()
|
||||
ViewManager::hideQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
@@ -484,7 +491,7 @@ PlaylistManager::hideQueue()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::historyBack()
|
||||
ViewManager::historyBack()
|
||||
{
|
||||
if ( m_historyPosition < 1 )
|
||||
return;
|
||||
@@ -494,7 +501,7 @@ PlaylistManager::historyBack()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::historyForward()
|
||||
ViewManager::historyForward()
|
||||
{
|
||||
if ( m_historyPosition >= m_pageHistory.count() - 1 )
|
||||
return;
|
||||
@@ -504,7 +511,7 @@ PlaylistManager::historyForward()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::showHistory( int historyPosition )
|
||||
ViewManager::showHistory( int historyPosition )
|
||||
{
|
||||
if ( historyPosition < 0 || historyPosition >= m_pageHistory.count() )
|
||||
{
|
||||
@@ -521,7 +528,7 @@ PlaylistManager::showHistory( int historyPosition )
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setFilter( const QString& filter )
|
||||
ViewManager::setFilter( const QString& filter )
|
||||
{
|
||||
m_filter = filter;
|
||||
|
||||
@@ -533,7 +540,7 @@ PlaylistManager::setFilter( const QString& filter )
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::applyFilter()
|
||||
ViewManager::applyFilter()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@@ -543,7 +550,7 @@ PlaylistManager::applyFilter()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setPage( ViewPage* page, bool trackHistory )
|
||||
ViewManager::setPage( ViewPage* page, bool trackHistory )
|
||||
{
|
||||
if ( !page )
|
||||
return;
|
||||
@@ -581,6 +588,9 @@ PlaylistManager::setPage( ViewPage* page, bool trackHistory )
|
||||
else if ( !currentPlaylistInterface() )
|
||||
emit tempPageActivated();*/
|
||||
|
||||
qDebug() << "View page shown:" << page->title();
|
||||
emit viewPageActivated( page );
|
||||
|
||||
if ( !AudioEngine::instance()->isPlaying() )
|
||||
AudioEngine::instance()->setPlaylist( currentPlaylistInterface() );
|
||||
|
||||
@@ -603,14 +613,14 @@ PlaylistManager::setPage( ViewPage* page, bool trackHistory )
|
||||
}
|
||||
|
||||
bool
|
||||
PlaylistManager::isNewPlaylistPageVisible() const
|
||||
ViewManager::isNewPlaylistPageVisible() const
|
||||
{
|
||||
return dynamic_cast< NewPlaylistWidget* >( currentPage() ) != 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::unlinkPlaylist()
|
||||
ViewManager::unlinkPlaylist()
|
||||
{
|
||||
if ( currentPlaylistInterface() )
|
||||
{
|
||||
@@ -630,7 +640,7 @@ PlaylistManager::unlinkPlaylist()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::updateView()
|
||||
ViewManager::updateView()
|
||||
{
|
||||
if ( currentPlaylistInterface() )
|
||||
{
|
||||
@@ -683,7 +693,7 @@ PlaylistManager::updateView()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::onWidgetDestroyed( QWidget* widget )
|
||||
ViewManager::onWidgetDestroyed( QWidget* widget )
|
||||
{
|
||||
qDebug() << "Destroyed child:" << widget << widget->metaObject()->className();
|
||||
|
||||
@@ -722,7 +732,7 @@ PlaylistManager::onWidgetDestroyed( QWidget* widget )
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setRepeatMode( PlaylistInterface::RepeatMode mode )
|
||||
ViewManager::setRepeatMode( PlaylistInterface::RepeatMode mode )
|
||||
{
|
||||
if ( currentPlaylistInterface() )
|
||||
currentPlaylistInterface()->setRepeatMode( mode );
|
||||
@@ -730,7 +740,7 @@ PlaylistManager::setRepeatMode( PlaylistInterface::RepeatMode mode )
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setShuffled( bool enabled )
|
||||
ViewManager::setShuffled( bool enabled )
|
||||
{
|
||||
if ( currentPlaylistInterface() )
|
||||
currentPlaylistInterface()->setShuffled( enabled );
|
||||
@@ -738,7 +748,7 @@ PlaylistManager::setShuffled( bool enabled )
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src,
|
||||
ViewManager::createPlaylist( const Tomahawk::source_ptr& src,
|
||||
const QVariant& contents )
|
||||
{
|
||||
Tomahawk::playlist_ptr p = Tomahawk::playlist_ptr( new Tomahawk::Playlist( src ) );
|
||||
@@ -748,7 +758,7 @@ PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src,
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
|
||||
ViewManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
|
||||
const QVariant& contents )
|
||||
{
|
||||
Tomahawk::dynplaylist_ptr p = Tomahawk::dynplaylist_ptr( new Tomahawk::DynamicPlaylist( src, contents.toMap().value( "type", QString() ).toString() ) );
|
||||
@@ -756,9 +766,27 @@ PlaylistManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
|
||||
p->reportCreated( p );
|
||||
}
|
||||
|
||||
ViewPage*
|
||||
ViewManager::pageForCollection( const collection_ptr& col ) const
|
||||
{
|
||||
return m_collectionViews.value( col, 0 );
|
||||
}
|
||||
|
||||
ViewPage*
|
||||
PlaylistManager::pageForInterface( PlaylistInterface* interface ) const
|
||||
ViewManager::pageForDynPlaylist(const dynplaylist_ptr& pl) const
|
||||
{
|
||||
return m_dynamicWidgets.value( pl, 0 );
|
||||
}
|
||||
|
||||
ViewPage*
|
||||
ViewManager::pageForPlaylist(const playlist_ptr& pl) const
|
||||
{
|
||||
return m_playlistViews.value( pl, 0 );
|
||||
}
|
||||
|
||||
|
||||
ViewPage*
|
||||
ViewManager::pageForInterface( PlaylistInterface* interface ) const
|
||||
{
|
||||
for ( int i = 0; i < m_pageHistory.count(); i++ )
|
||||
{
|
||||
@@ -772,7 +800,7 @@ PlaylistManager::pageForInterface( PlaylistInterface* interface ) const
|
||||
|
||||
|
||||
int
|
||||
PlaylistManager::positionInHistory( ViewPage* page ) const
|
||||
ViewManager::positionInHistory( ViewPage* page ) const
|
||||
{
|
||||
for ( int i = 0; i < m_pageHistory.count(); i++ )
|
||||
{
|
||||
@@ -785,7 +813,7 @@ PlaylistManager::positionInHistory( ViewPage* page ) const
|
||||
|
||||
|
||||
PlaylistInterface*
|
||||
PlaylistManager::currentPlaylistInterface() const
|
||||
ViewManager::currentPlaylistInterface() const
|
||||
{
|
||||
if ( currentPage() )
|
||||
return currentPage()->playlistInterface();
|
||||
@@ -795,7 +823,7 @@ PlaylistManager::currentPlaylistInterface() const
|
||||
|
||||
|
||||
Tomahawk::ViewPage*
|
||||
PlaylistManager::currentPage() const
|
||||
ViewManager::currentPage() const
|
||||
{
|
||||
if ( m_historyPosition >= 0 )
|
||||
return m_pageHistory.at( m_historyPosition );
|
||||
@@ -805,7 +833,7 @@ PlaylistManager::currentPage() const
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::setHistoryPosition( int position )
|
||||
ViewManager::setHistoryPosition( int position )
|
||||
{
|
||||
m_historyPosition = position;
|
||||
|
||||
@@ -815,7 +843,7 @@ PlaylistManager::setHistoryPosition( int position )
|
||||
|
||||
|
||||
Tomahawk::playlist_ptr
|
||||
PlaylistManager::playlistForInterface( PlaylistInterface* interface ) const
|
||||
ViewManager::playlistForInterface( PlaylistInterface* interface ) const
|
||||
{
|
||||
foreach ( PlaylistView* view, m_playlistViews.values() )
|
||||
{
|
||||
@@ -830,7 +858,7 @@ PlaylistManager::playlistForInterface( PlaylistInterface* interface ) const
|
||||
|
||||
|
||||
Tomahawk::dynplaylist_ptr
|
||||
PlaylistManager::dynamicPlaylistForInterface( PlaylistInterface* interface ) const
|
||||
ViewManager::dynamicPlaylistForInterface( PlaylistInterface* interface ) const
|
||||
{
|
||||
foreach ( DynamicWidget* view, m_dynamicWidgets.values() )
|
||||
{
|
||||
@@ -845,7 +873,7 @@ PlaylistManager::dynamicPlaylistForInterface( PlaylistInterface* interface ) con
|
||||
|
||||
|
||||
Tomahawk::collection_ptr
|
||||
PlaylistManager::collectionForInterface( PlaylistInterface* interface ) const
|
||||
ViewManager::collectionForInterface( PlaylistInterface* interface ) const
|
||||
{
|
||||
foreach ( CollectionView* view, m_collectionViews.values() )
|
||||
{
|
||||
@@ -867,7 +895,7 @@ PlaylistManager::collectionForInterface( PlaylistInterface* interface ) const
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::isSuperCollectionVisible() const
|
||||
ViewManager::isSuperCollectionVisible() const
|
||||
{
|
||||
return ( m_pageHistory.count() &&
|
||||
( currentPage()->playlistInterface() == m_superCollectionView->playlistInterface() ||
|
||||
@@ -876,7 +904,7 @@ PlaylistManager::isSuperCollectionVisible() const
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::showCurrentTrack()
|
||||
ViewManager::showCurrentTrack()
|
||||
{
|
||||
ViewPage* page = pageForInterface( AudioEngine::instance()->currentTrackPlaylist() );
|
||||
|
||||
@@ -889,14 +917,14 @@ PlaylistManager::showCurrentTrack()
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::onPlayClicked()
|
||||
ViewManager::onPlayClicked()
|
||||
{
|
||||
emit playClicked();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistManager::onPauseClicked()
|
||||
ViewManager::onPauseClicked()
|
||||
{
|
||||
emit pauseClicked();
|
||||
}
|
@@ -54,15 +54,15 @@ namespace Tomahawk
|
||||
class DynamicWidget;
|
||||
}
|
||||
|
||||
class DLLEXPORT PlaylistManager : public QObject
|
||||
class DLLEXPORT ViewManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static PlaylistManager* instance();
|
||||
static ViewManager* instance();
|
||||
|
||||
explicit PlaylistManager( QObject* parent = 0 );
|
||||
~PlaylistManager();
|
||||
explicit ViewManager( QObject* parent = 0 );
|
||||
~ViewManager();
|
||||
|
||||
QWidget* widget() const { return m_widget; }
|
||||
PlaylistView* queue() const;
|
||||
@@ -75,14 +75,23 @@ public:
|
||||
Tomahawk::ViewPage* pageForInterface( PlaylistInterface* interface ) const;
|
||||
int positionInHistory( Tomahawk::ViewPage* page ) const;
|
||||
|
||||
bool show( const Tomahawk::playlist_ptr& playlist );
|
||||
bool show( const Tomahawk::dynplaylist_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 );
|
||||
// Returns the shown viewpage
|
||||
Tomahawk::ViewPage* show( const Tomahawk::playlist_ptr& playlist );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::dynplaylist_ptr& playlist );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::artist_ptr& artist );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::album_ptr& album );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::collection_ptr& collection );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::source_ptr& source );
|
||||
|
||||
bool show( Tomahawk::ViewPage* page );
|
||||
Tomahawk::ViewPage* show( Tomahawk::ViewPage* page );
|
||||
|
||||
WelcomeWidget* welcomeWidget() const { return m_welcomeWidget; }
|
||||
ArtistView* superCollectionView() const { return m_superCollectionView; }
|
||||
|
||||
/// Get the view page for the given item. Not pretty...
|
||||
Tomahawk::ViewPage* pageForPlaylist( const Tomahawk::playlist_ptr& pl ) const;
|
||||
Tomahawk::ViewPage* pageForDynPlaylist( const Tomahawk::dynplaylist_ptr& pl ) const;
|
||||
Tomahawk::ViewPage* pageForCollection( const Tomahawk::collection_ptr& pl ) const;
|
||||
|
||||
signals:
|
||||
void numSourcesChanged( unsigned int sources );
|
||||
@@ -110,9 +119,10 @@ signals:
|
||||
void dynamicPlaylistActivated( const Tomahawk::dynplaylist_ptr& playlist );
|
||||
|
||||
void newPlaylistActivated();
|
||||
void viewPageActivated( Tomahawk::ViewPage* );
|
||||
|
||||
public slots:
|
||||
bool showSuperCollection();
|
||||
Tomahawk::ViewPage* showSuperCollection();
|
||||
void showWelcomePage();
|
||||
void showCurrentTrack();
|
||||
|
||||
@@ -189,7 +199,7 @@ private:
|
||||
QTimer m_filterTimer;
|
||||
QString m_filter;
|
||||
|
||||
static PlaylistManager* s_instance;
|
||||
static ViewManager* s_instance;
|
||||
};
|
||||
|
||||
#endif // PLAYLISTMANAGER_H
|
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/albummodel.h"
|
||||
#include "playlist/collectionflatmodel.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
|
||||
#include "widgets/overlaywidget.h"
|
||||
@@ -144,7 +144,7 @@ NewPlaylistWidget::savePlaylist()
|
||||
playlist = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), uuid(), ui->titleEdit->text(), "", "", false );
|
||||
playlist->createNewRevision( uuid(), playlist->currentrevision(), m_entries );
|
||||
|
||||
PlaylistManager::instance()->show( playlist );
|
||||
ViewManager::instance()->show( playlist );
|
||||
cancel();
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
|
||||
#include "widgets/overlaywidget.h"
|
||||
@@ -130,9 +130,9 @@ WelcomeWidget::onPlaylistActivated( QListWidgetItem* item )
|
||||
|
||||
PlaylistWidgetItem* pwi = dynamic_cast<PlaylistWidgetItem*>(item);
|
||||
if( Tomahawk::dynplaylist_ptr dynplaylist = pwi->playlist().dynamicCast< Tomahawk::DynamicPlaylist >() )
|
||||
PlaylistManager::instance()->show( dynplaylist );
|
||||
ViewManager::instance()->show( dynplaylist );
|
||||
else
|
||||
PlaylistManager::instance()->show( pwi->playlist() );
|
||||
ViewManager::instance()->show( pwi->playlist() );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -24,15 +24,16 @@
|
||||
#include "collection.h"
|
||||
#include "source.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
#include <QMimeData>
|
||||
#include <QSize>
|
||||
#include <playlist/playlistmanager.h>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
SourcesModel::SourcesModel( QObject* parent )
|
||||
: QAbstractItemModel( parent )
|
||||
, m_viewPageDelayedCacheItem( 0 )
|
||||
{
|
||||
m_rootItem = new SourceTreeItem( this, 0, Invalid );
|
||||
|
||||
@@ -40,12 +41,13 @@ SourcesModel::SourcesModel( QObject* parent )
|
||||
|
||||
// add misc children of root node
|
||||
GenericPageItem* recent = new GenericPageItem( this, m_rootItem->children().at( 0 ), tr( "Recently Played" ), QIcon( RESPATH "images/recently-played.png" ) );
|
||||
connect( recent, SIGNAL( activated() ), PlaylistManager::instance(), SLOT( showWelcomePage() ) );
|
||||
connect( recent, SIGNAL( activated() ), ViewManager::instance(), SLOT( showWelcomePage() ) );
|
||||
|
||||
onSourcesAdded( SourceList::instance()->sources() );
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceRemoved( Tomahawk::source_ptr ) ) );
|
||||
connect( ViewManager::instance(), SIGNAL( viewPageActivated( Tomahawk::ViewPage* ) ), this, SLOT( viewPageActivated( Tomahawk::ViewPage* ) ) );
|
||||
}
|
||||
|
||||
SourcesModel::~SourcesModel()
|
||||
@@ -186,19 +188,8 @@ SourcesModel::appendItem( const Tomahawk::source_ptr& source )
|
||||
beginInsertRows( QModelIndex(), rowCount(), rowCount() );
|
||||
// append to end
|
||||
CollectionItem* item = new CollectionItem( this, m_rootItem, source );
|
||||
connect( item, SIGNAL( updated() ), this, SLOT( collectionUpdated() ) );
|
||||
|
||||
endInsertRows();
|
||||
|
||||
if ( !source.isNull() )
|
||||
{
|
||||
qDebug() << "Appending source item:" << item->source()->friendlyName();
|
||||
|
||||
connect( source.data(), SIGNAL( stats( QVariantMap ) ), SLOT( onSourceChanged() ) );
|
||||
connect( source.data(), SIGNAL( playbackStarted( Tomahawk::query_ptr ) ), SLOT( onSourceChanged() ) );
|
||||
connect( source.data(), SIGNAL( stateChanged() ), SLOT( onSourceChanged() ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -229,6 +220,23 @@ SourcesModel::removeItem( const Tomahawk::source_ptr& source )
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
SourcesModel::viewPageActivated( Tomahawk::ViewPage* page )
|
||||
{
|
||||
if ( m_sourceTreeLinks.contains( page ) )
|
||||
{
|
||||
Q_ASSERT( m_sourceTreeLinks[ page ] );
|
||||
qDebug() << "Got view page activated for itemL:" << m_sourceTreeLinks[ page ]->text();
|
||||
QModelIndex idx = indexFromItem( m_sourceTreeLinks[ page ] );
|
||||
Q_ASSERT( idx.isValid() );
|
||||
|
||||
emit selectRequest( idx );
|
||||
} else {
|
||||
m_viewPageDelayedCacheItem = page;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
QModelIndex
|
||||
SourcesModel::indexFromPlaylist( const playlist_ptr& playlist )
|
||||
{
|
||||
@@ -257,30 +265,7 @@ SourcesModel::indexFromPlaylist( const playlist_ptr& playlist )
|
||||
}
|
||||
qDebug() << "FAILED to find playlist in source tree:" << playlist->title();
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourcesModel::onSourceChanged() {
|
||||
|
||||
Source* src = qobject_cast< Source* >( sender() );
|
||||
Q_ASSERT( src );
|
||||
|
||||
qDebug() << "Searching for source item:" << src->friendlyName();
|
||||
|
||||
for( int i = 0; i < rowCount(); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0 , QModelIndex() );
|
||||
|
||||
if( idx.isValid() && itemFromIndex( idx ) && itemFromIndex( idx )->type() == Collection && // this is a source
|
||||
static_cast< CollectionItem* >( itemFromIndex( idx ) )->source().data() == src ) // and it is the one we want
|
||||
{
|
||||
qDebug() << "Found changed source, emitting dataChanged:" << src->friendlyName();
|
||||
emit dataChanged( idx, idx );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void
|
||||
SourcesModel::loadSources()
|
||||
@@ -314,11 +299,19 @@ SourcesModel::onSourceRemoved( const source_ptr& source )
|
||||
}
|
||||
|
||||
void
|
||||
SourcesModel::collectionUpdated()
|
||||
SourcesModel::itemUpdated()
|
||||
{
|
||||
Q_ASSERT( qobject_cast< SourceTreeItem* >( sender() ) );
|
||||
SourceTreeItem* item = qobject_cast< SourceTreeItem* >( sender() );
|
||||
|
||||
if( !item )
|
||||
return;
|
||||
|
||||
QModelIndex idx = indexFromItem( item );
|
||||
emit dataChanged( idx, idx );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourcesModel::onItemRowsAddedBegin( int first, int last )
|
||||
{
|
||||
@@ -362,6 +355,19 @@ SourcesModel::onItemRowsRemovedDone()
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
void
|
||||
SourcesModel::linkSourceItemToPage( SourceTreeItem* item, ViewPage* p )
|
||||
{
|
||||
// TODO handle removal
|
||||
m_sourceTreeLinks[ p ] = item;
|
||||
|
||||
if( m_viewPageDelayedCacheItem = p )
|
||||
emit selectRequest( indexFromItem( item ) );
|
||||
|
||||
m_viewPageDelayedCacheItem = 0;
|
||||
}
|
||||
|
||||
|
||||
SourceTreeItem*
|
||||
SourcesModel::itemFromIndex( const QModelIndex& idx ) const
|
||||
{
|
||||
|
@@ -31,6 +31,7 @@ class SourceTreeItem;
|
||||
namespace Tomahawk {
|
||||
class Source;
|
||||
class Playlist;
|
||||
class ViewPage;
|
||||
}
|
||||
|
||||
class SourcesModel : public QAbstractItemModel
|
||||
@@ -43,13 +44,10 @@ public:
|
||||
Collection = 0,
|
||||
|
||||
Category = 1,
|
||||
|
||||
CategoryAdd = 2,
|
||||
|
||||
StaticPlaylist = 3,
|
||||
|
||||
AutomaticPlaylist = 4,
|
||||
|
||||
Stations = 5,
|
||||
|
||||
GenericPage = 6
|
||||
@@ -85,22 +83,26 @@ public:
|
||||
void appendItem( const Tomahawk::source_ptr& source );
|
||||
bool removeItem( const Tomahawk::source_ptr& source );
|
||||
|
||||
void linkSourceItemToPage( SourceTreeItem* item, Tomahawk::ViewPage* p );
|
||||
// HACK i don't like this
|
||||
// SLOW DON'T USE IF YOU CAN AVOID IT
|
||||
QModelIndex indexFromPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
// QModelIndex indexFromPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
QModelIndex indexFromItem( SourceTreeItem* item ) const;
|
||||
|
||||
signals:
|
||||
void selectRequest( const QModelIndex& idx );
|
||||
|
||||
private slots:
|
||||
void onSourcesAdded( const QList<Tomahawk::source_ptr>& sources );
|
||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||
void onSourceRemoved( const Tomahawk::source_ptr& source );
|
||||
|
||||
void onSourceChanged();
|
||||
void viewPageActivated( Tomahawk::ViewPage* );
|
||||
|
||||
public slots:
|
||||
void loadSources();
|
||||
void collectionUpdated();
|
||||
|
||||
void itemUpdated();
|
||||
void onItemRowsAddedBegin( int first, int last );
|
||||
void onItemRowsAddedDone();
|
||||
void onItemRowsRemovedBegin( int first, int last );
|
||||
@@ -114,6 +116,9 @@ private:
|
||||
// QModelIndex indexForCategory( const QModelIndex& sourceIndex, CategoryType type );
|
||||
|
||||
SourceTreeItem* m_rootItem;
|
||||
|
||||
QHash< Tomahawk::ViewPage*, SourceTreeItem* > m_sourceTreeLinks;
|
||||
Tomahawk::ViewPage* m_viewPageDelayedCacheItem;
|
||||
};
|
||||
|
||||
#endif // SOURCESMODEL_H
|
||||
|
@@ -36,6 +36,7 @@ SourcesProxyModel::SourcesProxyModel( SourcesModel* model, QObject* parent )
|
||||
setSourceModel( model );
|
||||
|
||||
connect( model, SIGNAL( askForExpand( QModelIndex ) ), this, SLOT( askedToExpand( QModelIndex ) ) );
|
||||
connect( model, SIGNAL( selectRequest( QModelIndex ) ), this, SLOT( selectRequested( QModelIndex ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -73,3 +74,11 @@ SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePar
|
||||
// accept rows that aren't sources
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SourcesProxyModel::selectRequested( const QModelIndex& idx )
|
||||
{
|
||||
qDebug() << "asking for select from idx:" << idx << idx.model()->metaObject()->className();
|
||||
emit selectRequest( mapFromSource( idx ) );
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,11 @@ public slots:
|
||||
void showOfflineSources();
|
||||
void hideOfflineSources();
|
||||
|
||||
void selectRequested( const QModelIndex& );
|
||||
|
||||
signals:
|
||||
void selectRequest( const QModelIndex& idx );
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
|
||||
|
@@ -20,10 +20,11 @@
|
||||
#include "playlist.h"
|
||||
#include "playlist/dynamic/DynamicPlaylist.h"
|
||||
#include "source.h"
|
||||
#include <playlist/playlistmanager.h>
|
||||
#include "viewmanager.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
|
||||
#include <QMimeData>
|
||||
#include <widgets/newplaylistwidget.h>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -37,6 +38,7 @@ SourceTreeItem::SourceTreeItem( SourcesModel* model, SourceTreeItem* parent, Sou
|
||||
connect( this, SIGNAL( beginChildRowsRemoved( int,int ) ), m_model, SLOT( onItemRowsRemovedBegin( int,int ) ) );
|
||||
connect( this, SIGNAL( childRowsAdded() ), m_model, SLOT( onItemRowsAddedDone() ) );
|
||||
connect( this, SIGNAL( childRowsRemoved() ), m_model, SLOT( onItemRowsRemovedDone() ) );
|
||||
connect( this, SIGNAL( updated() ), m_model, SLOT( itemUpdated() ) );
|
||||
|
||||
if( !m_parent )
|
||||
return;
|
||||
@@ -77,6 +79,9 @@ PlaylistItem::PlaylistItem( SourcesModel* mdl, SourceTreeItem* parent, const pla
|
||||
SLOT( onPlaylistLoaded( Tomahawk::PlaylistRevision ) ), Qt::QueuedConnection );
|
||||
connect( pl.data(), SIGNAL( changed() ),
|
||||
SIGNAL( updated() ), Qt::QueuedConnection );
|
||||
|
||||
if( ViewManager::instance()->pageForPlaylist( pl ) )
|
||||
model()->linkSourceItemToPage( this, ViewManager::instance()->pageForPlaylist( pl ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +127,8 @@ PlaylistItem::flags() const
|
||||
void
|
||||
PlaylistItem::activate()
|
||||
{
|
||||
PlaylistManager::instance()->show( m_playlist );
|
||||
ViewPage* p = ViewManager::instance()->show( m_playlist );
|
||||
model()->linkSourceItemToPage( this, p );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -215,7 +221,7 @@ DynPlaylistItem::playlist() const
|
||||
void
|
||||
DynPlaylistItem::activate()
|
||||
{
|
||||
PlaylistManager::instance()->show( m_playlist );
|
||||
ViewManager::instance()->show( m_playlist );
|
||||
}
|
||||
|
||||
|
||||
@@ -258,8 +264,10 @@ CategoryAddItem::activate()
|
||||
switch( m_categoryType ) {
|
||||
case SourcesModel::PlaylistsCategory:
|
||||
// only show if none is shown yet
|
||||
if( !PlaylistManager::instance()->isNewPlaylistPageVisible() )
|
||||
PlaylistManager::instance()->show( new NewPlaylistWidget() );
|
||||
if( !ViewManager::instance()->isNewPlaylistPageVisible() ) {
|
||||
ViewPage* p = ViewManager::instance()->show( new NewPlaylistWidget() );
|
||||
model()->linkSourceItemToPage( this, p );
|
||||
}
|
||||
break;
|
||||
case SourcesModel::StationsCategory:
|
||||
// TODO
|
||||
@@ -335,21 +343,29 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
||||
m_playlists = new CategoryItem( model(), this, SourcesModel::PlaylistsCategory, source->isLocal() );
|
||||
// ugh :( we're being added by the model, no need to notify for added rows now
|
||||
// m_playlists->blockSignals( true );
|
||||
onPlaylistsAdded( source->collection()->playlists() );
|
||||
onPlaylistsAdded( playlists );
|
||||
// m_playlists->blockSignals( false );
|
||||
}
|
||||
|
||||
// TODO always show for now, till we actually support stations
|
||||
// m_stations = new CategoryItem( model(), this, SourcesModel::StationsCategory, source->isLocal() );
|
||||
|
||||
if( ViewManager::instance()->pageForCollection( source->collection() ) )
|
||||
model()->linkSourceItemToPage( this, ViewManager::instance()->pageForCollection( source->collection() ) );
|
||||
|
||||
// HACK to load only for now
|
||||
source->collection()->dynamicPlaylists();
|
||||
|
||||
connect( source.data(), SIGNAL( stats( QVariantMap ) ), this, SIGNAL( updated() ) );
|
||||
connect( source.data(), SIGNAL( playbackStarted( Tomahawk::query_ptr ) ), this, SIGNAL( updated() ) );
|
||||
connect( source.data(), SIGNAL( stateChanged() ), this, SIGNAL( updated() ) );
|
||||
connect( source.data(), SIGNAL( offline() ), this, SIGNAL( updated() ) );
|
||||
connect( source.data(), SIGNAL( online() ), this, SIGNAL( updated() ) );
|
||||
|
||||
connect( source->collection().data(), SIGNAL( playlistsAdded( QList<Tomahawk::playlist_ptr> ) ),
|
||||
SLOT( onPlaylistsAdded( QList<Tomahawk::playlist_ptr> ) ) );
|
||||
SLOT( onPlaylistsAdded( QList<Tomahawk::playlist_ptr> ) ), Qt::QueuedConnection );
|
||||
connect( source->collection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ),
|
||||
SLOT( onPlaylistsDeleted( QList<Tomahawk::playlist_ptr> ) ) );
|
||||
SLOT( onPlaylistsDeleted( QList<Tomahawk::playlist_ptr> ) ), Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
Tomahawk::source_ptr
|
||||
@@ -368,9 +384,11 @@ void
|
||||
CollectionItem::activate()
|
||||
{
|
||||
if( source().isNull() ) {
|
||||
PlaylistManager::instance()->showSuperCollection();
|
||||
ViewPage* p = ViewManager::instance()->showSuperCollection();
|
||||
model()->linkSourceItemToPage( this, p );
|
||||
} else {
|
||||
PlaylistManager::instance()->show( source()->collection() );
|
||||
ViewPage* p = ViewManager::instance()->show( source()->collection() );
|
||||
model()->linkSourceItemToPage( this, p );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include "sourcetreeview.h"
|
||||
|
||||
#include "playlist.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "sourcesproxymodel.h"
|
||||
#include "sourcelist.h"
|
||||
#include "sourcetree/sourcetreeitem.h"
|
||||
@@ -92,6 +92,8 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
|
||||
m_model = new SourcesModel( this );
|
||||
m_proxyModel = new SourcesProxyModel( m_model, this );
|
||||
connect( m_proxyModel, SIGNAL( selectRequest( QModelIndex ) ), this, SLOT( selectRequest( QModelIndex ) ), Qt::QueuedConnection );
|
||||
|
||||
setModel( m_proxyModel );
|
||||
|
||||
header()->setStretchLastSection( false );
|
||||
@@ -104,17 +106,17 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
|
||||
hideOfflineSources();
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( playlistActivated( Tomahawk::playlist_ptr ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( playlistActivated( Tomahawk::playlist_ptr ) ),
|
||||
SLOT( onPlaylistActivated( Tomahawk::playlist_ptr ) ) );
|
||||
// connect( PlaylistManager::instance(), SIGNAL( dynamicPlaylistActivated( Tomahawk::dynplaylist_ptr ) ),
|
||||
// SLOT( onDynamicPlaylistActivated( Tomahawk::dynplaylist_ptr ) ) );
|
||||
connect( PlaylistManager::instance(), SIGNAL( collectionActivated( Tomahawk::collection_ptr ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( collectionActivated( Tomahawk::collection_ptr ) ),
|
||||
SLOT( onCollectionActivated( Tomahawk::collection_ptr ) ) );
|
||||
connect( PlaylistManager::instance(), SIGNAL( superCollectionActivated() ),
|
||||
connect( ViewManager::instance(), SIGNAL( superCollectionActivated() ),
|
||||
SLOT( onSuperCollectionActivated() ) );
|
||||
connect( PlaylistManager::instance(), SIGNAL( tempPageActivated() ),
|
||||
connect( ViewManager::instance(), SIGNAL( tempPageActivated() ),
|
||||
SLOT( onTempPageActivated() ) );
|
||||
connect( PlaylistManager::instance(), SIGNAL( newPlaylistActivated() ),
|
||||
connect( ViewManager::instance(), SIGNAL( newPlaylistActivated() ),
|
||||
SLOT( onNewPlaylistPageActivated() ) );
|
||||
}
|
||||
|
||||
@@ -168,12 +170,12 @@ SourceTreeView::hideOfflineSources()
|
||||
void
|
||||
SourceTreeView::onPlaylistActivated( const Tomahawk::playlist_ptr& playlist )
|
||||
{
|
||||
QModelIndex idx = m_proxyModel->mapFromSource( m_model->indexFromPlaylist( playlist ) );
|
||||
if ( idx.isValid() )
|
||||
{
|
||||
selectionModel()->select( idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current );
|
||||
// QModelIndex idx = m_proxyModel->mapFromSource( m_model->indexFromPlaylist( playlist ) );
|
||||
// if ( idx.isValid() )
|
||||
// {
|
||||
// selectionModel()->select( idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current );
|
||||
// setCurrentIndex( idx );
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -245,6 +247,14 @@ SourceTreeView::onItemExpanded( const QModelIndex& idx )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SourceTreeView::selectRequest( const QModelIndex& idx )
|
||||
{
|
||||
if( !selectionModel()->selectedIndexes().contains( idx ) )
|
||||
selectionModel()->select( idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::loadPlaylist()
|
||||
@@ -292,6 +302,8 @@ SourceTreeView::onCustomContextMenu( const QPoint& pos )
|
||||
|
||||
if ( model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ) == SourcesModel::StaticPlaylist )
|
||||
{
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
||||
if( item->playlist()->author()->isLocal() )
|
||||
m_playlistMenu.exec( mapToGlobal( pos ) );
|
||||
}
|
||||
}
|
||||
|
@@ -55,8 +55,8 @@ private slots:
|
||||
void onNewPlaylistPageActivated();
|
||||
|
||||
void onItemExpanded( const QModelIndex& idx );
|
||||
|
||||
void onItemActivated( const QModelIndex& index );
|
||||
void selectRequest( const QModelIndex& idx );
|
||||
|
||||
void loadPlaylist();
|
||||
void deletePlaylist();
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_collectionstats.h"
|
||||
#include "network/controlconnection.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "sip/SipHandler.h"
|
||||
#include "sourcetree/sourcetreeview.h"
|
||||
#include "utils/animatedsplitter.h"
|
||||
@@ -77,7 +77,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
setUnifiedTitleAndToolBarOnMac( true );
|
||||
#endif
|
||||
|
||||
PlaylistManager* pm = new PlaylistManager( this );
|
||||
ViewManager* pm = new ViewManager( this );
|
||||
connect( pm, SIGNAL( historyBackAvailable( bool ) ), SLOT( onHistoryBackAvailable( bool ) ) );
|
||||
connect( pm, SIGNAL( historyForwardAvailable( bool ) ), SLOT( onHistoryForwardAvailable( bool ) ) );
|
||||
|
||||
@@ -131,7 +131,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
buttonWidget->layout()->setSpacing( 0 );*/
|
||||
|
||||
ui->splitter->addWidget( sidebarWidget );
|
||||
ui->splitter->addWidget( PlaylistManager::instance()->widget() );
|
||||
ui->splitter->addWidget( ViewManager::instance()->widget() );
|
||||
|
||||
ui->splitter->setStretchFactor( 0, 1 );
|
||||
ui->splitter->setStretchFactor( 1, 3 );
|
||||
@@ -167,8 +167,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
connect( checkForUpdates, SIGNAL( triggered() ), updater, SLOT( CheckNow() ) );
|
||||
#endif
|
||||
|
||||
m_backAvailable = toolbar->addAction( QIcon( RESPATH "images/back.png" ), tr( "Back" ), PlaylistManager::instance(), SLOT( historyBack() ) );
|
||||
m_forwardAvailable = toolbar->addAction( QIcon( RESPATH "images/forward.png" ), tr( "Forward" ), PlaylistManager::instance(), SLOT( historyForward() ) );
|
||||
m_backAvailable = toolbar->addAction( QIcon( RESPATH "images/back.png" ), tr( "Back" ), ViewManager::instance(), SLOT( historyBack() ) );
|
||||
m_forwardAvailable = toolbar->addAction( QIcon( RESPATH "images/forward.png" ), tr( "Forward" ), ViewManager::instance(), SLOT( historyForward() ) );
|
||||
|
||||
statusBar()->addPermanentWidget( m_audioControls, 1 );
|
||||
|
||||
@@ -181,7 +181,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
|
||||
loadSettings();
|
||||
setupSignals();
|
||||
PlaylistManager::instance()->showWelcomePage();
|
||||
ViewManager::instance()->showWelcomePage();
|
||||
}
|
||||
|
||||
|
||||
@@ -241,10 +241,10 @@ void
|
||||
TomahawkWindow::setupSignals()
|
||||
{
|
||||
// <From PlaylistManager>
|
||||
connect( PlaylistManager::instance(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
m_audioControls, SLOT( onRepeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||
|
||||
connect( PlaylistManager::instance(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
connect( ViewManager::instance(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
m_audioControls, SLOT( onShuffleModeChanged( bool ) ) );
|
||||
|
||||
// <From AudioEngine>
|
||||
@@ -403,7 +403,7 @@ TomahawkWindow::createAutomaticPlaylist()
|
||||
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, false );
|
||||
playlist->setMode( Static );
|
||||
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
|
||||
PlaylistManager::instance()->show( playlist );
|
||||
ViewManager::instance()->show( playlist );
|
||||
}
|
||||
|
||||
|
||||
@@ -422,14 +422,14 @@ TomahawkWindow::createStation()
|
||||
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, false );
|
||||
playlist->setMode( OnDemand );
|
||||
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls() );
|
||||
PlaylistManager::instance()->show( playlist );
|
||||
ViewManager::instance()->show( playlist );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::createPlaylist()
|
||||
{
|
||||
PlaylistManager::instance()->show( new NewPlaylistWidget() );
|
||||
ViewManager::instance()->show( new NewPlaylistWidget() );
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user