fix: 修复了新建文件无法进入选择状态和重命名状态的BUG (#204)
* fix: Fixed a bug where newly created files would not automatically enter rename mode. * fix: Resolved an issue where files could not be selected in certain cases upon creation. --------- Co-authored-by: xy <eq_software@foxmail.com>
This commit is contained in:
parent
5ada4b6e4b
commit
764c8cce8c
|
@ -4437,15 +4437,17 @@ void MainWindow::onShowInsertCodeSnippetMenu()
|
|||
void MainWindow::onFilesViewCreateFolderFolderLoaded(const QString& path)
|
||||
{
|
||||
|
||||
if (mFilesViewNewCreatedFolder.isEmpty())
|
||||
if (mFilesViewNewCreatedFolder.isEmpty() && mFilesViewNewCreatedFile.isEmpty())
|
||||
return;
|
||||
|
||||
if (path!=extractFilePath(mFilesViewNewCreatedFolder))
|
||||
if (path!=extractFilePath(mFilesViewNewCreatedFolder) && path!=extractFilePath(mFilesViewNewCreatedFile))
|
||||
return;
|
||||
|
||||
disconnect(&mFileSystemModel,&QFileSystemModel::directoryLoaded,
|
||||
this,&MainWindow::onFilesViewCreateFolderFolderLoaded);
|
||||
QModelIndex newIndex = mFileSystemModel.index(mFilesViewNewCreatedFolder);
|
||||
|
||||
QModelIndex newIndex = mFileSystemModel.index(mFilesViewNewCreatedFolder.isEmpty() ? mFilesViewNewCreatedFile : mFilesViewNewCreatedFolder);
|
||||
|
||||
if (newIndex.isValid()) {
|
||||
ui->treeFiles->setCurrentIndex(newIndex);
|
||||
ui->treeFiles->edit(newIndex);
|
||||
|
@ -4503,7 +4505,6 @@ void MainWindow::onFilesViewCreateFile()
|
|||
dir = QDir(mFileSystemModel.fileInfo(index).absoluteFilePath());
|
||||
else
|
||||
dir = mFileSystemModel.fileInfo(index).absoluteDir();
|
||||
ui->treeFiles->expand(index);
|
||||
} else {
|
||||
dir = mFileSystemModel.rootDirectory();
|
||||
}
|
||||
|
@ -4525,8 +4526,12 @@ void MainWindow::onFilesViewCreateFile()
|
|||
// workaround: try create but do not truncate
|
||||
file.open(QFile::ReadWrite);
|
||||
#endif
|
||||
QModelIndex newIndex = mFileSystemModel.index(fileName);
|
||||
ui->treeFiles->setCurrentIndex(newIndex);
|
||||
file.close();
|
||||
QModelIndex newIndex = mFileSystemModel.index(dir.filePath(fileName));
|
||||
connect(&mFileSystemModel,&QFileSystemModel::directoryLoaded,
|
||||
this,&MainWindow::onFilesViewCreateFolderFolderLoaded);
|
||||
ui->treeFiles->expand(index);
|
||||
mFilesViewNewCreatedFile=mFileSystemModel.filePath(newIndex);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -906,6 +906,7 @@ private:
|
|||
|
||||
QString mClassBrowserCurrentStatement;
|
||||
QString mFilesViewNewCreatedFolder;
|
||||
QString mFilesViewNewCreatedFile;
|
||||
|
||||
bool mCheckSyntaxInBack;
|
||||
bool mShouldRemoveAllSettings;
|
||||
|
|
Loading…
Reference in New Issue