mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
bugfix: update outline info after renaming
Update the filePath property in VToc after renaming the note. Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
3769ac5311
commit
62f2d39fbc
@ -400,6 +400,7 @@ void VEditTab::requestUpdateCurHeader()
|
|||||||
|
|
||||||
void VEditTab::requestUpdateOutline()
|
void VEditTab::requestUpdateOutline()
|
||||||
{
|
{
|
||||||
|
checkToc();
|
||||||
emit outlineChanged(tableOfContent);
|
emit outlineChanged(tableOfContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,6 +428,9 @@ void VEditTab::updateCurHeader(const QString &anchor)
|
|||||||
}
|
}
|
||||||
curHeader = VAnchor(m_file->retrivePath(), "#" + anchor, -1);
|
curHeader = VAnchor(m_file->retrivePath(), "#" + anchor, -1);
|
||||||
if (!anchor.isEmpty()) {
|
if (!anchor.isEmpty()) {
|
||||||
|
if (checkToc()) {
|
||||||
|
emit outlineChanged(tableOfContent);
|
||||||
|
}
|
||||||
const QVector<VHeader> &headers = tableOfContent.headers;
|
const QVector<VHeader> &headers = tableOfContent.headers;
|
||||||
for (int i = 0; i < headers.size(); ++i) {
|
for (int i = 0; i < headers.size(); ++i) {
|
||||||
if (headers[i].anchor == curHeader.anchor) {
|
if (headers[i].anchor == curHeader.anchor) {
|
||||||
@ -443,6 +447,9 @@ void VEditTab::updateCurHeader(int p_lineNumber, int p_outlineIndex)
|
|||||||
if (!isEditMode || curHeader.lineNumber == p_lineNumber) {
|
if (!isEditMode || curHeader.lineNumber == p_lineNumber) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (checkToc()) {
|
||||||
|
emit outlineChanged(tableOfContent);
|
||||||
|
}
|
||||||
curHeader = VAnchor(m_file->retrivePath(), "", p_lineNumber);
|
curHeader = VAnchor(m_file->retrivePath(), "", p_lineNumber);
|
||||||
curHeader.m_outlineIndex = p_outlineIndex;
|
curHeader.m_outlineIndex = p_outlineIndex;
|
||||||
if (p_lineNumber > -1) {
|
if (p_lineNumber > -1) {
|
||||||
@ -519,3 +526,14 @@ void VEditTab::clearFindSelectionInWebView()
|
|||||||
webPreviewer->findText("");
|
webPreviewer->findText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VEditTab::checkToc()
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
if (tableOfContent.filePath != m_file->retrivePath()) {
|
||||||
|
tableOfContent.filePath = m_file->retrivePath();
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,9 @@ private:
|
|||||||
void scrollPreviewToHeader(int p_outlineIndex);
|
void scrollPreviewToHeader(int p_outlineIndex);
|
||||||
void findTextInWebView(const QString &p_text, uint p_options, bool p_peek,
|
void findTextInWebView(const QString &p_text, uint p_options, bool p_peek,
|
||||||
bool p_forward);
|
bool p_forward);
|
||||||
|
// Check if @tableOfContent is outdated (such as renaming the file).
|
||||||
|
// Return true if we need to update toc.
|
||||||
|
bool checkToc();
|
||||||
|
|
||||||
QPointer<VFile> m_file;
|
QPointer<VFile> m_file;
|
||||||
bool isEditMode;
|
bool isEditMode;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user