summaryrefslogtreecommitdiff
authordrw <drw>2005-05-23 23:41:35 (UTC)
committer drw <drw>2005-05-23 23:41:35 (UTC)
commit4d0e85830d39ef28f5ae8d3f9daa2cdf5616b2e2 (patch) (unidiff)
tree5b1561f5c64f674b25daa7eb16f8caec79e72d13
parent3e2acb4665ddcdb24e0749e3ebfc589313be0065 (diff)
downloadopie-4d0e85830d39ef28f5ae8d3f9daa2cdf5616b2e2.zip
opie-4d0e85830d39ef28f5ae8d3f9daa2cdf5616b2e2.tar.gz
opie-4d0e85830d39ef28f5ae8d3f9daa2cdf5616b2e2.tar.bz2
Remove unnecessary include
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/calculator/calculatorimpl.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp
index 05cb9b5..21c1e2e 100644
--- a/noncore/tools/calculator/calculatorimpl.cpp
+++ b/noncore/tools/calculator/calculatorimpl.cpp
@@ -1,334 +1,329 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
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/* 21/*
22 * 01/14/2002 Charles-Edouard Ruault <ce@ruault.com> 22 * 01/14/2002 Charles-Edouard Ruault <ce@ruault.com>
23 * Added support for Temperature conversions. 23 * Added support for Temperature conversions.
24 */ 24 */
25// Sat 03-09-2002 L.J. Potter added the inlined pixmaps here 25// Sat 03-09-2002 L.J. Potter added the inlined pixmaps here
26 26
27#include "calculatorimpl.h" 27#include "calculatorimpl.h"
28 28
29/* OPIE */ 29/* OPIE */
30#include <opie2/odebug.h> 30#include <opie2/odebug.h>
31#include <qpe/resource.h>
32#include <qpe/qmath.h> 31#include <qpe/qmath.h>
33#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
34using namespace Opie::Core; 33using namespace Opie::Core;
35 34
36/* QT */ 35/* QT */
37#include <qpushbutton.h> 36#include <qpushbutton.h>
38#include <qcombobox.h> 37#include <qcombobox.h>
39#include <qlabel.h> 38#include <qlabel.h>
40#include <qfont.h> 39#include <qfont.h>
41#include <qlayout.h> 40#include <qlayout.h>
42#include <qstringlist.h> 41#include <qstringlist.h>
43#include <qfile.h> 42#include <qfile.h>
44#include <qtextstream.h> 43#include <qtextstream.h>
45#include <qmessagebox.h> 44#include <qmessagebox.h>
46 45
47/* STD */ 46/* STD */
48#include <math.h> 47#include <math.h>
49 48
50/* XPM */ 49/* XPM */
51static char *oneoverx_xpm[] = { 50static char *oneoverx_xpm[] = {
52/* width height num_colors chars_per_pixel */ 51/* width height num_colors chars_per_pixel */
53" 13 11 2 1", 52" 13 11 2 1",
54/* colors */ 53/* colors */
55". c None", 54". c None",
56"# c #000000", 55"# c #000000",
57/* pixels */ 56/* pixels */
58"......#......", 57"......#......",
59".....##......", 58".....##......",
60"......#......" 59"......#......"
61".....###.....", 60".....###.....",
62".............", 61".............",
63"..#########..", 62"..#########..",
64".............", 63".............",
65"....##.##....", 64"....##.##....",
66"......#......", 65"......#......",
67"......#......", 66"......#......",
68"....##.##....", 67"....##.##....",
69}; 68};
70/* XPM */ 69/* XPM */
71static char *ythrootofx_xpm[] = { 70static char *ythrootofx_xpm[] = {
72/* width height num_colors chars_per_pixel */ 71/* width height num_colors chars_per_pixel */
73" 13 11 2 1", 72" 13 11 2 1",
74/* colors */ 73/* colors */
75". c None", 74". c None",
76"# c #000000", 75"# c #000000",
77/* pixels */ 76/* pixels */
78"#.#..........", 77"#.#..........",
79"#.#..........", 78"#.#..........",
80"###...#######", 79"###...#######",
81"..#..#.......", 80"..#..#.......",
82"###..#.......", 81"###..#.......",
83".....#.#...#.", 82".....#.#...#.",
84".#..#...#.#..", 83".#..#...#.#..",
85"#.#.#....#...", 84"#.#.#....#...",
86"..#.#...#.#..", 85"..#.#...#.#..",
87"...#...#...#.", 86"...#...#...#.",
88"...#........." 87"...#........."
89}; 88};
90/* XPM */ 89/* XPM */
91static char *xtopowerofy_xpm[] = { 90static char *xtopowerofy_xpm[] = {
92/* width height num_colors chars_per_pixel */ 91/* width height num_colors chars_per_pixel */
93" 9 8 2 1", 92" 9 8 2 1",
94/* colors */ 93/* colors */
95". c None", 94". c None",
96"# c #000000", 95"# c #000000",
97/* pixels */ 96/* pixels */
98"......#.#", 97"......#.#",
99"......#.#", 98"......#.#",
100"......###", 99"......###",
101"#...#...#", 100"#...#...#",
102".#.#..###", 101".#.#..###",
103"..#......", 102"..#......",
104".#.#.....", 103".#.#.....",
105"#...#...." 104"#...#...."
106}; 105};
107 106
108CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, 107CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name,
109 WFlags f ) 108 WFlags f )
110 : Calculator( parent, name, f ) 109 : Calculator( parent, name, f )
111{ 110{
112// xtopowerofy = Resource::loadPixmap("xtopowerofy");
113// ythrootofx = Resource::loadPixmap("ythrootofx");
114// oneoverx = Resource::loadPixmap("oneoverx");
115
116 memMark = new QLabel( "m", LCD ); 111 memMark = new QLabel( "m", LCD );
117 memMark->setFont( QFont( "helvetica", 12, QFont::Bold, TRUE ) ); 112 memMark->setFont( QFont( "helvetica", 12, QFont::Bold, TRUE ) );
118 memMark->resize( 12, 12 ); 113 memMark->resize( 12, 12 );
119 memMark->move( 4, 2 ); 114 memMark->move( 4, 2 );
120 memMark->hide(); 115 memMark->hide();
121 mem = 0; 116 mem = 0;
122 117
123 PushButtonMR->setEnabled( FALSE ); 118 PushButtonMR->setEnabled( FALSE );
124 119
125 current_mode = max_mode = conversion_mode_count = 0; 120 current_mode = max_mode = conversion_mode_count = 0;
126 last_conversion = -1; 121 last_conversion = -1;
127 122
128 // translation trick mode - with this stuff parsed in from a file is translatable 123 // translation trick mode - with this stuff parsed in from a file is translatable
129 QObject::tr("Standard"); 124 QObject::tr("Standard");
130 QObject::tr("Weight"); 125 QObject::tr("Weight");
131 QObject::tr("Distance"); 126 QObject::tr("Distance");
132 QObject::tr("Area"); 127 QObject::tr("Area");
133 QObject::tr("Temperatures"); 128 QObject::tr("Temperatures");
134 QObject::tr("Volume"); 129 QObject::tr("Volume");
135 QObject::tr("acres"); 130 QObject::tr("acres");
136 QObject::tr("°C"); 131 QObject::tr("C");
137 QObject::tr("carats"); 132 QObject::tr("carats");
138 QObject::tr("cm"); 133 QObject::tr("cm");
139 QObject::tr("cu cm"); 134 QObject::tr("cu cm");
140 QObject::tr("cu ft"); 135 QObject::tr("cu ft");
141 QObject::tr("cu in"); 136 QObject::tr("cu in");
142 QObject::tr("°F"); 137 QObject::tr("F");
143 QObject::tr("fl oz (US)"); 138 QObject::tr("fl oz (US)");
144 QObject::tr("ft"); 139 QObject::tr("ft");
145 QObject::tr("g"); 140 QObject::tr("g");
146 QObject::tr("gal (US)"); 141 QObject::tr("gal (US)");
147 QObject::tr("hectares"); 142 QObject::tr("hectares");
148 QObject::tr("in"); 143 QObject::tr("in");
149 QObject::tr("kg"); 144 QObject::tr("kg");
150 QObject::tr("km"); 145 QObject::tr("km");
151 QObject::tr("l"); 146 QObject::tr("l");
152 QObject::tr("lb"); 147 QObject::tr("lb");
153 QObject::tr("Lg tons"); 148 QObject::tr("Lg tons");
154 QObject::tr("m"); 149 QObject::tr("m");
155 QObject::tr("mg"); 150 QObject::tr("mg");
156 QObject::tr("mi"); 151 QObject::tr("mi");
157 QObject::tr("ml"); 152 QObject::tr("ml");
158 QObject::tr("mm"); 153 QObject::tr("mm");
159 QObject::tr("naut. mi"); 154 QObject::tr("naut. mi");
160 QObject::tr("oz"); 155 QObject::tr("oz");
161 QObject::tr("points"); 156 QObject::tr("points");
162 QObject::tr("pt"); 157 QObject::tr("pt");
163 QObject::tr("qt"); 158 QObject::tr("qt");
164 QObject::tr("sq cm"); 159 QObject::tr("sq cm");
165 QObject::tr("sq ft"); 160 QObject::tr("sq ft");
166 QObject::tr("sq in"); 161 QObject::tr("sq in");
167 QObject::tr("sq km"); 162 QObject::tr("sq km");
168 QObject::tr("sq m"); 163 QObject::tr("sq m");
169 QObject::tr("sq mi"); 164 QObject::tr("sq mi");
170 QObject::tr("sq mm"); 165 QObject::tr("sq mm");
171 QObject::tr("sq yd"); 166 QObject::tr("sq yd");
172 QObject::tr("st"); 167 QObject::tr("st");
173 QObject::tr("St tons"); 168 QObject::tr("St tons");
174 QObject::tr("tblspoon"); 169 QObject::tr("tblspoon");
175 QObject::tr("teaspoons"); 170 QObject::tr("teaspoons");
176 QObject::tr("tonnes"); 171 QObject::tr("tonnes");
177 QObject::tr("yd"); 172 QObject::tr("yd");
178 173
179 174
180//bgr_command.insert( PushButtonFunction); 175//bgr_command.insert( PushButtonFunction);
181 bgr_command.insert( PushButtonMPlus); 176 bgr_command.insert( PushButtonMPlus);
182 bgr_command.insert( PushButtonMR); 177 bgr_command.insert( PushButtonMR);
183 bgr_command.insert( PushButtonMC); 178 bgr_command.insert( PushButtonMC);
184 bgr_command.insert( PushButtonCE); 179 bgr_command.insert( PushButtonCE);
185 connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); 180 connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int)));
186 181
187 bgr_digits.insert(PushButton0); 182 bgr_digits.insert(PushButton0);
188 bgr_digits.insert(PushButton1); 183 bgr_digits.insert(PushButton1);
189 bgr_digits.insert(PushButton2); 184 bgr_digits.insert(PushButton2);
190 bgr_digits.insert(PushButton3); 185 bgr_digits.insert(PushButton3);
191 bgr_digits.insert(PushButton4); 186 bgr_digits.insert(PushButton4);
192 bgr_digits.insert(PushButton5); 187 bgr_digits.insert(PushButton5);
193 bgr_digits.insert(PushButton6); 188 bgr_digits.insert(PushButton6);
194 bgr_digits.insert(PushButton7); 189 bgr_digits.insert(PushButton7);
195 bgr_digits.insert(PushButton8); 190 bgr_digits.insert(PushButton8);
196 bgr_digits.insert(PushButton9); 191 bgr_digits.insert(PushButton9);
197 connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); 192 connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int)));
198 193
199 194
200 bgr_std.insert(PushButtonEquals); 195 bgr_std.insert(PushButtonEquals);
201 bgr_std.insert(PushButtonDecimal); 196 bgr_std.insert(PushButtonDecimal);
202 bgr_std.insert(PushButtonAdd); 197 bgr_std.insert(PushButtonAdd);
203 bgr_std.insert(PushButtonMinus); 198 bgr_std.insert(PushButtonMinus);
204 bgr_std.insert(PushButtonDivide); 199 bgr_std.insert(PushButtonDivide);
205 bgr_std.insert(PushButtonTimes); 200 bgr_std.insert(PushButtonTimes);
206 connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int))); 201 connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int)));
207 202
208// change the / to a proper division signal 203// change the / to a proper division signal
209 PushButtonDivide->setText(QChar(0xF7)); 204 PushButtonDivide->setText(QChar(0xF7));
210 205
211 func_buttons[0] = PushButtonF1; 206 func_buttons[0] = PushButtonF1;
212 func_buttons[1] = PushButtonF2; 207 func_buttons[1] = PushButtonF2;
213 func_buttons[2] = PushButtonF3; 208 func_buttons[2] = PushButtonF3;
214 func_buttons[3] = PushButtonF4; 209 func_buttons[3] = PushButtonF4;
215 func_buttons[4] = PushButtonF5; 210 func_buttons[4] = PushButtonF5;
216 func_buttons[5] = PushButtonF6; 211 func_buttons[5] = PushButtonF6;
217 func_buttons[6] = PushButtonF7; 212 func_buttons[6] = PushButtonF7;
218 func_buttons[7] = PushButtonF8; 213 func_buttons[7] = PushButtonF8;
219 func_buttons[8] = PushButtonF9; 214 func_buttons[8] = PushButtonF9;
220 func_buttons[9] = PushButtonF10; 215 func_buttons[9] = PushButtonF10;
221 func_buttons[10] = PushButtonF11; 216 func_buttons[10] = PushButtonF11;
222 func_buttons[11] = PushButtonF12; 217 func_buttons[11] = PushButtonF12;
223 218
224 for ( int x = 0 ; x < func_button_count ; x++ ) { 219 for ( int x = 0 ; x < func_button_count ; x++ ) {
225 QPushButton* tmpbutton = func_buttons[x]; 220 QPushButton* tmpbutton = func_buttons[x];
226 faces << tmpbutton->text(); 221 faces << tmpbutton->text();
227 bgr_function.insert(tmpbutton); 222 bgr_function.insert(tmpbutton);
228 } 223 }
229 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) ); 224 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) );
230 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs(int) ) ); 225 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs(int) ) );
231 226
232 connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); 227 connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) );
233 228
234 captions.append(tr("Standard")); 229 captions.append(tr("Standard"));
235 ComboBoxFunction->insertItem(captions.last()); 230 ComboBoxFunction->insertItem(captions.last());
236 231
237 // now add in the conversion modes 232 // now add in the conversion modes
238 // when the menu gets done, these should be in a submenu 233 // when the menu gets done, these should be in a submenu
239 QString tmp = QPEApplication::qpeDir(); 234 QString tmp = QPEApplication::qpeDir();
240 tmp += "etc/unit_conversion.dat"; 235 tmp += "etc/unit_conversion.dat";
241 QFile myfile(tmp); 236 QFile myfile(tmp);
242 if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { 237 if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) {
243 odebug << "Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp << oendl; 238 odebug << "Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp << oendl;
244 // disable the f button if no conv file available 239 // disable the f button if no conv file available
245 ComboBoxFunction->setEnabled(FALSE); 240 ComboBoxFunction->setEnabled(FALSE);
246 } 241 }
247 else { 242 else {
248 QString line, line2; 243 QString line, line2;
249 QTextStream ts(&myfile); 244 QTextStream ts(&myfile);
250 245
251 // first pass, see how many conversion types there are in order to allocate for them 246 // first pass, see how many conversion types there are in order to allocate for them
252 while ( ! ts.eof() ) { 247 while ( ! ts.eof() ) {
253 line = ts.readLine(); 248 line = ts.readLine();
254 if ( line.contains ("STARTTYPE" ) ) 249 if ( line.contains ("STARTTYPE" ) )
255 conversion_mode_count++; 250 conversion_mode_count++;
256 } 251 }
257 252
258 entry_list = new double[conversion_mode_count*func_button_count]; 253 entry_list = new double[conversion_mode_count*func_button_count];
259 preoffset_list = new double[conversion_mode_count*func_button_count]; 254 preoffset_list = new double[conversion_mode_count*func_button_count];
260 postoffset_list = new double[conversion_mode_count*func_button_count]; 255 postoffset_list = new double[conversion_mode_count*func_button_count];
261 myfile.close(); 256 myfile.close();
262 myfile.open( IO_Translate | IO_ReadOnly ); 257 myfile.open( IO_Translate | IO_ReadOnly );
263 QTextStream ts2(&myfile); 258 QTextStream ts2(&myfile);
264 259
265 // second pass, read in values 260 // second pass, read in values
266 int x = 0; 261 int x = 0;
267 while ( ! ts2.eof() ) { 262 while ( ! ts2.eof() ) {
268 line = ts2.readLine(); 263 line = ts2.readLine();
269 if ( line.contains("STARTTYPE") ) { 264 if ( line.contains("STARTTYPE") ) {
270 captions << tr( line.remove(0,10) ); 265 captions << tr( line.remove(0,10) );
271 ComboBoxFunction->insertItem(captions.last()); 266 ComboBoxFunction->insertItem(captions.last());
272 while ( !line.contains("ENDTYPE") ) { 267 while ( !line.contains("ENDTYPE") ) {
273 line = ts2.readLine(); 268 line = ts2.readLine();
274 if ( line.contains("NAME") ) { 269 if ( line.contains("NAME") ) {
275 faces << tr( line.remove(0,5) ); 270 faces << tr( line.remove(0,5) );
276 line2 = ts2.readLine(); 271 line2 = ts2.readLine();
277 line2.remove(0,6); 272 line2.remove(0,6);
278 entry_list[x] = line2.toDouble(); 273 entry_list[x] = line2.toDouble();
279 line2 = ts2.readLine(); 274 line2 = ts2.readLine();
280 line2.remove(0,7); 275 line2.remove(0,7);
281 preoffset_list[x] = line2.toDouble(); 276 preoffset_list[x] = line2.toDouble();
282 line2 = ts2.readLine(); 277 line2 = ts2.readLine();
283 line2.remove(0,8); 278 line2.remove(0,8);
284 postoffset_list[x] = line2.toDouble(); 279 postoffset_list[x] = line2.toDouble();
285 x++; 280 x++;
286 } 281 }
287 } 282 }
288 } 283 }
289 } 284 }
290 } 285 }
291 myfile.close(); 286 myfile.close();
292 clear(); 287 clear();
293 max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1; 288 max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1;
294 display_pixmap_faces(); 289 display_pixmap_faces();
295 290
296 qApp->installEventFilter( this ); 291 qApp->installEventFilter( this );
297} 292}
298 293
299bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) 294bool CalculatorImpl::eventFilter( QObject *o, QEvent *e )
300{ 295{
301 if ( e->type() == QEvent::KeyPress && state != sError ) { 296 if ( e->type() == QEvent::KeyPress && state != sError ) {
302 QKeyEvent *k = (QKeyEvent*)e; 297 QKeyEvent *k = (QKeyEvent*)e;
303 if ( k->key() >= Key_0 && k->key() <= Key_9 ) { 298 if ( k->key() >= Key_0 && k->key() <= Key_9 ) {
304 enterNumber( k->key() - Key_0 ); 299 enterNumber( k->key() - Key_0 );
305 return true; 300 return true;
306 } else { 301 } else {
307 switch ( k->key() ) { 302 switch ( k->key() ) {
308 case Key_Equal: 303 case Key_Equal:
309 std_buttons(0); 304 std_buttons(0);
310 return true; 305 return true;
311 case Key_Period: 306 case Key_Period:
312 std_buttons(1); 307 std_buttons(1);
313 return true; 308 return true;
314 case Key_Plus: 309 case Key_Plus:
315 std_buttons(2); 310 std_buttons(2);
316 return true; 311 return true;
317 case Key_Minus: 312 case Key_Minus:
318 std_buttons(3); 313 std_buttons(3);
319 return true; 314 return true;
320 case Key_Slash: 315 case Key_Slash:
321 std_buttons(4); 316 std_buttons(4);
322 return true; 317 return true;
323 case Key_Asterisk: 318 case Key_Asterisk:
324 std_buttons(5); 319 std_buttons(5);
325 return true; 320 return true;
326 case Key_Percent: 321 case Key_Percent:
327 execOp( oPercent ); 322 execOp( oPercent );
328 return true; 323 return true;
329 case Key_ParenLeft: 324 case Key_ParenLeft:
330 if ( current_mode < pre_conv_modes_count ) 325 if ( current_mode < pre_conv_modes_count )
331 execOp( oOpenBrace ); 326 execOp( oOpenBrace );
332 return true; 327 return true;
333 case Key_ParenRight: 328 case Key_ParenRight:
334 if ( current_mode < pre_conv_modes_count ) 329 if ( current_mode < pre_conv_modes_count )