import QtQuick import QtQuick.Controls import QtQuick.Layouts Item { id: pane property int docIndex: -1 property bool editMode: true property bool canOpenBeside: false property bool closable: false signal openBeside() signal closePane() function insertText(t) { textDisplay.insert(textDisplay.cursorPosition, t) } // Шапка файла — плавающий оверлей Rectangle { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right height: 30 z: 10 color: "#f0f0f0" border.color: "#ddd" RowLayout { anchors.fill: parent anchors.leftMargin: 8 anchors.rightMargin: 4 spacing: 6 Label { Layout.fillWidth: true elide: Text.ElideMiddle color: "#444" text: documentManager.titleAt(pane.docIndex) } ToolButton { text: "✎" checkable: true checked: pane.editMode onClicked: pane.editMode = true } ToolButton { text: "👁" checkable: true checked: !pane.editMode onClicked: pane.editMode = false } ToolButton { text: "\u2715" visible: pane.closable onClicked: pane.closePane() } } } // Текст файла — TextEdit внутри Flickable Flickable { id: flickable anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom contentWidth: textDisplay.paintedWidth contentHeight: textDisplay.paintedHeight clip: true flickableDirection: Flickable.VerticalFlick // ВРЕМЕННЫЙ красный фон для отладки размеров Rectangle { anchors.fill: parent color: "red" z: -1 } TextEdit { id: textDisplay width: flickable.width text: documentManager.activeIndex >= 0 ? documentManager.contentAt(documentManager.activeIndex) : "" color: "black" font.family: "Menlo, Consolas, 'DejaVu Sans Mono', monospace" font.pixelSize: 14 wrapMode: TextEdit.NoWrap readOnly: true selectByMouse: true } } // Загрузка контента при смене файла function refresh() { const idx = pane.docIndex if (idx >= 0) { const c = documentManager.contentAt(idx) textDisplay.text = c } else { textDisplay.text = "" } } function filePathDir(p) { const i = p.lastIndexOf("/") return i >= 0 ? p.substring(0, i) : p } onDocIndexChanged: refresh() onEditModeChanged: { refresh() } Connections { target: documentManager function onActiveIndexChanged() { if (documentManager.activeIndex === pane.docIndex) refresh() } } Component.onCompleted: refresh() }