mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
Initial work on a dir watcher for the scanner
This commit is contained in:
@@ -45,6 +45,12 @@ public:
|
|||||||
setSource( source );
|
setSource( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit DatabaseCommand_DeleteFiles( const QVariantList& ids, const Tomahawk::source_ptr& source, QObject* parent = 0 )
|
||||||
|
: DatabaseCommandLoggable( parent ), m_ids( ids )
|
||||||
|
{
|
||||||
|
setSource( source );
|
||||||
|
}
|
||||||
|
|
||||||
virtual QString commandname() const { return "deletefiles"; }
|
virtual QString commandname() const { return "deletefiles"; }
|
||||||
|
|
||||||
virtual void exec( DatabaseImpl* );
|
virtual void exec( DatabaseImpl* );
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
|
|
||||||
#include "musicscanner.h"
|
#include "musicscanner.h"
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
@@ -40,13 +41,20 @@ ScanManager::ScanManager( QObject* parent )
|
|||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_scanner( 0 )
|
, m_scanner( 0 )
|
||||||
, m_musicScannerThreadController( 0 )
|
, m_musicScannerThreadController( 0 )
|
||||||
|
, m_dirWatcher( 0 )
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
|
m_dirWatcher = new QFileSystemWatcher( parent );
|
||||||
|
|
||||||
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) );
|
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) );
|
||||||
|
connect( m_dirWatcher, SIGNAL( directoryChanged( const QString & ) ), SLOT( handleChangedDir( const QString & ) ) );
|
||||||
|
|
||||||
if ( TomahawkSettings::instance()->hasScannerPath() )
|
if ( TomahawkSettings::instance()->hasScannerPath() )
|
||||||
m_currScannerPath = TomahawkSettings::instance()->scannerPath();
|
m_currScannerPath = TomahawkSettings::instance()->scannerPath();
|
||||||
|
|
||||||
|
m_dirWatcher->addPaths( m_currScannerPath );
|
||||||
|
qDebug() << "filewatcher dirs = " << m_dirWatcher->directories();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,6 +91,8 @@ ScanManager::onSettingsChanged()
|
|||||||
m_currScannerPath != TomahawkSettings::instance()->scannerPath() )
|
m_currScannerPath != TomahawkSettings::instance()->scannerPath() )
|
||||||
{
|
{
|
||||||
m_currScannerPath = TomahawkSettings::instance()->scannerPath();
|
m_currScannerPath = TomahawkSettings::instance()->scannerPath();
|
||||||
|
m_dirWatcher->removePaths( m_dirWatcher->directories() );
|
||||||
|
m_dirWatcher->addPaths( m_currScannerPath );
|
||||||
runManualScan( m_currScannerPath );
|
runManualScan( m_currScannerPath );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,6 +117,14 @@ ScanManager::runManualScan( const QStringList& path )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScanManager::handleChangedDir( const QString &path )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
qDebug() << "Dir changed: " << path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScanManager::scannerFinished()
|
ScanManager::scannerFinished()
|
||||||
{
|
{
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
class MusicScanner;
|
class MusicScanner;
|
||||||
class QThread;
|
class QThread;
|
||||||
|
class QFileSystemWatcher;
|
||||||
|
|
||||||
class ScanManager : public QObject
|
class ScanManager : public QObject
|
||||||
{
|
{
|
||||||
@@ -42,6 +43,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void handleChangedDir( const QString &path );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void scannerQuit();
|
void scannerQuit();
|
||||||
void scannerFinished();
|
void scannerFinished();
|
||||||
@@ -55,6 +59,7 @@ private:
|
|||||||
MusicScanner* m_scanner;
|
MusicScanner* m_scanner;
|
||||||
QThread* m_musicScannerThreadController;
|
QThread* m_musicScannerThreadController;
|
||||||
QStringList m_currScannerPath;
|
QStringList m_currScannerPath;
|
||||||
|
QFileSystemWatcher* m_dirWatcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user