Fix: убрана binding text: pane.editorContent из TextArea — только явное присвоение через loadContent() (onDocIndexChanged + Timer 50ms + Connections.activeIndexChanged). Календарь: cal.currentMonth как явная зависимость в hasNote.
This commit is contained in:
+18
-13
@@ -224,7 +224,6 @@ Item {
|
|||||||
id: editor
|
id: editor
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: pane.editMode
|
visible: pane.editMode
|
||||||
text: pane.editorContent
|
|
||||||
onTextEdited: documentManager.updateContent(pane.docIndex, text)
|
onTextEdited: documentManager.updateContent(pane.docIndex, text)
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace"
|
font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace"
|
||||||
@@ -251,6 +250,17 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------- Просмотр (режим просмотра) ----------
|
// ---------- Просмотр (режим просмотра) ----------
|
||||||
|
function loadContent() {
|
||||||
|
if (pane.docIndex >= 0) {
|
||||||
|
const c = documentManager.contentAt(pane.docIndex)
|
||||||
|
editor.text = c
|
||||||
|
pane.editorContent = c
|
||||||
|
console.log("loadContent docIndex=" + pane.docIndex + " len=" + c.length)
|
||||||
|
} else {
|
||||||
|
editor.text = ""
|
||||||
|
pane.editorContent = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
function pathDir(p) {
|
function pathDir(p) {
|
||||||
const idx = p.lastIndexOf("/")
|
const idx = p.lastIndexOf("/")
|
||||||
return idx >= 0 ? p.substring(0, idx) : p
|
return idx >= 0 ? p.substring(0, idx) : p
|
||||||
@@ -304,9 +314,12 @@ Item {
|
|||||||
// Просмотр обновляется при изменении контента
|
// Просмотр обновляется при изменении контента
|
||||||
Connections {
|
Connections {
|
||||||
target: documentManager
|
target: documentManager
|
||||||
|
function onActiveIndexChanged() {
|
||||||
|
pane.loadContent()
|
||||||
|
}
|
||||||
function onContentChanged(i) {
|
function onContentChanged(i) {
|
||||||
if (i === pane.docIndex) {
|
if (i === pane.docIndex) {
|
||||||
pane.editorContent = documentManager.contentAt(i)
|
pane.loadContent()
|
||||||
if (!pane.editMode)
|
if (!pane.editMode)
|
||||||
pane.renderView()
|
pane.renderView()
|
||||||
}
|
}
|
||||||
@@ -316,22 +329,14 @@ Item {
|
|||||||
onDocIndexChanged: {
|
onDocIndexChanged: {
|
||||||
pane.refreshHeader()
|
pane.refreshHeader()
|
||||||
pane.renderView()
|
pane.renderView()
|
||||||
|
pane.loadContent()
|
||||||
loadTimer.start()
|
loadTimer.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Таймер для надёжной загрузки контента (обходит тайминг layout/QML)
|
|
||||||
Timer {
|
Timer {
|
||||||
id: loadTimer
|
id: loadTimer
|
||||||
interval: 30
|
interval: 50
|
||||||
onTriggered: {
|
onTriggered: pane.loadContent()
|
||||||
if (pane.docIndex >= 0) {
|
|
||||||
pane.editorContent = documentManager.contentAt(pane.docIndex)
|
|
||||||
if (pane.editMode)
|
|
||||||
editor.forceActiveFocus()
|
|
||||||
} else {
|
|
||||||
pane.editorContent = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onEditModeChanged: {
|
onEditModeChanged: {
|
||||||
if (!pane.editMode)
|
if (!pane.editMode)
|
||||||
|
|||||||
Reference in New Issue
Block a user