Loading editor/qml/SurveyEditorDialog.qml +155 −16 Changes for editor/qml/SurveyEditorDialog.qml: 155 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -156,11 +156,45 @@ Window { width: 280 height: Math.max(400, (questionModel.count + 3) * 90 + 40) /* Build a map of qId→index and collect all excludes info */ function buildExcludesMap() { var idToIdx = {} var excludedBySelected = {} /* qId → true if excluded by currently selected question */ var allExcludes = [] /* {fromIdx, toIdx, color, optLabel} */ for (var i = 0; i < questionModel.count; i++) { idToIdx[questionModel.get(i).qId] = i } for (var qi = 0; qi < questionModel.count; qi++) { var q = questionModel.get(qi) var opts = [] try { opts = JSON.parse(q.qOptionsJson) } catch(e) {} var tc = editorWin.typeColors[q.qType] || "#888" for (var oi = 0; oi < opts.length; oi++) { var ex = opts[oi].excludes || "" if (ex === "") continue var targets = ex.split(",") for (var ti = 0; ti < targets.length; ti++) { var tid = targets[ti].trim() if (tid === "") continue var toIdx = idToIdx[tid] if (toIdx !== undefined) { allExcludes.push({ fromIdx: qi, toIdx: toIdx, color: tc, optLabel: opts[oi].label || opts[oi].value || "" }) if (questionListView.currentIndex === qi) excludedBySelected[tid] = true } } } } return { idToIdx: idToIdx, excludedBySelected: excludedBySelected, allExcludes: allExcludes } } onPaint: { var ctx = getContext("2d") ctx.reset() ctx.clearRect(0, 0, width, height) var exMap = buildExcludesMap() var cx = width / 2 var nodeW = 220 var nodeH = 52 Loading @@ -168,21 +202,25 @@ Window { var y = 20 var x = cx - nodeW / 2 /* Store Y positions for branch drawing */ var nodeYPositions = [] drawNode(ctx, x, y, nodeW, nodeH, "#0f3460", "#e0e0e0", "Start Survey", titleField.text || "Untitled", "#4A90D9") titleField.text || "Untitled", "#4A90D9", 1.0) y += nodeH drawArrow(ctx, cx, y, cx, y + gap, "#4A90D9") y += gap drawNode(ctx, x, y, nodeW, nodeH, "#1a1a40", "#e0e0e0", "Participant", "Name, Email, Company", "#27AE60") "Name, Email, Company", "#27AE60", 1.0) y += nodeH drawArrow(ctx, cx, y, cx, y + gap, "#27AE60") y += gap for (var i = 0; i < questionModel.count; i++) { nodeYPositions.push(y) var q = questionModel.get(i) var tc = editorWin.typeColors[q.qType] || "#888" var icon = editorWin.typeIcons[q.qType] || "?" Loading @@ -202,12 +240,15 @@ Window { } var isSelected = (questionListView.currentIndex === i) var bgColor = isSelected ? "#2a2a5e" : "#1a1a40" var isExcluded = exMap.excludedBySelected[q.qId] === true var bgColor = isSelected ? "#2a2a5e" : (isExcluded ? "#1a0a0a" : "#1a1a40") var nodeAlpha = isExcluded ? 0.4 : 1.0 drawNode(ctx, x, y, nodeW, nodeH, bgColor, "#e0e0e0", label, detail, tc) "#e0e0e0", label, detail, tc, nodeAlpha) if (isSelected) { ctx.globalAlpha = 1.0 ctx.strokeStyle = tc ctx.lineWidth = 2 ctx.setLineDash([]) Loading @@ -215,17 +256,36 @@ Window { ctx.stroke() } /* Show excludes badge with count */ if (hasBranch) { var excludeCount = 0 for (var oi2 = 0; oi2 < opts.length; oi2++) { if (opts[oi2].excludes && opts[oi2].excludes !== "") excludeCount++ } ctx.globalAlpha = 1.0 ctx.fillStyle = "#F39C12" ctx.font = "9px sans-serif" ctx.font = "bold 9px sans-serif" ctx.textAlign = "right" ctx.fillText("branches", x + nodeW - 6, y + nodeH - 5) ctx.fillText("\u2937 " + excludeCount + " branch" + (excludeCount > 1 ? "es" : ""), x + nodeW - 6, y + nodeH - 5) } /* Show skip marker on excluded nodes */ if (isExcluded) { ctx.globalAlpha = 0.8 ctx.fillStyle = "#E74C3C" ctx.font = "bold 9px sans-serif" ctx.textAlign = "left" ctx.fillText("SKIP", x + 8, y + nodeH - 5) ctx.globalAlpha = 1.0 } y += nodeH if (i < questionModel.count - 1) { if (hasBranch) drawDashedArrow(ctx, cx, y, cx, y + gap, tc) else if (isExcluded) drawDashedArrow(ctx, cx, y, cx, y + gap, "#555") else drawArrow(ctx, cx, y, cx, y + gap, tc) } Loading @@ -237,10 +297,57 @@ Window { drawNode(ctx, x, y, nodeW, nodeH, "#0f3460", "#e0e0e0", "Submit", "Save & send results", "#27AE60") "Save & send results", "#27AE60", 1.0) /* Draw branch lines on the right side */ for (var bi = 0; bi < exMap.allExcludes.length; bi++) { var br = exMap.allExcludes[bi] var fromSelected = (questionListView.currentIndex === br.fromIdx) if (!fromSelected) continue var fromY = nodeYPositions[br.fromIdx] + nodeH / 2 var toY = nodeYPositions[br.toIdx] + nodeH / 2 var branchX = x + nodeW + 8 var branchXEnd = branchX + 14 + (bi % 3) * 6 ctx.strokeStyle = "#E74C3C" ctx.lineWidth = 1.5 ctx.setLineDash([3, 3]) ctx.globalAlpha = 0.7 ctx.beginPath() ctx.moveTo(x + nodeW, fromY) ctx.lineTo(branchXEnd, fromY) ctx.lineTo(branchXEnd, toY) ctx.lineTo(x + nodeW, toY) ctx.stroke() ctx.setLineDash([]) /* Arrow head pointing to excluded node */ ctx.fillStyle = "#E74C3C" ctx.beginPath() ctx.moveTo(x + nodeW + 6, toY - 4) ctx.lineTo(x + nodeW, toY) ctx.lineTo(x + nodeW + 6, toY + 4) ctx.closePath() ctx.fill() /* Label on branch line */ ctx.fillStyle = "#E74C3C" ctx.font = "8px sans-serif" ctx.textAlign = "left" var brLabel = br.optLabel if (brLabel.length > 8) brLabel = brLabel.substring(0, 8) + ".." ctx.save() ctx.translate(branchXEnd + 3, (fromY + toY) / 2) ctx.rotate(-Math.PI / 2) ctx.fillText(brLabel, 0, 0) ctx.restore() ctx.globalAlpha = 1.0 } } function drawNode(ctx, x, y, w, h, bg, fg, line1, line2, accent) { function drawNode(ctx, x, y, w, h, bg, fg, line1, line2, accent, alpha) { ctx.globalAlpha = alpha || 1.0 ctx.fillStyle = "rgba(0,0,0,0.3)" roundRect(ctx, x + 2, y + 2, w, h, 6) ctx.fill() Loading @@ -252,10 +359,10 @@ Window { ctx.fill() ctx.strokeStyle = accent ctx.lineWidth = 1 ctx.globalAlpha = 0.4 ctx.globalAlpha = 0.4 * (alpha || 1.0) roundRect(ctx, x, y, w, h, 6) ctx.stroke() ctx.globalAlpha = 1.0 ctx.globalAlpha = alpha || 1.0 ctx.fillStyle = fg ctx.font = "bold 11px sans-serif" ctx.textAlign = "left" Loading @@ -263,6 +370,7 @@ Window { ctx.fillStyle = "#999" ctx.font = "10px sans-serif" ctx.fillText(line2, x + 12, y + 38) ctx.globalAlpha = 1.0 } function drawArrow(ctx, x1, y1, x2, y2, color) { Loading Loading @@ -614,12 +722,43 @@ Window { onClicked: openMediaBrowser(index) } TextField { Layout.preferredWidth: 80 text: model.optExcludes; placeholderText: "excludes" font.pixelSize: 10; color: Theme.textMuted background: Rectangle { implicitHeight: 26; color: Theme.bgTertiary; border.color: Theme.border; radius: 2 } onTextChanged: { optionsModel.set(index, { optValue: model.optValue, optLabel: model.optLabel, optExcludes: text, optIcon: model.optIcon }); saveOptionsToQuestion() } /* Excludes: question picker */ RowLayout { Layout.preferredWidth: 160 spacing: 2 ComboBox { id: excludesCombo Layout.fillWidth: true font.pixelSize: 10 model: { var items = [{"text": qsTr("— no skip —"), "qId": ""}] for (var qi = 0; qi < questionModel.count; qi++) { if (qi === editingIndex) continue var qq = questionModel.get(qi) var lbl = "Q" + (qi + 1) + ": " + (qq.qText || qq.qType) if (lbl.length > 22) lbl = lbl.substring(0, 22) + ".." items.push({"text": lbl, "qId": qq.qId}) } return items } textRole: "text" currentIndex: { var ex = optionsModel.get(index) ? optionsModel.get(index).optExcludes : "" if (ex === "") return 0 for (var ci = 0; ci < model.length; ci++) { if (model[ci].qId === ex) return ci } return 0 } onActivated: function(ci) { var newExclude = model[ci].qId optionsModel.set(index, { optValue: optionsModel.get(index).optValue, optLabel: optionsModel.get(index).optLabel, optExcludes: newExclude, optIcon: optionsModel.get(index).optIcon }) saveOptionsToQuestion() } ToolTip.visible: hovered ToolTip.text: qsTr("Skip question when this option is selected") } } Button { Loading Loading
editor/qml/SurveyEditorDialog.qml +155 −16 Changes for editor/qml/SurveyEditorDialog.qml: 155 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -156,11 +156,45 @@ Window { width: 280 height: Math.max(400, (questionModel.count + 3) * 90 + 40) /* Build a map of qId→index and collect all excludes info */ function buildExcludesMap() { var idToIdx = {} var excludedBySelected = {} /* qId → true if excluded by currently selected question */ var allExcludes = [] /* {fromIdx, toIdx, color, optLabel} */ for (var i = 0; i < questionModel.count; i++) { idToIdx[questionModel.get(i).qId] = i } for (var qi = 0; qi < questionModel.count; qi++) { var q = questionModel.get(qi) var opts = [] try { opts = JSON.parse(q.qOptionsJson) } catch(e) {} var tc = editorWin.typeColors[q.qType] || "#888" for (var oi = 0; oi < opts.length; oi++) { var ex = opts[oi].excludes || "" if (ex === "") continue var targets = ex.split(",") for (var ti = 0; ti < targets.length; ti++) { var tid = targets[ti].trim() if (tid === "") continue var toIdx = idToIdx[tid] if (toIdx !== undefined) { allExcludes.push({ fromIdx: qi, toIdx: toIdx, color: tc, optLabel: opts[oi].label || opts[oi].value || "" }) if (questionListView.currentIndex === qi) excludedBySelected[tid] = true } } } } return { idToIdx: idToIdx, excludedBySelected: excludedBySelected, allExcludes: allExcludes } } onPaint: { var ctx = getContext("2d") ctx.reset() ctx.clearRect(0, 0, width, height) var exMap = buildExcludesMap() var cx = width / 2 var nodeW = 220 var nodeH = 52 Loading @@ -168,21 +202,25 @@ Window { var y = 20 var x = cx - nodeW / 2 /* Store Y positions for branch drawing */ var nodeYPositions = [] drawNode(ctx, x, y, nodeW, nodeH, "#0f3460", "#e0e0e0", "Start Survey", titleField.text || "Untitled", "#4A90D9") titleField.text || "Untitled", "#4A90D9", 1.0) y += nodeH drawArrow(ctx, cx, y, cx, y + gap, "#4A90D9") y += gap drawNode(ctx, x, y, nodeW, nodeH, "#1a1a40", "#e0e0e0", "Participant", "Name, Email, Company", "#27AE60") "Name, Email, Company", "#27AE60", 1.0) y += nodeH drawArrow(ctx, cx, y, cx, y + gap, "#27AE60") y += gap for (var i = 0; i < questionModel.count; i++) { nodeYPositions.push(y) var q = questionModel.get(i) var tc = editorWin.typeColors[q.qType] || "#888" var icon = editorWin.typeIcons[q.qType] || "?" Loading @@ -202,12 +240,15 @@ Window { } var isSelected = (questionListView.currentIndex === i) var bgColor = isSelected ? "#2a2a5e" : "#1a1a40" var isExcluded = exMap.excludedBySelected[q.qId] === true var bgColor = isSelected ? "#2a2a5e" : (isExcluded ? "#1a0a0a" : "#1a1a40") var nodeAlpha = isExcluded ? 0.4 : 1.0 drawNode(ctx, x, y, nodeW, nodeH, bgColor, "#e0e0e0", label, detail, tc) "#e0e0e0", label, detail, tc, nodeAlpha) if (isSelected) { ctx.globalAlpha = 1.0 ctx.strokeStyle = tc ctx.lineWidth = 2 ctx.setLineDash([]) Loading @@ -215,17 +256,36 @@ Window { ctx.stroke() } /* Show excludes badge with count */ if (hasBranch) { var excludeCount = 0 for (var oi2 = 0; oi2 < opts.length; oi2++) { if (opts[oi2].excludes && opts[oi2].excludes !== "") excludeCount++ } ctx.globalAlpha = 1.0 ctx.fillStyle = "#F39C12" ctx.font = "9px sans-serif" ctx.font = "bold 9px sans-serif" ctx.textAlign = "right" ctx.fillText("branches", x + nodeW - 6, y + nodeH - 5) ctx.fillText("\u2937 " + excludeCount + " branch" + (excludeCount > 1 ? "es" : ""), x + nodeW - 6, y + nodeH - 5) } /* Show skip marker on excluded nodes */ if (isExcluded) { ctx.globalAlpha = 0.8 ctx.fillStyle = "#E74C3C" ctx.font = "bold 9px sans-serif" ctx.textAlign = "left" ctx.fillText("SKIP", x + 8, y + nodeH - 5) ctx.globalAlpha = 1.0 } y += nodeH if (i < questionModel.count - 1) { if (hasBranch) drawDashedArrow(ctx, cx, y, cx, y + gap, tc) else if (isExcluded) drawDashedArrow(ctx, cx, y, cx, y + gap, "#555") else drawArrow(ctx, cx, y, cx, y + gap, tc) } Loading @@ -237,10 +297,57 @@ Window { drawNode(ctx, x, y, nodeW, nodeH, "#0f3460", "#e0e0e0", "Submit", "Save & send results", "#27AE60") "Save & send results", "#27AE60", 1.0) /* Draw branch lines on the right side */ for (var bi = 0; bi < exMap.allExcludes.length; bi++) { var br = exMap.allExcludes[bi] var fromSelected = (questionListView.currentIndex === br.fromIdx) if (!fromSelected) continue var fromY = nodeYPositions[br.fromIdx] + nodeH / 2 var toY = nodeYPositions[br.toIdx] + nodeH / 2 var branchX = x + nodeW + 8 var branchXEnd = branchX + 14 + (bi % 3) * 6 ctx.strokeStyle = "#E74C3C" ctx.lineWidth = 1.5 ctx.setLineDash([3, 3]) ctx.globalAlpha = 0.7 ctx.beginPath() ctx.moveTo(x + nodeW, fromY) ctx.lineTo(branchXEnd, fromY) ctx.lineTo(branchXEnd, toY) ctx.lineTo(x + nodeW, toY) ctx.stroke() ctx.setLineDash([]) /* Arrow head pointing to excluded node */ ctx.fillStyle = "#E74C3C" ctx.beginPath() ctx.moveTo(x + nodeW + 6, toY - 4) ctx.lineTo(x + nodeW, toY) ctx.lineTo(x + nodeW + 6, toY + 4) ctx.closePath() ctx.fill() /* Label on branch line */ ctx.fillStyle = "#E74C3C" ctx.font = "8px sans-serif" ctx.textAlign = "left" var brLabel = br.optLabel if (brLabel.length > 8) brLabel = brLabel.substring(0, 8) + ".." ctx.save() ctx.translate(branchXEnd + 3, (fromY + toY) / 2) ctx.rotate(-Math.PI / 2) ctx.fillText(brLabel, 0, 0) ctx.restore() ctx.globalAlpha = 1.0 } } function drawNode(ctx, x, y, w, h, bg, fg, line1, line2, accent) { function drawNode(ctx, x, y, w, h, bg, fg, line1, line2, accent, alpha) { ctx.globalAlpha = alpha || 1.0 ctx.fillStyle = "rgba(0,0,0,0.3)" roundRect(ctx, x + 2, y + 2, w, h, 6) ctx.fill() Loading @@ -252,10 +359,10 @@ Window { ctx.fill() ctx.strokeStyle = accent ctx.lineWidth = 1 ctx.globalAlpha = 0.4 ctx.globalAlpha = 0.4 * (alpha || 1.0) roundRect(ctx, x, y, w, h, 6) ctx.stroke() ctx.globalAlpha = 1.0 ctx.globalAlpha = alpha || 1.0 ctx.fillStyle = fg ctx.font = "bold 11px sans-serif" ctx.textAlign = "left" Loading @@ -263,6 +370,7 @@ Window { ctx.fillStyle = "#999" ctx.font = "10px sans-serif" ctx.fillText(line2, x + 12, y + 38) ctx.globalAlpha = 1.0 } function drawArrow(ctx, x1, y1, x2, y2, color) { Loading Loading @@ -614,12 +722,43 @@ Window { onClicked: openMediaBrowser(index) } TextField { Layout.preferredWidth: 80 text: model.optExcludes; placeholderText: "excludes" font.pixelSize: 10; color: Theme.textMuted background: Rectangle { implicitHeight: 26; color: Theme.bgTertiary; border.color: Theme.border; radius: 2 } onTextChanged: { optionsModel.set(index, { optValue: model.optValue, optLabel: model.optLabel, optExcludes: text, optIcon: model.optIcon }); saveOptionsToQuestion() } /* Excludes: question picker */ RowLayout { Layout.preferredWidth: 160 spacing: 2 ComboBox { id: excludesCombo Layout.fillWidth: true font.pixelSize: 10 model: { var items = [{"text": qsTr("— no skip —"), "qId": ""}] for (var qi = 0; qi < questionModel.count; qi++) { if (qi === editingIndex) continue var qq = questionModel.get(qi) var lbl = "Q" + (qi + 1) + ": " + (qq.qText || qq.qType) if (lbl.length > 22) lbl = lbl.substring(0, 22) + ".." items.push({"text": lbl, "qId": qq.qId}) } return items } textRole: "text" currentIndex: { var ex = optionsModel.get(index) ? optionsModel.get(index).optExcludes : "" if (ex === "") return 0 for (var ci = 0; ci < model.length; ci++) { if (model[ci].qId === ex) return ci } return 0 } onActivated: function(ci) { var newExclude = model[ci].qId optionsModel.set(index, { optValue: optionsModel.get(index).optValue, optLabel: optionsModel.get(index).optLabel, optExcludes: newExclude, optIcon: optionsModel.get(index).optIcon }) saveOptionsToQuestion() } ToolTip.visible: hovered ToolTip.text: qsTr("Skip question when this option is selected") } } Button { Loading