#include "mbwatchfile.h"
|
#include <QDir>
|
|
CMBWatchFile::CMBWatchFile()
|
{
|
m_pSystemWatcher = NULL;
|
}
|
|
CMBWatchFile::~CMBWatchFile()
|
{
|
if( m_pSystemWatcher ){
|
delete m_pSystemWatcher;
|
m_pSystemWatcher = NULL;
|
}
|
}
|
|
|
void CMBWatchFile::addWatchPath(QString path)
|
{
|
if( m_pSystemWatcher == NULL ){
|
|
m_pSystemWatcher = new QFileSystemWatcher();
|
connect(m_pSystemWatcher, SIGNAL(fileChanged(QString)), this, SLOT(fileUpdated(QString)));
|
}
|
|
// 添加监控路径
|
m_pSystemWatcher->addPath(path);
|
}
|
|
void CMBWatchFile::fileUpdated(const QString &path)
|
{
|
emit sigFileChange(path);
|
}
|