mirror of
https://github.com/YACReader/yacreader
synced 2025-07-27 01:15:07 -04:00
Added drop support for copying/moving comics in the current folder
This commit is contained in:
50
YACReaderLibrary/comic_files_manager.cpp
Normal file
50
YACReaderLibrary/comic_files_manager.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "comic_files_manager.h"
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
ComicFilesManager::ComicFilesManager(QObject *parent) :
|
||||
QObject(parent), canceled(false)
|
||||
{
|
||||
}
|
||||
|
||||
void ComicFilesManager::copyComicsTo(const QList<QString> &sourceComics, const QString &folderDest)
|
||||
{
|
||||
comics = sourceComics;
|
||||
folder = folderDest;
|
||||
move = false;
|
||||
}
|
||||
|
||||
void ComicFilesManager::moveComicsTo(const QList<QString> &sourceComics, const QString &folderDest)
|
||||
{
|
||||
comics = sourceComics;
|
||||
folder = folderDest;
|
||||
move = true;
|
||||
}
|
||||
|
||||
void ComicFilesManager::process()
|
||||
{
|
||||
int i=0;
|
||||
bool successProcesingFiles = false;
|
||||
foreach (QString source, comics) {
|
||||
QFileInfo info(source);
|
||||
if(QFile::copy(source, QDir::cleanPath(folder+'/'+info.fileName())))
|
||||
{
|
||||
successProcesingFiles = true;
|
||||
if(move)
|
||||
QFile::remove(source);
|
||||
}
|
||||
|
||||
i++;
|
||||
emit progress(i);
|
||||
}
|
||||
|
||||
if(successProcesingFiles)
|
||||
emit success();
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void ComicFilesManager::cancel()
|
||||
{
|
||||
|
||||
}
|
Reference in New Issue
Block a user