mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
* Prevent creating a new revision while already updating a playlist.
This commit is contained in:
@@ -39,6 +39,8 @@ DatabaseCommand_SetPlaylistRevision::DatabaseCommand_SetPlaylistRevision(
|
|||||||
, m_addedentries( addedentries )
|
, m_addedentries( addedentries )
|
||||||
, m_entries( entries )
|
, m_entries( entries )
|
||||||
{
|
{
|
||||||
|
Q_ASSERT( !newrev.isEmpty() );
|
||||||
|
Q_ASSERT( !oldrev.isEmpty() );
|
||||||
m_localOnly = ( newrev == oldrev );
|
m_localOnly = ( newrev == oldrev );
|
||||||
|
|
||||||
setPlaylistguid( playlistguid );
|
setPlaylistguid( playlistguid );
|
||||||
@@ -70,7 +72,6 @@ DatabaseCommand_SetPlaylistRevision::postCommitHook()
|
|||||||
|
|
||||||
// private, but we are a friend. will recall itself in its own thread:
|
// private, but we are a friend. will recall itself in its own thread:
|
||||||
playlist_ptr playlist = source()->collection()->playlist( m_playlistguid );
|
playlist_ptr playlist = source()->collection()->playlist( m_playlistguid );
|
||||||
|
|
||||||
if ( playlist.isNull() )
|
if ( playlist.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << m_playlistguid;
|
qDebug() << m_playlistguid;
|
||||||
|
@@ -113,6 +113,7 @@ Playlist::Playlist( const source_ptr& src,
|
|||||||
, m_lastmodified( lastmod )
|
, m_lastmodified( lastmod )
|
||||||
, m_createdOn( createdOn )
|
, m_createdOn( createdOn )
|
||||||
, m_shared( shared )
|
, m_shared( shared )
|
||||||
|
, m_busy( false )
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << "1";
|
// qDebug() << Q_FUNC_INFO << "1";
|
||||||
init();
|
init();
|
||||||
@@ -134,6 +135,7 @@ Playlist::Playlist( const source_ptr& author,
|
|||||||
, m_lastmodified( 0 )
|
, m_lastmodified( 0 )
|
||||||
, m_createdOn( 0 ) // will be set by db command
|
, m_createdOn( 0 ) // will be set by db command
|
||||||
, m_shared( shared )
|
, m_shared( shared )
|
||||||
|
, m_busy( false )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "2";
|
qDebug() << Q_FUNC_INFO << "2";
|
||||||
init();
|
init();
|
||||||
@@ -266,11 +268,16 @@ Playlist::loadRevision( const QString& rev )
|
|||||||
void
|
void
|
||||||
Playlist::createNewRevision( const QString& newrev, const QString& oldrev, const QList< plentry_ptr >& entries )
|
Playlist::createNewRevision( const QString& newrev, const QString& oldrev, const QList< plentry_ptr >& entries )
|
||||||
{
|
{
|
||||||
// qDebug() << "m_entries guids:";
|
qDebug() << Q_FUNC_INFO << newrev << oldrev << entries.count();
|
||||||
|
|
||||||
|
Q_ASSERT( !busy() );
|
||||||
|
if ( newrev != oldrev )
|
||||||
|
setBusy( true );
|
||||||
|
|
||||||
// calc list of newly added entries:
|
// calc list of newly added entries:
|
||||||
QList<plentry_ptr> added = newEntries( entries );
|
QList<plentry_ptr> added = newEntries( entries );
|
||||||
QStringList orderedguids;
|
QStringList orderedguids;
|
||||||
foreach( plentry_ptr p, entries )
|
foreach( const plentry_ptr& p, entries )
|
||||||
orderedguids << p->guid();
|
orderedguids << p->guid();
|
||||||
|
|
||||||
// source making the change (local user in this case)
|
// source making the change (local user in this case)
|
||||||
@@ -283,8 +290,8 @@ Playlist::createNewRevision( const QString& newrev, const QString& oldrev, const
|
|||||||
oldrev,
|
oldrev,
|
||||||
orderedguids,
|
orderedguids,
|
||||||
added,
|
added,
|
||||||
entries
|
entries );
|
||||||
);
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +323,7 @@ Playlist::setRevision( const QString& rev,
|
|||||||
|
|
||||||
PlaylistRevision pr = setNewRevision( rev, neworderedguids, oldorderedguids, is_newest_rev, addedmap );
|
PlaylistRevision pr = setNewRevision( rev, neworderedguids, oldorderedguids, is_newest_rev, addedmap );
|
||||||
|
|
||||||
|
Q_ASSERT( applied );
|
||||||
if ( applied )
|
if ( applied )
|
||||||
m_currentrevision = rev;
|
m_currentrevision = rev;
|
||||||
pr.applied = applied;
|
pr.applied = applied;
|
||||||
@@ -326,6 +334,8 @@ Playlist::setRevision( const QString& rev,
|
|||||||
SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ), Qt::UniqueConnection );
|
SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ), Qt::UniqueConnection );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBusy( false );
|
||||||
emit revisionLoaded( pr );
|
emit revisionLoaded( pr );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,6 +348,7 @@ Playlist::setNewRevision( const QString& rev,
|
|||||||
const QMap< QString, Tomahawk::plentry_ptr >& addedmap )
|
const QMap< QString, Tomahawk::plentry_ptr >& addedmap )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << rev << is_newest_rev << m_title << addedmap.count() << neworderedguids.count() << oldorderedguids.count();
|
qDebug() << Q_FUNC_INFO << rev << is_newest_rev << m_title << addedmap.count() << neworderedguids.count() << oldorderedguids.count();
|
||||||
|
|
||||||
// build up correctly ordered new list of plentry_ptrs from
|
// build up correctly ordered new list of plentry_ptrs from
|
||||||
// existing ones, and the ones that have been added
|
// existing ones, and the ones that have been added
|
||||||
QMap<QString, plentry_ptr> entriesmap;
|
QMap<QString, plentry_ptr> entriesmap;
|
||||||
@@ -461,8 +472,6 @@ Playlist::addEntry( const query_ptr& query, const QString& oldrev )
|
|||||||
void
|
void
|
||||||
Playlist::addEntries( const QList<query_ptr>& queries, const QString& oldrev )
|
Playlist::addEntries( const QList<query_ptr>& queries, const QString& oldrev )
|
||||||
{
|
{
|
||||||
//qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
QList<plentry_ptr> el = addEntriesInternal( queries );
|
QList<plentry_ptr> el = addEntriesInternal( queries );
|
||||||
|
|
||||||
QString newrev = uuid();
|
QString newrev = uuid();
|
||||||
@@ -522,3 +531,10 @@ Playlist::tracks()
|
|||||||
return queries;
|
return queries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Playlist::setBusy( bool b )
|
||||||
|
{
|
||||||
|
m_busy = b;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
@@ -143,6 +143,8 @@ public:
|
|||||||
unsigned int lastmodified() const { return m_lastmodified; }
|
unsigned int lastmodified() const { return m_lastmodified; }
|
||||||
uint createdOn() const { return m_createdOn; }
|
uint createdOn() const { return m_createdOn; }
|
||||||
|
|
||||||
|
bool busy() const { return m_busy; }
|
||||||
|
|
||||||
const QList< plentry_ptr >& entries() { return m_entries; }
|
const QList< plentry_ptr >& entries() { return m_entries; }
|
||||||
virtual void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
|
virtual void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
|
||||||
virtual void addEntries( const QList<Tomahawk::query_ptr>& queries, const QString& oldrev );
|
virtual void addEntries( const QList<Tomahawk::query_ptr>& queries, const QString& oldrev );
|
||||||
@@ -248,6 +250,8 @@ private:
|
|||||||
Playlist();
|
Playlist();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
void setBusy( bool b );
|
||||||
|
|
||||||
source_ptr m_source;
|
source_ptr m_source;
|
||||||
QString m_currentrevision;
|
QString m_currentrevision;
|
||||||
QString m_guid, m_title, m_info, m_creator;
|
QString m_guid, m_title, m_info, m_creator;
|
||||||
@@ -257,7 +261,7 @@ private:
|
|||||||
|
|
||||||
QList< plentry_ptr > m_entries;
|
QList< plentry_ptr > m_entries;
|
||||||
bool m_locallyChanged;
|
bool m_locallyChanged;
|
||||||
|
bool m_busy;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -216,6 +216,7 @@ PlaylistModel::insert( unsigned int row, const Tomahawk::query_ptr& query )
|
|||||||
onTracksInserted( row, ql );
|
onTracksInserted( row, ql );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistModel::trackResolved( bool )
|
PlaylistModel::trackResolved( bool )
|
||||||
{
|
{
|
||||||
@@ -296,16 +297,19 @@ PlaylistModel::onRevisionLoaded( Tomahawk::PlaylistRevision revision )
|
|||||||
loadPlaylist( m_playlist );
|
loadPlaylist( m_playlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMimeData*
|
QMimeData*
|
||||||
PlaylistModel::mimeData( const QModelIndexList& indexes ) const
|
PlaylistModel::mimeData( const QModelIndexList& indexes ) const
|
||||||
{
|
{
|
||||||
// Add the playlist id to the mime data so that we can detect dropping on ourselves
|
// Add the playlist id to the mime data so that we can detect dropping on ourselves
|
||||||
QMimeData* d = TrackModel::mimeData( indexes );
|
QMimeData* d = TrackModel::mimeData( indexes );
|
||||||
|
if ( !m_playlist.isNull() )
|
||||||
d->setData( "application/tomahawk.playlist.id", m_playlist->guid().toLatin1() );
|
d->setData( "application/tomahawk.playlist.id", m_playlist->guid().toLatin1() );
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
|
@@ -41,6 +41,7 @@ WelcomePlaylistModel::WelcomePlaylistModel( QObject* parent )
|
|||||||
void
|
void
|
||||||
WelcomePlaylistModel::loadFromSettings()
|
WelcomePlaylistModel::loadFromSettings()
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
if( !m_waitingForSome )
|
if( !m_waitingForSome )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -79,7 +80,6 @@ WelcomePlaylistModel::data( const QModelIndex& index, int role ) const
|
|||||||
if( !index.isValid() || !hasIndex( index.row(), index.column(), index.parent() ) )
|
if( !index.isValid() || !hasIndex( index.row(), index.column(), index.parent() ) )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
|
||||||
playlist_ptr pl = m_recplaylists[index.row()];
|
playlist_ptr pl = m_recplaylists[index.row()];
|
||||||
switch( role )
|
switch( role )
|
||||||
{
|
{
|
||||||
|
@@ -40,12 +40,14 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
|||||||
QList< dynplaylist_ptr > autoplaylists = source->collection()->autoPlaylists();
|
QList< dynplaylist_ptr > autoplaylists = source->collection()->autoPlaylists();
|
||||||
QList< dynplaylist_ptr > stations = source->collection()->stations();
|
QList< dynplaylist_ptr > stations = source->collection()->stations();
|
||||||
|
|
||||||
if( !playlists.isEmpty() || !autoplaylists.isEmpty() || source->isLocal() ) {
|
if ( !playlists.isEmpty() || !autoplaylists.isEmpty() || source->isLocal() )
|
||||||
|
{
|
||||||
m_playlists = new CategoryItem( model(), this, SourcesModel::PlaylistsCategory, source->isLocal() );
|
m_playlists = new CategoryItem( model(), this, SourcesModel::PlaylistsCategory, source->isLocal() );
|
||||||
onPlaylistsAdded( playlists );
|
onPlaylistsAdded( playlists );
|
||||||
onAutoPlaylistsAdded( autoplaylists );
|
onAutoPlaylistsAdded( autoplaylists );
|
||||||
}
|
}
|
||||||
if( !stations.isEmpty() || source->isLocal() ) {
|
if ( !stations.isEmpty() || source->isLocal() )
|
||||||
|
{
|
||||||
m_stations = new CategoryItem( model(), this, SourcesModel::StationsCategory, source->isLocal() );
|
m_stations = new CategoryItem( model(), this, SourcesModel::StationsCategory, source->isLocal() );
|
||||||
onStationsAdded( stations );
|
onStationsAdded( stations );
|
||||||
}
|
}
|
||||||
@@ -108,13 +110,13 @@ CollectionItem::peerSortValue() const
|
|||||||
void
|
void
|
||||||
CollectionItem::activate()
|
CollectionItem::activate()
|
||||||
{
|
{
|
||||||
if( source().isNull() ) {
|
ViewPage* p = 0;
|
||||||
ViewPage* p = ViewManager::instance()->showSuperCollection();
|
if ( source().isNull() )
|
||||||
|
p = ViewManager::instance()->showSuperCollection();
|
||||||
|
else
|
||||||
|
p = ViewManager::instance()->show( source()->collection() );
|
||||||
|
|
||||||
model()->linkSourceItemToPage( this, p );
|
model()->linkSourceItemToPage( this, p );
|
||||||
} else {
|
|
||||||
ViewPage* p = ViewManager::instance()->show( source()->collection() );
|
|
||||||
model()->linkSourceItemToPage( this, p );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -176,7 +178,9 @@ CollectionItem::onPlaylistsAdded( const QList< playlist_ptr >& playlists )
|
|||||||
if( playlists.isEmpty() )
|
if( playlists.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !m_playlists ) { // add the category too
|
if( !m_playlists )
|
||||||
|
{
|
||||||
|
// add the category too
|
||||||
int cur = children().count();
|
int cur = children().count();
|
||||||
beginRowsAdded( cur, cur );
|
beginRowsAdded( cur, cur );
|
||||||
m_playlists = new CategoryItem( model(), this, SourcesModel::PlaylistsCategory, source()->isLocal() );
|
m_playlists = new CategoryItem( model(), this, SourcesModel::PlaylistsCategory, source()->isLocal() );
|
||||||
|
@@ -82,14 +82,20 @@ Qt::ItemFlags
|
|||||||
PlaylistItem::flags() const
|
PlaylistItem::flags() const
|
||||||
{
|
{
|
||||||
Qt::ItemFlags flags = SourceTreeItem::flags();
|
Qt::ItemFlags flags = SourceTreeItem::flags();
|
||||||
|
flags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||||
|
|
||||||
if ( !m_loaded )
|
if ( !m_loaded )
|
||||||
flags &= !Qt::ItemIsEnabled;
|
flags &= !Qt::ItemIsEnabled;
|
||||||
|
|
||||||
flags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
|
||||||
if ( playlist()->author()->isLocal() )
|
if ( playlist()->author()->isLocal() )
|
||||||
flags |= Qt::ItemIsEditable;
|
flags |= Qt::ItemIsEditable;
|
||||||
|
|
||||||
|
if ( playlist()->busy() )
|
||||||
|
{
|
||||||
|
flags &= !Qt::ItemIsEnabled;
|
||||||
|
flags &= !Qt::ItemIsEditable;
|
||||||
|
flags &= !Qt::ItemIsDropEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +172,7 @@ PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
|||||||
|
|
||||||
if ( queries.count() && !m_playlist.isNull() && m_playlist->author()->isLocal() )
|
if ( queries.count() && !m_playlist.isNull() && m_playlist->author()->isLocal() )
|
||||||
{
|
{
|
||||||
qDebug() << "on playlist:" << m_playlist->title() << m_playlist->guid();
|
qDebug() << "on playlist:" << m_playlist->title() << m_playlist->guid() << m_playlist->currentrevision();
|
||||||
|
|
||||||
// TODO do we need to use this in the refactor?
|
// TODO do we need to use this in the refactor?
|
||||||
// QString rev = item->currentlyLoadedPlaylistRevision( playlist->guid() );
|
// QString rev = item->currentlyLoadedPlaylistRevision( playlist->guid() );
|
||||||
|
Reference in New Issue
Block a user