aboutsummaryrefslogtreecommitdiff
path: root/qml
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2013-12-07 17:33:25 +0200
committerOskari Timperi <oskari.timperi@iki.fi>2013-12-07 17:33:25 +0200
commitef5baad9ff47cfe32bb4f97368e0b3148765caa6 (patch)
tree87d59ecc69e7981489e16aeed62115b4a4927223 /qml
parent3aeb00f43988ae607082cdabe124b9d5e123e33c (diff)
downloadunitmaster-ef5baad9ff47cfe32bb4f97368e0b3148765caa6.tar.gz
unitmaster-ef5baad9ff47cfe32bb4f97368e0b3148765caa6.zip
shuffle stuff around and add directory for tests
Diffstat (limited to 'qml')
-rw-r--r--qml/harbour-unitmaster.qml15
-rw-r--r--qml/pages/AboutPage.qml31
-rw-r--r--qml/pages/AngleModel.qml50
-rw-r--r--qml/pages/LengthModel.qml92
-rw-r--r--qml/pages/MassModel.qml50
-rw-r--r--qml/pages/PressureModel.qml71
-rw-r--r--qml/pages/QuantityModel.qml43
-rw-r--r--qml/pages/QuantityPage.qml136
-rw-r--r--qml/pages/SelectQuantityPage.qml46
-rw-r--r--qml/pages/TemperatureModel.qml43
-rw-r--r--qml/pages/helpers.js5
11 files changed, 0 insertions, 582 deletions
diff --git a/qml/harbour-unitmaster.qml b/qml/harbour-unitmaster.qml
deleted file mode 100644
index 5d3cf21..0000000
--- a/qml/harbour-unitmaster.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-import "pages"
-
-ApplicationWindow
-{
- initialPage: SelectQuantityPage { }
- cover: CoverBackground {
- CoverPlaceholder {
- text: "Unit Master"
- }
- }
-}
-
-
diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml
deleted file mode 100644
index 0810846..0000000
--- a/qml/pages/AboutPage.qml
+++ /dev/null
@@ -1,31 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-import "helpers.js" as H
-
-Page {
- id: page
-
- SilicaFlickable {
- anchors.fill: parent
-
- Column {
- width: parent.width
- spacing: Theme.paddingLarge
-
- PageHeader {
- title: "About"
- }
-
- TextArea {
- readOnly: true
- width: parent.width
- horizontalAlignment: TextEdit.AlignHCenter
- text: "Unit Master\nCopyright 2013 Oskari Timperi\n\nThe
-application icon is derived from the Meanicons Icon Set\n(http://www.meanicons.com/)."
- }
- }
-
- }
-}
-
-
diff --git a/qml/pages/AngleModel.qml b/qml/pages/AngleModel.qml
deleted file mode 100644
index a81adb4..0000000
--- a/qml/pages/AngleModel.qml
+++ /dev/null
@@ -1,50 +0,0 @@
-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/LengthModel.qml b/qml/pages/LengthModel.qml
deleted file mode 100644
index a374be3..0000000
--- a/qml/pages/LengthModel.qml
+++ /dev/null
@@ -1,92 +0,0 @@
-import QtQuick 2.0
-
-ListModel {
- function from (title, value) {
- var functions = {
- "meter": function () { return value; },
- "kilometer": function () { return value*1000.0; },
- "decimeter": function () { return value/10.0; },
- "centimeter": function () { return value/100.0; },
- "millimeter": function () { return value/1000.0; },
- "thou": function () { return value*(25.4e-6); },
- "inch": function () { return value*0.0254; },
- "foot": function () { return value*0.3048; },
- "yard": function () { return value*0.9144; },
- "mile": function () { return value*1609.344; },
- "nautical mile": function () { return value*1852.0; }
- }
- return functions[title]();
- }
-
- function to (title, value) {
- var functions = {
- "meter": function () { return value; },
- "kilometer": function () { return value/1000.0; },
- "decimeter": function () { return value*10.0; },
- "centimeter": function () { return value*100.0; },
- "millimeter": function () { return value*1000.0; },
- "thou": function () { return value/(25.4e-6); },
- "inch": function () { return value/0.0254; },
- "foot": function () { return value/0.3048; },
- "yard": function () { return value/0.9144; },
- "mile": function () { return value/1609.344; },
- "nautical mile": function () { return value/1852.0; }
- };
- return functions[title]();
- }
-
- ListElement {
- title: "meter"
- abbr: "m"
- }
-
- ListElement {
- title: "kilometer"
- abbr: "km"
- }
-
- ListElement {
- title: "decimeter"
- abbr: "dm"
- }
-
- ListElement {
- title: "centimeter"
- abbr: "cm"
- }
-
- ListElement {
- title: "millimeter"
- abbr: "mm"
- }
-
- ListElement {
- title: "thou"
- abbr: "thou"
- }
-
- ListElement {
- title: "inch"
- abbr: "inch"
- }
-
- ListElement {
- title: "foot"
- abbr: "ft"
- }
-
- ListElement {
- title: "yard"
- abbr: "yd"
- }
-
- ListElement {
- title: "mile"
- abbr: ""
- }
-
- ListElement {
- title: "nautical mile"
- abbr: ""
- }
-}
diff --git a/qml/pages/MassModel.qml b/qml/pages/MassModel.qml
deleted file mode 100644
index cadcdf0..0000000
--- a/qml/pages/MassModel.qml
+++ /dev/null
@@ -1,50 +0,0 @@
-import QtQuick 2.0
-
-ListModel {
- function from(title, value) {
- var functions = {
- "kilogram": function () { return value; },
- "gram": function () { return value/1000.0; },
- "tonne": function () { return value*1000.0; },
- "pound": function () { return value*0.45359237; },
- "ounce": function () { return value*0.028349523125; }
- };
- return functions[title]();
- }
-
- function to(title, value) {
- var functions = {
- "kilogram": function () { return value; },
- "gram": function () { return value*1000.0; },
- "tonne": function () { return value/1000.0; },
- "pound": function () { return value/0.45359237; },
- "ounce": function () { return value/0.028349523125; }
- };
- return functions[title]();
- }
-
- ListElement {
- title: "kilogram"
- abbr: "kg"
- }
-
- ListElement {
- title: "gram"
- abbr: "g"
- }
-
- ListElement {
- title: "tonne"
- abbr: "t"
- }
-
- ListElement {
- title: "pound"
- abbr: "lb"
- }
-
- ListElement {
- title: "ounce"
- abbr: "oz"
- }
-}
diff --git a/qml/pages/PressureModel.qml b/qml/pages/PressureModel.qml
deleted file mode 100644
index 2196f8a..0000000
--- a/qml/pages/PressureModel.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644
index f7e3844..0000000
--- a/qml/pages/QuantityModel.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-import QtQuick 2.0
-
-ListModel {
- ListElement {
- title: "mass"
- model: "MassModel.qml"
- }
-
- ListElement {
- title: "length"
- model: "LengthModel.qml"
- }
-
- ListElement {
- title: "temperature"
- model: "TemperatureModel.qml"
- }
-
-// ListElement {
-// title: "time"
-// model: "TimeModel.qml"
-// }
-
-// ListElement {
-// title: "current"
-// model: "CurrentModel.qml"
-// }
-
-// ListElement {
-// title: "area"
-// model: "AreaModel.qml"
-// }
-
- ListElement {
- title: "angle"
- model: "AngleModel.qml"
- }
-
- ListElement {
- title: "pressure"
- model: "PressureModel.qml"
- }
-}
diff --git a/qml/pages/QuantityPage.qml b/qml/pages/QuantityPage.qml
deleted file mode 100644
index 0d5c4de..0000000
--- a/qml/pages/QuantityPage.qml
+++ /dev/null
@@ -1,136 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-import "helpers.js" as Helpers
-
-Page {
- id: page
-
- property string modelFilename
- property string quantityName
-
- function formatText(value, unit) {
- return "%1 %2".arg(value.toPrecision(5)).arg(pluralize(unit, value));
- }
-
- function updateResult() {
- var f = parseFloat(fromField.text);
-
- if (fromField.text.length === 0) {
- f = 0.0;
- }
-
- if (fromCombo.value.length === 0 || toCombo.value.length === 0)
- return;
-
- var model = modelLoader.item;
-
- var fromUnit = model.get(fromCombo.currentIndex).title;
- var toUnit = model.get(toCombo.currentIndex).title;
-
- var result = model.from(fromUnit, f);
- result = model.to(toUnit, result);
-
- resultLabel.text = formatText(result, toUnit);
- }
-
- function pluralize(s, n) {
- if (n !== 1) {
- if (s === "inch") {
- return "inches";
- } else if (s === "foot") {
- return "feet";
- } else if (s === "celcius") {
- return s;
- }
- return s + "s";
- }
-
- return s;
- }
-
- function makeTitle(title, abbr) {
- if (abbr.length > 0) {
- return "%1 (%2)".arg(title).arg(abbr);
- }
-
- return title;
- }
-
- Component.onCompleted: {
- modelLoader.setSource(modelFilename);
- }
-
- Loader {
- id: modelLoader
- onLoaded: {
- fromRepeater.model = modelLoader.item;
- toRepeater.model = modelLoader.item;
- }
- }
-
- Column {
- id: column
- spacing: Theme.paddingLarge
- anchors.fill: parent
-
- PageHeader {
- title: Helpers.capitalize(page.quantityName)
- }
-
- ComboBox {
- id: fromCombo
- width: parent.width
- label: "From"
- menu: ContextMenu {
- Repeater {
- id: fromRepeater
- delegate: MenuItem {
- text: makeTitle(title, abbr)
- }
- }
- }
- onValueChanged: updateResult()
- }
-
- TextField {
- id: fromField
- width: parent.width
- placeholderText: "enter " + pluralize(fromRepeater.model.get(fromCombo.currentIndex).title, 0)
- inputMethodHints: Qt.ImhFormattedNumbersOnly
- EnterKey.onClicked: {
- parent.focus = true;
- updateResult();
- }
- onTextChanged: {
- updateResult();
- }
- }
-
- ComboBox {
- id: toCombo
- width: parent.width
- label: "To"
- menu: ContextMenu {
- Repeater {
- id: toRepeater
- delegate: MenuItem {
- text: makeTitle(title, abbr)
- }
- }
- }
- onValueChanged: updateResult()
- }
-
- SectionHeader {
- text: "Result"
- }
-
- Label {
- id: resultLabel
- height: Theme.itemSizeSmall
- anchors.horizontalCenter: parent.horizontalCenter
- }
- }
-}
-
-
diff --git a/qml/pages/SelectQuantityPage.qml b/qml/pages/SelectQuantityPage.qml
deleted file mode 100644
index 4e1456d..0000000
--- a/qml/pages/SelectQuantityPage.qml
+++ /dev/null
@@ -1,46 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-import "helpers.js" as H
-
-Page {
- id: page
-
- QuantityModel {
- id: quantityModel
- }
-
- SilicaListView {
- anchors.fill: parent
- model: quantityModel
- spacing: Theme.paddingLarge
- delegate: BackgroundItem {
- width: ListView.view.width
- Label {
- x: Theme.paddingLarge
- text: H.capitalize(title)
- anchors.verticalCenter: parent.verticalCenter
- }
- onClicked: {
- var props = {
- "first": true,
- "modelFilename": model,
- "quantityName": title
- };
- pageStack.push(Qt.resolvedUrl("QuantityPage.qml"), props);
- }
- }
- header: PageHeader {
- title: "Quantity"
- }
- VerticalScrollDecorator {}
-
- PullDownMenu {
- MenuItem {
- text: "About"
- onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
- }
- }
- }
-}
-
-
diff --git a/qml/pages/TemperatureModel.qml b/qml/pages/TemperatureModel.qml
deleted file mode 100644
index 74fc7d2..0000000
--- a/qml/pages/TemperatureModel.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-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"
- }
-}
diff --git a/qml/pages/helpers.js b/qml/pages/helpers.js
deleted file mode 100644
index dd7ad7c..0000000
--- a/qml/pages/helpers.js
+++ /dev/null
@@ -1,5 +0,0 @@
-.pragma library
-
-function capitalize(str) {
- return str.substr(0, 1).toUpperCase() + str.substr(1);
-}