1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-07 17:42:35 +02:00

Manage queued scan type in ScanManager.

This commit is contained in:
Christopher Reichert 2012-06-30 15:34:00 -05:00
parent c1ec90b825
commit 5ad53e0af5
2 changed files with 22 additions and 2 deletions

View File

@ -50,6 +50,7 @@ ScanManager::ScanManager( QObject* parent )
, m_musicScannerThreadController( 0 )
, m_currScannerPaths()
, m_cachedScannerDirs()
, m_queuedScanType( None )
{
s_instance = this;
@ -157,6 +158,8 @@ ScanManager::runNormalScan( bool manualFull )
if ( m_musicScannerThreadController || !m_scanner.isNull() ) //still running if these are not zero
{
if ( m_queuedScanType != Full )
m_queuedScanType = manualFull ? Full : Normal;
tDebug( LOGVERBOSE ) << "Could not run dir scan, old scan still running";
return;
}
@ -176,7 +179,6 @@ ScanManager::runNormalScan( bool manualFull )
DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes( true );
connect( cmd, SIGNAL( done( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ),
SLOT( fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ) );
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
}
@ -203,6 +205,8 @@ ScanManager::runFileScan( const QStringList &paths )
if ( m_musicScannerThreadController || !m_scanner.isNull() ) //still running if these are not zero
{
if ( m_queuedScanType == None )
m_queuedScanType = File;
tDebug( LOGVERBOSE ) << "Could not run file scan, old scan still running";
return;
}
@ -273,6 +277,20 @@ ScanManager::scannerFinished()
m_musicScannerThreadController = 0;
}
switch ( m_queuedScanType ) {
case Full:
case Normal:
runNormalScan( m_queuedScanType == Full );
break;
case File:
runFileScan();
break;
default:
break;
}
m_queuedScanType = None;
m_scanTimer->start();
m_currScannerPaths.clear();
SourceList::instance()->getLocal()->scanningFinished( 0 );

View File

@ -41,6 +41,7 @@ Q_OBJECT
public:
enum ScanMode { DirScan, FileScan };
enum ScanType { None, Full, Normal, File };
static ScanManager* instance();
@ -51,7 +52,7 @@ signals:
void finished();
public slots:
void runFileScan( const QStringList &paths );
void runFileScan( const QStringList &paths = QStringList() );
void runFullRescan();
void runNormalScan( bool manualFull = false );
@ -77,6 +78,7 @@ private:
QStringList m_cachedScannerDirs;
QTimer* m_scanTimer;
ScanType m_queuedScanType;
};
#endif