Diffstat (limited to 'noncore/tools/calculator/calculatorimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/calculator/calculatorimpl.cpp | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp index 8d11132..163b4da 100644 --- a/noncore/tools/calculator/calculatorimpl.cpp +++ b/noncore/tools/calculator/calculatorimpl.cpp | |||
@@ -97,48 +97,100 @@ static char *xtopowerofy_xpm[] = { | |||
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 | // translation trick mode - with this stuff parsed in from a file is translatable | ||
122 | QObject::tr("Standard"); | ||
123 | QObject::tr("Weight"); | ||
124 | QObject::tr("Distance"); | ||
125 | QObject::tr("Area"); | ||
126 | QObject::tr("Temperatures"); | ||
127 | QObject::tr("Volume"); | ||
128 | QObject::tr("acres"); | ||
129 | QObject::tr("°C"); | ||
130 | QObject::tr("carats"); | ||
131 | QObject::tr("cm"); | ||
132 | QObject::tr("cu cm"); | ||
133 | QObject::tr("cu ft"); | ||
134 | QObject::tr("cu in"); | ||
135 | QObject::tr("°F"); | ||
136 | QObject::tr("fl oz (US)"); | ||
137 | QObject::tr("ft"); | ||
138 | QObject::tr("g"); | ||
139 | QObject::tr("gal (US)"); | ||
140 | QObject::tr("hectares"); | ||
141 | QObject::tr("in"); | ||
142 | QObject::tr("kg"); | ||
143 | QObject::tr("km"); | ||
144 | QObject::tr("l"); | ||
145 | QObject::tr("lb"); | ||
146 | QObject::tr("Lg tons"); | ||
147 | QObject::tr("m"); | ||
148 | QObject::tr("mg"); | ||
149 | QObject::tr("mi"); | ||
150 | QObject::tr("ml"); | ||
151 | QObject::tr("mm"); | ||
152 | QObject::tr("naut. mi"); | ||
153 | QObject::tr("oz"); | ||
154 | QObject::tr("points"); | ||
155 | QObject::tr("pt"); | ||
156 | QObject::tr("qt"); | ||
157 | QObject::tr("sq cm"); | ||
158 | QObject::tr("sq ft"); | ||
159 | QObject::tr("sq in"); | ||
160 | QObject::tr("sq km"); | ||
161 | QObject::tr("sq m"); | ||
162 | QObject::tr("sq mi"); | ||
163 | QObject::tr("sq mm"); | ||
164 | QObject::tr("sq yd"); | ||
165 | QObject::tr("st"); | ||
166 | QObject::tr("St tons"); | ||
167 | QObject::tr("tblspoon"); | ||
168 | QObject::tr("teaspoons"); | ||
169 | QObject::tr("tonnes"); | ||
170 | QObject::tr("yd"); | ||
171 | |||
172 | |||
121 | //bgr_command.insert( PushButtonFunction); | 173 | //bgr_command.insert( PushButtonFunction); |
122 | bgr_command.insert( PushButtonMPlus); | 174 | bgr_command.insert( PushButtonMPlus); |
123 | bgr_command.insert( PushButtonMR); | 175 | bgr_command.insert( PushButtonMR); |
124 | bgr_command.insert( PushButtonMC); | 176 | bgr_command.insert( PushButtonMC); |
125 | bgr_command.insert( PushButtonCE); | 177 | bgr_command.insert( PushButtonCE); |
126 | connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); | 178 | connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); |
127 | 179 | ||
128 | bgr_digits.insert(PushButton0); | 180 | bgr_digits.insert(PushButton0); |
129 | bgr_digits.insert(PushButton1); | 181 | bgr_digits.insert(PushButton1); |
130 | bgr_digits.insert(PushButton2); | 182 | bgr_digits.insert(PushButton2); |
131 | bgr_digits.insert(PushButton3); | 183 | bgr_digits.insert(PushButton3); |
132 | bgr_digits.insert(PushButton4); | 184 | bgr_digits.insert(PushButton4); |
133 | bgr_digits.insert(PushButton5); | 185 | bgr_digits.insert(PushButton5); |
134 | bgr_digits.insert(PushButton6); | 186 | bgr_digits.insert(PushButton6); |
135 | bgr_digits.insert(PushButton7); | 187 | bgr_digits.insert(PushButton7); |
136 | bgr_digits.insert(PushButton8); | 188 | bgr_digits.insert(PushButton8); |
137 | bgr_digits.insert(PushButton9); | 189 | bgr_digits.insert(PushButton9); |
138 | connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); | 190 | connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); |
139 | 191 | ||
140 | 192 | ||
141 | bgr_std.insert(PushButtonEquals); | 193 | bgr_std.insert(PushButtonEquals); |
142 | bgr_std.insert(PushButtonDecimal); | 194 | bgr_std.insert(PushButtonDecimal); |
143 | bgr_std.insert(PushButtonAdd); | 195 | bgr_std.insert(PushButtonAdd); |
144 | bgr_std.insert(PushButtonMinus); | 196 | bgr_std.insert(PushButtonMinus); |
@@ -187,54 +239,54 @@ CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, | |||
187 | } | 239 | } |
188 | else { | 240 | else { |
189 | QString line, line2; | 241 | QString line, line2; |
190 | QTextStream ts(&myfile); | 242 | QTextStream ts(&myfile); |
191 | 243 | ||
192 | // 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 |
193 | while ( ! ts.eof() ) { | 245 | while ( ! ts.eof() ) { |
194 | line = ts.readLine(); | 246 | line = ts.readLine(); |
195 | if ( line.contains ("STARTTYPE" ) ) | 247 | if ( line.contains ("STARTTYPE" ) ) |
196 | conversion_mode_count++; | 248 | conversion_mode_count++; |
197 | } | 249 | } |
198 | 250 | ||
199 | entry_list = new double[conversion_mode_count*func_button_count]; | 251 | entry_list = new double[conversion_mode_count*func_button_count]; |
200 | preoffset_list = new double[conversion_mode_count*func_button_count]; | 252 | preoffset_list = new double[conversion_mode_count*func_button_count]; |
201 | postoffset_list = new double[conversion_mode_count*func_button_count]; | 253 | postoffset_list = new double[conversion_mode_count*func_button_count]; |
202 | myfile.close(); | 254 | myfile.close(); |
203 | myfile.open( IO_Translate | IO_ReadOnly ); | 255 | myfile.open( IO_Translate | IO_ReadOnly ); |
204 | QTextStream ts2(&myfile); | 256 | QTextStream ts2(&myfile); |
205 | 257 | ||
206 | // second pass, read in values | 258 | // second pass, read in values |
207 | int x = 0; | 259 | int x = 0; |
208 | while ( ! ts2.eof() ) { | 260 | while ( ! ts2.eof() ) { |
209 | line = ts2.readLine(); | 261 | line = ts2.readLine(); |
210 | if ( line.contains("STARTTYPE") ) { | 262 | if ( line.contains("STARTTYPE") ) { |
211 | captions << line.remove(0,10); | 263 | captions << tr( line.remove(0,10) ); |
212 | ComboBoxFunction->insertItem(captions.last()); | 264 | ComboBoxFunction->insertItem(captions.last()); |
213 | while ( !line.contains("ENDTYPE") ) { | 265 | while ( !line.contains("ENDTYPE") ) { |
214 | line = ts2.readLine(); | 266 | line = ts2.readLine(); |
215 | if ( line.contains("NAME") ) { | 267 | if ( line.contains("NAME") ) { |
216 | faces << line.remove(0,5); | 268 | faces << tr( line.remove(0,5) ); |
217 | line2 = ts2.readLine(); | 269 | line2 = ts2.readLine(); |
218 | line2.remove(0,6); | 270 | line2.remove(0,6); |
219 | entry_list[x] = line2.toDouble(); | 271 | entry_list[x] = line2.toDouble(); |
220 | line2 = ts2.readLine(); | 272 | line2 = ts2.readLine(); |
221 | line2.remove(0,7); | 273 | line2.remove(0,7); |
222 | preoffset_list[x] = line2.toDouble(); | 274 | preoffset_list[x] = line2.toDouble(); |
223 | line2 = ts2.readLine(); | 275 | line2 = ts2.readLine(); |
224 | line2.remove(0,8); | 276 | line2.remove(0,8); |
225 | postoffset_list[x] = line2.toDouble(); | 277 | postoffset_list[x] = line2.toDouble(); |
226 | x++; | 278 | x++; |
227 | } | 279 | } |
228 | } | 280 | } |
229 | } | 281 | } |
230 | } | 282 | } |
231 | } | 283 | } |
232 | myfile.close(); | 284 | myfile.close(); |
233 | clear(); | 285 | clear(); |
234 | 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; |
235 | display_pixmap_faces(); | 287 | display_pixmap_faces(); |
236 | 288 | ||
237 | qApp->installEventFilter( this ); | 289 | qApp->installEventFilter( this ); |
238 | } | 290 | } |
239 | 291 | ||
240 | bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) | 292 | bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) |