on xenial help sign in
Buttons just pass their id up, not the whole data
commita05f78e2a03a8f7d929352a6370fc309371a5721 authorAlbert Astals <albert.astals@canonical.com> dateThu 6 Feb 2014, 16:03 (13 years ago) parent8e6a811
4 files changed+15−16
qml/Dash/Previews/PreviewActionButton.qml+2−2 qml/Dash/Previews/PreviewActionCombo.qml+2−2 qml/Dash/Previews/PreviewActions.qml+2−2 tests/qmltests/Dash/Previews/tst_PreviewActions.qml+9−10
qml/Dash/Previews/PreviewActionButton.qml+2−2
@@ -18,7 +18,7 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919
2020Button {
21− signal triggeredAction(var data)
21+ signal triggeredAction(string id)
2222
2323 property var data: null
2424 objectName: "button" + (data && data.id || "")
@@ -26,5 +26,5 @@ Button {
2626 text: data && data.label || ""
2727 iconSource: data && data.icon || ""
2828 iconPosition: "left"
29− onClicked: triggeredAction(data)
29+ onClicked: triggeredAction(data.id)
3030}
qml/Dash/Previews/PreviewActionCombo.qml+2−2
@@ -23,7 +23,7 @@ Item {
2323 width: childrenRect.width
2424 height: childrenRect.height
2525
26− signal triggeredAction(var data)
26+ signal triggeredAction(string id)
2727
2828 property alias model: actionRepeater.model
2929
@@ -62,7 +62,7 @@ Item {
6262 c.maxWidth = Math.max(c.maxWidth, implicitWidth);
6363 }
6464 onClicked: {
65− root.triggeredAction(modelData)
65+ root.triggeredAction(modelData.id)
6666 }
6767 }
6868 }
qml/Dash/Previews/PreviewActions.qml+2−2
@@ -47,7 +47,7 @@ PreviewWidget {
4747 Connections {
4848 target: loader.item
4949 onTriggeredAction: {
50− root.triggered(root.widgetId, data.id, data);
50+ root.triggered(root.widgetId, id, null);
5151 }
5252 }
5353 }
@@ -55,7 +55,7 @@ PreviewWidget {
5555 PreviewActionButton {
5656 data: visible ? actions[0] : null
5757 visible: actions && actions.length > 0
58− onTriggeredAction: root.triggered(root.widgetId, data.id, data);
58+ onTriggeredAction: root.triggered(root.widgetId, id, null);
5959 }
6060
6161 }
tests/qmltests/Dash/Previews/tst_PreviewActions.qml+9−10
@@ -79,7 +79,7 @@ Rectangle {
7979 name: "PreviewActionTest"
8080 when: windowShown
8181
82− function checkButtonPressSignal(target, id, buttonNumber)
82+ function checkButtonPressSignal(target, id)
8383 {
8484 var button = findChild(root, "button" + id);
8585 verify(button != null);
@@ -89,15 +89,14 @@ Rectangle {
8989 compare(spy.count, 1);
9090 compare(spy.signalArguments[0][0], target.widgetId);
9191 compare(spy.signalArguments[0][1], id);
92− compare(spy.signalArguments[0][2], target.widgetData["actions"][buttonNumber]);
9392 }
9493
9594 function test_checkButtons_data() {
9695 return [
97− {tag: "oneActionButton", target: oneAction, id: "someid", buttonNumber: 0 },
98− {tag: "twobuttonsButton0", target: twoActions, id: "someid1", buttonNumber: 0 },
99− {tag: "twobuttonsButton1", target: twoActions, id: "someid2", buttonNumber: 1 },
100− {tag: "buttonAndComboButton0", target: buttonAndCombo, id: "someid3", buttonNumber: 0 }
96+ {tag: "oneActionButton", target: oneAction, id: "someid" },
97+ {tag: "twobuttonsButton0", target: twoActions, id: "someid1" },
98+ {tag: "twobuttonsButton1", target: twoActions, id: "someid2" },
99+ {tag: "buttonAndComboButton0", target: buttonAndCombo, id: "someid3" }
101100 ]
102101 }
103102
@@ -107,10 +106,10 @@ Rectangle {
107106
108107 function test_comboButton_data() {
109108 return [
110− {tag: "button1", id: "someid4", buttonNumber: 1 },
111− {tag: "button2", id: "someid5", buttonNumber: 2 },
112− {tag: "button3", id: "someid6", buttonNumber: 3 },
113− {tag: "button4", id: "someid7", buttonNumber: 4 }
109+ {tag: "button1", id: "someid4" },
110+ {tag: "button2", id: "someid5" },
111+ {tag: "button3", id: "someid6" },
112+ {tag: "button4", id: "someid7" }
114113 ]
115114 }
116115