mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Made deleting tracks from a collction a little faster.
This commit is contained in:
@@ -242,8 +242,9 @@ Collection::delTracks( const QStringList& files )
|
||||
int i = 0;
|
||||
foreach ( const query_ptr& query, m_tracks )
|
||||
{
|
||||
foreach ( QString file, files )
|
||||
foreach ( const QString& file, files )
|
||||
{
|
||||
bool found = false;
|
||||
foreach ( const result_ptr& result, query->results() )
|
||||
{
|
||||
if ( file == result->url() )
|
||||
@@ -251,8 +252,13 @@ Collection::delTracks( const QStringList& files )
|
||||
// qDebug() << Q_FUNC_INFO << "Found deleted result:" << file;
|
||||
tracks << query;
|
||||
m_tracks.removeAt( i );
|
||||
i--;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( found )
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@@ -35,7 +35,7 @@ using namespace Tomahawk;
|
||||
void
|
||||
DatabaseCommand_DeleteFiles::postCommitHook()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( !m_files.count() )
|
||||
return;
|
||||
@@ -49,12 +49,6 @@ DatabaseCommand_DeleteFiles::postCommitHook()
|
||||
|
||||
emit notify( m_files );
|
||||
|
||||
// also re-calc the collection stats, to updates the "X tracks" in the sidebar etc:
|
||||
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() );
|
||||
connect( cmd, SIGNAL( done( QVariantMap ) ),
|
||||
source().data(), SLOT( setStats( QVariantMap ) ), Qt::QueuedConnection );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
|
||||
if( source()->isLocal() )
|
||||
Servent::instance()->triggerDBSync();
|
||||
}
|
||||
@@ -63,7 +57,7 @@ DatabaseCommand_DeleteFiles::postCommitHook()
|
||||
void
|
||||
DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
Q_ASSERT( !source().isNull() );
|
||||
|
||||
int deleted = 0;
|
||||
@@ -122,7 +116,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
||||
|
||||
foreach( const QVariant& id, m_ids )
|
||||
{
|
||||
qDebug() << "Deleting" << id.toUInt() << "from db for source" << srcid;
|
||||
// qDebug() << "Deleting" << id.toUInt() << "from db for source" << srcid;
|
||||
|
||||
const QString url = QString( "servent://%1\t%2" ).arg( source()->userName() ).arg( id.toString() );
|
||||
m_files << url;
|
||||
@@ -141,7 +135,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "Deleted" << deleted << m_ids << m_files;
|
||||
// qDebug() << "Deleted" << deleted << m_ids << m_files;
|
||||
|
||||
emit done( m_files, source()->collection() );
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ DatabaseWorker::doWork()
|
||||
if ( cmd->doesMutates() )
|
||||
{
|
||||
bool transok = m_dbimpl->database().transaction();
|
||||
// Q_ASSERT( transok );
|
||||
Q_ASSERT( transok );
|
||||
Q_UNUSED( transok );
|
||||
}
|
||||
try
|
||||
@@ -132,7 +132,7 @@ DatabaseWorker::doWork()
|
||||
//
|
||||
if ( !cmd->singletonCmd() )
|
||||
{
|
||||
qDebug() << "Setting lastop for source" << cmd->source()->id() << "to" << cmd->guid();
|
||||
// qDebug() << "Setting lastop for source" << cmd->source()->id() << "to" << cmd->guid();
|
||||
|
||||
TomahawkSqlQuery query = m_dbimpl->newquery();
|
||||
query.prepare( "UPDATE source SET lastop = ? WHERE id = ?" );
|
||||
@@ -150,17 +150,13 @@ DatabaseWorker::doWork()
|
||||
|
||||
if ( cmd->doesMutates() )
|
||||
{
|
||||
qDebug() << "Committing" << cmd->commandname();;
|
||||
qDebug() << "Committing" << cmd->commandname() << cmd->guid();
|
||||
if ( !m_dbimpl->database().commit() )
|
||||
{
|
||||
|
||||
qDebug() << "*FAILED TO COMMIT TRANSACTION*";
|
||||
throw "commit failed";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Committed" << cmd->commandname();
|
||||
}
|
||||
}
|
||||
|
||||
//uint duration = timer.elapsed();
|
||||
@@ -197,8 +193,7 @@ DatabaseWorker::doWork()
|
||||
cmd->emitFinished();
|
||||
|
||||
QMutexLocker lock( &m_mut );
|
||||
m_outstanding--;
|
||||
if ( m_outstanding > 0 )
|
||||
if ( --m_outstanding > 0 )
|
||||
QTimer::singleShot( 0, this, SLOT( doWork() ) );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user