mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
Manage queued scan type in ScanManager.
This commit is contained in:
@@ -50,6 +50,7 @@ ScanManager::ScanManager( QObject* parent )
|
|||||||
, m_musicScannerThreadController( 0 )
|
, m_musicScannerThreadController( 0 )
|
||||||
, m_currScannerPaths()
|
, m_currScannerPaths()
|
||||||
, m_cachedScannerDirs()
|
, m_cachedScannerDirs()
|
||||||
|
, m_queuedScanType( None )
|
||||||
{
|
{
|
||||||
s_instance = this;
|
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_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";
|
tDebug( LOGVERBOSE ) << "Could not run dir scan, old scan still running";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -176,7 +179,6 @@ ScanManager::runNormalScan( bool manualFull )
|
|||||||
DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes( true );
|
DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes( true );
|
||||||
connect( cmd, SIGNAL( done( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ),
|
connect( cmd, SIGNAL( done( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ),
|
||||||
SLOT( fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ) );
|
SLOT( fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
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_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";
|
tDebug( LOGVERBOSE ) << "Could not run file scan, old scan still running";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -273,6 +277,20 @@ ScanManager::scannerFinished()
|
|||||||
m_musicScannerThreadController = 0;
|
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_scanTimer->start();
|
||||||
m_currScannerPaths.clear();
|
m_currScannerPaths.clear();
|
||||||
SourceList::instance()->getLocal()->scanningFinished( 0 );
|
SourceList::instance()->getLocal()->scanningFinished( 0 );
|
||||||
|
@@ -41,6 +41,7 @@ Q_OBJECT
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum ScanMode { DirScan, FileScan };
|
enum ScanMode { DirScan, FileScan };
|
||||||
|
enum ScanType { None, Full, Normal, File };
|
||||||
|
|
||||||
static ScanManager* instance();
|
static ScanManager* instance();
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ signals:
|
|||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void runFileScan( const QStringList &paths );
|
void runFileScan( const QStringList &paths = QStringList() );
|
||||||
void runFullRescan();
|
void runFullRescan();
|
||||||
void runNormalScan( bool manualFull = false );
|
void runNormalScan( bool manualFull = false );
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ private:
|
|||||||
QStringList m_cachedScannerDirs;
|
QStringList m_cachedScannerDirs;
|
||||||
|
|
||||||
QTimer* m_scanTimer;
|
QTimer* m_scanTimer;
|
||||||
|
ScanType m_queuedScanType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user