mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
fixed bug deleting folders
This commit is contained in:
parent
1def3ee438
commit
bba514b727
@ -28,8 +28,8 @@ LIBS += -lpoppler-qt4
|
|||||||
INCLUDEPATH += ../dependencies/poppler/include/qt4
|
INCLUDEPATH += ../dependencies/poppler/include/qt4
|
||||||
}
|
}
|
||||||
|
|
||||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
|
#QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
|
||||||
QMAKE_LFLAGS_RELEASE += /LTCG
|
#QMAKE_LFLAGS_RELEASE += /LTCG
|
||||||
CONFIG -= embed_manifest_exe
|
CONFIG -= embed_manifest_exe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1493,39 +1493,47 @@ void LibraryWindow::addFolderToCurrentIndex()
|
|||||||
void LibraryWindow::deleteSelectedFolder()
|
void LibraryWindow::deleteSelectedFolder()
|
||||||
{
|
{
|
||||||
QModelIndex currentIndex = getCurrentFolderIndex();
|
QModelIndex currentIndex = getCurrentFolderIndex();
|
||||||
|
QString relativePath = foldersModel->getFolderPath(currentIndex);
|
||||||
|
QString folderPath = QDir::cleanPath(currentPath()+relativePath);
|
||||||
|
|
||||||
if(!currentIndex.isValid())
|
if(!currentIndex.isValid())
|
||||||
QMessageBox::information(this,tr("No folder selected"), tr("Please, select a folder first"));
|
QMessageBox::information(this,tr("No folder selected"), tr("Please, select a folder first"));
|
||||||
else
|
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);
|
QString libraryPath = QDir::cleanPath(currentPath());
|
||||||
|
if((libraryPath == folderPath) || relativePath.isEmpty() || relativePath == "/")
|
||||||
if(ret == QMessageBox::Yes)
|
QMessageBox::critical(this,tr("Error in path"),tr("There was an error accessing the folder's path"));
|
||||||
|
else
|
||||||
{
|
{
|
||||||
//no folders multiselection by now
|
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);
|
||||||
QModelIndexList indexList;
|
|
||||||
indexList << currentIndex;
|
|
||||||
|
|
||||||
QList<QString> paths;
|
if(ret == QMessageBox::Yes)
|
||||||
paths << QDir::cleanPath(currentPath()+foldersModel->getFolderPath(currentIndex));
|
{
|
||||||
|
//no folders multiselection by now
|
||||||
|
QModelIndexList indexList;
|
||||||
|
indexList << currentIndex;
|
||||||
|
|
||||||
FoldersRemover * remover = new FoldersRemover(indexList,paths);
|
QList<QString> 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()));
|
remover->moveToThread(thread);
|
||||||
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)
|
connect(thread, SIGNAL(started()), remover, SLOT(process()));
|
||||||
thread->start();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user