mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Wait for the playlist to be created before we add stuff to it.
This commit is contained in:
@@ -47,7 +47,7 @@ DatabaseCommand_CreatePlaylist::DatabaseCommand_CreatePlaylist( const source_ptr
|
|||||||
void
|
void
|
||||||
DatabaseCommand_CreatePlaylist::exec( DatabaseImpl* lib )
|
DatabaseCommand_CreatePlaylist::exec( DatabaseImpl* lib )
|
||||||
{
|
{
|
||||||
createPlaylist(lib, false);
|
createPlaylist( lib, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,32 +55,29 @@ void
|
|||||||
DatabaseCommand_CreatePlaylist::postCommitHook()
|
DatabaseCommand_CreatePlaylist::postCommitHook()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( source().isNull() || source()->collection().isNull() )
|
if ( m_report == false )
|
||||||
{
|
|
||||||
qDebug() << "Source has gone offline, not emitting to GUI.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( m_report == false )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "..reporting..";
|
qDebug() << Q_FUNC_INFO << "reporting...";
|
||||||
if( m_playlist.isNull() ) {
|
if ( m_playlist.isNull() )
|
||||||
|
{
|
||||||
source_ptr src = source();
|
source_ptr src = source();
|
||||||
QMetaObject::invokeMethod( ViewManager::instance(),
|
QMetaObject::invokeMethod( ViewManager::instance(),
|
||||||
"createPlaylist",
|
"createPlaylist",
|
||||||
Qt::BlockingQueuedConnection,
|
Qt::BlockingQueuedConnection,
|
||||||
QGenericArgument( "Tomahawk::source_ptr", (const void*)&src ),
|
QGenericArgument( "Tomahawk::source_ptr", (const void*)&src ),
|
||||||
Q_ARG( QVariant, m_v )
|
Q_ARG( QVariant, m_v ) );
|
||||||
);
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
m_playlist->reportCreated( m_playlist );
|
m_playlist->reportCreated( m_playlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( source()->isLocal() )
|
||||||
if( source()->isLocal() )
|
|
||||||
Servent::instance()->triggerDBSync();
|
Servent::instance()->triggerDBSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DatabaseCommand_CreatePlaylist::createPlaylist( DatabaseImpl* lib, bool dynamic)
|
DatabaseCommand_CreatePlaylist::createPlaylist( DatabaseImpl* lib, bool dynamic)
|
||||||
{
|
{
|
||||||
@@ -89,7 +86,7 @@ DatabaseCommand_CreatePlaylist::createPlaylist( DatabaseImpl* lib, bool dynamic)
|
|||||||
Q_ASSERT( !source().isNull() );
|
Q_ASSERT( !source().isNull() );
|
||||||
|
|
||||||
uint now = 0;
|
uint now = 0;
|
||||||
if( m_playlist.isNull() )
|
if ( m_playlist.isNull() )
|
||||||
{
|
{
|
||||||
now = m_v.toMap()[ "createdon" ].toUInt();
|
now = m_v.toMap()[ "createdon" ].toUInt();
|
||||||
}
|
}
|
||||||
@@ -106,14 +103,17 @@ DatabaseCommand_CreatePlaylist::createPlaylist( DatabaseImpl* lib, bool dynamic)
|
|||||||
cre.bindValue( ":source", source()->isLocal() ? QVariant(QVariant::Int) : source()->id() );
|
cre.bindValue( ":source", source()->isLocal() ? QVariant(QVariant::Int) : source()->id() );
|
||||||
cre.bindValue( ":dynplaylist", dynamic );
|
cre.bindValue( ":dynplaylist", dynamic );
|
||||||
cre.bindValue( ":createdOn", now );
|
cre.bindValue( ":createdOn", now );
|
||||||
if( !m_playlist.isNull() ) {
|
if ( !m_playlist.isNull() )
|
||||||
|
{
|
||||||
cre.bindValue( ":guid", m_playlist->guid() );
|
cre.bindValue( ":guid", m_playlist->guid() );
|
||||||
cre.bindValue( ":shared", m_playlist->shared() );
|
cre.bindValue( ":shared", m_playlist->shared() );
|
||||||
cre.bindValue( ":title", m_playlist->title() );
|
cre.bindValue( ":title", m_playlist->title() );
|
||||||
cre.bindValue( ":info", m_playlist->info() );
|
cre.bindValue( ":info", m_playlist->info() );
|
||||||
cre.bindValue( ":creator", m_playlist->creator() );
|
cre.bindValue( ":creator", m_playlist->creator() );
|
||||||
cre.bindValue( ":lastmodified", m_playlist->lastmodified() );
|
cre.bindValue( ":lastmodified", m_playlist->lastmodified() );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
QVariantMap m = m_v.toMap();
|
QVariantMap m = m_v.toMap();
|
||||||
cre.bindValue( ":guid", m.value( "guid" ) );
|
cre.bindValue( ":guid", m.value( "guid" ) );
|
||||||
cre.bindValue( ":shared", m.value( "shared" ) );
|
cre.bindValue( ":shared", m.value( "shared" ) );
|
||||||
|
@@ -137,7 +137,7 @@ GlobalActionManager::handlePlaylistCommand( const QUrl& url )
|
|||||||
|
|
||||||
if( parts[ 0 ] == "import" ) {
|
if( parts[ 0 ] == "import" ) {
|
||||||
if( !url.hasQueryItem( "xspf" ) ) {
|
if( !url.hasQueryItem( "xspf" ) ) {
|
||||||
qDebug() << "No xspf to load..";
|
qDebug() << "No xspf to load...";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QUrl xspf = QUrl( url.queryItemValue( "xspf" ) );
|
QUrl xspf = QUrl( url.queryItemValue( "xspf" ) );
|
||||||
|
@@ -133,7 +133,8 @@ XSPFLoader::gotBody()
|
|||||||
|
|
||||||
QString artist, album, track, duration, annotation, url;
|
QString artist, album, track, duration, annotation, url;
|
||||||
QDomElement n = e.firstChildElement();
|
QDomElement n = e.firstChildElement();
|
||||||
for ( ; !n.isNull(); n = n.nextSiblingElement() ) {
|
for ( ; !n.isNull(); n = n.nextSiblingElement() )
|
||||||
|
{
|
||||||
if (n.namespaceURI() == m_NS && n.localName() == "duration") {
|
if (n.namespaceURI() == m_NS && n.localName() == "duration") {
|
||||||
duration = n.text();
|
duration = n.text();
|
||||||
} else if (n.namespaceURI() == m_NS && n.localName() == "annotation") {
|
} else if (n.namespaceURI() == m_NS && n.localName() == "annotation") {
|
||||||
@@ -149,8 +150,10 @@ XSPFLoader::gotBody()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( artist.isEmpty() || track.isEmpty() ) {
|
if( artist.isEmpty() || track.isEmpty() )
|
||||||
if( !shownError ) {
|
{
|
||||||
|
if( !shownError )
|
||||||
|
{
|
||||||
QMessageBox::warning( 0, tr( "Failed to save tracks" ), tr( "Some tracks in the playlist do not contain an artist and a title. They will be ignored." ), QMessageBox::Ok );
|
QMessageBox::warning( 0, tr( "Failed to save tracks" ), tr( "Some tracks in the playlist do not contain an artist and a title. They will be ignored." ), QMessageBox::Ok );
|
||||||
shownError = true;
|
shownError = true;
|
||||||
}
|
}
|
||||||
@@ -167,6 +170,7 @@ XSPFLoader::gotBody()
|
|||||||
p->query()->setDuration( duration.toInt() / 1000 );
|
p->query()->setDuration( duration.toInt() / 1000 );
|
||||||
if( !url.isEmpty() )
|
if( !url.isEmpty() )
|
||||||
p->query()->setResultHint( url );
|
p->query()->setResultHint( url );
|
||||||
|
|
||||||
m_entries << p;
|
m_entries << p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +198,19 @@ XSPFLoader::gotBody()
|
|||||||
m_creator,
|
m_creator,
|
||||||
false );
|
false );
|
||||||
|
|
||||||
m_playlist->createNewRevision( uuid(), m_playlist->currentrevision(), m_entries );
|
connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onCreated() ) );
|
||||||
deleteLater();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit ok( m_playlist );
|
emit ok( m_playlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
XSPFLoader::onCreated()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
Playlist* playlist = qobject_cast<Playlist*>(sender());
|
||||||
|
m_playlist->createNewRevision( uuid(), m_playlist->currentrevision(), m_entries );
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
@@ -66,6 +66,8 @@ private slots:
|
|||||||
void networkLoadFinished();
|
void networkLoadFinished();
|
||||||
void networkError( QNetworkReply::NetworkError e );
|
void networkError( QNetworkReply::NetworkError e );
|
||||||
|
|
||||||
|
void onCreated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reportError();
|
void reportError();
|
||||||
void gotBody();
|
void gotBody();
|
||||||
|
Reference in New Issue
Block a user