Hi,
I have a qfilesystemmodel and I have a menu to delete a file/folder.
Here the code :
for( int i = 0; i < SelectedIndexes.count(); ++i )
{
const QFileInfo FileInfo
= Model
->fileInfo
( SelectedIndexes
[ i
] );
if( FileInfo.isDir() )
{
if( QDir( FileInfo.
absoluteFilePath() ).
removeRecursively() == false ) DE::CEngine::GetLogger().LogError( "\"%s\" can not be deleted", FileInfo.absoluteFilePath().toUtf8().data() );
}
else
{
if( QDir( FileInfo.
dir().
absolutePath() ).
remove( FileInfo.
fileName() ) == false ) DE::CEngine::GetLogger().LogError( "\"%s\" can not be deleted", FileInfo.absoluteFilePath().toUtf8().data() );
}
}
for( int i = 0; i < SelectedIndexes.count(); ++i )
{
const QFileInfo FileInfo = Model->fileInfo( SelectedIndexes[ i ] );
if( FileInfo.isDir() )
{
if( QDir( FileInfo.absoluteFilePath() ).removeRecursively() == false )
DE::CEngine::GetLogger().LogError( "\"%s\" can not be deleted", FileInfo.absoluteFilePath().toUtf8().data() );
}
else
{
if( QDir( FileInfo.dir().absolutePath() ).remove( FileInfo.fileName() ) == false )
DE::CEngine::GetLogger().LogError( "\"%s\" can not be deleted", FileInfo.absoluteFilePath().toUtf8().data() );
}
}
To copy to clipboard, switch view to plain text mode
The problem is when you enter the folder inside a folder and try to remove, you can't remove.
* Root
** Folder
*** Inside_Folder
Once a setRootIndex is called on the "Inside_Folder" if you set the rootIndex to the root and try to remove Folder, you can't.
That removes "Inside_Folder" but not "Folder" you have to redo a remove action on Folder a second time to remove it.
A fix exists on this problem ? How ?
Thanks for the help
Bookmarks