aboutsummaryrefslogtreecommitdiff
path: root/src/qml/pages/AngleModel.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/pages/AngleModel.qml')
-rw-r--r--src/qml/pages/AngleModel.qml50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/qml/pages/AngleModel.qml b/src/qml/pages/AngleModel.qml
new file mode 100644
index 0000000..a81adb4
--- /dev/null
+++ b/src/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: ""
+ }
+}