on xenial help sign in
Buttons just pass their id up, not the whole data
a05f78eAlbert Astals
qml/Dash/Previews/PreviewActionButton.qml+2−2
@@ -18,7 +18,7 @@ import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19
19
20Button {
20Button {
21− signal triggeredAction(var data)
21+ signal triggeredAction(string id)
22
22
23 property var data: null
23 property var data: null
24 objectName: "button" + (data && data.id || "")
24 objectName: "button" + (data && data.id || "")
@@ -26,5 +26,5 @@ Button {
26 text: data && data.label || ""
26 text: data && data.label || ""
27 iconSource: data && data.icon || ""
27 iconSource: data && data.icon || ""
28 iconPosition: "left"
28 iconPosition: "left"
29− onClicked: triggeredAction(data)
29+ onClicked: triggeredAction(data.id)
30}
30}
qml/Dash/Previews/PreviewActionCombo.qml+2−2
@@ -23,7 +23,7 @@ Item {
23 width: childrenRect.width
23 width: childrenRect.width
24 height: childrenRect.height
24 height: childrenRect.height
25
25
26− signal triggeredAction(var data)
26+ signal triggeredAction(string id)
27
27
28 property alias model: actionRepeater.model
28 property alias model: actionRepeater.model
29
29
@@ -62,7 +62,7 @@ Item {
62 c.maxWidth = Math.max(c.maxWidth, implicitWidth);
62 c.maxWidth = Math.max(c.maxWidth, implicitWidth);
63 }
63 }
64 onClicked: {
64 onClicked: {
65− root.triggeredAction(modelData)
65+ root.triggeredAction(modelData.id)
66 }
66 }
67 }
67 }
68 }
68 }
qml/Dash/Previews/PreviewActions.qml+2−2
@@ -47,7 +47,7 @@ PreviewWidget {
47 Connections {
47 Connections {
48 target: loader.item
48 target: loader.item
49 onTriggeredAction: {
49 onTriggeredAction: {
50− root.triggered(root.widgetId, data.id, data);
50+ root.triggered(root.widgetId, id, null);
51 }
51 }
52 }
52 }
53 }
53 }
@@ -55,7 +55,7 @@ PreviewWidget {
55 PreviewActionButton {
55 PreviewActionButton {
56 data: visible ? actions[0] : null
56 data: visible ? actions[0] : null
57 visible: actions && actions.length > 0
57 visible: actions && actions.length > 0
58− onTriggeredAction: root.triggered(root.widgetId, data.id, data);
58+ onTriggeredAction: root.triggered(root.widgetId, id, null);
59 }
59 }
60
60
61 }
61 }
tests/qmltests/Dash/Previews/tst_PreviewActions.qml+9−10
@@ -79,7 +79,7 @@ Rectangle {
79 name: "PreviewActionTest"
79 name: "PreviewActionTest"
80 when: windowShown
80 when: windowShown
81
81
82− function checkButtonPressSignal(target, id, buttonNumber)
82+ function checkButtonPressSignal(target, id)
83 {
83 {
84 var button = findChild(root, "button" + id);
84 var button = findChild(root, "button" + id);
85 verify(button != null);
85 verify(button != null);
@@ -89,15 +89,14 @@ Rectangle {
89 compare(spy.count, 1);
89 compare(spy.count, 1);
90 compare(spy.signalArguments[0][0], target.widgetId);
90 compare(spy.signalArguments[0][0], target.widgetId);
91 compare(spy.signalArguments[0][1], id);
91 compare(spy.signalArguments[0][1], id);
92− compare(spy.signalArguments[0][2], target.widgetData["actions"][buttonNumber]);
93 }
92 }
94
93
95 function test_checkButtons_data() {
94 function test_checkButtons_data() {
96 return [
95 return [
97− {tag: "oneActionButton", target: oneAction, id: "someid", buttonNumber: 0 },
96+ {tag: "oneActionButton", target: oneAction, id: "someid" },
98− {tag: "twobuttonsButton0", target: twoActions, id: "someid1", buttonNumber: 0 },
97+ {tag: "twobuttonsButton0", target: twoActions, id: "someid1" },
99− {tag: "twobuttonsButton1", target: twoActions, id: "someid2", buttonNumber: 1 },
98+ {tag: "twobuttonsButton1", target: twoActions, id: "someid2" },
100− {tag: "buttonAndComboButton0", target: buttonAndCombo, id: "someid3", buttonNumber: 0 }
99+ {tag: "buttonAndComboButton0", target: buttonAndCombo, id: "someid3" }
101 ]
100 ]
102 }
101 }
103
102
@@ -107,10 +106,10 @@ Rectangle {
107
106
108 function test_comboButton_data() {
107 function test_comboButton_data() {
109 return [
108 return [
110− {tag: "button1", id: "someid4", buttonNumber: 1 },
109+ {tag: "button1", id: "someid4" },
111− {tag: "button2", id: "someid5", buttonNumber: 2 },
110+ {tag: "button2", id: "someid5" },
112− {tag: "button3", id: "someid6", buttonNumber: 3 },
111+ {tag: "button3", id: "someid6" },
113− {tag: "button4", id: "someid7", buttonNumber: 4 }
112+ {tag: "button4", id: "someid7" }
114 ]
113 ]
115 }
114 }
116
115