aboutsummaryrefslogtreecommitdiff
path: root/qml/pages/TemperatureModel.qml
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2013-12-04 21:48:18 +0200
committerOskari Timperi <oskari.timperi@iki.fi>2013-12-04 21:48:18 +0200
commitae134f41ada5c1bd3455d3d9cd76cb01b6471a01 (patch)
treef04e8c85e0270294e56e9f5033bd7e2c619ad33e /qml/pages/TemperatureModel.qml
downloadunitmaster-ae134f41ada5c1bd3455d3d9cd76cb01b6471a01.tar.gz
unitmaster-ae134f41ada5c1bd3455d3d9cd76cb01b6471a01.zip
initial commit
Diffstat (limited to 'qml/pages/TemperatureModel.qml')
-rw-r--r--qml/pages/TemperatureModel.qml43
1 files changed, 43 insertions, 0 deletions
diff --git a/qml/pages/TemperatureModel.qml b/qml/pages/TemperatureModel.qml
new file mode 100644
index 0000000..74fc7d2
--- /dev/null
+++ b/qml/pages/TemperatureModel.qml
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+
+ListModel {
+ function from(title, value) {
+ var functions = {
+ "kelvin": function () { return value; },
+ "celcius": function () { return value + 273.15; },
+ "fahrenheit": function () { return (value + 459.67) * 5.0 / 9.0; },
+ "rankine": function () { return value * 5.0 / 9.0; }
+ };
+ return functions[title]();
+ }
+
+ function to(title, value) {
+ var functions = {
+ "kelvin": function () { return value; },
+ "celcius": function () { return value - 273.15; },
+ "fahrenheit": function () { return value * 9.0 / 5.0 - 459.67; },
+ "rankine": function () { return value * 9.0 / 5.0; }
+ };
+ return functions[title]();
+ }
+
+ ListElement {
+ title: "kelvin"
+ abbr: "K"
+ }
+
+ ListElement {
+ title: "celcius"
+ abbr: "°C"
+ }
+
+ ListElement {
+ title: "fahrenheit"
+ abbr: "F"
+ }
+
+ ListElement {
+ title: "rankine"
+ abbr: "°R"
+ }
+}