Commit 9333cb26 authored by Volker Krause's avatar Volker Krause
Browse files

Adapt opening hours interval view column headers to the available space

parent c7f5c0aa
...@@ -105,6 +105,10 @@ Column { ...@@ -105,6 +105,10 @@ Column {
endDate: new Date(intervalModel.beginDate.getTime() + 7 * 24 * 3600 * 1000) endDate: new Date(intervalModel.beginDate.getTime() + 7 * 24 * 3600 * 1000)
} }
FontMetrics {
id: fm
}
ListView { ListView {
id: intervalView id: intervalView
width: parent.width width: parent.width
...@@ -118,13 +122,14 @@ Column { ...@@ -118,13 +122,14 @@ Column {
clip: true clip: true
header: Row { header: Row {
id: intervalHeader id: intervalHeader
property int itemWidth: (intervalHeader.ListView.view.width - intervalHeader.ListView.view.labelWidth - Kirigami.Units.smallSpacing) / 8 property int colCount: (intervalView.width - Kirigami.Units.smallSpacing - intervalView.labelWidth) / fm.advanceWidth(intervalModel.formatTimeColumnHeader(12, 59)) < 8 ? 4 : 8
property int itemWidth: (intervalHeader.ListView.view.width - intervalHeader.ListView.view.labelWidth - Kirigami.Units.smallSpacing) / colCount
x: intervalHeader.ListView.view.labelWidth + Kirigami.Units.smallSpacing + intervalHeader.itemWidth/2 x: intervalHeader.ListView.view.labelWidth + Kirigami.Units.smallSpacing + intervalHeader.itemWidth/2
Repeater { Repeater {
// TODO we might need to use less when space constrained horizontally // TODO we might need to use less when space constrained horizontally
model: [3, 6, 9, 12, 15, 18, 21] model: colCount - 1
QQC2.Label { QQC2.Label {
text: intervalModel.formatTimeColumnHeader(modelData, 0) text: intervalModel.formatTimeColumnHeader((modelData + 1) * 24/colCount, 0)
width: intervalHeader.itemWidth width: intervalHeader.itemWidth
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment