author | llornkcor <llornkcor> | 2002-09-30 03:36:02 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-30 03:36:02 (UTC) |
commit | 57e740cb3826b88b10daad09b8d453dd609af9cb (patch) (unidiff) | |
tree | 32bdbebdd37107d62225aa71c926b8cb8f0c39e8 | |
parent | 251458a2dd6d75c59440dc006060db2544de5d0e (diff) | |
download | opie-57e740cb3826b88b10daad09b8d453dd609af9cb.zip opie-57e740cb3826b88b10daad09b8d453dd609af9cb.tar.gz opie-57e740cb3826b88b10daad09b8d453dd609af9cb.tar.bz2 |
one tr - Standard, the rest of the catagories are in etc/unit_conversion.dat
-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 0925073..8d11132 100644 --- a/noncore/tools/calculator/calculatorimpl.cpp +++ b/noncore/tools/calculator/calculatorimpl.cpp | |||
@@ -79,193 +79,193 @@ static char *ythrootofx_xpm[] = { | |||
79 | "..#.#...#.#..", | 79 | "..#.#...#.#..", |
80 | "...#...#...#.", | 80 | "...#...#...#.", |
81 | "...#........." | 81 | "...#........." |
82 | }; | 82 | }; |
83 | /* XPM */ | 83 | /* XPM */ |
84 | static char *xtopowerofy_xpm[] = { | 84 | static char *xtopowerofy_xpm[] = { |
85 | /* width height num_colors chars_per_pixel */ | 85 | /* width height num_colors chars_per_pixel */ |
86 | " 9 8 2 1", | 86 | " 9 8 2 1", |
87 | /* colors */ | 87 | /* colors */ |
88 | ". c None", | 88 | ". c None", |
89 | "# c #000000", | 89 | "# c #000000", |
90 | /* pixels */ | 90 | /* pixels */ |
91 | "......#.#", | 91 | "......#.#", |
92 | "......#.#", | 92 | "......#.#", |
93 | "......###", | 93 | "......###", |
94 | "#...#...#", | 94 | "#...#...#", |
95 | ".#.#..###", | 95 | ".#.#..###", |
96 | "..#......", | 96 | "..#......", |
97 | ".#.#.....", | 97 | ".#.#.....", |
98 | "#...#...." | 98 | "#...#...." |
99 | }; | 99 | }; |
100 | 100 | ||
101 | CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, | 101 | CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, |
102 | WFlags f ) | 102 | WFlags f ) |
103 | : Calculator( parent, name, f ) | 103 | : Calculator( parent, name, f ) |
104 | { | 104 | { |
105 | // xtopowerofy = Resource::loadPixmap("xtopowerofy"); | 105 | // xtopowerofy = Resource::loadPixmap("xtopowerofy"); |
106 | // ythrootofx = Resource::loadPixmap("ythrootofx"); | 106 | // ythrootofx = Resource::loadPixmap("ythrootofx"); |
107 | // oneoverx = Resource::loadPixmap("oneoverx"); | 107 | // oneoverx = Resource::loadPixmap("oneoverx"); |
108 | 108 | ||
109 | memMark = new QLabel( "m", LCD ); | 109 | memMark = new QLabel( "m", LCD ); |
110 | memMark->setFont( QFont( "helvetica", 12, QFont::Bold, TRUE ) ); | 110 | memMark->setFont( QFont( "helvetica", 12, QFont::Bold, TRUE ) ); |
111 | memMark->resize( 12, 12 ); | 111 | memMark->resize( 12, 12 ); |
112 | memMark->move( 4, 2 ); | 112 | memMark->move( 4, 2 ); |
113 | memMark->hide(); | 113 | memMark->hide(); |
114 | mem = 0; | 114 | mem = 0; |
115 | 115 | ||
116 | PushButtonMR->setEnabled( FALSE ); | 116 | PushButtonMR->setEnabled( FALSE ); |
117 | 117 | ||
118 | current_mode = max_mode = conversion_mode_count = 0; | 118 | current_mode = max_mode = conversion_mode_count = 0; |
119 | last_conversion = -1; | 119 | last_conversion = -1; |
120 | 120 | ||
121 | //bgr_command.insert( PushButtonFunction); | 121 | //bgr_command.insert( PushButtonFunction); |
122 | bgr_command.insert( PushButtonMPlus); | 122 | bgr_command.insert( PushButtonMPlus); |
123 | bgr_command.insert( PushButtonMR); | 123 | bgr_command.insert( PushButtonMR); |
124 | bgr_command.insert( PushButtonMC); | 124 | bgr_command.insert( PushButtonMC); |
125 | bgr_command.insert( PushButtonCE); | 125 | bgr_command.insert( PushButtonCE); |
126 | connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); | 126 | connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); |
127 | 127 | ||
128 | bgr_digits.insert(PushButton0); | 128 | bgr_digits.insert(PushButton0); |
129 | bgr_digits.insert(PushButton1); | 129 | bgr_digits.insert(PushButton1); |
130 | bgr_digits.insert(PushButton2); | 130 | bgr_digits.insert(PushButton2); |
131 | bgr_digits.insert(PushButton3); | 131 | bgr_digits.insert(PushButton3); |
132 | bgr_digits.insert(PushButton4); | 132 | bgr_digits.insert(PushButton4); |
133 | bgr_digits.insert(PushButton5); | 133 | bgr_digits.insert(PushButton5); |
134 | bgr_digits.insert(PushButton6); | 134 | bgr_digits.insert(PushButton6); |
135 | bgr_digits.insert(PushButton7); | 135 | bgr_digits.insert(PushButton7); |
136 | bgr_digits.insert(PushButton8); | 136 | bgr_digits.insert(PushButton8); |
137 | bgr_digits.insert(PushButton9); | 137 | bgr_digits.insert(PushButton9); |
138 | connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); | 138 | connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); |
139 | 139 | ||
140 | 140 | ||
141 | bgr_std.insert(PushButtonEquals); | 141 | bgr_std.insert(PushButtonEquals); |
142 | bgr_std.insert(PushButtonDecimal); | 142 | bgr_std.insert(PushButtonDecimal); |
143 | bgr_std.insert(PushButtonAdd); | 143 | bgr_std.insert(PushButtonAdd); |
144 | bgr_std.insert(PushButtonMinus); | 144 | bgr_std.insert(PushButtonMinus); |
145 | bgr_std.insert(PushButtonDivide); | 145 | bgr_std.insert(PushButtonDivide); |
146 | bgr_std.insert(PushButtonTimes); | 146 | bgr_std.insert(PushButtonTimes); |
147 | connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int))); | 147 | connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int))); |
148 | 148 | ||
149 | // change the / to a proper division signal | 149 | // change the / to a proper division signal |
150 | PushButtonDivide->setText(QChar(0xF7)); | 150 | PushButtonDivide->setText(QChar(0xF7)); |
151 | 151 | ||
152 | func_buttons[0] = PushButtonF1; | 152 | func_buttons[0] = PushButtonF1; |
153 | func_buttons[1] = PushButtonF2; | 153 | func_buttons[1] = PushButtonF2; |
154 | func_buttons[2] = PushButtonF3; | 154 | func_buttons[2] = PushButtonF3; |
155 | func_buttons[3] = PushButtonF4; | 155 | func_buttons[3] = PushButtonF4; |
156 | func_buttons[4] = PushButtonF5; | 156 | func_buttons[4] = PushButtonF5; |
157 | func_buttons[5] = PushButtonF6; | 157 | func_buttons[5] = PushButtonF6; |
158 | func_buttons[6] = PushButtonF7; | 158 | func_buttons[6] = PushButtonF7; |
159 | func_buttons[7] = PushButtonF8; | 159 | func_buttons[7] = PushButtonF8; |
160 | func_buttons[8] = PushButtonF9; | 160 | func_buttons[8] = PushButtonF9; |
161 | func_buttons[9] = PushButtonF10; | 161 | func_buttons[9] = PushButtonF10; |
162 | func_buttons[10] = PushButtonF11; | 162 | func_buttons[10] = PushButtonF11; |
163 | func_buttons[11] = PushButtonF12; | 163 | func_buttons[11] = PushButtonF12; |
164 | 164 | ||
165 | for ( int x = 0 ; x < func_button_count ; x++ ) { | 165 | for ( int x = 0 ; x < func_button_count ; x++ ) { |
166 | QPushButton* tmpbutton = func_buttons[x]; | 166 | QPushButton* tmpbutton = func_buttons[x]; |
167 | faces << tmpbutton->text(); | 167 | faces << tmpbutton->text(); |
168 | bgr_function.insert(tmpbutton); | 168 | bgr_function.insert(tmpbutton); |
169 | } | 169 | } |
170 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) ); | 170 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) ); |
171 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs (int) ) ); | 171 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs (int) ) ); |
172 | 172 | ||
173 | connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); | 173 | connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); |
174 | 174 | ||
175 | captions.append("Standard"); | 175 | captions.append(tr("Standard")); |
176 | ComboBoxFunction->insertItem(captions.last()); | 176 | ComboBoxFunction->insertItem(captions.last()); |
177 | 177 | ||
178 | // now add in the conversion modes | 178 | // now add in the conversion modes |
179 | // when the menu gets done, these should be in a submenu | 179 | // when the menu gets done, these should be in a submenu |
180 | QString tmp = QPEApplication::qpeDir(); | 180 | QString tmp = QPEApplication::qpeDir(); |
181 | tmp += "etc/unit_conversion.dat"; | 181 | tmp += "etc/unit_conversion.dat"; |
182 | QFile myfile(tmp); | 182 | QFile myfile(tmp); |
183 | if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { | 183 | if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { |
184 | qDebug("Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp); | 184 | qDebug("Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp); |
185 | // disable the f button if no conv file available | 185 | // disable the f button if no conv file available |
186 | ComboBoxFunction->setEnabled(FALSE); | 186 | ComboBoxFunction->setEnabled(FALSE); |
187 | } | 187 | } |
188 | else { | 188 | else { |
189 | QString line, line2; | 189 | QString line, line2; |
190 | QTextStream ts(&myfile); | 190 | QTextStream ts(&myfile); |
191 | 191 | ||
192 | // first pass, see how many conversion types there are in order to allocate for them | 192 | // first pass, see how many conversion types there are in order to allocate for them |
193 | while ( ! ts.eof() ) { | 193 | while ( ! ts.eof() ) { |
194 | line = ts.readLine(); | 194 | line = ts.readLine(); |
195 | if ( line.contains ("STARTTYPE" ) ) | 195 | if ( line.contains ("STARTTYPE" ) ) |
196 | conversion_mode_count++; | 196 | conversion_mode_count++; |
197 | } | 197 | } |
198 | 198 | ||
199 | entry_list = new double[conversion_mode_count*func_button_count]; | 199 | entry_list = new double[conversion_mode_count*func_button_count]; |
200 | preoffset_list = new double[conversion_mode_count*func_button_count]; | 200 | preoffset_list = new double[conversion_mode_count*func_button_count]; |
201 | postoffset_list = new double[conversion_mode_count*func_button_count]; | 201 | postoffset_list = new double[conversion_mode_count*func_button_count]; |
202 | myfile.close(); | 202 | myfile.close(); |
203 | myfile.open( IO_Translate | IO_ReadOnly ); | 203 | myfile.open( IO_Translate | IO_ReadOnly ); |
204 | QTextStream ts2(&myfile); | 204 | QTextStream ts2(&myfile); |
205 | 205 | ||
206 | // second pass, read in values | 206 | // second pass, read in values |
207 | int x = 0; | 207 | int x = 0; |
208 | while ( ! ts2.eof() ) { | 208 | while ( ! ts2.eof() ) { |
209 | line = ts2.readLine(); | 209 | line = ts2.readLine(); |
210 | if ( line.contains("STARTTYPE") ) { | 210 | if ( line.contains("STARTTYPE") ) { |
211 | captions << line.remove(0,10); | 211 | captions << line.remove(0,10); |
212 | ComboBoxFunction->insertItem(captions.last()); | 212 | ComboBoxFunction->insertItem(captions.last()); |
213 | while ( !line.contains("ENDTYPE") ) { | 213 | while ( !line.contains("ENDTYPE") ) { |
214 | line = ts2.readLine(); | 214 | line = ts2.readLine(); |
215 | if ( line.contains("NAME") ) { | 215 | if ( line.contains("NAME") ) { |
216 | faces << line.remove(0,5); | 216 | faces << line.remove(0,5); |
217 | line2 = ts2.readLine(); | 217 | line2 = ts2.readLine(); |
218 | line2.remove(0,6); | 218 | line2.remove(0,6); |
219 | entry_list[x] = line2.toDouble(); | 219 | entry_list[x] = line2.toDouble(); |
220 | line2 = ts2.readLine(); | 220 | line2 = ts2.readLine(); |
221 | line2.remove(0,7); | 221 | line2.remove(0,7); |
222 | preoffset_list[x] = line2.toDouble(); | 222 | preoffset_list[x] = line2.toDouble(); |
223 | line2 = ts2.readLine(); | 223 | line2 = ts2.readLine(); |
224 | line2.remove(0,8); | 224 | line2.remove(0,8); |
225 | postoffset_list[x] = line2.toDouble(); | 225 | postoffset_list[x] = line2.toDouble(); |
226 | x++; | 226 | x++; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | } | 231 | } |
232 | myfile.close(); | 232 | myfile.close(); |
233 | clear(); | 233 | clear(); |
234 | max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1; | 234 | max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1; |
235 | display_pixmap_faces(); | 235 | display_pixmap_faces(); |
236 | 236 | ||
237 | qApp->installEventFilter( this ); | 237 | qApp->installEventFilter( this ); |
238 | } | 238 | } |
239 | 239 | ||
240 | bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) | 240 | bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) |
241 | { | 241 | { |
242 | if ( e->type() == QEvent::KeyPress && state != sError ) { | 242 | if ( e->type() == QEvent::KeyPress && state != sError ) { |
243 | QKeyEvent *k = (QKeyEvent*)e; | 243 | QKeyEvent *k = (QKeyEvent*)e; |
244 | if ( k->key() >= Key_0 && k->key() <= Key_9 ) { | 244 | if ( k->key() >= Key_0 && k->key() <= Key_9 ) { |
245 | enterNumber( k->key() - Key_0 ); | 245 | enterNumber( k->key() - Key_0 ); |
246 | return true; | 246 | return true; |
247 | } else { | 247 | } else { |
248 | switch ( k->key() ) { | 248 | switch ( k->key() ) { |
249 | case Key_Equal: | 249 | case Key_Equal: |
250 | std_buttons(0); | 250 | std_buttons(0); |
251 | return true; | 251 | return true; |
252 | case Key_Period: | 252 | case Key_Period: |
253 | std_buttons(1); | 253 | std_buttons(1); |
254 | return true; | 254 | return true; |
255 | case Key_Plus: | 255 | case Key_Plus: |
256 | std_buttons(2); | 256 | std_buttons(2); |
257 | return true; | 257 | return true; |
258 | case Key_Minus: | 258 | case Key_Minus: |
259 | std_buttons(3); | 259 | std_buttons(3); |
260 | return true; | 260 | return true; |
261 | case Key_Slash: | 261 | case Key_Slash: |
262 | std_buttons(4); | 262 | std_buttons(4); |
263 | return true; | 263 | return true; |
264 | case Key_Asterisk: | 264 | case Key_Asterisk: |
265 | std_buttons(5); | 265 | std_buttons(5); |
266 | return true; | 266 | return true; |
267 | case Key_Percent: | 267 | case Key_Percent: |
268 | execOp( oPercent ); | 268 | execOp( oPercent ); |
269 | return true; | 269 | return true; |
270 | case Key_ParenLeft: | 270 | case Key_ParenLeft: |
271 | if ( current_mode < pre_conv_modes_count ) | 271 | if ( current_mode < pre_conv_modes_count ) |