From bba514b7275992957f0cee0a7dbc86ceede650e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 23 Oct 2014 13:28:38 +0200 Subject: [PATCH] fixed bug deleting folders --- YACReaderLibrary/YACReaderLibrary.pro | 4 +-- YACReaderLibrary/library_window.cpp | 48 ++++++++++++++++----------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 013e4ec9..b1e689bf 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -28,8 +28,8 @@ LIBS += -lpoppler-qt4 INCLUDEPATH += ../dependencies/poppler/include/qt4 } -QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL -QMAKE_LFLAGS_RELEASE += /LTCG +#QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL +#QMAKE_LFLAGS_RELEASE += /LTCG CONFIG -= embed_manifest_exe } diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 49966a34..01c5daad 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1493,39 +1493,47 @@ void LibraryWindow::addFolderToCurrentIndex() void LibraryWindow::deleteSelectedFolder() { QModelIndex currentIndex = getCurrentFolderIndex(); + QString relativePath = foldersModel->getFolderPath(currentIndex); + QString folderPath = QDir::cleanPath(currentPath()+relativePath); if(!currentIndex.isValid()) QMessageBox::information(this,tr("No folder selected"), tr("Please, select a folder first")); else { - 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?"),QMessageBox::Yes,QMessageBox::No); - - if(ret == QMessageBox::Yes) + QString libraryPath = QDir::cleanPath(currentPath()); + if((libraryPath == folderPath) || relativePath.isEmpty() || relativePath == "/") + QMessageBox::critical(this,tr("Error in path"),tr("There was an error accessing the folder's path")); + else { - //no folders multiselection by now - QModelIndexList indexList; - indexList << currentIndex; + 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); - QList paths; - paths << QDir::cleanPath(currentPath()+foldersModel->getFolderPath(currentIndex)); + if(ret == QMessageBox::Yes) + { + //no folders multiselection by now + QModelIndexList indexList; + indexList << currentIndex; - FoldersRemover * remover = new FoldersRemover(indexList,paths); + QList paths; + paths << folderPath; - QThread * thread = NULL; + FoldersRemover * remover = new FoldersRemover(indexList,paths); - thread = new QThread(this); + QThread * thread = NULL; - remover->moveToThread(thread); + thread = new QThread(this); - connect(thread, SIGNAL(started()), remover, SLOT(process())); - connect(remover, SIGNAL(remove(QModelIndex)), foldersModel, SLOT(deleteFolder(QModelIndex))); - connect(remover, SIGNAL(removeError()),this,SLOT(errorDeletingFolder())); - connect(remover, SIGNAL(finished()),this,SLOT(reloadCovers())); - connect(remover, SIGNAL(finished()), remover, SLOT(deleteLater())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + remover->moveToThread(thread); - if(thread != NULL) - thread->start(); + connect(thread, SIGNAL(started()), remover, SLOT(process())); + connect(remover, SIGNAL(remove(QModelIndex)), foldersModel, SLOT(deleteFolder(QModelIndex))); + connect(remover, SIGNAL(removeError()),this,SLOT(errorDeletingFolder())); + connect(remover, SIGNAL(finished()),this,SLOT(reloadCovers())); + connect(remover, SIGNAL(finished()), remover, SLOT(deleteLater())); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + + if(thread != NULL) + thread->start(); + } } } }