mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 08:19:42 +01:00
* Protect DynamicPlaylists, too.
* Only load the five most recent playlists & 25 tracks in the WelcomeWidget.
This commit is contained in:
parent
0d23934200
commit
5a64fc1361
@ -40,7 +40,6 @@ DatabaseCommand_SetPlaylistRevision::DatabaseCommand_SetPlaylistRevision(
|
||||
, m_entries( entries )
|
||||
{
|
||||
Q_ASSERT( !newrev.isEmpty() );
|
||||
Q_ASSERT( !oldrev.isEmpty() );
|
||||
m_localOnly = ( newrev == oldrev );
|
||||
|
||||
setPlaylistguid( playlistguid );
|
||||
|
@ -175,7 +175,7 @@ Playlist::create( const source_ptr& author,
|
||||
// reportCreated for us automatically, which should cause new playlists to be added to the GUI.
|
||||
|
||||
DatabaseCommand_CreatePlaylist* cmd = new DatabaseCommand_CreatePlaylist( author, playlist );
|
||||
connect( cmd, SIGNAL(finished()), playlist.data(), SIGNAL(created()) );
|
||||
connect( cmd, SIGNAL( finished() ), playlist.data(), SIGNAL( created() ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
playlist->reportCreated( playlist );
|
||||
return playlist;
|
||||
@ -244,6 +244,7 @@ Playlist::loadRevision( const QString& rev )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << currentrevision() << rev << m_title;
|
||||
|
||||
setBusy( true );
|
||||
DatabaseCommand_LoadPlaylistEntries* cmd =
|
||||
new DatabaseCommand_LoadPlaylistEntries( rev.isEmpty() ? currentrevision() : rev );
|
||||
|
||||
|
@ -114,6 +114,7 @@ Q_PROPERTY( bool shared READ shared WRITE setShared )
|
||||
friend class ::DatabaseCommand_LoadAllPlaylists;
|
||||
friend class ::DatabaseCommand_SetPlaylistRevision;
|
||||
friend class ::DatabaseCommand_CreatePlaylist;
|
||||
friend class DynamicPlaylist;
|
||||
|
||||
public:
|
||||
~Playlist();
|
||||
|
@ -153,6 +153,9 @@ DynamicPlaylist::createNewRevision( const QString& newrev,
|
||||
const QList< dyncontrol_ptr>& controls,
|
||||
const QList< plentry_ptr >& entries )
|
||||
{
|
||||
Q_ASSERT( !busy() );
|
||||
setBusy( true );
|
||||
|
||||
// get the newly added tracks
|
||||
QList< plentry_ptr > added = newEntries( entries );
|
||||
|
||||
@ -162,21 +165,21 @@ DynamicPlaylist::createNewRevision( const QString& newrev,
|
||||
|
||||
// no conflict resolution or partial updating for controls. all or nothing baby
|
||||
|
||||
// source making the change (local user in this case)
|
||||
source_ptr author = SourceList::instance()->getLocal();
|
||||
// command writes new rev to DB and calls setRevision, which emits our signal
|
||||
DatabaseCommand_SetDynamicPlaylistRevision* cmd =
|
||||
new DatabaseCommand_SetDynamicPlaylistRevision( author,
|
||||
guid(),
|
||||
newrev,
|
||||
oldrev,
|
||||
orderedguids,
|
||||
added,
|
||||
entries,
|
||||
type,
|
||||
Static,
|
||||
controls );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
// source making the change (local user in this case)
|
||||
source_ptr author = SourceList::instance()->getLocal();
|
||||
// command writes new rev to DB and calls setRevision, which emits our signal
|
||||
DatabaseCommand_SetDynamicPlaylistRevision* cmd =
|
||||
new DatabaseCommand_SetDynamicPlaylistRevision( author,
|
||||
guid(),
|
||||
newrev,
|
||||
oldrev,
|
||||
orderedguids,
|
||||
added,
|
||||
entries,
|
||||
type,
|
||||
Static,
|
||||
controls );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
// create a new revision that will be an ondemand playlist, as it has no entries
|
||||
@ -205,6 +208,7 @@ DynamicPlaylist::loadRevision( const QString& rev )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Loading with:" << ( rev.isEmpty() ? currentrevision() : rev );
|
||||
|
||||
setBusy( true );
|
||||
DatabaseCommand_LoadDynamicPlaylist* cmd = new DatabaseCommand_LoadDynamicPlaylist( rev.isEmpty() ? currentrevision() : rev );
|
||||
|
||||
if( m_generator->mode() == OnDemand ) {
|
||||
@ -335,10 +339,11 @@ void DynamicPlaylist::setRevision( const QString& rev,
|
||||
dpr.type = type;
|
||||
dpr.mode = Static;
|
||||
|
||||
if( applied ) {
|
||||
if( applied )
|
||||
setCurrentrevision( rev );
|
||||
}
|
||||
|
||||
// qDebug() << "EMITTING REVISION LOADED 1!";
|
||||
setBusy( false );
|
||||
emit dynamicRevisionLoaded( dpr );
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,11 @@ void
|
||||
PlaylistModel::trackResolved( bool )
|
||||
{
|
||||
Tomahawk::Query* q = qobject_cast< Query* >( sender() );
|
||||
Q_ASSERT( q );
|
||||
if ( !q )
|
||||
{
|
||||
// Track has been removed from the playlist by now
|
||||
return;
|
||||
}
|
||||
|
||||
m_waitingForResolved.removeAll( q );
|
||||
disconnect( q, SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolved( bool ) ) );
|
||||
|
@ -385,9 +385,14 @@ TomahawkSettings::recentlyPlayedPlaylists() const
|
||||
}
|
||||
|
||||
QStringList
|
||||
TomahawkSettings::recentlyPlayedPlaylistGuids() const
|
||||
TomahawkSettings::recentlyPlayedPlaylistGuids( unsigned int amount ) const
|
||||
{
|
||||
return value( "playlists/recentlyPlayed" ).toStringList();
|
||||
QStringList p = value( "playlists/recentlyPlayed" ).toStringList();
|
||||
|
||||
while ( amount && p.count() > (int)amount )
|
||||
p.removeAt( p.count() - 1 );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );
|
||||
|
||||
QList<Tomahawk::playlist_ptr> recentlyPlayedPlaylists() const;
|
||||
QStringList recentlyPlayedPlaylistGuids() const;
|
||||
QStringList recentlyPlayedPlaylistGuids( unsigned int amount = 0 ) const;
|
||||
void appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
|
||||
/// SIP plugins
|
||||
|
@ -28,6 +28,7 @@ using namespace Tomahawk;
|
||||
WelcomePlaylistModel::WelcomePlaylistModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
, m_waitingForSome( true )
|
||||
, m_maxPlaylists( 0 )
|
||||
{
|
||||
loadFromSettings();
|
||||
|
||||
@ -49,7 +50,7 @@ WelcomePlaylistModel::loadFromSettings()
|
||||
m_recplaylists.clear();
|
||||
m_waitingForSome = false;
|
||||
|
||||
QStringList playlist_guids = TomahawkSettings::instance()->recentlyPlayedPlaylistGuids();
|
||||
QStringList playlist_guids = TomahawkSettings::instance()->recentlyPlayedPlaylistGuids( m_maxPlaylists );
|
||||
|
||||
for( int i = playlist_guids.size() - 1; i >= 0; i-- )
|
||||
{
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
{ ArtistRole = Qt::UserRole, TrackCountRole, PlaylistRole };
|
||||
|
||||
explicit WelcomePlaylistModel( QObject* parent = 0 );
|
||||
|
||||
void setMaxPlaylists( unsigned int max ) { m_maxPlaylists = max; }
|
||||
|
||||
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
|
||||
virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
|
||||
|
||||
@ -53,6 +56,7 @@ private:
|
||||
QHash< QString, Tomahawk::playlist_ptr > m_cached;
|
||||
mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
|
||||
|
||||
unsigned int m_maxPlaylists;
|
||||
bool m_waitingForSome;
|
||||
};
|
||||
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include <QPainter>
|
||||
#include "welcomeplaylistmodel.h"
|
||||
|
||||
#define HISTORY_TRACK_ITEMS 50
|
||||
#define HISTORY_PLAYLIST_ITEMS 10
|
||||
#define HISTORY_TRACK_ITEMS 25
|
||||
#define HISTORY_PLAYLIST_ITEMS 5
|
||||
#define HISTORY_RESOLVING_TIMEOUT 2500
|
||||
|
||||
|
||||
@ -44,14 +44,15 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
WelcomePlaylistModel* model = new WelcomePlaylistModel( this );
|
||||
model->setMaxPlaylists( HISTORY_PLAYLIST_ITEMS );
|
||||
|
||||
ui->playlistWidget->setItemDelegate( new PlaylistDelegate() );
|
||||
WelcomePlaylistModel* model = new WelcomePlaylistModel( this );
|
||||
ui->playlistWidget->setModel( model );
|
||||
ui->playlistWidget->overlay()->resize( 380, 86 );
|
||||
ui->tracksView->overlay()->setEnabled( false );
|
||||
|
||||
connect( model,SIGNAL( emptinessChanged( bool) ), this, SLOT( updatePlaylists() ) );
|
||||
|
||||
connect( model, SIGNAL( emptinessChanged( bool) ), this, SLOT( updatePlaylists() ) );
|
||||
|
||||
m_tracksModel = new PlaylistModel( ui->tracksView );
|
||||
ui->tracksView->setPlaylistModel( m_tracksModel );
|
||||
|
Loading…
x
Reference in New Issue
Block a user