The designer's data model lives in internal/labels: STOCKS are the physical roll in the printer (geometry in mm, margins, dpi — seeded with the common Brother DK sizes, the QL family being what prompted the feature), TEMPLATES are one design each, of two kinds: the QSO label glued on the card, whose repeating table carries several contacts of the same station, and the address label for the envelope, whose lines collapse when a variable is empty. Everything is measured in millimetres — labels are sold in mm, and an operator lining a design up against a physical sticker thinks in mm; pixels exist only in the renderer, at the stock's dpi. The canvas renderer is shared between the editor's preview and the future print path, so there is no second implementation for the preview to disagree with. The preview is fed with the log's latest contacts rather than lorem ipsum: real data shows a too-narrow column immediately. Printing (PDF, one page per label at exact size) is the next module; nothing here prints yet.
31 lines
1.5 KiB
SQL
31 lines
1.5 KiB
SQL
-- Label designer: printable labels for paper QSL work.
|
|
--
|
|
-- Two tables because the two things have different lifetimes. A STOCK is the
|
|
-- physical roll in the printer (width, height, margins) — one per label size,
|
|
-- shared by every design printed on it. A TEMPLATE is one design (what goes on
|
|
-- the label) and points at the stock it was drawn for. Deleting a design must
|
|
-- never take the roll definition of the other designs with it.
|
|
--
|
|
-- kind separates the two families the operator designs: 'qso' (the label glued
|
|
-- on the QSL card, with its repeating QSO table) and 'address' (destination or
|
|
-- return address). is_default is per (kind, profile scope) — printing wants
|
|
-- "the QSO label" and "the address label" without asking every time.
|
|
CREATE TABLE label_stocks (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
json TEXT NOT NULL,
|
|
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
|
|
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
|
|
);
|
|
CREATE TABLE label_templates (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
kind TEXT NOT NULL,
|
|
profile_id INTEGER REFERENCES station_profiles(id) ON DELETE SET NULL,
|
|
stock_id INTEGER REFERENCES label_stocks(id) ON DELETE SET NULL,
|
|
json TEXT NOT NULL,
|
|
is_default INTEGER NOT NULL DEFAULT 0,
|
|
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
|
|
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
|
|
);
|