-rw-r--r-- | etc/unit_conversion.dat | 211 | ||||
-rw-r--r-- | noncore/tools/calculator/calculatorimpl.cpp | 24 | ||||
-rw-r--r-- | noncore/tools/calculator/calculatorimpl.h | 2 |
3 files changed, 232 insertions, 5 deletions
diff --git a/etc/unit_conversion.dat b/etc/unit_conversion.dat index 5ae312e..c19adf1 100644 --- a/etc/unit_conversion.dat +++ b/etc/unit_conversion.dat | |||
@@ -23,39 +23,75 @@ STND grams | |||
23 | 23 | ||
24 | NAME mg | 24 | NAME mg |
25 | RATIO 1000 | 25 | RATIO 1000 |
26 | PREOFF 0.0 | ||
27 | POSTOFF 0.0 | ||
28 | |||
26 | 29 | ||
27 | NAME g | 30 | NAME g |
28 | RATIO 1 | 31 | RATIO 1 |
32 | PREOFF 0.0 | ||
33 | POSTOFF 0.0 | ||
34 | |||
29 | 35 | ||
30 | NAME kg | 36 | NAME kg |
31 | RATIO 0.001 | 37 | RATIO 0.001 |
38 | PREOFF 0.0 | ||
39 | POSTOFF 0.0 | ||
40 | |||
32 | 41 | ||
33 | NAME tonnes | 42 | NAME tonnes |
34 | RATIO 1e-06 | 43 | RATIO 1e-06 |
44 | PREOFF 0.0 | ||
45 | POSTOFF 0.0 | ||
46 | |||
35 | 47 | ||
36 | NAME carats | 48 | NAME carats |
37 | RATIO 5 | 49 | RATIO 5 |
50 | PREOFF 0.0 | ||
51 | POSTOFF 0.0 | ||
52 | |||
38 | 53 | ||
39 | NAME oz | 54 | NAME oz |
40 | RATIO 0.03527336860670194 | 55 | RATIO 0.03527336860670194 |
56 | PREOFF 0.0 | ||
57 | POSTOFF 0.0 | ||
58 | |||
41 | 59 | ||
42 | NAME lb | 60 | NAME lb |
43 | RATIO 0.002204585537918871 | 61 | RATIO 0.002204585537918871 |
62 | PREOFF 0.0 | ||
63 | POSTOFF 0.0 | ||
64 | |||
44 | 65 | ||
45 | NAME st | 66 | NAME st |
46 | RATIO 0.0001574703955656337 | 67 | RATIO 0.0001574703955656337 |
68 | PREOFF 0.0 | ||
69 | POSTOFF 0.0 | ||
70 | |||
47 | 71 | ||
48 | NAME St tons | 72 | NAME St tons |
49 | RATIO 1.102292768959636e-06 | 73 | RATIO 1.102292768959636e-06 |
74 | PREOFF 0.0 | ||
75 | POSTOFF 0.0 | ||
76 | |||
50 | 77 | ||
51 | NAME Lg tons | 78 | NAME Lg tons |
52 | RATIO 9.841899722852103e-07 | 79 | RATIO 9.841899722852103e-07 |
80 | PREOFF 0.0 | ||
81 | POSTOFF 0.0 | ||
82 | |||
53 | 83 | ||
54 | NAME | 84 | NAME |
55 | RATIO 1. | 85 | RATIO 1. |
86 | PREOFF 0.0 | ||
87 | POSTOFF 0.0 | ||
88 | |||
56 | 89 | ||
57 | NAME | 90 | NAME |
58 | RATIO 1. | 91 | RATIO 1. |
92 | PREOFF 0.0 | ||
93 | POSTOFF 0.0 | ||
94 | |||
59 | 95 | ||
60 | ENDTYPE | 96 | ENDTYPE |
61 | 97 | ||
@@ -66,39 +102,75 @@ STND m | |||
66 | 102 | ||
67 | NAME mm | 103 | NAME mm |
68 | RATIO 1000 | 104 | RATIO 1000 |
105 | PREOFF 0.0 | ||
106 | POSTOFF 0.0 | ||
107 | |||
69 | 108 | ||
70 | NAME cm | 109 | NAME cm |
71 | RATIO 100 | 110 | RATIO 100 |
111 | PREOFF 0.0 | ||
112 | POSTOFF 0.0 | ||
113 | |||
72 | 114 | ||
73 | NAME m | 115 | NAME m |
74 | RATIO 1 | 116 | RATIO 1 |
117 | PREOFF 0.0 | ||
118 | POSTOFF 0.0 | ||
119 | |||
75 | 120 | ||
76 | NAME km | 121 | NAME km |
77 | RATIO 0.001 | 122 | RATIO 0.001 |
123 | PREOFF 0.0 | ||
124 | POSTOFF 0.0 | ||
125 | |||
78 | 126 | ||
79 | NAME points | 127 | NAME points |
80 | RATIO 2834.64566929134 | 128 | RATIO 2834.64566929134 |
129 | PREOFF 0.0 | ||
130 | POSTOFF 0.0 | ||
131 | |||
81 | 132 | ||
82 | NAME in | 133 | NAME in |
83 | RATIO 39.3700787401575 | 134 | RATIO 39.3700787401575 |
135 | PREOFF 0.0 | ||
136 | POSTOFF 0.0 | ||
137 | |||
84 | 138 | ||
85 | NAME ft | 139 | NAME ft |
86 | RATIO 3.280839895013123 | 140 | RATIO 3.280839895013123 |
141 | PREOFF 0.0 | ||
142 | POSTOFF 0.0 | ||
143 | |||
87 | 144 | ||
88 | NAME yd | 145 | NAME yd |
89 | RATIO 1.093613298337708 | 146 | RATIO 1.093613298337708 |
147 | PREOFF 0.0 | ||
148 | POSTOFF 0.0 | ||
149 | |||
90 | 150 | ||
91 | NAME mi | 151 | NAME mi |
92 | RATIO 0.0006213711922373339 | 152 | RATIO 0.0006213711922373339 |
153 | PREOFF 0.0 | ||
154 | POSTOFF 0.0 | ||
155 | |||
93 | 156 | ||
94 | NAME naut. mi | 157 | NAME naut. mi |
95 | RATIO 0.0005399568034557236 | 158 | RATIO 0.0005399568034557236 |
159 | PREOFF 0.0 | ||
160 | POSTOFF 0.0 | ||
161 | |||
96 | 162 | ||
97 | NAME | 163 | NAME |
98 | RATIO 1. | 164 | RATIO 1. |
165 | PREOFF 0.0 | ||
166 | POSTOFF 0.0 | ||
167 | |||
99 | 168 | ||
100 | NAME | 169 | NAME |
101 | RATIO 1. | 170 | RATIO 1. |
171 | PREOFF 0.0 | ||
172 | POSTOFF 0.0 | ||
173 | |||
102 | 174 | ||
103 | ENDTYPE | 175 | ENDTYPE |
104 | 176 | ||
@@ -109,42 +181,142 @@ STND sq m | |||
109 | 181 | ||
110 | NAME sq mm | 182 | NAME sq mm |
111 | RATIO 1000000 | 183 | RATIO 1000000 |
184 | PREOFF 0.0 | ||
185 | POSTOFF 0.0 | ||
186 | |||
112 | 187 | ||
113 | NAME sq cm | 188 | NAME sq cm |
114 | RATIO 10000 | 189 | RATIO 10000 |
190 | PREOFF 0.0 | ||
191 | POSTOFF 0.0 | ||
192 | |||
115 | 193 | ||
116 | NAME sq m | 194 | NAME sq m |
117 | RATIO 1 | 195 | RATIO 1 |
196 | PREOFF 0.0 | ||
197 | POSTOFF 0.0 | ||
198 | |||
118 | 199 | ||
119 | NAME sq km | 200 | NAME sq km |
120 | RATIO 1e-06 | 201 | RATIO 1e-06 |
202 | PREOFF 0.0 | ||
203 | POSTOFF 0.0 | ||
204 | |||
121 | 205 | ||
122 | NAME hectares | 206 | NAME hectares |
123 | RATIO 0.0001 | 207 | RATIO 0.0001 |
208 | PREOFF 0.0 | ||
209 | POSTOFF 0.0 | ||
210 | |||
124 | 211 | ||
125 | NAME sq in | 212 | NAME sq in |
126 | RATIO 1550.0031000062 | 213 | RATIO 1550.0031000062 |
214 | PREOFF 0.0 | ||
215 | POSTOFF 0.0 | ||
216 | |||
127 | 217 | ||
128 | NAME sq ft | 218 | NAME sq ft |
129 | RATIO 10.7639104167097 | 219 | RATIO 10.7639104167097 |
220 | PREOFF 0.0 | ||
221 | POSTOFF 0.0 | ||
222 | |||
130 | 223 | ||
131 | NAME sq yd | 224 | NAME sq yd |
132 | RATIO 1.19599004630108 | 225 | RATIO 1.19599004630108 |
226 | PREOFF 0.0 | ||
227 | POSTOFF 0.0 | ||
228 | |||
133 | 229 | ||
134 | NAME sq mi | 230 | NAME sq mi |
135 | RATIO 0.000000386102158542446 | 231 | RATIO 0.000000386102158542446 |
232 | PREOFF 0.0 | ||
233 | POSTOFF 0.0 | ||
234 | |||
136 | 235 | ||
137 | NAME acres | 236 | NAME acres |
138 | RATIO 0.0002471053814671653 | 237 | RATIO 0.0002471053814671653 |
238 | PREOFF 0.0 | ||
239 | POSTOFF 0.0 | ||
240 | |||
139 | 241 | ||
140 | NAME | 242 | NAME |
141 | RATIO 1. | 243 | RATIO 1. |
244 | PREOFF 0.0 | ||
245 | POSTOFF 0.0 | ||
246 | |||
142 | 247 | ||
143 | NAME | 248 | NAME |
144 | RATIO 1. | 249 | RATIO 1. |
250 | PREOFF 0.0 | ||
251 | POSTOFF 0.0 | ||
252 | |||
145 | 253 | ||
146 | ENDTYPE | 254 | ENDTYPE |
147 | 255 | ||
256 | STARTTYPE Temperatures | ||
257 | STND °C | ||
258 | |||
259 | NAME | ||
260 | RATIO 1. | ||
261 | PREOFF 0.0 | ||
262 | POSTOFF 0.0 | ||
263 | |||
264 | NAME | ||
265 | RATIO 1. | ||
266 | PREOFF 0.0 | ||
267 | POSTOFF 0.0 | ||
268 | |||
269 | NAME | ||
270 | RATIO 1. | ||
271 | PREOFF 0.0 | ||
272 | POSTOFF 0.0 | ||
273 | |||
274 | NAME | ||
275 | RATIO 1. | ||
276 | PREOFF 0.0 | ||
277 | POSTOFF 0.0 | ||
278 | |||
279 | NAME | ||
280 | RATIO 1. | ||
281 | PREOFF 0.0 | ||
282 | POSTOFF 0.0 | ||
283 | |||
284 | NAME °C | ||
285 | RATIO 1.0 | ||
286 | PREOFF 0.0 | ||
287 | POSTOFF 0.0 | ||
288 | |||
289 | NAME °F | ||
290 | RATIO 1.8 | ||
291 | PREOFF -32.0 | ||
292 | POSTOFF +32.0 | ||
293 | |||
294 | NAME | ||
295 | RATIO 1. | ||
296 | PREOFF 0.0 | ||
297 | POSTOFF 0.0 | ||
298 | |||
299 | NAME | ||
300 | RATIO 1. | ||
301 | PREOFF 0.0 | ||
302 | POSTOFF 0.0 | ||
303 | |||
304 | NAME | ||
305 | RATIO 1. | ||
306 | PREOFF 0.0 | ||
307 | POSTOFF 0.0 | ||
308 | |||
309 | NAME | ||
310 | RATIO 1. | ||
311 | PREOFF 0.0 | ||
312 | POSTOFF 0.0 | ||
313 | |||
314 | NAME | ||
315 | RATIO 1. | ||
316 | PREOFF 0.0 | ||
317 | POSTOFF 0.0 | ||
318 | |||
319 | ENDTYPE | ||
148 | 320 | ||
149 | 321 | ||
150 | STARTTYPE Volume | 322 | STARTTYPE Volume |
@@ -152,39 +324,75 @@ STND litres | |||
152 | 324 | ||
153 | NAME cu cm | 325 | NAME cu cm |
154 | RATIO 1000 | 326 | RATIO 1000 |
327 | PREOFF 0.0 | ||
328 | POSTOFF 0.0 | ||
329 | |||
155 | 330 | ||
156 | NAME ml | 331 | NAME ml |
157 | RATIO 1000 | 332 | RATIO 1000 |
333 | PREOFF 0.0 | ||
334 | POSTOFF 0.0 | ||
335 | |||
158 | 336 | ||
159 | NAME l | 337 | NAME l |
160 | RATIO 1 | 338 | RATIO 1 |
339 | PREOFF 0.0 | ||
340 | POSTOFF 0.0 | ||
341 | |||
161 | 342 | ||
162 | NAME tblspoon | 343 | NAME tblspoon |
163 | RATIO 67.6280454036859 | 344 | RATIO 67.6280454036859 |
345 | PREOFF 0.0 | ||
346 | POSTOFF 0.0 | ||
347 | |||
164 | 348 | ||
165 | NAME teaspoons | 349 | NAME teaspoons |
166 | RATIO 202.884136211058 | 350 | RATIO 202.884136211058 |
351 | PREOFF 0.0 | ||
352 | POSTOFF 0.0 | ||
353 | |||
167 | 354 | ||
168 | NAME cu in | 355 | NAME cu in |
169 | RATIO 61.0237440947323 | 356 | RATIO 61.0237440947323 |
357 | PREOFF 0.0 | ||
358 | POSTOFF 0.0 | ||
359 | |||
170 | 360 | ||
171 | NAME cu ft | 361 | NAME cu ft |
172 | RATIO 0.0353146667214886 | 362 | RATIO 0.0353146667214886 |
363 | PREOFF 0.0 | ||
364 | POSTOFF 0.0 | ||
365 | |||
173 | 366 | ||
174 | NAME pt | 367 | NAME pt |
175 | RATIO 2.11337641886519 | 368 | RATIO 2.11337641886519 |
369 | PREOFF 0.0 | ||
370 | POSTOFF 0.0 | ||
371 | |||
176 | 372 | ||
177 | NAME qt | 373 | NAME qt |
178 | RATIO 1.05668820943259 | 374 | RATIO 1.05668820943259 |
375 | PREOFF 0.0 | ||
376 | POSTOFF 0.0 | ||
377 | |||
179 | 378 | ||
180 | NAME gal (US) | 379 | NAME gal (US) |
181 | RATIO 0.264172052358148 | 380 | RATIO 0.264172052358148 |
381 | PREOFF 0.0 | ||
382 | POSTOFF 0.0 | ||
383 | |||
182 | 384 | ||
183 | NAME | 385 | NAME |
184 | RATIO 1. | 386 | RATIO 1. |
387 | PREOFF 0.0 | ||
388 | POSTOFF 0.0 | ||
389 | |||
185 | 390 | ||
186 | NAME | 391 | NAME |
187 | RATIO 1. | 392 | RATIO 1. |
393 | PREOFF 0.0 | ||
394 | POSTOFF 0.0 | ||
395 | |||
188 | 396 | ||
189 | ENDTYPE | 397 | ENDTYPE |
190 | 398 | ||
@@ -192,4 +400,7 @@ Extra units | |||
192 | 400 | ||
193 | NAME fl oz (US) | 401 | NAME fl oz (US) |
194 | RATIO 33.8140227018429 | 402 | RATIO 33.8140227018429 |
403 | PREOFF 0.0 | ||
404 | POSTOFF 0.0 | ||
405 | |||
195 | 406 | ||
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp index 2f7d7ce..1b93c7f 100644 --- a/noncore/tools/calculator/calculatorimpl.cpp +++ b/noncore/tools/calculator/calculatorimpl.cpp | |||
@@ -18,6 +18,11 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | /* | ||
22 | * 01/14/2002 Charles-Edouard Ruault <ce@ruault.com> | ||
23 | * Added support for Temperature conversions. | ||
24 | */ | ||
25 | |||
21 | #include "calculatorimpl.h" | 26 | #include "calculatorimpl.h" |
22 | 27 | ||
23 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
@@ -134,7 +139,8 @@ CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, | |||
134 | } | 139 | } |
135 | 140 | ||
136 | entry_list = new double[conversion_mode_count*func_button_count]; | 141 | entry_list = new double[conversion_mode_count*func_button_count]; |
137 | 142 | preoffset_list = new double[conversion_mode_count*func_button_count]; | |
143 | postoffset_list = new double[conversion_mode_count*func_button_count]; | ||
138 | myfile.close(); | 144 | myfile.close(); |
139 | myfile.open( IO_Translate | IO_ReadOnly ); | 145 | myfile.open( IO_Translate | IO_ReadOnly ); |
140 | QTextStream ts2(&myfile); | 146 | QTextStream ts2(&myfile); |
@@ -153,6 +159,12 @@ CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, | |||
153 | line2 = ts2.readLine(); | 159 | line2 = ts2.readLine(); |
154 | line2.remove(0,6); | 160 | line2.remove(0,6); |
155 | entry_list[x] = line2.toDouble(); | 161 | entry_list[x] = line2.toDouble(); |
162 | line2 = ts2.readLine(); | ||
163 | line2.remove(0,7); | ||
164 | preoffset_list[x] = line2.toDouble(); | ||
165 | line2 = ts2.readLine(); | ||
166 | line2.remove(0,8); | ||
167 | postoffset_list[x] = line2.toDouble(); | ||
156 | x++; | 168 | x++; |
157 | } | 169 | } |
158 | } | 170 | } |
@@ -220,16 +232,18 @@ void CalculatorImpl::do_convert(int button) { | |||
220 | button < changeable_func_button_count ) { | 232 | button < changeable_func_button_count ) { |
221 | if ( last_conversion > -1 ) { | 233 | if ( last_conversion > -1 ) { |
222 | if( state == sNewNumber ){ | 234 | if( state == sNewNumber ){ |
223 | acc = num | 235 | acc = (num+ preoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) |
224 | / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) | 236 | / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) |
225 | * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) ; | 237 | * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) |
238 | +postoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + button]; | ||
226 | num = acc; | 239 | num = acc; |
227 | LCD->display( acc ); | 240 | LCD->display( acc ); |
228 | } else { | 241 | } else { |
229 | state = sNewNumber; | 242 | state = sNewNumber; |
230 | num = num | 243 | num = (num+ preoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) |
231 | / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) | 244 | / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) |
232 | * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) ; | 245 | * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) |
246 | + postoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + button];; | ||
233 | LCD->display( num ); | 247 | LCD->display( num ); |
234 | acc = num; | 248 | acc = num; |
235 | } | 249 | } |
diff --git a/noncore/tools/calculator/calculatorimpl.h b/noncore/tools/calculator/calculatorimpl.h index bfb726f..f0180c9 100644 --- a/noncore/tools/calculator/calculatorimpl.h +++ b/noncore/tools/calculator/calculatorimpl.h | |||
@@ -124,6 +124,8 @@ private: | |||
124 | 124 | ||
125 | // an array of doubles holding the conversion ratios | 125 | // an array of doubles holding the conversion ratios |
126 | double* entry_list; | 126 | double* entry_list; |
127 | double* preoffset_list; | ||
128 | double* postoffset_list; | ||
127 | 129 | ||
128 | QPixmap xtopowerofy; | 130 | QPixmap xtopowerofy; |
129 | QPixmap ythrootofx; | 131 | QPixmap ythrootofx; |