diff options
-rw-r--r-- | filestreewidget.cpp | 3 | ||||
-rw-r--r-- | smglobals.cpp | 28 | ||||
-rw-r--r-- | smglobals.h | 1 |
3 files changed, 27 insertions, 5 deletions
diff --git a/filestreewidget.cpp b/filestreewidget.cpp index d44e561..1a17be5 100644 --- a/filestreewidget.cpp +++ b/filestreewidget.cpp @@ -430,9 +430,6 @@ bool FilesTreeView::event(QEvent *e){ return exitHover(); } } - if(!QFileInfo(curIdx.data(FilesTreeModel::FullPathRole).toString()).exists()){ - return exitHover(); - } } if(e->type() == QEvent::HoverEnter){ doHover(curIdx); diff --git a/smglobals.cpp b/smglobals.cpp index 8e49726..62e7537 100644 --- a/smglobals.cpp +++ b/smglobals.cpp @@ -188,7 +188,8 @@ const QPair<QString, QString> SmGlobals::FrameCache::prepFrame(const QString &so if(when.isEmpty()){ when = mWhen; } - const QPair<QString, QString> source(sourceFile, when); + const QString fileName = QFileInfo(sourceFile).fileName(); + const QPair<QString, QString> source(fileName, when); if(!mFrameCache.contains(source)){ grabFrame(sourceFile, when); } @@ -211,7 +212,7 @@ void SmGlobals::FrameCache::grabFrame(const QString &sourceFile, QString when){ return; } ffmpeg.waitForFinished(); - QPair<QString, QString> pair(sourceFile, when); + QPair<QString, QString> pair(sourceInfo.fileName(), when); mFrameCache.insert(pair, tempFile.fileName()); } } @@ -231,4 +232,27 @@ void SmGlobals::FrameCache::readCache(){ QPair<QString, QString> pair(source, pos); mFrameCache.insert(pair, cacheFile); } + cleanup(); +} + +/* cleanup function for fucked up framecache: + Key was full path until recently, not just the filename, so + duplicates showed up when hovering over the same in different + paths, eg, archive or filesystem. Should be removed in the future +*/ +void SmGlobals::FrameCache::cleanup(){ + QHash<QPair<QString, QString>, QString> newFrameCache; + QHash<QPair<QString, QString>, QString>::const_iterator it = mFrameCache.constBegin(); + while(it != mFrameCache.constEnd()){ + QPair<QString, QString> key = it.key(); + QFileInfo fi(key.first); + QPair<QString, QString> newEntry(fi.fileName(), key.second); + if(!newFrameCache.contains(newEntry)){ + newFrameCache.insert(newEntry, it.value()); + }else{ + QFile::remove(it.value()); + } + ++it; + } + mFrameCache = newFrameCache; } diff --git a/smglobals.h b/smglobals.h index 7033b34..1193522 100644 --- a/smglobals.h +++ b/smglobals.h @@ -30,6 +30,7 @@ class SmGlobals : public QObject { private: void readCache(); void grabFrame(const QString &sourceFile, QString when); + void cleanup(); const QPair<QString, QString> prepFrame(const QString &sourceFile, QString when); QHash<QPair<QString, QString>, QString> mFrameCache; const qint32 mMagic; |