Open parent directory if it doesn't exist
This commit is contained in:
+14
-3
@@ -678,10 +678,21 @@ void DirView::setDir(const QString &path)
|
||||
if(oldPath.left(ROOT_LEN) != path.left(ROOT_LEN))
|
||||
_dirFileSystemModel->setRootPath(path.left(ROOT_LEN));
|
||||
|
||||
_dirFileSystemModel->setDir(path);
|
||||
setRootIndex(_dirFileSystemModel->index(path, 0));
|
||||
QString newPath = path;
|
||||
if(!QFileInfo::exists(path))
|
||||
{
|
||||
QDir dir(path);
|
||||
do
|
||||
{
|
||||
dir.setPath(QDir::cleanPath(dir.filePath("..")));
|
||||
}while(!dir.exists() && !dir.isRoot());
|
||||
newPath = dir.path();
|
||||
}
|
||||
|
||||
_dirFileSystemModel->setDir(newPath);
|
||||
setRootIndex(_dirFileSystemModel->index(newPath, 0));
|
||||
clearSelection();
|
||||
if(oldPath != path)emit dirChanged(path);
|
||||
if(oldPath != newPath)emit dirChanged(newPath);
|
||||
}
|
||||
|
||||
QString DirView::dir() const
|
||||
|
||||
Reference in New Issue
Block a user