Skip to content

Commit

Permalink
Scroll bar when content height is > height.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenD98 committed Sep 3, 2024
1 parent 5a83f47 commit 5ee1832
Showing 1 changed file with 54 additions and 43 deletions.
97 changes: 54 additions & 43 deletions src/qml/PositioningInformationView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,74 @@ Rectangle {
property color textColor: positionSource.currentness ? Theme.mainTextColor : Theme.secondaryTextColor
property double cellHeight: 26
property double cellPadding: 6
property real contentHeight: grid.count / grid.numberOfColumns * cellHeight
property real contentHeight: grid.numberOfRows * cellHeight

color: Theme.mainBackgroundColorSemiOpaque
anchors.margins: 20
width: parent.width
clip: true

GridView {
id: grid

readonly property real numberOfColumns: parent.width > 1000 ? 6 : parent.width > 620 ? 3 : 2

flow: GridView.FlowTopToBottom
model: PositioningInformationModel {
id: positioningInformationModel
distanceUnits: projectInfo.distanceUnits
coordinateDisplayCrs: projectInfo.coordinateDisplayCrs
}
anchors.fill: parent
cellHeight: positioningInformationView.cellHeight
cellWidth: parent.width / numberOfColumns
clip: true
Flickable {
width: parent.width
height: positioningInformationView.height
contentHeight: grid.height
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: QfScrollBar {
}
delegate: Rectangle {
readonly property real currentColumn: parseInt(index / (grid.count / grid.numberOfColumns))
readonly property real currentRow: index % (grid.count / grid.numberOfColumns)

width: grid.cellWidth
height: grid.cellHeight
color: {
if (currentColumn % 2 == 0) {
return currentRow % 2 == 0 ? alternateBackgroundColor : backgroundColor;
} else {
return currentRow % 2 == 0 ? backgroundColor : alternateBackgroundColor;
}
GridView {
id: grid

readonly property real numberOfColumns: parent.width > 1000 ? 6 : parent.width > 620 ? 3 : 2
readonly property real numberOfRows: grid.count / numberOfColumns

flow: GridView.FlowTopToBottom
boundsBehavior: Flickable.StopAtBounds
model: PositioningInformationModel {
id: positioningInformationModel
distanceUnits: projectInfo.distanceUnits
coordinateDisplayCrs: projectInfo.coordinateDisplayCrs
}
height: numberOfRows * cellHeight
width: parent.width
cellHeight: positioningInformationView.cellHeight
cellWidth: parent.width / numberOfColumns
clip: true

RowLayout {
anchors.margins: cellPadding
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
delegate: Rectangle {
readonly property real currentColumn: parseInt(index / (grid.count / grid.numberOfColumns))
readonly property real currentRow: index % (grid.count / grid.numberOfColumns)

Text {
font: Theme.tipFont
color: Theme.secondaryTextColor
text: Name
width: grid.cellWidth
height: grid.cellHeight
color: {
if (currentColumn % 2 == 0) {
return currentRow % 2 == 0 ? alternateBackgroundColor : backgroundColor;
} else {
return currentRow % 2 == 0 ? backgroundColor : alternateBackgroundColor;
}
}

Text {
Layout.fillWidth: true
font: Theme.tipFont
color: positioningInformationView.textColor
text: Value ? Value : qsTr("N/A")
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
RowLayout {
anchors.margins: cellPadding
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right

Text {
font: Theme.tipFont
color: Theme.secondaryTextColor
text: Name
}

Text {
Layout.fillWidth: true
font: Theme.tipFont
color: positioningInformationView.textColor
text: Value ? Value : qsTr("N/A")
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
}
}
Expand Down

0 comments on commit 5ee1832

Please sign in to comment.