mirror of
				https://github.com/YACReader/yacreader
				synced 2025-10-31 00:04:26 -04:00 
			
		
		
		
	Fixed data base info retrieving through DBHelper, value(QString) should never be used because it is really slow. All items sorting should be done at db level or using std::sort.
				
					
				
			This commit is contained in:
		
							
								
								
									
										63
									
								
								YACReaderLibrary/comics_remover.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								YACReaderLibrary/comics_remover.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| #include "comics_remover.h" | ||||
|  | ||||
| #include <QFile> | ||||
| #include <QDir> | ||||
|  | ||||
| #include "QsLog.h" | ||||
|  | ||||
| ComicsRemover::ComicsRemover(QModelIndexList & il, QList<QString> &  ps, QObject *parent) | ||||
|     :QObject(parent),indexList(il), paths(ps) | ||||
| { | ||||
| } | ||||
|  | ||||
| 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::remove(currentComicPath)) | ||||
| 			emit remove(mi.row()); | ||||
| 		else | ||||
| 			emit removeError(); | ||||
| 	} | ||||
|  | ||||
| 	emit finished(); | ||||
| } | ||||
|  | ||||
|  | ||||
| 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(d.removeRecursively() || !d.exists()) //the folder is in the DB but no in the drive... | ||||
|             emit remove(mi); | ||||
|         else | ||||
|             emit removeError(); | ||||
|     } | ||||
|  | ||||
|     emit finished(); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user