95c03040c7
- FileStore: защита от выхода за пределы хранилища (isInsideVault), валидация имён (запрет скрытых, зарезервированных, управляющих символов), проверка destDir, лимит watcher, dailyNote валидация, openVault проверка isDir - DocumentManager: лимит 10МБ, кламп автосейва 0.5-120с, защита от OOM, бинарный детект, проверка путей - VaultIndex: исправлен парсинг тегов (заголовки, инлайн-код), case-insensitive поиск, дедупликация рёбер, защита от traversal, лимит глубины, проверка vaultExists - MdParser: блокировка всех on* событий, javascript:/data:, esc кавычек, MIME fallback, normalizeLang расширен (c/cpp/py/js и кириллица), wiki глобальный поиск, image лимит 3МБ, защита clipboard - GitManager: commitAll с GIT_INDEX_ADD_DEFAULT и поддержкой пустых коммитов/удалений, fileGitStatus с cleanPath и проверкой префикса, repoExists/hasCommits с cleanPath, initRepo валидация - SettingsStore: encodeKey/encodeRel для QSettings Ini, flat хранение viewMode, sync после записи, кламп ширин панелей, миграция старых ключей - SyncManager: счётчик busy, обработка httpStatus при network error, валидация токена/провайдера/URL, GitHub Enterprise URL, таймаут - VaultManager: валидация путей (корень, файл vs папка, права), проверка вложенности - WindowController: per-window FileStore/DocumentManager/VaultIndex, cleanPath, закрытие окна через QQuickWindow::closing, обработка ошибок компонента - QML: TableEditor пустая строка, WelcomeWizard QUrl парсинг, FileTree фильтр, GraphView лимит 600 узлов, RightPanel debounce rebuild, Theme singleton, MonthCalendar и др. - Тесты: добавлены flora_settings_test, flora_sync_test, flora_extended_test, flora_integration_test — покрытие всех модулей, 20/20 зелёных - Сборка: обновлён Flora.app (4.6М бинарь -> 173М бандл, ad-hoc подпись, проверен offscreen запуск, версия 0.0.1 + cmark 0.29 + libgit2 1.9) - .gitignore: добавлены Testing/, coverage, gcda/gcov, __pycache__, .tmp, test-vault и др.
151 lines
5.4 KiB
QML
151 lines
5.4 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Flora
|
|
|
|
Dialog {
|
|
id: root
|
|
|
|
signal markdownReady(string md)
|
|
|
|
title: qsTr("Таблица")
|
|
modal: true
|
|
width: 560
|
|
anchors.centerIn: parent
|
|
closePolicy: Dialog.NoAutoClose
|
|
standardButtons: Dialog.NoButton
|
|
background: Rectangle { color: Theme.surface; border.color: Theme.borderStrong; radius: 10 }
|
|
|
|
property int rows: 1
|
|
property int cols: 2
|
|
property var cells: []
|
|
|
|
readonly property int cellW: 120
|
|
readonly property int cellH: 34
|
|
|
|
function cell(r, c) { const i = r * cols + c; return i < cells.length ? cells[i] : "" }
|
|
function setCell(r, c, v) { const i = r * cols + c; if (i < cells.length) cells[i] = v }
|
|
|
|
function addRowAfter(r) {
|
|
// Новая строка пустая, а не копия
|
|
const ins = r + 1
|
|
const flat = []
|
|
for (let rr = 0; rr <= rows; ++rr) {
|
|
if (rr === ins) for (let c = 0; c < cols; ++c) flat.push("")
|
|
for (let c = 0; c < cols; ++c) if (rr < rows) flat.push(cell(rr, c))
|
|
}
|
|
cells = flat; rows += 1
|
|
}
|
|
|
|
function addColAfter(c) {
|
|
const src = []
|
|
for (let r = 0; r < rows; ++r) src.push(cell(r, c))
|
|
const ins = c + 1
|
|
const flat = []
|
|
for (let rr = 0; rr < rows; ++rr) {
|
|
for (let cc = 0; cc <= cols; ++cc) {
|
|
if (cc === ins) flat.push("")
|
|
if (cc < cols) flat.push(cell(rr, cc))
|
|
}
|
|
}
|
|
cells = flat; cols += 1
|
|
}
|
|
|
|
function buildMarkdown() {
|
|
let out = ""
|
|
for (let c = 0; c < cols; ++c) out += (c === 0 ? "| " : " | ") + cell(0, c)
|
|
out += " |\n"
|
|
for (let c = 0; c < cols; ++c) out += (c === 0 ? "| " : " | ") + "---"
|
|
out += " |\n"
|
|
for (let r = 1; r < rows; ++r) {
|
|
for (let c = 0; c < cols; ++c) out += (c === 0 ? "| " : " | ") + cell(r, c)
|
|
out += " |\n"
|
|
}
|
|
return out
|
|
}
|
|
|
|
function resetDialog() {
|
|
rows = 1; cols = 2; cells = []
|
|
for (let i = 0; i < rows * cols; ++i) cells.push("")
|
|
}
|
|
|
|
Component.onCompleted: resetDialog()
|
|
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
spacing: 10
|
|
|
|
Label { text: qsTr("Заполните ячейки таблицы"); color: Theme.textSecondary; font.pixelSize: 11 }
|
|
|
|
Flickable {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
contentWidth: cellGrid.width + 30
|
|
contentHeight: cellGrid.height + 30
|
|
clip: true
|
|
ScrollBar.horizontal: ScrollBar {}
|
|
ScrollBar.vertical: ScrollBar {}
|
|
Row {
|
|
id: tableRow
|
|
spacing: 0
|
|
Grid {
|
|
id: cellGrid
|
|
columns: root.cols
|
|
columnSpacing: 3
|
|
rowSpacing: 3
|
|
Repeater {
|
|
model: root.rows * root.cols
|
|
delegate: TextField {
|
|
width: root.cellW; height: root.cellH
|
|
placeholderText: (Math.floor(model / root.cols)===0 ? qsTr("Заголовок") : qsTr("Ячейка"))
|
|
placeholderTextColor: Theme.textFaint
|
|
text: root.cell(Math.floor(model / root.cols), model % root.cols)
|
|
color: Theme.text
|
|
background: Rectangle { color: Theme.bgAlt; border.color: parent.activeFocus ? Theme.accent : Theme.border; radius: 6 }
|
|
onTextEdited: root.setCell(Math.floor(model / root.cols), model % root.cols, text)
|
|
}
|
|
}
|
|
}
|
|
Grid {
|
|
columns: 1; columnSpacing: 3; rowSpacing: 3
|
|
anchors.leftMargin: 4
|
|
Repeater {
|
|
model: root.rows
|
|
delegate: Button {
|
|
width: 24; height: root.cellH
|
|
text: "+"
|
|
ToolTip.text: qsTr("Добавить строку")
|
|
ToolTip.visible: hovered
|
|
onClicked: root.addRowAfter(model)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Row {
|
|
anchors.top: tableRow.bottom; anchors.topMargin: 4
|
|
Grid {
|
|
columns: root.cols; columnSpacing: 3; rowSpacing: 3
|
|
Repeater {
|
|
model: root.cols
|
|
delegate: Button {
|
|
width: root.cellW; height: 24
|
|
text: "+"
|
|
ToolTip.text: qsTr("Добавить столбец")
|
|
ToolTip.visible: hovered
|
|
onClicked: root.addColAfter(model)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Item { Layout.fillWidth: true }
|
|
Label { text: qsTr("Строк: %1 Столбцов: %2").arg(root.rows).arg(root.cols); color: Theme.textMuted; font.pixelSize: 11 }
|
|
Button { text: qsTr("Отмена"); onClicked: root.reject() }
|
|
Button { text: qsTr("Вставить"); highlighted: true; onClicked: { root.markdownReady(buildMarkdown()); root.accept() } }
|
|
}
|
|
}
|
|
}
|