Diffstat (limited to 'noncore/tools/calculator/calculatorimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/calculator/calculatorimpl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp index 163b4da..dead03d 100644 --- a/noncore/tools/calculator/calculatorimpl.cpp +++ b/noncore/tools/calculator/calculatorimpl.cpp | |||
@@ -127,193 +127,193 @@ CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, | |||
127 | QObject::tr("Volume"); | 127 | QObject::tr("Volume"); |
128 | QObject::tr("acres"); | 128 | QObject::tr("acres"); |
129 | QObject::tr("°C"); | 129 | QObject::tr("°C"); |
130 | QObject::tr("carats"); | 130 | QObject::tr("carats"); |
131 | QObject::tr("cm"); | 131 | QObject::tr("cm"); |
132 | QObject::tr("cu cm"); | 132 | QObject::tr("cu cm"); |
133 | QObject::tr("cu ft"); | 133 | QObject::tr("cu ft"); |
134 | QObject::tr("cu in"); | 134 | QObject::tr("cu in"); |
135 | QObject::tr("°F"); | 135 | QObject::tr("°F"); |
136 | QObject::tr("fl oz (US)"); | 136 | QObject::tr("fl oz (US)"); |
137 | QObject::tr("ft"); | 137 | QObject::tr("ft"); |
138 | QObject::tr("g"); | 138 | QObject::tr("g"); |
139 | QObject::tr("gal (US)"); | 139 | QObject::tr("gal (US)"); |
140 | QObject::tr("hectares"); | 140 | QObject::tr("hectares"); |
141 | QObject::tr("in"); | 141 | QObject::tr("in"); |
142 | QObject::tr("kg"); | 142 | QObject::tr("kg"); |
143 | QObject::tr("km"); | 143 | QObject::tr("km"); |
144 | QObject::tr("l"); | 144 | QObject::tr("l"); |
145 | QObject::tr("lb"); | 145 | QObject::tr("lb"); |
146 | QObject::tr("Lg tons"); | 146 | QObject::tr("Lg tons"); |
147 | QObject::tr("m"); | 147 | QObject::tr("m"); |
148 | QObject::tr("mg"); | 148 | QObject::tr("mg"); |
149 | QObject::tr("mi"); | 149 | QObject::tr("mi"); |
150 | QObject::tr("ml"); | 150 | QObject::tr("ml"); |
151 | QObject::tr("mm"); | 151 | QObject::tr("mm"); |
152 | QObject::tr("naut. mi"); | 152 | QObject::tr("naut. mi"); |
153 | QObject::tr("oz"); | 153 | QObject::tr("oz"); |
154 | QObject::tr("points"); | 154 | QObject::tr("points"); |
155 | QObject::tr("pt"); | 155 | QObject::tr("pt"); |
156 | QObject::tr("qt"); | 156 | QObject::tr("qt"); |
157 | QObject::tr("sq cm"); | 157 | QObject::tr("sq cm"); |
158 | QObject::tr("sq ft"); | 158 | QObject::tr("sq ft"); |
159 | QObject::tr("sq in"); | 159 | QObject::tr("sq in"); |
160 | QObject::tr("sq km"); | 160 | QObject::tr("sq km"); |
161 | QObject::tr("sq m"); | 161 | QObject::tr("sq m"); |
162 | QObject::tr("sq mi"); | 162 | QObject::tr("sq mi"); |
163 | QObject::tr("sq mm"); | 163 | QObject::tr("sq mm"); |
164 | QObject::tr("sq yd"); | 164 | QObject::tr("sq yd"); |
165 | QObject::tr("st"); | 165 | QObject::tr("st"); |
166 | QObject::tr("St tons"); | 166 | QObject::tr("St tons"); |
167 | QObject::tr("tblspoon"); | 167 | QObject::tr("tblspoon"); |
168 | QObject::tr("teaspoons"); | 168 | QObject::tr("teaspoons"); |
169 | QObject::tr("tonnes"); | 169 | QObject::tr("tonnes"); |
170 | QObject::tr("yd"); | 170 | QObject::tr("yd"); |
171 | 171 | ||
172 | 172 | ||
173 | //bgr_command.insert( PushButtonFunction); | 173 | //bgr_command.insert( PushButtonFunction); |
174 | bgr_command.insert( PushButtonMPlus); | 174 | bgr_command.insert( PushButtonMPlus); |
175 | bgr_command.insert( PushButtonMR); | 175 | bgr_command.insert( PushButtonMR); |
176 | bgr_command.insert( PushButtonMC); | 176 | bgr_command.insert( PushButtonMC); |
177 | bgr_command.insert( PushButtonCE); | 177 | bgr_command.insert( PushButtonCE); |
178 | connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); | 178 | connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); |
179 | 179 | ||
180 | bgr_digits.insert(PushButton0); | 180 | bgr_digits.insert(PushButton0); |
181 | bgr_digits.insert(PushButton1); | 181 | bgr_digits.insert(PushButton1); |
182 | bgr_digits.insert(PushButton2); | 182 | bgr_digits.insert(PushButton2); |
183 | bgr_digits.insert(PushButton3); | 183 | bgr_digits.insert(PushButton3); |
184 | bgr_digits.insert(PushButton4); | 184 | bgr_digits.insert(PushButton4); |
185 | bgr_digits.insert(PushButton5); | 185 | bgr_digits.insert(PushButton5); |
186 | bgr_digits.insert(PushButton6); | 186 | bgr_digits.insert(PushButton6); |
187 | bgr_digits.insert(PushButton7); | 187 | bgr_digits.insert(PushButton7); |
188 | bgr_digits.insert(PushButton8); | 188 | bgr_digits.insert(PushButton8); |
189 | bgr_digits.insert(PushButton9); | 189 | bgr_digits.insert(PushButton9); |
190 | connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); | 190 | connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); |
191 | 191 | ||
192 | 192 | ||
193 | bgr_std.insert(PushButtonEquals); | 193 | bgr_std.insert(PushButtonEquals); |
194 | bgr_std.insert(PushButtonDecimal); | 194 | bgr_std.insert(PushButtonDecimal); |
195 | bgr_std.insert(PushButtonAdd); | 195 | bgr_std.insert(PushButtonAdd); |
196 | bgr_std.insert(PushButtonMinus); | 196 | bgr_std.insert(PushButtonMinus); |
197 | bgr_std.insert(PushButtonDivide); | 197 | bgr_std.insert(PushButtonDivide); |
198 | bgr_std.insert(PushButtonTimes); | 198 | bgr_std.insert(PushButtonTimes); |
199 | connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int))); | 199 | connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int))); |
200 | 200 | ||
201 | // change the / to a proper division signal | 201 | // change the / to a proper division signal |
202 | PushButtonDivide->setText(QChar(0xF7)); | 202 | PushButtonDivide->setText(QChar(0xF7)); |
203 | 203 | ||
204 | func_buttons[0] = PushButtonF1; | 204 | func_buttons[0] = PushButtonF1; |
205 | func_buttons[1] = PushButtonF2; | 205 | func_buttons[1] = PushButtonF2; |
206 | func_buttons[2] = PushButtonF3; | 206 | func_buttons[2] = PushButtonF3; |
207 | func_buttons[3] = PushButtonF4; | 207 | func_buttons[3] = PushButtonF4; |
208 | func_buttons[4] = PushButtonF5; | 208 | func_buttons[4] = PushButtonF5; |
209 | func_buttons[5] = PushButtonF6; | 209 | func_buttons[5] = PushButtonF6; |
210 | func_buttons[6] = PushButtonF7; | 210 | func_buttons[6] = PushButtonF7; |
211 | func_buttons[7] = PushButtonF8; | 211 | func_buttons[7] = PushButtonF8; |
212 | func_buttons[8] = PushButtonF9; | 212 | func_buttons[8] = PushButtonF9; |
213 | func_buttons[9] = PushButtonF10; | 213 | func_buttons[9] = PushButtonF10; |
214 | func_buttons[10] = PushButtonF11; | 214 | func_buttons[10] = PushButtonF11; |
215 | func_buttons[11] = PushButtonF12; | 215 | func_buttons[11] = PushButtonF12; |
216 | 216 | ||
217 | for ( int x = 0 ; x < func_button_count ; x++ ) { | 217 | for ( int x = 0 ; x < func_button_count ; x++ ) { |
218 | QPushButton* tmpbutton = func_buttons[x]; | 218 | QPushButton* tmpbutton = func_buttons[x]; |
219 | faces << tmpbutton->text(); | 219 | faces << tmpbutton->text(); |
220 | bgr_function.insert(tmpbutton); | 220 | bgr_function.insert(tmpbutton); |
221 | } | 221 | } |
222 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) ); | 222 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) ); |
223 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs (int) ) ); | 223 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs(int) ) ); |
224 | 224 | ||
225 | connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); | 225 | connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); |
226 | 226 | ||
227 | captions.append(tr("Standard")); | 227 | captions.append(tr("Standard")); |
228 | ComboBoxFunction->insertItem(captions.last()); | 228 | ComboBoxFunction->insertItem(captions.last()); |
229 | 229 | ||
230 | // now add in the conversion modes | 230 | // now add in the conversion modes |
231 | // when the menu gets done, these should be in a submenu | 231 | // when the menu gets done, these should be in a submenu |
232 | QString tmp = QPEApplication::qpeDir(); | 232 | QString tmp = QPEApplication::qpeDir(); |
233 | tmp += "etc/unit_conversion.dat"; | 233 | tmp += "etc/unit_conversion.dat"; |
234 | QFile myfile(tmp); | 234 | QFile myfile(tmp); |
235 | if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { | 235 | if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { |
236 | qDebug("Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp); | 236 | qDebug("Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp); |
237 | // disable the f button if no conv file available | 237 | // disable the f button if no conv file available |
238 | ComboBoxFunction->setEnabled(FALSE); | 238 | ComboBoxFunction->setEnabled(FALSE); |
239 | } | 239 | } |
240 | else { | 240 | else { |
241 | QString line, line2; | 241 | QString line, line2; |
242 | QTextStream ts(&myfile); | 242 | QTextStream ts(&myfile); |
243 | 243 | ||
244 | // first pass, see how many conversion types there are in order to allocate for them | 244 | // first pass, see how many conversion types there are in order to allocate for them |
245 | while ( ! ts.eof() ) { | 245 | while ( ! ts.eof() ) { |
246 | line = ts.readLine(); | 246 | line = ts.readLine(); |
247 | if ( line.contains ("STARTTYPE" ) ) | 247 | if ( line.contains ("STARTTYPE" ) ) |
248 | conversion_mode_count++; | 248 | conversion_mode_count++; |
249 | } | 249 | } |
250 | 250 | ||
251 | entry_list = new double[conversion_mode_count*func_button_count]; | 251 | entry_list = new double[conversion_mode_count*func_button_count]; |
252 | preoffset_list = new double[conversion_mode_count*func_button_count]; | 252 | preoffset_list = new double[conversion_mode_count*func_button_count]; |
253 | postoffset_list = new double[conversion_mode_count*func_button_count]; | 253 | postoffset_list = new double[conversion_mode_count*func_button_count]; |
254 | myfile.close(); | 254 | myfile.close(); |
255 | myfile.open( IO_Translate | IO_ReadOnly ); | 255 | myfile.open( IO_Translate | IO_ReadOnly ); |
256 | QTextStream ts2(&myfile); | 256 | QTextStream ts2(&myfile); |
257 | 257 | ||
258 | // second pass, read in values | 258 | // second pass, read in values |
259 | int x = 0; | 259 | int x = 0; |
260 | while ( ! ts2.eof() ) { | 260 | while ( ! ts2.eof() ) { |
261 | line = ts2.readLine(); | 261 | line = ts2.readLine(); |
262 | if ( line.contains("STARTTYPE") ) { | 262 | if ( line.contains("STARTTYPE") ) { |
263 | captions << tr( line.remove(0,10) ); | 263 | captions << tr( line.remove(0,10) ); |
264 | ComboBoxFunction->insertItem(captions.last()); | 264 | ComboBoxFunction->insertItem(captions.last()); |
265 | while ( !line.contains("ENDTYPE") ) { | 265 | while ( !line.contains("ENDTYPE") ) { |
266 | line = ts2.readLine(); | 266 | line = ts2.readLine(); |
267 | if ( line.contains("NAME") ) { | 267 | if ( line.contains("NAME") ) { |
268 | faces << tr( line.remove(0,5) ); | 268 | faces << tr( line.remove(0,5) ); |
269 | line2 = ts2.readLine(); | 269 | line2 = ts2.readLine(); |
270 | line2.remove(0,6); | 270 | line2.remove(0,6); |
271 | entry_list[x] = line2.toDouble(); | 271 | entry_list[x] = line2.toDouble(); |
272 | line2 = ts2.readLine(); | 272 | line2 = ts2.readLine(); |
273 | line2.remove(0,7); | 273 | line2.remove(0,7); |
274 | preoffset_list[x] = line2.toDouble(); | 274 | preoffset_list[x] = line2.toDouble(); |
275 | line2 = ts2.readLine(); | 275 | line2 = ts2.readLine(); |
276 | line2.remove(0,8); | 276 | line2.remove(0,8); |
277 | postoffset_list[x] = line2.toDouble(); | 277 | postoffset_list[x] = line2.toDouble(); |
278 | x++; | 278 | x++; |
279 | } | 279 | } |
280 | } | 280 | } |
281 | } | 281 | } |
282 | } | 282 | } |
283 | } | 283 | } |
284 | myfile.close(); | 284 | myfile.close(); |
285 | clear(); | 285 | clear(); |
286 | max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1; | 286 | max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1; |
287 | display_pixmap_faces(); | 287 | display_pixmap_faces(); |
288 | 288 | ||
289 | qApp->installEventFilter( this ); | 289 | qApp->installEventFilter( this ); |
290 | } | 290 | } |
291 | 291 | ||
292 | bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) | 292 | bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) |
293 | { | 293 | { |
294 | if ( e->type() == QEvent::KeyPress && state != sError ) { | 294 | if ( e->type() == QEvent::KeyPress && state != sError ) { |
295 | QKeyEvent *k = (QKeyEvent*)e; | 295 | QKeyEvent *k = (QKeyEvent*)e; |
296 | if ( k->key() >= Key_0 && k->key() <= Key_9 ) { | 296 | if ( k->key() >= Key_0 && k->key() <= Key_9 ) { |
297 | enterNumber( k->key() - Key_0 ); | 297 | enterNumber( k->key() - Key_0 ); |
298 | return true; | 298 | return true; |
299 | } else { | 299 | } else { |
300 | switch ( k->key() ) { | 300 | switch ( k->key() ) { |
301 | case Key_Equal: | 301 | case Key_Equal: |
302 | std_buttons(0); | 302 | std_buttons(0); |
303 | return true; | 303 | return true; |
304 | case Key_Period: | 304 | case Key_Period: |
305 | std_buttons(1); | 305 | std_buttons(1); |
306 | return true; | 306 | return true; |
307 | case Key_Plus: | 307 | case Key_Plus: |
308 | std_buttons(2); | 308 | std_buttons(2); |
309 | return true; | 309 | return true; |
310 | case Key_Minus: | 310 | case Key_Minus: |
311 | std_buttons(3); | 311 | std_buttons(3); |
312 | return true; | 312 | return true; |
313 | case Key_Slash: | 313 | case Key_Slash: |
314 | std_buttons(4); | 314 | std_buttons(4); |
315 | return true; | 315 | return true; |
316 | case Key_Asterisk: | 316 | case Key_Asterisk: |
317 | std_buttons(5); | 317 | std_buttons(5); |
318 | return true; | 318 | return true; |
319 | case Key_Percent: | 319 | case Key_Percent: |