diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2013-12-07 16:11:42 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2013-12-07 16:11:42 +0200 |
| commit | 06d81aa3629d7802b2ad510a80a39d1333fa9f94 (patch) | |
| tree | 0a8638214f90f51b4c967a201caf4331e639efe9 | |
| parent | 55d66c41944a0a7a5796eb9f1dc3d85c3f0348c0 (diff) | |
| download | unitmaster-06d81aa3629d7802b2ad510a80a39d1333fa9f94.tar.gz unitmaster-06d81aa3629d7802b2ad510a80a39d1333fa9f94.zip | |
add models for angle and pressure
| -rw-r--r-- | qml/pages/AngleModel.qml | 50 | ||||
| -rw-r--r-- | qml/pages/PressureModel.qml | 71 | ||||
| -rw-r--r-- | qml/pages/QuantityModel.qml | 10 |
3 files changed, 131 insertions, 0 deletions
diff --git a/qml/pages/AngleModel.qml b/qml/pages/AngleModel.qml new file mode 100644 index 0000000..a81adb4 --- /dev/null +++ b/qml/pages/AngleModel.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +ListModel { + function from(title, value) { + var functions = { + "radian": function () { return value; }, + "degree": function () { return value*Math.PI/180.0; }, + "gon": function () { return value*Math.PI/200.0; }, + "arcminute": function () { return value*Math.PI/10800; }, + "arcsecond": function () { return value*Math.PI/648000; } + }; + return functions[title](); + } + + function to(title, value) { + var functions = { + "radian": function () { return value; }, + "degree": function () { return value*180.0/Math.PI; }, + "gon": function () { return value*200.0/Math.PI; }, + "arcminute": function () { return value*10800/Math.PI; }, + "arcsecond": function () { return value*648000/Math.PI; } + }; + return functions[title](); + } + + ListElement { + title: "radian" + abbr: "rad" + } + + ListElement { + title: "degree" + abbr: "deg" + } + + ListElement { + title: "gon" + abbr: "" + } + + ListElement { + title: "arcminute" + abbr: "" + } + + ListElement { + title: "arcsecond" + abbr: "" + } +} diff --git a/qml/pages/PressureModel.qml b/qml/pages/PressureModel.qml new file mode 100644 index 0000000..2196f8a --- /dev/null +++ b/qml/pages/PressureModel.qml @@ -0,0 +1,71 @@ +import QtQuick 2.0 + +ListModel { + function from(title, value) { + var functions = { + "pascal": function () { return value; }, + "kilopascal": function () { return value*1000; }, + "bar": function () { return value*1e5; }, + "millibar": function () { return value*100.0; }, + "pounds per square inch": function () { return value*(6.8948e3); }, + "technical atmosphere": function () { return value*0.980665e5; }, + "standard atmosphere": function () { return value*1.01325e5; }, + "torr": function () { return value*133.3224; } + }; + return functions[title](); + } + + function to(title, value) { + var functions = { + "pascal": function () { return value; }, + "kilopascal": function () { return value/1000; }, + "bar": function () { return value/1e5; }, + "millibar": function () { return value/100.0; }, + "pounds per square inch": function () { return value/(6.8948e3); }, + "technical atmosphere": function () { return value/(0.980665e5); }, + "standard atmosphere": function () { return value/(1.01325e5); }, + "torr": function () { return value/133.3224; } + }; + return functions[title](); + } + + ListElement { + title: "pascal" + abbr: "Pa" + } + + ListElement { + title: "kilopascal" + abbr: "kPa" + } + + ListElement { + title: "bar" + abbr: "" + } + + ListElement { + title: "millibar" + abbr: "mbar" + } + + ListElement { + title: "pounds per square inch" + abbr: "psi" + } + + ListElement { + title: "technical atmosphere" + abbr: "at" + } + + ListElement { + title: "standard atmosphere" + abbr: "atm" + } + + ListElement { + title: "torr" + abbr: "" + } +} diff --git a/qml/pages/QuantityModel.qml b/qml/pages/QuantityModel.qml index de0cf14..f7e3844 100644 --- a/qml/pages/QuantityModel.qml +++ b/qml/pages/QuantityModel.qml @@ -30,4 +30,14 @@ ListModel { // title: "area" // model: "AreaModel.qml" // } + + ListElement { + title: "angle" + model: "AngleModel.qml" + } + + ListElement { + title: "pressure" + model: "PressureModel.qml" + } } |
