Make the last column take all the available size

The grid layout had each column fixed to a width
taken as a portion of the grid width, but since
the grid has a columnSpacing defined as well,
the computation doesn't add up, helping in causing
an infinite recursion problem in the attempt of
sizing and positioning all the children of the layout

[Dirk Hohndel: heavily modified, but the basic idea remains]

Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Marco Martin 2016-05-02 16:48:03 +02:00 committed by Dirk Hohndel
parent 304af311f0
commit 029b524f37

View file

@ -18,7 +18,7 @@ Item {
property real col4Width: gridWidth * 0.20
width: diveDetailsPage.width - diveDetailsPage.leftPadding - diveDetailsPage.rightPadding
height: mainLayout.implicitHeight + bottomLayout.implicitHeight + Kirigami.Units.iconSizes.large
height: mainLayout.implicitHeight + bottomLayout.implicitHeight + bottomLayout2.implicitHeight + Kirigami.Units.iconSizes.large
Rectangle {
z: 99
color: Kirigami.Theme.textColor
@ -145,15 +145,14 @@ Item {
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6
Layout.maximumWidth: detailsView.col1Width
Layout.preferredWidth: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
id: txtSuit
text: dive.suit
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col2Width
Layout.preferredWidth: detailsView.col2Width
Layout.fillWidth: true
}
Kirigami.Label {
@ -161,7 +160,7 @@ Item {
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6
Layout.maximumWidth: detailsView.col3Width
Layout.preferredWidth: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
@ -169,22 +168,21 @@ Item {
text: dive.airTemp
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width
Layout.preferredWidth: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
}
Kirigami.Label {
text: "Cylinder:"
opacity: 0.6
Layout.maximumWidth: detailsView.col1Width
Layout.preferredWidth: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
id: txtCylinder
text: dive.getCylinder
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col2Width
Layout.preferredWidth: detailsView.col2Width
Layout.fillWidth: true
}
Kirigami.Label {
@ -192,7 +190,7 @@ Item {
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6
Layout.maximumWidth: detailsView.col3Width
Layout.preferredWidth: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
@ -200,7 +198,7 @@ Item {
text: dive.waterTemp
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width
Layout.preferredWidth: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
}
Kirigami.Label {
@ -208,22 +206,21 @@ Item {
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6
Layout.maximumWidth: detailsView.col1Width
Layout.preferredWidth: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
id: txtDiveMaster
text: dive.divemaster
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col2Width
Layout.preferredWidth: detailsView.col2Width
Layout.fillWidth: true
}
Kirigami.Label {
text: "Weight:"
opacity: 0.6
Layout.maximumWidth: detailsView.col3Width
Layout.preferredWidth: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
@ -231,7 +228,7 @@ Item {
text: dive.sumWeight
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width
Layout.preferredWidth: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
}
}
// clearly, Qt 5.6.0 is buggy as having this as one GridLayout
@ -252,22 +249,21 @@ Item {
text: "Buddy:"
opacity: 0.6
Layout.maximumWidth: detailsView.col1Width
Layout.preferredWidth: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
id: txtBuddy
text: dive.buddy
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col2Width
Layout.preferredWidth: detailsView.col2Width
Layout.fillWidth: true
}
Kirigami.Label {
text: "SAC:"
opacity: 0.6
Layout.maximumWidth: detailsView.col3Width
Layout.preferredWidth: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
@ -275,7 +271,7 @@ Item {
text: dive.sac
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width
Layout.preferredWidth: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
}
Kirigami.Heading {
@ -292,7 +288,6 @@ Item {
focus: true
Layout.columnSpan: 4
Layout.fillWidth: true
Layout.fillHeight: true
//selectByMouse: true
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
}