diff options
Diffstat (limited to 'smdirwatcher.cpp')
-rw-r--r-- | smdirwatcher.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/smdirwatcher.cpp b/smdirwatcher.cpp index d825c2c..038c4cf 100644 --- a/smdirwatcher.cpp +++ b/smdirwatcher.cpp @@ -17,7 +17,7 @@ #include "smtreeitem.h" #include "helper.h" -SmDirWatcher::SmDirWatcher(int numFields, QObject *parent) : QThread(parent), mFd(0), mDescr(0), mNumFields(numFields) { +SmDirWatcher::SmDirWatcher(int numFields, QObject *parent) : QThread(parent), mFd(0), mDescr(0), mNumFields(numFields), mExpensiveOps(true) { mBufLen = 1024 * (sizeof(struct inotify_event) + 16); mINdata = new char[mBufLen]; mFd = inotify_init(); @@ -47,20 +47,22 @@ void SmDirWatcher::setDir(const QString &dir){ QString mime = data.at(SmDirModel::Type).toString(); SmTreeItem *newItem = new SmTreeItem(data, rootItem); rootItem->appendChild(newItem); - Md5Summer *s = new Md5Summer(fi.absoluteFilePath()); - s->setAutoDelete(false); - connect(s, SIGNAL(md5sumDone(QString,QString)), this, SIGNAL(setMd5Sum(QString,QString))); - mAsyncTasks.append(s); - if(mime.startsWith("video")){ - FfmpegGatherer *g = new FfmpegGatherer(fi.absoluteFilePath()); - g->setAutoDelete(false); - connect(g, SIGNAL(ffmpegDone(QString,QVariantMap)), this, SIGNAL(setFfmpeg(QString,QVariantMap))); - mAsyncTasks.append(g); - }else if(mime.startsWith("image")){ - PicSizeGatherer *pg = new PicSizeGatherer(fi.absoluteFilePath()); - pg->setAutoDelete(false); - connect(pg, SIGNAL(picSizeDone(QString,QVariant)), this, SIGNAL(setPicSize(QString,QVariant))); - mAsyncTasks.append(pg); + if(mExpensiveOps){ + Md5Summer *s = new Md5Summer(fi.absoluteFilePath()); + s->setAutoDelete(false); + connect(s, SIGNAL(md5sumDone(QString,QString)), this, SIGNAL(setMd5Sum(QString,QString))); + mAsyncTasks.append(s); + if(mime.startsWith("video")){ + FfmpegGatherer *g = new FfmpegGatherer(fi.absoluteFilePath()); + g->setAutoDelete(false); + connect(g, SIGNAL(ffmpegDone(QString,QVariantMap)), this, SIGNAL(setFfmpeg(QString,QVariantMap))); + mAsyncTasks.append(g); + }else if(mime.startsWith("image")){ + PicSizeGatherer *pg = new PicSizeGatherer(fi.absoluteFilePath()); + pg->setAutoDelete(false); + connect(pg, SIGNAL(picSizeDone(QString,QVariant)), this, SIGNAL(setPicSize(QString,QVariant))); + mAsyncTasks.append(pg); + } } } emit population(rootItem); @@ -79,6 +81,9 @@ void SmDirWatcher::startAsyncJobs(){ } void SmDirWatcher::gatherAsync(const QString &path){ + if(!mExpensiveOps){ + return; + } QString mimeType = Helper::mimeType(path); Md5Summer *s = new Md5Summer(path); connect(s, SIGNAL(md5sumDone(QString,QString)), this, SIGNAL(setMd5Sum(QString,QString))); @@ -94,6 +99,10 @@ void SmDirWatcher::gatherAsync(const QString &path){ } } +void SmDirWatcher::setExpensiveOps(bool expensiveOps){ + mExpensiveOps = expensiveOps; +} + QList<QVariant> SmDirWatcher::generalData(const QString &path){ QFileInfo fi(path); QList<QVariant> data; |