diff options
author | Arno <am@disconnect.de> | 2013-09-14 07:28:19 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-09-14 07:28:19 +0200 |
commit | 19a7e82de5decb45caf07acc0d1161b1f05cb15b (patch) | |
tree | ba036f290965b58482abf8b415200457341f2e89 | |
parent | c115772c658ba1138d05ef6604bc36d4b6d96867 (diff) | |
download | SheMov-19a7e82de5decb45caf07acc0d1161b1f05cb15b.tar.gz SheMov-19a7e82de5decb45caf07acc0d1161b1f05cb15b.tar.bz2 SheMov-19a7e82de5decb45caf07acc0d1161b1f05cb15b.zip |
Get rid of FrameCache
-rw-r--r-- | configurationdialog.cpp | 14 | ||||
-rw-r--r-- | configurationdialog.h | 2 | ||||
-rw-r--r-- | consistencycheck.cpp | 3 | ||||
-rw-r--r-- | fileview.cpp | 1 | ||||
-rw-r--r-- | framecache.cpp | 158 | ||||
-rw-r--r-- | framecache.h | 72 | ||||
-rw-r--r-- | newmoviewizard.cpp | 1 | ||||
-rw-r--r-- | shemov.cpp | 13 | ||||
-rw-r--r-- | shemov.h | 2 | ||||
-rw-r--r-- | shemov.pro | 2 | ||||
-rw-r--r-- | smglobals.cpp | 11 | ||||
-rw-r--r-- | smglobals.h | 5 |
12 files changed, 2 insertions, 282 deletions
diff --git a/configurationdialog.cpp b/configurationdialog.cpp index b60bd8a..724b4cb 100644 --- a/configurationdialog.cpp +++ b/configurationdialog.cpp @@ -119,13 +119,6 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : S QLabel *miscl6 = new QLabel(tr("Opacity of hover window")); miscInputGrid->addWidget(miscl6, 0, 0); miscInputGrid->addWidget(mHoverOpacity, 0, 1); - QLabel *miscl7 = new QLabel(tr("Grab frame at ([hh:mm:ss])")); - mGrabFrameFrom = new QLineEdit; - QRegExp frameValid("\\d{2}:\\d{2}:\\d{2}"); - QRegExpValidator *frameValidator = new QRegExpValidator(frameValid, this); - mGrabFrameFrom->setValidator(frameValidator); - miscInputGrid->addWidget(miscl7, 1, 0); - miscInputGrid->addWidget(mGrabFrameFrom, 1, 1); QLabel *miscl8 = new QLabel(tr("Y cursor offset (hover)")); mCursorOffset = new QSpinBox; mCursorOffset->setMinimum(-100); @@ -427,10 +420,6 @@ void ConfigurationDialog::accept(){ QDialog::accept(); } -void ConfigurationDialog::setGrabFrameEnabled(bool enabled){ - mGrabFrameFrom->setEnabled(enabled); -} - void ConfigurationDialog::readSettings(){ QSettings s; @@ -459,8 +448,6 @@ void ConfigurationDialog::readSettings(){ // read misc mHoverPics->setChecked(s.value("ui/hoverpics", false).toBool()); mHoverOpacity->setValue(s.value("ui/hoveropacity", 10).toInt()); - mGrabFrameFrom->setText(s.value("ui/grabframe", "00:00:00").toString()); - mGrabFrameFrom->setEnabled(s.value("ui/hovermovies", false).toBool()); mAutoAddCovers->setChecked(s.value("ui/autoaddcovers", false).toBool()); mIconizeCovers->setChecked(s.value("ui/iconizecovers", false).toBool()); mCursorOffset->setValue(s.value("ui/cursoroffset", SmGlobals::instance()->cursorSize().height()).toInt()); @@ -553,7 +540,6 @@ void ConfigurationDialog::writeSettings(){ //write misc s.setValue("ui/hoverpics", (mHoverPics->checkState() == Qt::Checked)); s.setValue("ui/hoveropacity", mHoverOpacity->value()); - s.setValue("ui/grabframe", mGrabFrameFrom->text()); s.setValue("ui/autoaddcovers", (mAutoAddCovers->checkState() == Qt::Checked)); s.setValue("ui/iconizecovers", (mIconizeCovers->checkState() == Qt::Checked)); s.setValue("ui/cursoroffset", mCursorOffset->value()); diff --git a/configurationdialog.h b/configurationdialog.h index 06544c5..b848520 100644 --- a/configurationdialog.h +++ b/configurationdialog.h @@ -36,7 +36,6 @@ class ConfigurationDialog : public SmDialog { void accept(); private slots: - void setGrabFrameEnabled(bool enabled); void chooseColor(QWidget *label); void alternateColorsChanged(int); void randomGradientChanged(int); @@ -67,7 +66,6 @@ class ConfigurationDialog : public SmDialog { QLineEdit *mDatabasePassword; QLineEdit *mWindowsDrive; QLineEdit *mStripPath; - QLineEdit *mGrabFrameFrom; QComboBox *mIconForFolder; QComboBox *mIconForFile; QComboBox *mIconForSeries; diff --git a/consistencycheck.cpp b/consistencycheck.cpp index 759e2ae..7e463a2 100644 --- a/consistencycheck.cpp +++ b/consistencycheck.cpp @@ -433,9 +433,6 @@ void ConsistencyChecker::doFsCheck(const QFileInfo &start, const QVector<QString } mCancelMutex.unlock(); if(fi.isDir()){ - if(fi.fileName() == ".frameCache"){ - continue; - } doFsCheck(fi, md5sums); }else{ QString md5sum = Helper::md5Sum(fi.absoluteFilePath()); diff --git a/fileview.cpp b/fileview.cpp index a9ed678..73cbd24 100644 --- a/fileview.cpp +++ b/fileview.cpp @@ -34,7 +34,6 @@ #include "filesystemfileproxy.h" #include "filepropertiesdialog.h" #include "smdirmodel.h" -#include "framecache.h" FileView::FileView(QWidget *parent) : SmTreeView("ui/fsheaderpos", parent), mDeleteA(0) { setAttribute(Qt::WA_Hover); diff --git a/framecache.cpp b/framecache.cpp deleted file mode 100644 index e6fceaa..0000000 --- a/framecache.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version - 2 of the License, or (at your option) any later version. -*/ - -#include <QFile> -#include <QDataStream> -#include <QSettings> -#include <QDir> -#include <QSemaphore> -#include <QMutex> -#include <QProcess> -#include <QTemporaryFile> -#include <QPixmap> - -#include "framecache.h" - -FrameCache::FrameCache(QObject *parent) : QObject(parent){ - mSemFree = new QSemaphore(128); // 128 queued requests for a frame, should be enough - mSemUsed = new QSemaphore; - mFrameCache = new QHash<QPair<QString, QString>, QString>(); - mDataQueue = new QQueue<QPair<QString, QString> >(); - mCacheMx = new QMutex; - mGenerator = new FrameCacheGenerator(this); - mGenerator->init(mSemFree, mSemUsed, mCacheMx, mDataQueue, mFrameCache); - mGenerator->readConfig(); - rebuild(); - mGenerator->start(); - QSettings s; - mWhen = s.value("ui/grabframe", "00:00:00").toString(); -} - -FrameCache::~FrameCache(){ - mGenerator->exit(); -} - -const QPixmap FrameCache::entry(const QString &sourcePath, const QString &when){ - QFileInfo fi(sourcePath); - QString w = when.isEmpty() ? mWhen : when; - QPair<QString, QString> key = qMakePair<QString, QString>(fi.fileName(), w); - mCacheMx->lock(); - QPixmap retval; - if(!mFrameCache->contains(key)){ - QString nullPath = mFrameCache->value(qMakePair<QString, QString>(key.first, "00:00:00")); - if(!nullPath.isEmpty()){ - mCacheMx->unlock(); - return QPixmap(nullPath); - } - mCacheMx->unlock(); - mSemFree->acquire(); - mDataQueue->enqueue(qMakePair<QString, QString>(sourcePath, when)); - mSemUsed->release(); - return QPixmap(); - } - retval = QPixmap(mFrameCache->value(key)); - mCacheMx->unlock(); - return retval; - -} - -const QString FrameCache::entryPath(const QString &sourcePath, const QString &when){ - QFileInfo fi(sourcePath); - if(!fi.exists()){ - return QString(); - } - QPair<QString, QString> data = qMakePair<QString, QString>(fi.fileName(), when); - QMutexLocker l(mCacheMx); - return mFrameCache->value(data); -} - -void FrameCache::rebuild(){ - QMutexLocker l(mCacheMx); - QDir cdir(mGenerator->cacheDir()); - QFileInfoList files = cdir.entryInfoList(QDir::Files); - mFrameCache->clear(); - foreach(QFileInfo fi, files){ - QString base = fi.fileName(); - base.chop(fi.suffix().size() + 1); // basename doesn't work, b/c we have filenames w spaces - base.chop(7); //remove temp. extension - QString when = base.right(8); - base.chop(9); //remove when + _, leaving the orig. filename - QPair<QString, QString> key = qMakePair<QString, QString>(base, when); - if(mFrameCache->contains(key)){ - QFile::remove(fi.absoluteFilePath()); - }else{ - mFrameCache->insert(key, fi.absoluteFilePath()); - } - } -} - -FrameCacheGenerator::FrameCacheGenerator(QObject *parent) : QThread(parent), mCacheSubDir(".frameCache"), mCacheFileName("cache") {} - -void FrameCacheGenerator::init(QSemaphore *set, QSemaphore *get, QMutex *cachemx, QQueue<QPair<QString, QString> > *data, QHash<QPair<QString, QString>, QString> *cache){ - mSemFree = set; - mSemUsed = get; - mDataQueue = data; - mCacheMx = cachemx; - mFrameCache = cache; -} - -void FrameCacheGenerator::readConfig(){ - QSettings s; - QString archive = s.value("paths/archivedir").toString(); - if(archive.isEmpty()){ - return; - } - QDir archiveDir(archive); - if(!archiveDir.exists(mCacheSubDir)){ - archiveDir.mkdir(mCacheSubDir); - } - mCacheDir = QString("%1/%2").arg(archive).arg(mCacheSubDir); - mCacheFile = QString("%1/%2").arg(mCacheDir).arg(mCacheFileName); - - mFfMpegPath = s.value("paths/ffmpeg").toString(); -} - -void FrameCacheGenerator::run(){ - forever{ - mSemUsed->acquire(); - QPair<QString, QString> cur = mDataQueue->dequeue(); - if(!grabFrame(cur.first, cur.second)){ - grabFrame(cur.first, "00:00:00"); - } - mSemFree->release(); - } -} - -bool FrameCacheGenerator::grabFrame(const QString &sourceFile, QString when){ - QFileInfo sourceInfo(sourceFile); - if(!sourceInfo.exists()){ - return false; - } - QString tmpTemplate = QString("%1/%2_%3-XXXXXX.png").arg(mCacheDir).arg(sourceInfo.fileName()).arg(when); - QTemporaryFile tempFile(tmpTemplate); - tempFile.setAutoRemove(false); - if(tempFile.open()){ - QStringList ffMpegArgs = QStringList() << "-vframes" << "1" << "-ss" << when << "-i" << sourceFile << "-y" << tempFile.fileName(); - QProcess ffmpeg; - ffmpeg.start(mFfMpegPath, ffMpegArgs); - if(!ffmpeg.waitForStarted()){ - return false; - } - ffmpeg.waitForFinished(); - QFileInfo tfi(tempFile.fileName()); - if(tfi.size() == 0){ - tempFile.remove(); - return false; - } - QPair<QString, QString> pair(sourceInfo.fileName(), when); - mCacheMx->lock(); - mFrameCache->insert(pair, tempFile.fileName()); - mCacheMx->unlock(); - return true; - } - return false; -} diff --git a/framecache.h b/framecache.h deleted file mode 100644 index 867eda7..0000000 --- a/framecache.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version - 2 of the License, or (at your option) any later version. -*/ - -#ifndef FRAMECACHE_H -#define FRAMECACHE_H - -#include <QThread> -#include <QPair> -#include <QHash> -#include <QPair> -#include <QQueue> -#include <QString> - -class QSemaphore; -class QMutex; -class FrameCacheGenerator; - -class FrameCache : public QObject { - Q_OBJECT - public: - explicit FrameCache(QObject *parent = 0); - ~FrameCache(); - const QPixmap entry(const QString &sourcePath, const QString &when = QString()); - const QString entryPath(const QString &sourcePath, const QString &when); - - public slots: - void rebuild(); - - private: - QHash<QPair<QString, QString>, QString> *mFrameCache; - QQueue<QPair<QString, QString> > *mDataQueue; - QString mCacheFile; - qint32 mMagic; - QSemaphore *mSemFree; - QSemaphore *mSemUsed; - QMutex *mCacheMx; - FrameCacheGenerator *mGenerator; - QString mWhen; -}; - -class FrameCacheGenerator : public QThread { - Q_OBJECT - public: - explicit FrameCacheGenerator(QObject *parent = 0); - void init(QSemaphore *set, QSemaphore *get, QMutex *cachemx, QQueue<QPair<QString, QString> > *data, QHash<QPair<QString, QString>, QString> *cache); - const QString cacheFile() const { return mCacheFile; } - const QString cacheDir() const { return mCacheDir; } - void readConfig(); - - public slots: - void run(); - - private: - bool grabFrame(const QString &sourceFile, QString when); - QSemaphore *mSemFree; - QSemaphore *mSemUsed; - QMutex *mCacheMx; - QQueue<QPair<QString, QString> > *mDataQueue; - QHash<QPair<QString, QString>, QString> *mFrameCache; - QString mCacheDir; - QString mCacheFile; - QString mFfMpegPath; - const QString mCacheSubDir; - const QString mCacheFileName; - -}; - -#endif // FRAMECACHE_H diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp index 6837c72..76a007d 100644 --- a/newmoviewizard.cpp +++ b/newmoviewizard.cpp @@ -33,7 +33,6 @@ #include "helper.h" #include "pictureviewer2.h" #include "archivemodel.h" -#include "framecache.h" #include "archivecontroller.h" #include "archiveview.h" @@ -33,7 +33,6 @@ #include "newpicsdialog.h" #include "pictureswidget.h" #include "smdirmodel.h" -#include "framecache.h" #include "archiveview.h" #include "archivecontroller.h" @@ -386,11 +385,7 @@ void SheMov::createActions(){ //connnect mQuitA = new QAction(tr("Quit"), this); mQuitA->setShortcut(tr("CTRL+q")); - mRebuildFrameCacheA = new QAction(tr("Rebuild frame cache") ,this); - - // general actions connect(mQuitA, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); - connect(mRebuildFrameCacheA, SIGNAL(triggered()), this, SLOT(rebuildFrameCache())); //Edit menu (FS) mCdupA = new QAction(QIcon(":/up_dick.png"), tr("Go up"), this); @@ -648,7 +643,6 @@ void SheMov::createMenus(){ analyzeMenu->addAction(mAnalyzeSeriesA); analyzeMenu->addAction(mAnalyzePartsA); fileMenu->addMenu(analyzeMenu); - fileMenu->addAction(mRebuildFrameCacheA); fileMenu->addSeparator(); fileMenu->addAction(mQuitA); menuBar()->addMenu(fileMenu); @@ -885,13 +879,6 @@ void SheMov::createPalette(){ qApp->setPalette(pal); } -void SheMov::rebuildFrameCache(){ - int retval = QMessageBox::question(this, tr("Question"), tr("Rebuild frame cache from directory?"), QMessageBox::Yes | QMessageBox::No); - if(retval == QMessageBox::Yes){ - SmGlobals::instance()->frameCache()->rebuild(); - } -} - void SheMov::analyzeActors(){ EmptyActorsDialog d(tr("Actors"), this); d.populate(); @@ -50,7 +50,6 @@ class SheMov : public QMainWindow { void checkMount(bool mounted); void newPicsDialog(); void newPicsDialogWithFiles(); - void rebuildFrameCache(); void analyzeActors(); void analyzeGenres(); @@ -103,7 +102,6 @@ class SheMov : public QMainWindow { QAction *mArchiveSelectedPicsA; QAction *mConsistencyA; QAction *mNewPicsA; - QAction *mRebuildFrameCacheA; QAction *mNewMovieWizardA; QAction *mMoveToArchiveA; QAction *mFSViewPropertiesA; @@ -37,7 +37,6 @@ SOURCES = main.cpp \ picfilesmodel.cpp \ smdirwatcher.cpp \ smdirmodel.cpp \ - framecache.cpp \ smtreeview.cpp \ archivemodel.cpp \ archiveview.cpp \ @@ -75,7 +74,6 @@ HEADERS = \ picfilesmodel.h \ smdirwatcher.h \ smdirmodel.h \ - framecache.h \ smtreeview.h \ archivemodel.h \ archiveview.h \ diff --git a/smglobals.cpp b/smglobals.cpp index 7388968..cd03cc4 100644 --- a/smglobals.cpp +++ b/smglobals.cpp @@ -28,7 +28,6 @@ #include "pictureviewer2.h" #include "picfilesmodel.h" #include "configurationdialog.h" -#include "framecache.h" #include "archivecontroller.h" SmGlobals *SmGlobals::mInstance = 0; @@ -37,7 +36,6 @@ SmGlobals::~SmGlobals(){ foreach(QAbstractItemModel *model, mModels.values()){ model->deleteLater(); } - mFrameCache->deleteLater(); } SmGlobals *SmGlobals::instance(){ @@ -108,13 +106,6 @@ PictureViewer2 *SmGlobals::pictureViewer() { return mPictureViewer; } -FrameCache *SmGlobals::frameCache() { - if(!mFrameCache){ - mFrameCache = new FrameCache; - } - return mFrameCache; -} - QSize SmGlobals::cursorSize() { if(!mCursorSize.isValid()){ Display *dpy = XOpenDisplay(0); @@ -133,7 +124,7 @@ QIcon SmGlobals::iconFor(const QString &type){ return retval; } -SmGlobals::SmGlobals() : mPictureViewer(0), mFrameCache(0), mArchiveController(0){ +SmGlobals::SmGlobals() : mPictureViewer(0), mArchiveController(0){ mIcons.insert("Dildo", ":/dildo.png"); mIcons.insert("Dick to left", ":/back_dick.png"); mIcons.insert("Dick pointing up", ":/up_dick.png"); diff --git a/smglobals.h b/smglobals.h index 72604ab..ac80c87 100644 --- a/smglobals.h +++ b/smglobals.h @@ -16,7 +16,6 @@ class QAbstractItemModel; class PictureViewer2; class QPixmap; class SeriesTreeWidget; -class FrameCache; class ArchiveController; class SmGlobals : public QObject { @@ -26,7 +25,6 @@ class SmGlobals : public QObject { static SmGlobals *instance(); QAbstractItemModel *model(const QString &which); PictureViewer2 *pictureViewer(); - FrameCache *frameCache(); void setArchiveController(ArchiveController *c) { mArchiveController = c; } ArchiveController *archiveController() { return mArchiveController; } QSize cursorSize(); @@ -44,8 +42,7 @@ class SmGlobals : public QObject { QHash<QString, QAbstractItemModel*> mModels; PictureViewer2 *mPictureViewer; SeriesTreeWidget *mSeriesTreeWidget; - FrameCache *mFrameCache; - QSize mCursorSize; + QSize mCursorSize; QHash<QString, QString> mIcons; qint64 mDvdSize; ArchiveController *mArchiveController; |