import QtQuick Item { property bool privateMode: false property int copyCount: 0 property int pinCount: 0 property int pasteCount: 0 property int deleteCount: 0 property int externalUpdates: 0 property var rows: [ { "id": "clip-needle", "title": "needle document", "kind": "text", "age": "now", "icon": "", "pinned": false, "isImage": false, "swatch": "" }, { "id": "clip-other", "title": "other document", "kind": "text", "age": "1m", "icon": "", "pinned": false, "isImage": false, "swatch": "" } ] function filtered(query) { const needle = String(query || "").toLowerCase(); return rows.filter(row => needle.length === 0 || String(row.title).toLowerCase().indexOf(needle) >= 0); } function stateObject(query) { return { "privateMode": privateMode, "rows": filtered(query), "lastAction": {} }; } function stateJson() { return JSON.stringify(stateObject("")); } function search(query) { return JSON.stringify(stateObject(String(query || ""))); } function copy(id) { copyCount++; return stateJson(); } function paste(id) { pasteCount++; return stateJson(); } function togglePin(id) { const wanted = String(id); rows = rows.map(row => row.id === wanted ? Object.assign({}, row, { "pinned": !row.pinned }) : row); pinCount++; return stateJson(); } function deleteRow(id) { const wanted = String(id); rows = rows.filter(row => row.id !== wanted); deleteCount++; return stateJson(); } function setPrivateMode(enabled) { privateMode = !!enabled; return stateJson(); } function externalUpdate() { externalUpdates++; rows = rows.concat([ { "id": `clip-external-${externalUpdates}`, "title": "needle external update", "kind": "text", "age": "now", "icon": "", "pinned": false, "isImage": false, "swatch": "" } ]); } }