Пример #1
0
void
ViewManager::createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents )
{
    Tomahawk::playlist_ptr p = Tomahawk::playlist_ptr( new Tomahawk::Playlist( src ) );
    QJson::QObjectHelper::qvariant2qobject( contents.toMap(), p.data() );
    p->reportCreated( p );
}
Пример #2
0
void
Collection::addPlaylist( const Tomahawk::playlist_ptr& p )
{
    if ( m_playlists.contains( p->guid() ) )
        return;

    QList<playlist_ptr> toadd;
    toadd << p;
    m_playlists.insert( p->guid(), p );

/*    qDebug() << Q_FUNC_INFO << "Collection name" << name()
                            << "from source id" << source()->id()
                            << "numplaylists:" << m_playlists.count();*/
    emit playlistsAdded( toadd );
}
Пример #3
0
void
ViewManager::loadCurrentPlaylistSettings()
{
    TomahawkSettings* s = TomahawkSettings::instance();
    Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
    if ( !pl.isNull() ) {
        currentPlaylistInterface()->setShuffled( s->shuffleState( pl->guid() ));
        currentPlaylistInterface()->setRepeatMode( s->repeatMode( pl->guid() ));
    } else {
        Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
        if ( !dynPl.isNull() ) {
            currentPlaylistInterface()->setShuffled( s->shuffleState( dynPl->guid() ));
        }
    }
}
Пример #4
0
bool
PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
{
    PlaylistView* view;
    if ( !m_playlistViews.contains( playlist ) )
    {
        view = new PlaylistView();
        PlaylistModel* model = new PlaylistModel();
        view->setModel( model );
        view->setFrameShape( QFrame::NoFrame );
        view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
        model->loadPlaylist( playlist );
        playlist->resolve();

        m_playlistViews.insert( playlist, view );
    }
    else
    {
        view = m_playlistViews.value( playlist );
    }
    
    setPage( view );
    TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
    emit numSourcesChanged( SourceList::instance()->count() );

    return true;
}
Пример #5
0
void
LocalCollection::createBookmarksPlaylist()
{
    if( bookmarksPlaylist().isNull() ) {
        QString guid = uuid();
        Tomahawk::playlist_ptr p = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), guid, tr( "Bookmarks" ), tr( "Saved tracks" ), QString(), false );

#ifndef ENABLE_HEADLESS
        ViewManager::instance()->createPageForPlaylist( p );
//         connect( p.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( loaded( Tomahawk::PlaylistRevision ) ), Qt::QueuedConnection );
        connect( p.data(), SIGNAL( created() ), this, SLOT( created() ) );
#endif
        TomahawkSettings::instance()->setBookmarkPlaylist( guid );
//         p->createNewRevision( uuid(), p->currentrevision(), QList< Tomahawk::plentry_ptr >() );
    }
}
Пример #6
0
void
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries )
{
    if ( !m_playlist.isNull() )
    {
        disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
        disconnect( m_playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
    }

    if ( rowCount( QModelIndex() ) && loadEntries )
    {
        clear();
    }

    m_playlist = playlist;
    connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
    connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );

    setReadOnly( !m_playlist->author()->isLocal() );
    setTitle( playlist->title() );
    setDescription( tr( "A playlist by %1" ).arg( playlist->author()->isLocal() ? tr( "you" ) : playlist->author()->friendlyName() ) );

    if ( !loadEntries )
        return;

    TrackModelItem* plitem;
    QList<plentry_ptr> entries = playlist->entries();
    if ( entries.count() )
    {
        int c = rowCount( QModelIndex() );

        qDebug() << "Starting loading" << playlist->title();
        emit beginInsertRows( QModelIndex(), c, c + entries.count() - 1 );

        m_waitingForResolved.clear();
        foreach( const plentry_ptr& entry, entries )
        {
            qDebug() << entry->query()->toString();
            plitem = new TrackModelItem( entry, m_rootItem );
            plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );

            connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );

            if( !entry->query()->resolvingFinished() && entry->query()->playable() ) {
                m_waitingForResolved.append( entry->query().data() );
                connect( entry->query().data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolved( bool ) ) );
            }
Пример #7
0
void
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries )
{
    if ( !m_playlist.isNull() )
    {
        disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
        disconnect( m_playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
        disconnect( m_playlist.data(), SIGNAL( changed() ), this, SIGNAL( playlistChanged() ) );
    }

    if ( loadEntries )
        clear();

    m_playlist = playlist;
    connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
    connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
    connect( playlist.data(), SIGNAL( changed() ), this, SIGNAL( playlistChanged() ) );

    setReadOnly( !m_playlist->author()->isLocal() );
    setTitle( playlist->title() );
    setDescription( tr( "A playlist by %1, created %2" )
                  .arg( playlist->author()->isLocal() ? tr( "you" ) : playlist->author()->friendlyName() )
                  .arg( TomahawkUtils::ageToString( QDateTime::fromTime_t( playlist->createdOn() ), true ) ) );

    m_isTemporary = false;
    if ( !loadEntries )
        return;

    QList<plentry_ptr> entries = playlist->entries();
    append( entries );
}
Пример #8
0
void
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries )
{
    Q_D( PlaylistModel );

    if ( d->playlist )
    {
        disconnect( d->playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
        disconnect( d->playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
        disconnect( d->playlist.data(), SIGNAL( changed() ), this, SLOT( onPlaylistChanged() ) );
    }

    if ( loadEntries )
    {
        startLoading();
        clear();
    }

    d->playlist = playlist;
    connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
    connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), SIGNAL( playlistDeleted() ) );
    connect( playlist.data(), SIGNAL( changed() ), SLOT( onPlaylistChanged() ) );

    setReadOnly( !d->playlist->author()->isLocal() );
    d->isTemporary = false;

    onPlaylistChanged();
    if ( !loadEntries )
        return;

    if ( playlist->loaded() )
    {
        QList<plentry_ptr> entries = playlist->entries();
        appendEntries( entries );

        // finishLoading() will be called by appendEntries, so it can keep showing it until all tracks are resolved
        // finishLoading();

        /*    foreach ( const plentry_ptr& p, entries )
                  qDebug() << p->guid() << p->query()->track() << p->query()->artist(); */
    }
}
Пример #9
0
void
Collection::deletePlaylist( const Tomahawk::playlist_ptr& p )
{
    QList<playlist_ptr> todelete;
    todelete << p;
    m_playlists.remove( p->guid() );

/*    qDebug() << Q_FUNC_INFO << "Collection name" << name()
                            << "from source id" << source()->id()
                            << "numplaylists:" << m_playlists.count();*/
    emit playlistsDeleted( todelete );
}
Пример #10
0
void
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries )
{
    if ( !m_playlist.isNull() )
    {
        disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
        disconnect( m_playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
        disconnect( m_playlist.data(), SIGNAL( changed() ), this, SLOT( onPlaylistChanged() ) );
    }

    m_isLoading = true;

    if ( loadEntries )
        clear();

    m_playlist = playlist;
    connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
    connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), SIGNAL( playlistDeleted() ) );
    connect( playlist.data(), SIGNAL( changed() ), SLOT( onPlaylistChanged() ) );

    setReadOnly( !m_playlist->author()->isLocal() );
    m_isTemporary = false;

    onPlaylistChanged();

    if ( !loadEntries )
    {
        m_isLoading = false;
        return;
    }

    QList<plentry_ptr> entries = playlist->entries();
/*    foreach ( const plentry_ptr& p, entries )
        qDebug() << p->guid() << p->query()->track() << p->query()->artist();*/

    appendEntries( entries );

    m_isLoading = false;
}
Пример #11
0
QModelIndex
SourcesModel::playlistToIndex( const Tomahawk::playlist_ptr& playlist )
{
    for ( int i = 0; i < rowCount(); i++ )
    {
        QModelIndex pidx = index( i, 0 );

        for ( int j = 0; j < rowCount( pidx ); j++ )
        {
            QModelIndex idx = index( j, 0, pidx );
            SourcesModel::SourceType type = SourcesModel::indexType( idx );

            if ( type == SourcesModel::PlaylistSource )
            {
                playlist_ptr p = SourcesModel::indexToPlaylist( idx );
                if ( playlist.data() == p.data() )
                    return idx;
            }
        }
    }

    return QModelIndex();
}
Пример #12
0
void
ContextMenu::addToPlaylist( int playlistIdx )
{
    Tomahawk::playlist_ptr playlist = m_playlists.at( playlistIdx );
    playlist->addEntries( m_queries );
}
Пример #13
0
bool caseInsensitiveLessThan(Tomahawk::playlist_ptr &s1, Tomahawk::playlist_ptr &s2)
{
    return s1->title().toLower() < s2->title().toLower();
}