on xenial help sign in
Different way of top aligning labels when the other one in the row is multiline

And better wrapping Unfortunately this seems to fail with Qt 5.4.2 and Qt 5.5 alpha but at least it fixes the immediate problem for Vivid Fixes: #1442085 Approved by: Andrea Cimitan

commitfadec19f244e0f37404a30fe9bbc685c61cdc79d authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 22 Apr 2015, 14:45 (11 years ago) parent551a103353f874
2 files changed+17−7
qml/Dash/Previews/PreviewTable.qml+2−3 tests/qmltests/Dash/Previews/tst_PreviewTable.qml+15−4
qml/Dash/Previews/PreviewTable.qml+2−3
@@ -74,9 +74,8 @@ PreviewWidget {
7474 visible: root.expanded || rowIndex < maximumCollapsedRowCount
7575 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
7676 font.bold: index == 0
77− verticalAlignment: Text.AlignTop
78− wrapMode: Text.WordWrap
79− Layout.fillHeight: true
77+ wrapMode: Text.Wrap
78+ Layout.alignment: Qt.AlignTop
8079 Layout.maximumWidth: column.width - x
8180 }
8281 }
tests/qmltests/Dash/Previews/tst_PreviewTable.qml+15−4
@@ -28,24 +28,27 @@ Rectangle {
2828
2929 property var widgetDataComplete: {
3030 "title": "Title here longa long long long long long long long long long long",
31− "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
31+ "values": [ [ "Long Label 1", "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
3232 }
3333
3434 property var widgetDataNoTitle: {
35− "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
35+ "values": [ [ "Long Label 1", "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
3636 }
3737
3838 PreviewWidgetFactory {
3939 id: previewTable
4040 anchors { left: parent.left; right: parent.right }
4141 widgetType: "table"
42− widgetData: widgetDataComplete
4342
4443 Rectangle {
4544 color: "red"
4645 anchors.fill: parent
4746 opacity: 0.5
4847 }
48+
49+ Component.onCompleted: {
50+ previewTable.widgetData = widgetDataComplete
51+ }
4952 }
5053
5154 UT.UnityTestCase {
@@ -56,9 +59,17 @@ Rectangle {
5659 previewTable.widgetData = widgetDataComplete;
5760 }
5861
62+ function test_label_heights() {
63+ verify(findChild(previewTable, "label00").height == findChild(previewTable, "label10").height);
64+ verify(findChild(previewTable, "label01").height == findChild(previewTable, "label11").height);
65+ verify(findChild(previewTable, "label01").height > findChild(previewTable, "label00").height * 3);
66+ verify(findChild(previewTable, "label00").height == findChild(previewTable, "label20").height);
67+ verify(findChild(previewTable, "label20").height == findChild(previewTable, "label21").height);
68+ }
69+
5970 function test_values() {
6071 compare(findChild(previewTable, "label00").text, "Long Label 1");
61− compare(findChild(previewTable, "label01").text, "Value 1");
72+ compare(findChild(previewTable, "label01").text, "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2");
6273 compare(findChild(previewTable, "label10").text, "Label 2");
6374 compare(findChild(previewTable, "label11").text, "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2");
6475 compare(findChild(previewTable, "label20").text, "Label 3");