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