Files
metabuilder/qml/MetaBuilder/DatabaseLogic.js
johndoe6345789 827387d807 style(qt6): enforce 80-character line margin across all QML and JS files
88 files reformatted — zero logic changes:
- All views, components, and JS modules wrapped to 80-char margin
- Long property bindings, ternaries, and strings broken at natural points
- Theme.qml theme definitions expanded to multi-line
- StyleVariables tokens wrapped
- Section comment rulers trimmed to 80 chars

Trade-off: LOC increases from line wrapping (compact single-line properties
now span 2-3 lines). Content unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 15:20:01 +00:00

86 lines
2.5 KiB
JavaScript

// DatabaseLogic.js — DBAL + utility logic for
// DatabaseManager
function formatSize(kb) {
return kb < 1024
? kb + " KB"
: (kb / 1024).toFixed(1) + " MB"
}
function totalRecords(backends) {
var s = 0
for (var i = 0; i < backends.length; i++)
s += backends[i].records
return s
}
function totalSize(backends) {
var s = 0
for (var i = 0; i < backends.length; i++)
s += backends[i].sizeKb
return s
}
function connectedCount(backends) {
var c = 0
for (var i = 0; i < backends.length; i++)
if (backends[i].status === "connected") c++
return c
}
function testConnectionLive(root, dbal,
testTimer, index) {
root.testingIndex = index
if (root.useLiveData) {
dbal.execute("core/test-connection",
{ adapter: root.backends[index].key },
function(result, error) {
var newResults = Object.assign(
{}, root.testResults)
newResults[index] =
(!error && result && result.success)
? "success" : "error"
root.testResults = newResults
root.testingIndex = -1
})
} else {
testTimer.targetIndex = index
testTimer.start()
}
}
function loadAdapterStatus(root, dbal) {
dbal.execute("core/adapters", {},
function(result, error) {
if (!error && result && result.adapters
&& result.adapters.length > 0) {
var liveBackends = []
for (var i = 0;
i < result.adapters.length; i++) {
var a = result.adapters[i]
liveBackends.push({
name: a.name || "",
key: a.key || "",
status: a.status
|| "disconnected",
description:
a.description || "",
connectionString:
a.connectionString || "",
records: a.records || 0,
sizeKb: a.sizeKb || 0,
lastBackup:
a.lastBackup || "Never"
})
}
root.backends = liveBackends
if (root.selectedBackendIndex
>= liveBackends.length)
root.selectedBackendIndex = 0
if (root.activeBackendIndex
>= liveBackends.length)
root.activeBackendIndex = 0
}
})
}