diff --git a/src/libtomahawk/database/databasecommand_deletefiles.h b/src/libtomahawk/database/databasecommand_deletefiles.h index 4668d0249..53d16f314 100644 --- a/src/libtomahawk/database/databasecommand_deletefiles.h +++ b/src/libtomahawk/database/databasecommand_deletefiles.h @@ -45,6 +45,12 @@ public: 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 void exec( DatabaseImpl* ); diff --git a/src/scanmanager.cpp b/src/scanmanager.cpp index 017dc8171..81d11969e 100644 --- a/src/scanmanager.cpp +++ b/src/scanmanager.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "musicscanner.h" #include "tomahawksettings.h" @@ -40,13 +41,20 @@ ScanManager::ScanManager( QObject* parent ) : QObject( parent ) , m_scanner( 0 ) , m_musicScannerThreadController( 0 ) + , m_dirWatcher( 0 ) { s_instance = this; + m_dirWatcher = new QFileSystemWatcher( parent ); + connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) ); + connect( m_dirWatcher, SIGNAL( directoryChanged( const QString & ) ), SLOT( handleChangedDir( const QString & ) ) ); if ( TomahawkSettings::instance()->hasScannerPath() ) 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_dirWatcher->removePaths( m_dirWatcher->directories() ); + m_dirWatcher->addPaths( 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 ScanManager::scannerFinished() { diff --git a/src/scanmanager.h b/src/scanmanager.h index a20d9990f..999b629b5 100644 --- a/src/scanmanager.h +++ b/src/scanmanager.h @@ -26,6 +26,7 @@ class MusicScanner; class QThread; +class QFileSystemWatcher; class ScanManager : public QObject { @@ -42,6 +43,9 @@ public: signals: void finished(); +public slots: + void handleChangedDir( const QString &path ); + private slots: void scannerQuit(); void scannerFinished(); @@ -55,6 +59,7 @@ private: MusicScanner* m_scanner; QThread* m_musicScannerThreadController; QStringList m_currScannerPath; + QFileSystemWatcher* m_dirWatcher; }; #endif