mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Some checks failed
Build / Initialization (push) Has been cancelled
Build / Code Format Validation (push) Has been cancelled
Build / Linux (Qt6) (push) Has been cancelled
Build / Linux (Qt6 + 7zip) (push) Has been cancelled
Build / macOS (Qt6 Universal) (push) Has been cancelled
Build / Windows x64 (Qt6) (push) Has been cancelled
Build / Windows ARM64 (Qt6) (push) Has been cancelled
Build / Docker amd64 Image (push) Has been cancelled
Build / Docker arm64 Image (push) Has been cancelled
Build / Publish Dev Builds (push) Has been cancelled
Build / Publish Release (push) Has been cancelled
Build / Publish YACReader10 Pre-release Builds (push) Has been cancelled
65 lines
1.7 KiB
C++
65 lines
1.7 KiB
C++
#include "comics_remover.h"
|
|
|
|
#include "QsLog.h"
|
|
|
|
#include <QDir>
|
|
#include <QFile>
|
|
|
|
ComicsRemover::ComicsRemover(QModelIndexList &il, QList<QString> &ps, qulonglong parentId, QObject *parent)
|
|
: QObject(parent), indexList(il), paths(ps), parentId(parentId)
|
|
{
|
|
}
|
|
|
|
void ComicsRemover::process()
|
|
{
|
|
QString currentComicPath;
|
|
QListIterator<QModelIndex> i(indexList);
|
|
QListIterator<QString> i2(paths);
|
|
i.toBack();
|
|
i2.toBack();
|
|
|
|
while (i.hasPrevious() && i2.hasPrevious()) {
|
|
QModelIndex mi = i.previous();
|
|
currentComicPath = i2.previous();
|
|
if (QFile::moveToTrash(currentComicPath))
|
|
emit remove(mi.row());
|
|
else if (QFile::remove(currentComicPath))
|
|
emit remove(mi.row());
|
|
else
|
|
emit removeError();
|
|
}
|
|
|
|
emit finished();
|
|
emit removedItemsFromFolder(parentId);
|
|
}
|
|
|
|
FoldersRemover::FoldersRemover(QModelIndexList &il, QList<QString> &ps, QObject *parent)
|
|
: QObject(parent), indexList(il), paths(ps)
|
|
{
|
|
}
|
|
|
|
void FoldersRemover::process()
|
|
{
|
|
QString currentFolderPath;
|
|
QListIterator<QModelIndex> i(indexList);
|
|
QListIterator<QString> i2(paths);
|
|
i.toBack();
|
|
i2.toBack();
|
|
|
|
QLOG_DEBUG() << "Deleting folders" << paths.at(0);
|
|
|
|
while (i.hasPrevious() && i2.hasPrevious()) {
|
|
QModelIndex mi = i.previous();
|
|
currentFolderPath = i2.previous();
|
|
QDir d(currentFolderPath);
|
|
if (QFile::moveToTrash(currentFolderPath))
|
|
emit remove(mi);
|
|
else if (d.removeRecursively() || !d.exists()) // the folder is in the DB but no in the drive...
|
|
emit remove(mi);
|
|
else
|
|
emit removeError();
|
|
}
|
|
|
|
emit finished();
|
|
}
|