Фикс: editorContent property (явное присвоение вместо биндинга на функцию), граф — pan левой кнопкой по пустому месту + lastMouseXY, календарь — точка под цифрой (dayLabel.bottom), orphan code cleanup GraphView

This commit is contained in:
Flora (opencode)
2026-08-17 16:04:46 +03:00
parent 7b43b0c4fc
commit 84be13a32d
3 changed files with 37 additions and 31 deletions
+12 -5
View File
@@ -11,6 +11,7 @@ Item {
property bool editMode: true
property bool canOpenBeside: false // кнопка «открыть рядом» (заглавная панель)
property bool closable: false // кнопка «закрыть панель» (вторая панель)
property string editorContent: "" // явное содержимое для TextArea (не биндинг на функцию)
signal openBeside()
signal closePane()
@@ -223,7 +224,7 @@ Item {
id: editor
anchors.fill: parent
visible: pane.editMode
text: documentManager.contentAt(pane.docIndex)
text: pane.editorContent
onTextEdited: documentManager.updateContent(pane.docIndex, text)
selectByMouse: true
font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace"
@@ -300,21 +301,27 @@ Item {
pane.refreshHeader()
}
}
// Просмотр обновляется при изменении контента (например, при правке в соседней панели)
// Просмотр обновляется при изменении контента
Connections {
target: documentManager
function onContentChanged(i) {
if (i === pane.docIndex && !pane.editMode)
if (i === pane.docIndex) {
pane.editorContent = documentManager.contentAt(i)
if (!pane.editMode)
pane.renderView()
}
}
}
onDocIndexChanged: {
pane.refreshHeader()
pane.renderView()
if (pane.docIndex >= 0 && pane.editMode) {
editor.text = documentManager.contentAt(pane.docIndex)
if (pane.docIndex >= 0) {
pane.editorContent = documentManager.contentAt(pane.docIndex)
if (pane.editMode)
editor.forceActiveFocus()
} else {
pane.editorContent = ""
}
}
onEditModeChanged: {
+19 -21
View File
@@ -14,6 +14,8 @@ Canvas {
property real zoom: 1.0
property real panX: 0
property real panY: 0
property real lastMouseX: 0
property real lastMouseY: 0
function nodeForKey(key) {
for (let i = 0; i < nodes.length; ++i)
@@ -91,45 +93,42 @@ Canvas {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
acceptedButtons: Qt.LeftButton
onWheel: (w) => {
// Масштабирование колесом мыши
const factor = w.angleDelta.y > 0 ? 1.15 : 0.87
g.zoom = Math.max(0.2, Math.min(5.0, g.zoom * factor))
g.requestPaint()
}
onPressed: (m) => {
dragKey = ""
// Переводим экранные координаты в координаты графа
g.dragKey = ""
g.lastMouseX = m.x
g.lastMouseY = m.y
const gx = (m.x - width / 2 - panX) / zoom + width / 2
const gy = (m.y - height / 2 - panY) / zoom + height / 2
for (const key in g.pos) {
const p = g.pos[key]
const dx = gx - p.x, dy = gy - p.y
if (dx * dx + dy * dy <= 256) { // радиус захвата 16px
dragKey = key
if (dx * dx + dy * dy <= 256) {
g.dragKey = key
break
}
}
}
onPositionChanged: (m) => {
if (dragKey.length > 0 && g.pos[dragKey]) {
if (g.dragKey.length > 0 && g.pos[g.dragKey]) {
const gx = (m.x - width / 2 - panX) / zoom + width / 2
const gy = (m.y - height / 2 - panY) / zoom + height / 2
g.pos[dragKey] = { x: gx, y: gy }
g.requestPaint()
} else if (m.buttons & Qt.RightButton) {
// Перетаскивание фона (pan)
panX += m.x - m.__lastX
panY += m.y - m.__lastY
g.requestPaint()
g.pos[g.dragKey] = { x: gx, y: gy }
} else {
g.panX += m.x - g.lastMouseX
g.panY += m.y - g.lastMouseY
}
m.__lastX = m.x
m.__lastY = m.y
g.lastMouseX = m.x
g.lastMouseY = m.y
g.requestPaint()
}
onReleased: (m) => {
if (dragKey.length === 0) {
// Клик по узлу (открыть файл)
if (g.dragKey.length === 0) {
const gx = (m.x - width / 2 - panX) / zoom + width / 2
const gy = (m.y - height / 2 - panY) / zoom + height / 2
for (const key in g.pos) {
@@ -143,10 +142,9 @@ Canvas {
}
}
}
dragKey = ""
g.dragKey = ""
}
onDoubleClicked: (m) => {
// Двойной клик — сброс позиции/масштаба
onDoubleClicked: {
g.zoom = 1.0; g.panX = 0; g.panY = 0; g.relayout()
}
}
+4 -3
View File
@@ -96,6 +96,7 @@ Item {
}
Label {
id: dayLabel
anchors.centerIn: parent
visible: modelData > 0
text: modelData
@@ -103,15 +104,15 @@ Item {
color: modelData > 0 ? "#222" : "#ddd"
}
// Точка — есть заметка за этот день
// Точка — есть заметка за этот день (под цифрой)
Rectangle {
visible: modelData > 0 && parent.hasNote
width: 5
height: 5
radius: 3
color: "#3b82f6"
anchors.bottom: parent.bottom
anchors.bottomMargin: 3
anchors.top: dayLabel.bottom
anchors.topMargin: 1
anchors.horizontalCenter: parent.horizontalCenter
}