diff options
author | Caroline Chao <caroline.chao@digia.com> | 2014-05-10 12:23:45 +0200 |
---|---|---|
committer | Caroline Chao <caroline.chao@digia.com> | 2014-05-12 09:31:50 +0200 |
commit | 1abd2c072b91482ffddeaccb421bc997c26d3c77 (patch) | |
tree | f674fa4a6390f0855db121ee513a848325efc3dc /qml/pages/OneDayZoomItem.qml | |
parent | 11cb0682d0f1dc8434b5711dea6ec174f69095dc (diff) |
Review the temperature label preferredWidth calculation in zoom item
It is now more generic and can adapt to different localizations
and temperature units if needed.
Change-Id: I8b756cd117e5be8bfbf3cc538c62542a5c9e371c
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'qml/pages/OneDayZoomItem.qml')
-rw-r--r-- | qml/pages/OneDayZoomItem.qml | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/qml/pages/OneDayZoomItem.qml b/qml/pages/OneDayZoomItem.qml index ffe3363..294bc75 100644 --- a/qml/pages/OneDayZoomItem.qml +++ b/qml/pages/OneDayZoomItem.qml @@ -125,14 +125,23 @@ GridLayout { Layout.alignment: Qt.AlignCenter } TouchLabel { - Layout.preferredWidth: expectedTextWidth(Utils.getTempFormat(Utils.getMaxTempLenght(ApplicationInfo.currentCityModel))) - + 4 * ApplicationInfo.ratio + id: tempLabel property int temp: Utils.getTemperature(root.sliderValue, root.model) text : Utils.getTempFormat(temp) color: temp < 0 ? ApplicationInfo.colors.blue : ApplicationInfo.colors.doubleDarkGray pixelSize: 72 letterSpacing: -0.5 Layout.alignment: Qt.AlignLeft + function getLongestTempWidth() { + var itemsInDay = root.model.periodCount() + var longestTempWidth = 0 + for (var indexInDay = 0; indexInDay < itemsInDay; indexInDay++) { + var tempTemperature = Utils.getTemperature(indexInDay, root.model) + longestTempWidth = Math.max(longestTempWidth, tempLabel.expectedTextWidth(Utils.getTempFormat(tempTemperature))) + } + return longestTempWidth + } + Component.onCompleted: Layout.preferredWidth = getLongestTempWidth() + 4 * ApplicationInfo.ratio } RowLayout { Layout.columnSpan: 2 |