diff options
Diffstat (limited to 'src/qml/pages/PressureModel.qml')
| -rw-r--r-- | src/qml/pages/PressureModel.qml | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/qml/pages/PressureModel.qml b/src/qml/pages/PressureModel.qml new file mode 100644 index 0000000..2196f8a --- /dev/null +++ b/src/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: "" + } +} |
