mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 20:00:13 +02:00
[tools] Add support for scanning a whole directory
This commit is contained in:
@@ -37,7 +37,30 @@ main( int argc, char* argv[] )
|
|||||||
}
|
}
|
||||||
else if ( pathInfo.isDir() )
|
else if ( pathInfo.isDir() )
|
||||||
{
|
{
|
||||||
// TODO: Run MusicScanner recursively
|
// Register needed metatypes
|
||||||
|
qRegisterMetaType< QDir >( "QDir" );
|
||||||
|
qRegisterMetaType< QFileInfo >( "QFileInfo" );
|
||||||
|
|
||||||
|
// Create the MusicScanner instance
|
||||||
|
QStringList paths;
|
||||||
|
paths << pathInfo.canonicalFilePath();
|
||||||
|
MusicScanner scanner( MusicScanner::DirScan, paths, 0 );
|
||||||
|
|
||||||
|
// We want a dry-run of the scanner and not update any internal data.
|
||||||
|
scanner.showProgress( false );
|
||||||
|
scanner.updateIndex( false );
|
||||||
|
|
||||||
|
// Start the MusicScanner in its own thread
|
||||||
|
QThread scannerThread( 0 );
|
||||||
|
scannerThread.start();
|
||||||
|
// We need to do this or the finished() signal/quit() SLOT is not called.
|
||||||
|
scannerThread.moveToThread( &scannerThread );
|
||||||
|
scanner.moveToThread( &scannerThread );
|
||||||
|
QObject::connect( &scanner, SIGNAL( finished() ), &scannerThread, SLOT( quit() ) );
|
||||||
|
QMetaObject::invokeMethod( &scanner, "scan", Qt::QueuedConnection );
|
||||||
|
|
||||||
|
// Wait until the scanner has done its work.
|
||||||
|
scannerThread.wait();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user