Фикс: editorContent property (явное присвоение вместо биндинга на функцию), граф — pan левой кнопкой по пустому месту + lastMouseXY, календарь — точка под цифрой (dayLabel.bottom), orphan code cleanup GraphView
This commit is contained in:
@@ -11,6 +11,7 @@ Item {
|
|||||||
property bool editMode: true
|
property bool editMode: true
|
||||||
property bool canOpenBeside: false // кнопка «открыть рядом» (заглавная панель)
|
property bool canOpenBeside: false // кнопка «открыть рядом» (заглавная панель)
|
||||||
property bool closable: false // кнопка «закрыть панель» (вторая панель)
|
property bool closable: false // кнопка «закрыть панель» (вторая панель)
|
||||||
|
property string editorContent: "" // явное содержимое для TextArea (не биндинг на функцию)
|
||||||
|
|
||||||
signal openBeside()
|
signal openBeside()
|
||||||
signal closePane()
|
signal closePane()
|
||||||
@@ -223,7 +224,7 @@ Item {
|
|||||||
id: editor
|
id: editor
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: pane.editMode
|
visible: pane.editMode
|
||||||
text: documentManager.contentAt(pane.docIndex)
|
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"
|
||||||
@@ -300,21 +301,27 @@ Item {
|
|||||||
pane.refreshHeader()
|
pane.refreshHeader()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Просмотр обновляется при изменении контента (например, при правке в соседней панели)
|
// Просмотр обновляется при изменении контента
|
||||||
Connections {
|
Connections {
|
||||||
target: documentManager
|
target: documentManager
|
||||||
function onContentChanged(i) {
|
function onContentChanged(i) {
|
||||||
if (i === pane.docIndex && !pane.editMode)
|
if (i === pane.docIndex) {
|
||||||
|
pane.editorContent = documentManager.contentAt(i)
|
||||||
|
if (!pane.editMode)
|
||||||
pane.renderView()
|
pane.renderView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onDocIndexChanged: {
|
onDocIndexChanged: {
|
||||||
pane.refreshHeader()
|
pane.refreshHeader()
|
||||||
pane.renderView()
|
pane.renderView()
|
||||||
if (pane.docIndex >= 0 && pane.editMode) {
|
if (pane.docIndex >= 0) {
|
||||||
editor.text = documentManager.contentAt(pane.docIndex)
|
pane.editorContent = documentManager.contentAt(pane.docIndex)
|
||||||
|
if (pane.editMode)
|
||||||
editor.forceActiveFocus()
|
editor.forceActiveFocus()
|
||||||
|
} else {
|
||||||
|
pane.editorContent = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onEditModeChanged: {
|
onEditModeChanged: {
|
||||||
|
|||||||
+19
-21
@@ -14,6 +14,8 @@ Canvas {
|
|||||||
property real zoom: 1.0
|
property real zoom: 1.0
|
||||||
property real panX: 0
|
property real panX: 0
|
||||||
property real panY: 0
|
property real panY: 0
|
||||||
|
property real lastMouseX: 0
|
||||||
|
property real lastMouseY: 0
|
||||||
|
|
||||||
function nodeForKey(key) {
|
function nodeForKey(key) {
|
||||||
for (let i = 0; i < nodes.length; ++i)
|
for (let i = 0; i < nodes.length; ++i)
|
||||||
@@ -91,45 +93,42 @@ Canvas {
|
|||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onWheel: (w) => {
|
onWheel: (w) => {
|
||||||
// Масштабирование колесом мыши
|
|
||||||
const factor = w.angleDelta.y > 0 ? 1.15 : 0.87
|
const factor = w.angleDelta.y > 0 ? 1.15 : 0.87
|
||||||
g.zoom = Math.max(0.2, Math.min(5.0, g.zoom * factor))
|
g.zoom = Math.max(0.2, Math.min(5.0, g.zoom * factor))
|
||||||
g.requestPaint()
|
g.requestPaint()
|
||||||
}
|
}
|
||||||
onPressed: (m) => {
|
onPressed: (m) => {
|
||||||
dragKey = ""
|
g.dragKey = ""
|
||||||
// Переводим экранные координаты в координаты графа
|
g.lastMouseX = m.x
|
||||||
|
g.lastMouseY = m.y
|
||||||
const gx = (m.x - width / 2 - panX) / zoom + width / 2
|
const gx = (m.x - width / 2 - panX) / zoom + width / 2
|
||||||
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
||||||
for (const key in g.pos) {
|
for (const key in g.pos) {
|
||||||
const p = g.pos[key]
|
const p = g.pos[key]
|
||||||
const dx = gx - p.x, dy = gy - p.y
|
const dx = gx - p.x, dy = gy - p.y
|
||||||
if (dx * dx + dy * dy <= 256) { // радиус захвата 16px
|
if (dx * dx + dy * dy <= 256) {
|
||||||
dragKey = key
|
g.dragKey = key
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onPositionChanged: (m) => {
|
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 gx = (m.x - width / 2 - panX) / zoom + width / 2
|
||||||
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
||||||
g.pos[dragKey] = { x: gx, y: gy }
|
g.pos[g.dragKey] = { x: gx, y: gy }
|
||||||
g.requestPaint()
|
} else {
|
||||||
} else if (m.buttons & Qt.RightButton) {
|
g.panX += m.x - g.lastMouseX
|
||||||
// Перетаскивание фона (pan)
|
g.panY += m.y - g.lastMouseY
|
||||||
panX += m.x - m.__lastX
|
|
||||||
panY += m.y - m.__lastY
|
|
||||||
g.requestPaint()
|
|
||||||
}
|
}
|
||||||
m.__lastX = m.x
|
g.lastMouseX = m.x
|
||||||
m.__lastY = m.y
|
g.lastMouseY = m.y
|
||||||
|
g.requestPaint()
|
||||||
}
|
}
|
||||||
onReleased: (m) => {
|
onReleased: (m) => {
|
||||||
if (dragKey.length === 0) {
|
if (g.dragKey.length === 0) {
|
||||||
// Клик по узлу (открыть файл)
|
|
||||||
const gx = (m.x - width / 2 - panX) / zoom + width / 2
|
const gx = (m.x - width / 2 - panX) / zoom + width / 2
|
||||||
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
||||||
for (const key in g.pos) {
|
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()
|
g.zoom = 1.0; g.panX = 0; g.panY = 0; g.relayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
id: dayLabel
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
visible: modelData > 0
|
visible: modelData > 0
|
||||||
text: modelData
|
text: modelData
|
||||||
@@ -103,15 +104,15 @@ Item {
|
|||||||
color: modelData > 0 ? "#222" : "#ddd"
|
color: modelData > 0 ? "#222" : "#ddd"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Точка — есть заметка за этот день
|
// Точка — есть заметка за этот день (под цифрой)
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: modelData > 0 && parent.hasNote
|
visible: modelData > 0 && parent.hasNote
|
||||||
width: 5
|
width: 5
|
||||||
height: 5
|
height: 5
|
||||||
radius: 3
|
radius: 3
|
||||||
color: "#3b82f6"
|
color: "#3b82f6"
|
||||||
anchors.bottom: parent.bottom
|
anchors.top: dayLabel.bottom
|
||||||
anchors.bottomMargin: 3
|
anchors.topMargin: 1
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user