| 1212 | } |
| 1213 | |
| 1214 | void LibraryWindow::deleteSelectedFolder() |
| 1215 | { |
| 1216 | QModelIndex currentIndex = getCurrentFolderIndex(); |
| 1217 | QString relativePath = foldersModel->getFolderPath(currentIndex); |
| 1218 | QString folderPath = QDir::cleanPath(currentPath() + relativePath); |
| 1219 | |
| 1220 | if (!currentIndex.isValid()) |
| 1221 | QMessageBox::information(this, tr("No folder selected"), tr("Please, select a folder first")); |
| 1222 | else { |
| 1223 | QString libraryPath = QDir::cleanPath(currentPath()); |
| 1224 | if ((libraryPath == folderPath) || relativePath.isEmpty() || relativePath == "/") |
| 1225 | QMessageBox::critical(this, tr("Error in path"), tr("There was an error accessing the folder's path")); |
| 1226 | else { |
| 1227 | int ret = QMessageBox::question(this, tr("Delete folder"), tr("The selected folder and all its contents will be deleted from your disk. Are you sure?") + "\n\nFolder : " + folderPath, QMessageBox::Yes, QMessageBox::No); |
| 1228 | |
| 1229 | if (ret == QMessageBox::Yes) { |
| 1230 | // no folders multiselection by now |
| 1231 | QModelIndexList indexList; |
| 1232 | indexList << currentIndex; |
| 1233 | |
| 1234 | QList<QString> paths; |
| 1235 | paths << folderPath; |
| 1236 | |
| 1237 | auto remover = new FoldersRemover(indexList, paths); |
| 1238 | const auto thread = new QThread(this); |
| 1239 | moveAndConnectRemoverToThread(remover, thread); |
| 1240 | |
| 1241 | connect(remover, &FoldersRemover::remove, foldersModel, &FolderModel::deleteFolder); |
| 1242 | connect(remover, &FoldersRemover::removeError, this, &LibraryWindow::errorDeletingFolder); |
| 1243 | connect(remover, &FoldersRemover::finished, navigationController, &YACReaderNavigationController::reselectCurrentFolder); |
| 1244 | |
| 1245 | thread->start(); |
| 1246 | } |
| 1247 | } |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | void LibraryWindow::errorDeletingFolder() |
| 1252 | { |
nothing calls this directly
no test coverage detected