diff options
author | Arno <arno@disconnect.de> | 2018-01-04 06:40:38 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-01-04 06:40:38 +0100 |
commit | 65cb7d95cd2b8e5d24f686fd22be7325e5a9d039 (patch) | |
tree | 3fd2222f686ed35a14830059cf8e13a7184ebe13 | |
parent | b416e9dcbb41422e0ba964b05e65f4b549b7680b (diff) | |
download | ShemovCleaner-65cb7d95cd2b8e5d24f686fd22be7325e5a9d039.tar.gz ShemovCleaner-65cb7d95cd2b8e5d24f686fd22be7325e5a9d039.tar.bz2 ShemovCleaner-65cb7d95cd2b8e5d24f686fd22be7325e5a9d039.zip |
Add cache operations
Implement functions to remove files from cached data, or clear it
completely. This may be necessary if something happened without us
knowing, e.g. a file was copied by another program.
-rw-r--r-- | bizarre_amputee.png | bin | 0 -> 688 bytes | |||
-rw-r--r-- | filewidget.cpp | 32 | ||||
-rw-r--r-- | filewidget.h | 4 | ||||
-rw-r--r-- | male_chastity_belt.png | bin | 0 -> 927 bytes | |||
-rw-r--r-- | shemovcleaner.qrc | 2 |
5 files changed, 38 insertions, 0 deletions
diff --git a/bizarre_amputee.png b/bizarre_amputee.png Binary files differnew file mode 100644 index 0000000..0b1d62a --- /dev/null +++ b/bizarre_amputee.png diff --git a/filewidget.cpp b/filewidget.cpp index e13fe77..3d2ff28 100644 --- a/filewidget.cpp +++ b/filewidget.cpp @@ -165,11 +165,20 @@ void FileWidget::createActions(){ connect(mPreviewA, SIGNAL(triggered()), this, SLOT(preview())); mAddAsOriginA = new QAction(QIcon(":/butt_plug.png"), tr("Add as Origin..."), this); connect(mAddAsOriginA, SIGNAL(triggered()), this, SLOT(addAsOrigin())); + mRemoveFromCacheA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Remove selected"), this); + connect(mRemoveFromCacheA, &QAction::triggered, this, &FileWidget::removeFromCache); + mClearCacheA = new QAction(QIcon(":/male_chastity_belt.png"), tr("Clear..."), this); + connect(mClearCacheA, &QAction::triggered, this, &FileWidget::clearCache); QMenu *fileMenu = new QMenu(tr("&File")); fileMenu->addAction(mSelDirA); fileMenu->addAction(mRefreshA); fileMenu->addSeparator(); + QMenu *cacheMenu = new QMenu(tr("Cache")); + cacheMenu->addAction(mRemoveFromCacheA); + cacheMenu->addAction(mClearCacheA); + fileMenu->addMenu(cacheMenu); + fileMenu->addSeparator(); fileMenu->addAction(Globals::instance()->action(Globals::QuitAction)); QMenu *editMenu = new QMenu(tr("&Edit")); @@ -633,6 +642,29 @@ void FileWidget::copySuccess(bool success, QString source){ } } +void FileWidget::removeFromCache(){ + QModelIndexList curSel = mFileView->selectionModel()->selectedRows(); + int count = 0; + for(const QModelIndex &i : curSel){ + QString fullPath = i.data(FullPathRole).toString(); + if(mFileCache.remove(fullPath)){ + ++count; + } + } + QString msg = QString(tr("Removed %1 files from cache")).arg(QString::number(count)); + gatherData(); + emit statusMessage(msg); +} + +void FileWidget::clearCache(){ + int retval = QMessageBox::question(this, tr("Clear cache"), tr("Really empty the cache?")); + if(retval == QMessageBox::Yes){ + mFileCache.clear(); + gatherData(); + emit statusMessage(tr("Cache cleared!")); + } +} + void FileWidget::fileSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected){ Q_UNUSED(selected); Q_UNUSED(deselected); diff --git a/filewidget.h b/filewidget.h index c9e40d4..5e2b910 100644 --- a/filewidget.h +++ b/filewidget.h @@ -73,6 +73,8 @@ class FileWidget : public QWidget { void copyFiles(QString destDir); void hideCopyProgress(); void copySuccess(bool success, QString source); + void removeFromCache(); + void clearCache(); protected: virtual void keyPressEvent(QKeyEvent *e); @@ -116,6 +118,8 @@ class FileWidget : public QWidget { QAction *mPasteA; QAction *mDeleteA; QAction *mAddAsOriginA; + QAction *mRemoveFromCacheA; + QAction *mClearCacheA; ProgressDialog *mCopyProgress; FileDisplay *mFileDisplay; VideoSorter *mProxy; diff --git a/male_chastity_belt.png b/male_chastity_belt.png Binary files differnew file mode 100644 index 0000000..ca3a859 --- /dev/null +++ b/male_chastity_belt.png diff --git a/shemovcleaner.qrc b/shemovcleaner.qrc index ebf7917..f938c0b 100644 --- a/shemovcleaner.qrc +++ b/shemovcleaner.qrc @@ -19,5 +19,7 @@ <file>snapshot.png</file> <file>curlybrackets.png</file> <file>shemovcleaner_splash.png</file> + <file>bizarre_amputee.png</file> + <file>male_chastity_belt.png</file> </qresource> </RCC> |