mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
bug-fix: respect the open mode even if the file has been opened
This commit is contained in:
parent
01788a5301
commit
73ede805d1
@ -126,10 +126,10 @@ void VEditArea::openFile(VFile *p_file, OpenFileMode p_mode)
|
|||||||
if (!p_file) {
|
if (!p_file) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "VEditArea open" << p_file->getName() << (int)p_mode;
|
|
||||||
|
|
||||||
// Find if it has been opened already
|
// Find if it has been opened already
|
||||||
int winIdx, tabIdx;
|
int winIdx, tabIdx;
|
||||||
|
bool existFile = false;
|
||||||
bool setFocus = false;
|
bool setFocus = false;
|
||||||
auto tabs = findTabsByFile(p_file);
|
auto tabs = findTabsByFile(p_file);
|
||||||
if (!tabs.empty()) {
|
if (!tabs.empty()) {
|
||||||
@ -143,7 +143,9 @@ void VEditArea::openFile(VFile *p_file, OpenFileMode p_mode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setFocus = true;
|
setFocus = true;
|
||||||
|
existFile = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,11 +155,20 @@ void VEditArea::openFile(VFile *p_file, OpenFileMode p_mode)
|
|||||||
insertSplitWindow(0);
|
insertSplitWindow(0);
|
||||||
curWindowIndex = 0;
|
curWindowIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
winIdx = curWindowIndex;
|
winIdx = curWindowIndex;
|
||||||
tabIdx = openFileInWindow(winIdx, p_file, p_mode);
|
tabIdx = openFileInWindow(winIdx, p_file, p_mode);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
setCurrentTab(winIdx, tabIdx, setFocus);
|
setCurrentTab(winIdx, tabIdx, setFocus);
|
||||||
|
|
||||||
|
if (existFile) {
|
||||||
|
if (p_mode == OpenFileMode::Read) {
|
||||||
|
readFile();
|
||||||
|
} else if (p_mode == OpenFileMode::Edit) {
|
||||||
|
editFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QPair<int, int> > VEditArea::findTabsByFile(const VFile *p_file)
|
QVector<QPair<int, int> > VEditArea::findTabsByFile(const VFile *p_file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user