summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--etc/unit_conversion.dat211
-rw-r--r--noncore/tools/calculator/calculatorimpl.cpp24
-rw-r--r--noncore/tools/calculator/calculatorimpl.h2
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
@@ -14,182 +14,393 @@
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21STARTTYPE Weight 21STARTTYPE Weight
22STND grams 22STND grams
23 23
24NAME mg 24NAME mg
25RATIO 1000 25RATIO 1000
26PREOFF 0.0
27POSTOFF 0.0
28
26 29
27NAME g 30NAME g
28RATIO 1 31RATIO 1
32PREOFF 0.0
33POSTOFF 0.0
34
29 35
30NAME kg 36NAME kg
31RATIO 0.001 37RATIO 0.001
38PREOFF 0.0
39POSTOFF 0.0
40
32 41
33NAME tonnes 42NAME tonnes
34RATIO 1e-06 43RATIO 1e-06
44PREOFF 0.0
45POSTOFF 0.0
46
35 47
36NAME carats 48NAME carats
37RATIO 5 49RATIO 5
50PREOFF 0.0
51POSTOFF 0.0
52
38 53
39NAME oz 54NAME oz
40RATIO 0.03527336860670194 55RATIO 0.03527336860670194
56PREOFF 0.0
57POSTOFF 0.0
58
41 59
42NAME lb 60NAME lb
43RATIO 0.002204585537918871 61RATIO 0.002204585537918871
62PREOFF 0.0
63POSTOFF 0.0
64
44 65
45NAME st 66NAME st
46RATIO 0.0001574703955656337 67RATIO 0.0001574703955656337
68PREOFF 0.0
69POSTOFF 0.0
70
47 71
48NAME St tons 72NAME St tons
49RATIO 1.102292768959636e-06 73RATIO 1.102292768959636e-06
74PREOFF 0.0
75POSTOFF 0.0
76
50 77
51NAME Lg tons 78NAME Lg tons
52RATIO 9.841899722852103e-07 79RATIO 9.841899722852103e-07
80PREOFF 0.0
81POSTOFF 0.0
82
53 83
54NAME 84NAME
55RATIO 1. 85RATIO 1.
86PREOFF 0.0
87POSTOFF 0.0
88
56 89
57NAME 90NAME
58RATIO 1. 91RATIO 1.
92PREOFF 0.0
93POSTOFF 0.0
94
59 95
60ENDTYPE 96ENDTYPE
61 97
62 98
63 99
64STARTTYPE Distance 100STARTTYPE Distance
65STND m 101STND m
66 102
67NAME mm 103NAME mm
68RATIO 1000 104RATIO 1000
105PREOFF 0.0
106POSTOFF 0.0
107
69 108
70NAME cm 109NAME cm
71RATIO 100 110RATIO 100
111PREOFF 0.0
112POSTOFF 0.0
113
72 114
73NAME m 115NAME m
74RATIO 1 116RATIO 1
117PREOFF 0.0
118POSTOFF 0.0
119
75 120
76NAME km 121NAME km
77RATIO 0.001 122RATIO 0.001
123PREOFF 0.0
124POSTOFF 0.0
125
78 126
79NAME points 127NAME points
80RATIO 2834.64566929134 128RATIO 2834.64566929134
129PREOFF 0.0
130POSTOFF 0.0
131
81 132
82NAME in 133NAME in
83RATIO 39.3700787401575 134RATIO 39.3700787401575
135PREOFF 0.0
136POSTOFF 0.0
137
84 138
85NAME ft 139NAME ft
86RATIO 3.280839895013123 140RATIO 3.280839895013123
141PREOFF 0.0
142POSTOFF 0.0
143
87 144
88NAME yd 145NAME yd
89RATIO 1.093613298337708 146RATIO 1.093613298337708
147PREOFF 0.0
148POSTOFF 0.0
149
90 150
91NAME mi 151NAME mi
92RATIO 0.0006213711922373339 152RATIO 0.0006213711922373339
153PREOFF 0.0
154POSTOFF 0.0
155
93 156
94NAME naut. mi 157NAME naut. mi
95RATIO 0.0005399568034557236 158RATIO 0.0005399568034557236
159PREOFF 0.0
160POSTOFF 0.0
161
96 162
97NAME 163NAME
98RATIO 1. 164RATIO 1.
165PREOFF 0.0
166POSTOFF 0.0
167
99 168
100NAME 169NAME
101RATIO 1. 170RATIO 1.
171PREOFF 0.0
172POSTOFF 0.0
173
102 174
103ENDTYPE 175ENDTYPE
104 176
105 177
106 178
107STARTTYPE Area 179STARTTYPE Area
108STND sq m 180STND sq m
109 181
110NAME sq mm 182NAME sq mm
111RATIO 1000000 183RATIO 1000000
184PREOFF 0.0
185POSTOFF 0.0
186
112 187
113NAME sq cm 188NAME sq cm
114RATIO 10000 189RATIO 10000
190PREOFF 0.0
191POSTOFF 0.0
192
115 193
116NAME sq m 194NAME sq m
117RATIO 1 195RATIO 1
196PREOFF 0.0
197POSTOFF 0.0
198
118 199
119NAME sq km 200NAME sq km
120RATIO 1e-06 201RATIO 1e-06
202PREOFF 0.0
203POSTOFF 0.0
204
121 205
122NAME hectares 206NAME hectares
123RATIO 0.0001 207RATIO 0.0001
208PREOFF 0.0
209POSTOFF 0.0
210
124 211
125NAME sq in 212NAME sq in
126RATIO 1550.0031000062 213RATIO 1550.0031000062
214PREOFF 0.0
215POSTOFF 0.0
216
127 217
128NAME sq ft 218NAME sq ft
129RATIO 10.7639104167097 219RATIO 10.7639104167097
220PREOFF 0.0
221POSTOFF 0.0
222
130 223
131NAME sq yd 224NAME sq yd
132RATIO 1.19599004630108 225RATIO 1.19599004630108
226PREOFF 0.0
227POSTOFF 0.0
228
133 229
134NAME sq mi 230NAME sq mi
135RATIO 0.000000386102158542446 231RATIO 0.000000386102158542446
232PREOFF 0.0
233POSTOFF 0.0
234
136 235
137NAME acres 236NAME acres
138RATIO 0.0002471053814671653 237RATIO 0.0002471053814671653
238PREOFF 0.0
239POSTOFF 0.0
240
139 241
140NAME 242NAME
141RATIO 1. 243RATIO 1.
244PREOFF 0.0
245POSTOFF 0.0
246
142 247
143NAME 248NAME
144RATIO 1. 249RATIO 1.
250PREOFF 0.0
251POSTOFF 0.0
252
145 253
146ENDTYPE 254ENDTYPE
147 255
256STARTTYPE Temperatures
257STND °C
258
259NAME
260RATIO 1.
261PREOFF 0.0
262POSTOFF 0.0
263
264NAME
265RATIO 1.
266PREOFF 0.0
267POSTOFF 0.0
268
269NAME
270RATIO 1.
271PREOFF 0.0
272POSTOFF 0.0
273
274NAME
275RATIO 1.
276PREOFF 0.0
277POSTOFF 0.0
278
279NAME
280RATIO 1.
281PREOFF 0.0
282POSTOFF 0.0
283
284NAME °C
285RATIO 1.0
286PREOFF 0.0
287POSTOFF 0.0
288
289NAME °F
290RATIO 1.8
291PREOFF -32.0
292POSTOFF +32.0
293
294NAME
295RATIO 1.
296PREOFF 0.0
297POSTOFF 0.0
298
299NAME
300RATIO 1.
301PREOFF 0.0
302POSTOFF 0.0
303
304NAME
305RATIO 1.
306PREOFF 0.0
307POSTOFF 0.0
308
309NAME
310RATIO 1.
311PREOFF 0.0
312POSTOFF 0.0
313
314NAME
315RATIO 1.
316PREOFF 0.0
317POSTOFF 0.0
318
319ENDTYPE
148 320
149 321
150STARTTYPE Volume 322STARTTYPE Volume
151STND litres 323STND litres
152 324
153NAME cu cm 325NAME cu cm
154RATIO 1000 326RATIO 1000
327PREOFF 0.0
328POSTOFF 0.0
329
155 330
156NAME ml 331NAME ml
157RATIO 1000 332RATIO 1000
333PREOFF 0.0
334POSTOFF 0.0
335
158 336
159NAME l 337NAME l
160RATIO 1 338RATIO 1
339PREOFF 0.0
340POSTOFF 0.0
341
161 342
162NAME tblspoon 343NAME tblspoon
163RATIO 67.6280454036859 344RATIO 67.6280454036859
345PREOFF 0.0
346POSTOFF 0.0
347
164 348
165NAME teaspoons 349NAME teaspoons
166RATIO 202.884136211058 350RATIO 202.884136211058
351PREOFF 0.0
352POSTOFF 0.0
353
167 354
168NAME cu in 355NAME cu in
169RATIO 61.0237440947323 356RATIO 61.0237440947323
357PREOFF 0.0
358POSTOFF 0.0
359
170 360
171NAME cu ft 361NAME cu ft
172RATIO 0.0353146667214886 362RATIO 0.0353146667214886
363PREOFF 0.0
364POSTOFF 0.0
365
173 366
174NAME pt 367NAME pt
175RATIO 2.11337641886519 368RATIO 2.11337641886519
369PREOFF 0.0
370POSTOFF 0.0
371
176 372
177NAME qt 373NAME qt
178RATIO 1.05668820943259 374RATIO 1.05668820943259
375PREOFF 0.0
376POSTOFF 0.0
377
179 378
180NAME gal (US) 379NAME gal (US)
181RATIO 0.264172052358148 380RATIO 0.264172052358148
381PREOFF 0.0
382POSTOFF 0.0
383
182 384
183NAME 385NAME
184RATIO 1. 386RATIO 1.
387PREOFF 0.0
388POSTOFF 0.0
389
185 390
186NAME 391NAME
187RATIO 1. 392RATIO 1.
393PREOFF 0.0
394POSTOFF 0.0
395
188 396
189ENDTYPE 397ENDTYPE
190 398
191Extra units 399Extra units
192 400
193NAME fl oz (US) 401NAME fl oz (US)
194RATIO 33.8140227018429 402RATIO 33.8140227018429
403PREOFF 0.0
404POSTOFF 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
@@ -9,24 +9,29 @@
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
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>
24#include <qpe/qmath.h> 29#include <qpe/qmath.h>
25#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
26 31
27#include <qpushbutton.h> 32#include <qpushbutton.h>
28#include <qcombobox.h> 33#include <qcombobox.h>
29#include <qlabel.h> 34#include <qlabel.h>
30#include <qfont.h> 35#include <qfont.h>
31#include <qlayout.h> 36#include <qlayout.h>
32#include <qstringlist.h> 37#include <qstringlist.h>
@@ -125,43 +130,50 @@ CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name,
125 else { 130 else {
126 QString line, line2; 131 QString line, line2;
127 QTextStream ts(&myfile); 132 QTextStream ts(&myfile);
128 133
129 // first pass, see how many conversion types there are in order to allocate for them 134 // first pass, see how many conversion types there are in order to allocate for them
130 while ( ! ts.eof() ) { 135 while ( ! ts.eof() ) {
131 line = ts.readLine(); 136 line = ts.readLine();
132 if ( line.contains ("STARTTYPE" ) ) 137 if ( line.contains ("STARTTYPE" ) )
133 conversion_mode_count++; 138 conversion_mode_count++;
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);
141 147
142 // second pass, read in values 148 // second pass, read in values
143 int x = 0; 149 int x = 0;
144 while ( ! ts2.eof() ) { 150 while ( ! ts2.eof() ) {
145 line = ts2.readLine(); 151 line = ts2.readLine();
146 if ( line.contains("STARTTYPE") ) { 152 if ( line.contains("STARTTYPE") ) {
147 captions << line.remove(0,10); 153 captions << line.remove(0,10);
148 ComboBoxFunction->insertItem(captions.last()); 154 ComboBoxFunction->insertItem(captions.last());
149 while ( !line.contains("ENDTYPE") ) { 155 while ( !line.contains("ENDTYPE") ) {
150 line = ts2.readLine(); 156 line = ts2.readLine();
151 if ( line.contains("NAME") ) { 157 if ( line.contains("NAME") ) {
152 faces << line.remove(0,5); 158 faces << line.remove(0,5);
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 }
159 } 171 }
160 } 172 }
161 } 173 }
162 myfile.close(); 174 myfile.close();
163 clear(); 175 clear();
164 max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1; 176 max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1;
165 display_pixmap_faces(); 177 display_pixmap_faces();
166 178
167 qApp->installEventFilter( this ); 179 qApp->installEventFilter( this );
@@ -211,34 +223,36 @@ bool CalculatorImpl::eventFilter( QObject *o, QEvent *e )
211 } 223 }
212 } 224 }
213 return Calculator::eventFilter( o, e ); 225 return Calculator::eventFilter( o, e );
214} 226}
215 227
216void CalculatorImpl::do_convert(int button) { 228void CalculatorImpl::do_convert(int button) {
217 if ( state == sError ) 229 if ( state == sError )
218 return; 230 return;
219 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) && 231 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) &&
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 }
236 } 250 }
237 last_conversion = button; 251 last_conversion = button;
238 } 252 }
239} 253}
240 254
241 255
242void CalculatorImpl::function_button(int mode){ 256void CalculatorImpl::function_button(int mode){
243 if ( state == sError ) 257 if ( state == sError )
244 clear(); 258 clear();
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
@@ -115,21 +115,23 @@ private:
115 115
116 // an array of pointers to the func buttons 116 // an array of pointers to the func buttons
117 static const int func_button_count = 12; 117 static const int func_button_count = 12;
118 // this is an abomination 118 // this is an abomination
119 static const int changeable_func_button_count = 10; 119 static const int changeable_func_button_count = 10;
120 QPushButton* func_buttons[func_button_count]; 120 QPushButton* func_buttons[func_button_count];
121 121
122 QButtonGroup bgr_function, bgr_digits, bgr_std, bgr_command; 122 QButtonGroup bgr_function, bgr_digits, bgr_std, bgr_command;
123 QStringList faces, captions; 123 QStringList faces, captions;
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;
130 QPixmap oneoverx; 132 QPixmap oneoverx;
131 133
132 void display_pixmap_faces(void); 134 void display_pixmap_faces(void);
133}; 135};
134 136
135#endif 137#endif