summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-29 16:45:13 (UTC)
committer mickeyl <mickeyl>2003-10-29 16:45:13 (UTC)
commite8697a4281f7a265b69e6bf5253383c73a38626b (patch) (unidiff)
tree040470f8f5c90c0d72ff5f01a272143571842078
parentd5d9b307e950d9038215e4d63e64bc9cd5d85352 (diff)
downloadopie-e8697a4281f7a265b69e6bf5253383c73a38626b.zip
opie-e8697a4281f7a265b69e6bf5253383c73a38626b.tar.gz
opie-e8697a4281f7a265b69e6bf5253383c73a38626b.tar.bz2
merge noncore/tools/*
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/calculator/calculator.pro4
-rw-r--r--noncore/tools/calculator/calculatorimpl.cpp56
-rw-r--r--noncore/tools/calculator/calculatorimpl.h4
-rw-r--r--noncore/tools/calculator/main.cpp13
-rw-r--r--noncore/tools/clock/clock.h3
-rw-r--r--noncore/tools/clock/clock.pro5
-rw-r--r--noncore/tools/clock/main.cpp11
-rw-r--r--noncore/tools/euroconv/euroconv.pro5
-rw-r--r--noncore/tools/euroconv/main.cpp30
-rw-r--r--noncore/tools/formatter/formatter.cpp2
-rw-r--r--noncore/tools/formatter/formatter.h3
-rw-r--r--noncore/tools/formatter/formatter.pro4
-rw-r--r--noncore/tools/formatter/main.cpp10
-rw-r--r--noncore/tools/opie-sh/opie-sh.control2
-rw-r--r--noncore/tools/remote/opie-remote.control2
15 files changed, 90 insertions, 64 deletions
diff --git a/noncore/tools/calculator/calculator.pro b/noncore/tools/calculator/calculator.pro
index 0fe5bb2..8a5fcfe 100644
--- a/noncore/tools/calculator/calculator.pro
+++ b/noncore/tools/calculator/calculator.pro
@@ -1,33 +1,31 @@
1 DESTDIR = $(OPIEDIR)/bin 1 CONFIG = qt warn_on release quick-app
2 TEMPLATE= app
3 CONFIG = qt warn_on release
4 HEADERS = calculatorimpl.h 2 HEADERS = calculatorimpl.h
5 SOURCES = calculatorimpl.cpp \ 3 SOURCES = calculatorimpl.cpp \
6 main.cpp 4 main.cpp
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 7LIBS += -lqpe
10 INTERFACES= calculator.ui 8 INTERFACES= calculator.ui
11 TARGET = calculator 9 TARGET = calculator
12 10
13TRANSLATIONS = ../../../i18n/de/calculator.ts \ 11TRANSLATIONS = ../../../i18n/de/calculator.ts \
14 ../../../i18n/nl/calculator.ts \ 12 ../../../i18n/nl/calculator.ts \
15 ../../../i18n/xx/calculator.ts \ 13 ../../../i18n/xx/calculator.ts \
16 ../../../i18n/en/calculator.ts \ 14 ../../../i18n/en/calculator.ts \
17 ../../../i18n/es/calculator.ts \ 15 ../../../i18n/es/calculator.ts \
18 ../../../i18n/fr/calculator.ts \ 16 ../../../i18n/fr/calculator.ts \
19 ../../../i18n/hu/calculator.ts \ 17 ../../../i18n/hu/calculator.ts \
20 ../../../i18n/ja/calculator.ts \ 18 ../../../i18n/ja/calculator.ts \
21 ../../../i18n/ko/calculator.ts \ 19 ../../../i18n/ko/calculator.ts \
22 ../../../i18n/no/calculator.ts \ 20 ../../../i18n/no/calculator.ts \
23 ../../../i18n/pl/calculator.ts \ 21 ../../../i18n/pl/calculator.ts \
24 ../../../i18n/pt/calculator.ts \ 22 ../../../i18n/pt/calculator.ts \
25 ../../../i18n/pt_BR/calculator.ts \ 23 ../../../i18n/pt_BR/calculator.ts \
26 ../../../i18n/sl/calculator.ts \ 24 ../../../i18n/sl/calculator.ts \
27 ../../../i18n/zh_CN/calculator.ts \ 25 ../../../i18n/zh_CN/calculator.ts \
28 ../../../i18n/zh_TW/calculator.ts \ 26 ../../../i18n/zh_TW/calculator.ts \
29 ../../../i18n/da/calculator.ts 27 ../../../i18n/da/calculator.ts
30 28
31 29
32 30
33include ( $(OPIEDIR)/include.pro ) 31include ( $(OPIEDIR)/include.pro )
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
@@ -1,676 +1,728 @@
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#include <qpe/resource.h> 29#include <qpe/resource.h>
30#include <qpe/qmath.h> 30#include <qpe/qmath.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32 32
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qfont.h> 36#include <qfont.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qmessagebox.h> 41#include <qmessagebox.h>
42#include <math.h> 42#include <math.h>
43/* XPM */ 43/* XPM */
44static char *oneoverx_xpm[] = { 44static char *oneoverx_xpm[] = {
45/* width height num_colors chars_per_pixel */ 45/* width height num_colors chars_per_pixel */
46" 13 11 2 1", 46" 13 11 2 1",
47/* colors */ 47/* colors */
48". c None", 48". c None",
49"# c #000000", 49"# c #000000",
50/* pixels */ 50/* pixels */
51"......#......", 51"......#......",
52".....##......", 52".....##......",
53"......#......" 53"......#......"
54".....###.....", 54".....###.....",
55".............", 55".............",
56"..#########..", 56"..#########..",
57".............", 57".............",
58"....##.##....", 58"....##.##....",
59"......#......", 59"......#......",
60"......#......", 60"......#......",
61"....##.##....", 61"....##.##....",
62}; 62};
63/* XPM */ 63/* XPM */
64static char *ythrootofx_xpm[] = { 64static char *ythrootofx_xpm[] = {
65/* width height num_colors chars_per_pixel */ 65/* width height num_colors chars_per_pixel */
66" 13 11 2 1", 66" 13 11 2 1",
67/* colors */ 67/* colors */
68". c None", 68". c None",
69"# c #000000", 69"# c #000000",
70/* pixels */ 70/* pixels */
71"#.#..........", 71"#.#..........",
72"#.#..........", 72"#.#..........",
73"###...#######", 73"###...#######",
74"..#..#.......", 74"..#..#.......",
75"###..#.......", 75"###..#.......",
76".....#.#...#.", 76".....#.#...#.",
77".#..#...#.#..", 77".#..#...#.#..",
78"#.#.#....#...", 78"#.#.#....#...",
79"..#.#...#.#..", 79"..#.#...#.#..",
80"...#...#...#.", 80"...#...#...#.",
81"...#........." 81"...#........."
82}; 82};
83/* XPM */ 83/* XPM */
84static char *xtopowerofy_xpm[] = { 84static 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
101CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, 101CalculatorImpl::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);
145 bgr_std.insert(PushButtonDivide); 197 bgr_std.insert(PushButtonDivide);
146 bgr_std.insert(PushButtonTimes); 198 bgr_std.insert(PushButtonTimes);
147 connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int))); 199 connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int)));
148 200
149// change the / to a proper division signal 201// change the / to a proper division signal
150 PushButtonDivide->setText(QChar(0xF7)); 202 PushButtonDivide->setText(QChar(0xF7));
151 203
152 func_buttons[0] = PushButtonF1; 204 func_buttons[0] = PushButtonF1;
153 func_buttons[1] = PushButtonF2; 205 func_buttons[1] = PushButtonF2;
154 func_buttons[2] = PushButtonF3; 206 func_buttons[2] = PushButtonF3;
155 func_buttons[3] = PushButtonF4; 207 func_buttons[3] = PushButtonF4;
156 func_buttons[4] = PushButtonF5; 208 func_buttons[4] = PushButtonF5;
157 func_buttons[5] = PushButtonF6; 209 func_buttons[5] = PushButtonF6;
158 func_buttons[6] = PushButtonF7; 210 func_buttons[6] = PushButtonF7;
159 func_buttons[7] = PushButtonF8; 211 func_buttons[7] = PushButtonF8;
160 func_buttons[8] = PushButtonF9; 212 func_buttons[8] = PushButtonF9;
161 func_buttons[9] = PushButtonF10; 213 func_buttons[9] = PushButtonF10;
162 func_buttons[10] = PushButtonF11; 214 func_buttons[10] = PushButtonF11;
163 func_buttons[11] = PushButtonF12; 215 func_buttons[11] = PushButtonF12;
164 216
165 for ( int x = 0 ; x < func_button_count ; x++ ) { 217 for ( int x = 0 ; x < func_button_count ; x++ ) {
166 QPushButton* tmpbutton = func_buttons[x]; 218 QPushButton* tmpbutton = func_buttons[x];
167 faces << tmpbutton->text(); 219 faces << tmpbutton->text();
168 bgr_function.insert(tmpbutton); 220 bgr_function.insert(tmpbutton);
169 } 221 }
170 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) ); 222 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) );
171 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs (int) ) ); 223 connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs (int) ) );
172 224
173 connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); 225 connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) );
174 226
175 captions.append(tr("Standard")); 227 captions.append(tr("Standard"));
176 ComboBoxFunction->insertItem(captions.last()); 228 ComboBoxFunction->insertItem(captions.last());
177 229
178 // now add in the conversion modes 230 // now add in the conversion modes
179 // when the menu gets done, these should be in a submenu 231 // when the menu gets done, these should be in a submenu
180 QString tmp = QPEApplication::qpeDir(); 232 QString tmp = QPEApplication::qpeDir();
181 tmp += "etc/unit_conversion.dat"; 233 tmp += "etc/unit_conversion.dat";
182 QFile myfile(tmp); 234 QFile myfile(tmp);
183 if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { 235 if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) {
184 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);
185 // disable the f button if no conv file available 237 // disable the f button if no conv file available
186 ComboBoxFunction->setEnabled(FALSE); 238 ComboBoxFunction->setEnabled(FALSE);
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
240bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) 292bool CalculatorImpl::eventFilter( QObject *o, QEvent *e )
241{ 293{
242 if ( e->type() == QEvent::KeyPress && state != sError ) { 294 if ( e->type() == QEvent::KeyPress && state != sError ) {
243 QKeyEvent *k = (QKeyEvent*)e; 295 QKeyEvent *k = (QKeyEvent*)e;
244 if ( k->key() >= Key_0 && k->key() <= Key_9 ) { 296 if ( k->key() >= Key_0 && k->key() <= Key_9 ) {
245 enterNumber( k->key() - Key_0 ); 297 enterNumber( k->key() - Key_0 );
246 return true; 298 return true;
247 } else { 299 } else {
248 switch ( k->key() ) { 300 switch ( k->key() ) {
249 case Key_Equal: 301 case Key_Equal:
250 std_buttons(0); 302 std_buttons(0);
251 return true; 303 return true;
252 case Key_Period: 304 case Key_Period:
253 std_buttons(1); 305 std_buttons(1);
254 return true; 306 return true;
255 case Key_Plus: 307 case Key_Plus:
256 std_buttons(2); 308 std_buttons(2);
257 return true; 309 return true;
258 case Key_Minus: 310 case Key_Minus:
259 std_buttons(3); 311 std_buttons(3);
260 return true; 312 return true;
261 case Key_Slash: 313 case Key_Slash:
262 std_buttons(4); 314 std_buttons(4);
263 return true; 315 return true;
264 case Key_Asterisk: 316 case Key_Asterisk:
265 std_buttons(5); 317 std_buttons(5);
266 return true; 318 return true;
267 case Key_Percent: 319 case Key_Percent:
268 execOp( oPercent ); 320 execOp( oPercent );
269 return true; 321 return true;
270 case Key_ParenLeft: 322 case Key_ParenLeft:
271 if ( current_mode < pre_conv_modes_count ) 323 if ( current_mode < pre_conv_modes_count )
272 execOp( oOpenBrace ); 324 execOp( oOpenBrace );
273 return true; 325 return true;
274 case Key_ParenRight: 326 case Key_ParenRight:
275 if ( current_mode < pre_conv_modes_count ) 327 if ( current_mode < pre_conv_modes_count )
276 execOp( oCloseBrace ); 328 execOp( oCloseBrace );
277 return true; 329 return true;
278 default: 330 default:
279 break; 331 break;
280 } 332 }
281 } 333 }
282 } 334 }
283 return Calculator::eventFilter( o, e ); 335 return Calculator::eventFilter( o, e );
284} 336}
285 337
286void CalculatorImpl::do_convert(int button) { 338void CalculatorImpl::do_convert(int button) {
287 if ( state == sError ) 339 if ( state == sError )
288 return; 340 return;
289 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) && 341 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) &&
290 button < changeable_func_button_count ) { 342 button < changeable_func_button_count ) {
291 if ( last_conversion > -1 ) { 343 if ( last_conversion > -1 ) {
292 if( state == sNewNumber ){ 344 if( state == sNewNumber ){
293 acc = (num+ preoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) 345 acc = (num+ preoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion])
294 / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) 346 / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion])
295 * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) 347 * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button])
296 +postoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + button]; 348 +postoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + button];
297 num = acc; 349 num = acc;
298 LCD->display( acc ); 350 LCD->display( acc );
299 } else { 351 } else {
300 state = sNewNumber; 352 state = sNewNumber;
301 num = (num+ preoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) 353 num = (num+ preoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion])
302 / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) 354 / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion])
303 * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) 355 * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button])
304 + postoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + button];; 356 + postoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + button];;
305 LCD->display( num ); 357 LCD->display( num );
306 acc = num; 358 acc = num;
307 } 359 }
308 } 360 }
309 last_conversion = button; 361 last_conversion = button;
310 } 362 }
311} 363}
312 364
313 365
314void CalculatorImpl::function_button(int mode){ 366void CalculatorImpl::function_button(int mode){
315 if ( state == sError ) 367 if ( state == sError )
316 clear(); 368 clear();
317 // dont need the next line when using a popup menu 369 // dont need the next line when using a popup menu
318 current_mode = mode; 370 current_mode = mode;
319 371
320 // reset the last conv 372 // reset the last conv
321 last_conversion = -1; 373 last_conversion = -1;
322 374
323 // set the caption 375 // set the caption
324 this->setCaption( captions[current_mode] ); 376 this->setCaption( captions[current_mode] );
325 377
326 reset_conv(); 378 reset_conv();
327 379
328 for ( int x = 0 ; x < changeable_func_button_count ; x++ ) { 380 for ( int x = 0 ; x < changeable_func_button_count ; x++ ) {
329 QPushButton* tmpbutton = func_buttons[x]; 381 QPushButton* tmpbutton = func_buttons[x];
330 382
331 // if its a conversion , make it a toggle button 383 // if its a conversion , make it a toggle button
332 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) { 384 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) {
333 tmpbutton->setToggleButton(TRUE); 385 tmpbutton->setToggleButton(TRUE);
334 } else { 386 } else {
335 tmpbutton->setToggleButton(FALSE); 387 tmpbutton->setToggleButton(FALSE);
336 } 388 }
337 tmpbutton->setText( faces[current_mode * func_button_count + x] ); 389 tmpbutton->setText( faces[current_mode * func_button_count + x] );
338 } 390 }
339 391
340 if ( current_mode == 0 ) display_pixmap_faces(); 392 if ( current_mode == 0 ) display_pixmap_faces();
341 393
342 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) { 394 if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) {
343 bgr_function.setExclusive(TRUE); 395 bgr_function.setExclusive(TRUE);
344 } else { 396 } else {
345 bgr_function.setExclusive(FALSE); 397 bgr_function.setExclusive(FALSE);
346 } 398 }
347} 399}
348 400
349void CalculatorImpl::display_pixmap_faces() { 401void CalculatorImpl::display_pixmap_faces() {
350 QPixmap image0( ( const char** ) xtopowerofy_xpm); 402 QPixmap image0( ( const char** ) xtopowerofy_xpm);
351 QPushButton* tmpbutton = func_buttons[5]; 403 QPushButton* tmpbutton = func_buttons[5];
352 tmpbutton->setPixmap(image0); 404 tmpbutton->setPixmap(image0);
353 405
354 QPixmap image1( ( const char** ) ythrootofx_xpm); 406 QPixmap image1( ( const char** ) ythrootofx_xpm);
355 tmpbutton = func_buttons[6]; 407 tmpbutton = func_buttons[6];
356 tmpbutton->setPixmap(image1); 408 tmpbutton->setPixmap(image1);
357 409
358 QPixmap image2( ( const char** ) oneoverx_xpm); 410 QPixmap image2( ( const char** ) oneoverx_xpm);
359 tmpbutton = func_buttons[3]; 411 tmpbutton = func_buttons[3];
360 tmpbutton->setPixmap(image2); 412 tmpbutton->setPixmap(image2);
361} 413}
362 414
363void CalculatorImpl::clear() { 415void CalculatorImpl::clear() {
364 acc = num = 0; 416 acc = num = 0;
365 operationStack.clear(); 417 operationStack.clear();
366 state = sStart; 418 state = sStart;
367 numDecimals = 0; 419 numDecimals = 0;
368 numOpenBraces = 0; 420 numOpenBraces = 0;
369 flPoint = FALSE; 421 flPoint = FALSE;
370 LCD->display( 0 ); 422 LCD->display( 0 );
371 fake = QString::null; 423 fake = QString::null;
372 424
373 reset_conv(); 425 reset_conv();
374} 426}
375 427
376void CalculatorImpl::reset_conv() { 428void CalculatorImpl::reset_conv() {
377 for ( int x = 0 ; x < changeable_func_button_count ; x++ ) { 429 for ( int x = 0 ; x < changeable_func_button_count ; x++ ) {
378 QPushButton* tmpbutton = func_buttons[x]; 430 QPushButton* tmpbutton = func_buttons[x];
379 431
380 // dont carry any selections into the next mode 432 // dont carry any selections into the next mode
381 if ( tmpbutton->state() == QPushButton::On ) { 433 if ( tmpbutton->state() == QPushButton::On ) {
382 tmpbutton->toggle(); 434 tmpbutton->toggle();
383 } 435 }
384 } 436 }
385 437
386 last_conversion = -1; 438 last_conversion = -1;
387} 439}
388 440
389void CalculatorImpl::std_buttons(int button) 441void CalculatorImpl::std_buttons(int button)
390{ 442{
391 if ( state == sError ) 443 if ( state == sError )
392 return; 444 return;
393 execOp( (Operation)(button + oSum) ); 445 execOp( (Operation)(button + oSum) );
394} 446}
395 447
396void CalculatorImpl::std_funcs(int button) { 448void CalculatorImpl::std_funcs(int button) {
397 if ( state == sError ) 449 if ( state == sError )
398 return; 450 return;
399 if ( current_mode < pre_conv_modes_count || 451 if ( current_mode < pre_conv_modes_count ||
400 button > changeable_func_button_count-1 ) { 452 button > changeable_func_button_count-1 ) {
401 Operation op; 453 Operation op;
402 if ( button < 10 ) 454 if ( button < 10 )
403 op = (Operation)(button + oSin); 455 op = (Operation)(button + oSin);
404 else if ( button == 10 ) 456 else if ( button == 10 )
405 op = oOpenBrace; 457 op = oOpenBrace;
406 else 458 else
407 op = oCloseBrace; 459 op = oCloseBrace;
408 execOp( op ); 460 execOp( op );
409 } 461 }
410} 462}
411 463
412void CalculatorImpl::execOp( Operation i ) 464void CalculatorImpl::execOp( Operation i )
413{ 465{
414 switch (i) { 466 switch (i) {
415 // these operators only affect the current number. 467 // these operators only affect the current number.
416 case oDivX: 468 case oDivX:
417 case oLog: 469 case oLog:
418 case oLn: 470 case oLn:
419 case oSin: 471 case oSin:
420 case oCos: 472 case oCos:
421 case oTan: 473 case oTan:
422 num = evalExpr(i); 474 num = evalExpr(i);
423 break; 475 break;
424 476
425 case oAdd: 477 case oAdd:
426 case oSub: { 478 case oSub: {
427 processStack( oAdd ); 479 processStack( oAdd );
428 Op op( num, i ); 480 Op op( num, i );
429 operationStack.push( op ); 481 operationStack.push( op );
430 break; 482 break;
431 } 483 }
432 case oDiv: 484 case oDiv:
433 case oMult: 485 case oMult:
434 case oRoot: 486 case oRoot:
435 case oXsquared: { 487 case oXsquared: {
436 processStack( oDiv ); 488 processStack( oDiv );
437 Op op( num, i ); 489 Op op( num, i );
438 operationStack.push( op ); 490 operationStack.push( op );
439 break; 491 break;
440 } 492 }
441 case oChSign: 493 case oChSign:
442 num = -num; 494 num = -num;
443 LCD->display(num); 495 LCD->display(num);
444 return; 496 return;
445 497
446 case oOpenBrace: { 498 case oOpenBrace: {
447 Op op( 0, oOpenBrace ); 499 Op op( 0, oOpenBrace );
448 operationStack.push( op ); 500 operationStack.push( op );
449 numOpenBraces++; 501 numOpenBraces++;
450 state = sNewNumber; 502 state = sNewNumber;
451 return; 503 return;
452 } 504 }
453 case oCloseBrace: { 505 case oCloseBrace: {
454 if ( numOpenBraces == 0 ) 506 if ( numOpenBraces == 0 )
455 return; 507 return;
456 processStack( oAdd ); 508 processStack( oAdd );
457 if ( operationStack.top().operation != oOpenBrace ) 509 if ( operationStack.top().operation != oOpenBrace )
458 qDebug( "Calculator: internal Error" ); 510 qDebug( "Calculator: internal Error" );
459 operationStack.pop(); 511 operationStack.pop();
460 state = sNewNumber; 512 state = sNewNumber;
461 numOpenBraces--; 513 numOpenBraces--;
462 break; 514 break;
463 } 515 }
464 516
465 case oPoint: 517 case oPoint:
466 flPoint = TRUE; 518 flPoint = TRUE;
467 return; 519 return;
468 520
469 case oPercent: 521 case oPercent:
470 processStack( oPercent ); 522 processStack( oPercent );
471 break; 523 break;
472 524
473 525
474 case oSum: 526 case oSum:
475 processStack( oSum ); 527 processStack( oSum );
476 break; 528 break;
477 529
478 default: 530 default:
479 return; 531 return;
480 }; 532 };
481 533
482 if ( state == sError ) { 534 if ( state == sError ) {
483 LCD->display( "Error" ); 535 LCD->display( "Error" );
484 return; 536 return;
485 } else { 537 } else {
486 LCD->display(num); 538 LCD->display(num);
487 } 539 }
488 state = sNewNumber; 540 state = sNewNumber;
489 numDecimals = 0; 541 numDecimals = 0;
490 flPoint = FALSE; 542 flPoint = FALSE;
491} 543}
492 544
493 545
494void CalculatorImpl::processStack( int op ) 546void CalculatorImpl::processStack( int op )
495{ 547{
496 //dubious percent hack, since the changeable operator precedences are 548 //dubious percent hack, since the changeable operator precedences are
497 //pretty much hardwired to be less than the non-changeable 549 //pretty much hardwired to be less than the non-changeable
498 bool percent = FALSE; 550 bool percent = FALSE;
499 if ( op == oPercent ) { 551 if ( op == oPercent ) {
500 percent = TRUE; 552 percent = TRUE;
501 op = oSum; 553 op = oSum;
502 } 554 }
503 while( !operationStack.isEmpty() && operationStack.top().operation >= op ) { 555 while( !operationStack.isEmpty() && operationStack.top().operation >= op ) {
504 Op operation = operationStack.pop(); 556 Op operation = operationStack.pop();
505 acc = operation.number; 557 acc = operation.number;
506 if ( percent ) { 558 if ( percent ) {
507 if ( operation.operation == oAdd || operation.operation == oSub ) 559 if ( operation.operation == oAdd || operation.operation == oSub )
508 num = acc*num/100; 560 num = acc*num/100;
509 else 561 else
510 num = num / 100; 562 num = num / 100;
511 } 563 }
512 num = evalExpr( operation.operation ); 564 num = evalExpr( operation.operation );
513 percent = FALSE; 565 percent = FALSE;
514 } 566 }
515} 567}
516 568
517 569
518double CalculatorImpl::evalExpr( int op ) { 570double CalculatorImpl::evalExpr( int op ) {
519 double sum = 0; 571 double sum = 0;
520 572
521 switch( op ){ 573 switch( op ){
522 case oPercent: sum = num / 100.; break; 574 case oPercent: sum = num / 100.; break;
523 case oDivX: 575 case oDivX:
524 if (num == 0) 576 if (num == 0)
525 state = sError; 577 state = sError;
526 else 578 else
527 sum = 1 / num; 579 sum = 1 / num;
528 break; 580 break;
529 case oXsquared: 581 case oXsquared:
530 sum = pow(acc,num); 582 sum = pow(acc,num);
531 break; 583 break;
532 case oChSign: (state == sStart) ? sum = -num : sum = -acc; break; 584 case oChSign: (state == sStart) ? sum = -num : sum = -acc; break;
533 case oSub: sum = acc - num; break; 585 case oSub: sum = acc - num; break;
534 case oMult: sum = acc * num; break; 586 case oMult: sum = acc * num; break;
535 case oAdd: sum = acc + num; break; 587 case oAdd: sum = acc + num; break;
536 case oDiv: { 588 case oDiv: {
537 if (num == 0) { 589 if (num == 0) {
538 state = sError; 590 state = sError;
539 } else { 591 } else {
540 sum = acc / num; 592 sum = acc / num;
541 } 593 }
542 break; 594 break;
543 } 595 }
544 case oRoot: 596 case oRoot:
545 /* the linux library is dumb, and can't to -x to 1/n 597 /* the linux library is dumb, and can't to -x to 1/n
546 when n is odd. (even and error of course is acceptable */ 598 when n is odd. (even and error of course is acceptable */
547 if((acc < 0) && (int(num) == num) && (int(num) % 2 == 1 )) { 599 if((acc < 0) && (int(num) == num) && (int(num) % 2 == 1 )) {
548 sum = pow(-acc, 1 / num); 600 sum = pow(-acc, 1 / num);
549 sum = -sum; 601 sum = -sum;
550 } else { 602 } else {
551 sum = pow(acc, 1 / num); 603 sum = pow(acc, 1 / num);
552 } 604 }
553 break; 605 break;
554 case oLog: 606 case oLog:
555 sum = log10(num); 607 sum = log10(num);
556 break; 608 break;
557 case oLn: 609 case oLn:
558 sum = log(num); 610 sum = log(num);
559 break; 611 break;
560 case oTan: sum = qTan(num);break; 612 case oTan: sum = qTan(num);break;
561 case oSin: sum = qSin(num);break; 613 case oSin: sum = qSin(num);break;
562 case oCos: sum = qCos(num);break; 614 case oCos: sum = qCos(num);break;
563 default: sum = num; break; 615 default: sum = num; break;
564 } 616 }
565 617
566 if ( isinf( sum ) || isnan( sum ) ) 618 if ( isinf( sum ) || isnan( sum ) )
567 state = sError; 619 state = sError;
568 return sum; 620 return sum;
569} 621}
570 622
571 623
572void CalculatorImpl::enterNumber( int n ) 624void CalculatorImpl::enterNumber( int n )
573{ 625{
574 if ( state == sError ) 626 if ( state == sError )
575 return; 627 return;
576 if( state == sStart ){ 628 if( state == sStart ){
577 if( LCD->value() > 0 ){ 629 if( LCD->value() > 0 ){
578 QString s = QString::number( LCD->value(), 'g', LCD->numDigits()); 630 QString s = QString::number( LCD->value(), 'g', LCD->numDigits());
579 if( s.length() > (uint)(LCD->numDigits() - 2)) return; 631 if( s.length() > (uint)(LCD->numDigits() - 2)) return;
580 632
581 } else if( (int)fake.length() >= LCD->numDigits() || numDecimals >=12 ){ 633 } else if( (int)fake.length() >= LCD->numDigits() || numDecimals >=12 ){
582 return; 634 return;
583 } 635 }
584 } 636 }
585 637
586 if( state == sNewNumber ){ 638 if( state == sNewNumber ){
587 state = sStart; 639 state = sStart;
588 acc = 0; 640 acc = 0;
589 if( flPoint ){ 641 if( flPoint ){
590 numDecimals = 1; 642 numDecimals = 1;
591 num = n / pow(10, numDecimals); 643 num = n / pow(10, numDecimals);
592 } else 644 } else
593 num = n; 645 num = n;
594 } else if( flPoint ){ 646 } else if( flPoint ){
595 numDecimals++; 647 numDecimals++;
596 if( num < 0 ){ 648 if( num < 0 ){
597 num -= n / pow(10, numDecimals); 649 num -= n / pow(10, numDecimals);
598 } else { 650 } else {
599 num += n / pow(10, numDecimals); 651 num += n / pow(10, numDecimals);
600 } 652 }
601 } else { 653 } else {
602 num *= 10; 654 num *= 10;
603 if( num < 0 ) 655 if( num < 0 )
604 num -= n; 656 num -= n;
605 else 657 else
606 num += n; 658 num += n;
607 } 659 }
608 660
609 // We need feedback in the calc display while entering fl.point zeros. 661 // We need feedback in the calc display while entering fl.point zeros.
610 // This is a small hack to display sequences like: 0.000 and 1.100 662 // This is a small hack to display sequences like: 0.000 and 1.100
611 double integer, fraction; 663 double integer, fraction;
612 fraction = modf( num, &integer ); 664 fraction = modf( num, &integer );
613 if( flPoint ){ 665 if( flPoint ){
614 QString is, fs, zeros; 666 QString is, fs, zeros;
615 667
616 is = QString::number( integer, 'g', 13 ); 668 is = QString::number( integer, 'g', 13 );
617 fs = QString::number( fraction, 'g', numDecimals ); 669 fs = QString::number( fraction, 'g', numDecimals );
618 if( fs.contains('e') ){ 670 if( fs.contains('e') ){
619 fs = QString::number( fraction, 'f', LCD->numDigits() ); 671 fs = QString::number( fraction, 'f', LCD->numDigits() );
620 } 672 }
621 fs = fs.mid( 2, numDecimals ); 673 fs = fs.mid( 2, numDecimals );
622 674
623 if( (integer == 0) && (fraction == 0) ) 675 if( (integer == 0) && (fraction == 0) )
624 fake = "0."; 676 fake = "0.";
625 else if( (integer != 0) && (fraction == 0) ) 677 else if( (integer != 0) && (fraction == 0) )
626 fake = is + "."; 678 fake = is + ".";
627 else 679 else
628 fake = is + "." + fs; 680 fake = is + "." + fs;
629 681
630 zeros.fill( '0', (numDecimals - fs.length()) ); 682 zeros.fill( '0', (numDecimals - fs.length()) );
631 fake += zeros; 683 fake += zeros;
632 // ### This code sets LCD->value() to zero since it sets a text 684 // ### This code sets LCD->value() to zero since it sets a text
633 // ### Avoid getting the current value from LCD->value() for 685 // ### Avoid getting the current value from LCD->value() for
634 // ### calculations. 686 // ### calculations.
635 LCD->display( fake ); 687 LCD->display( fake );
636 } else 688 } else
637 LCD->display( num ); 689 LCD->display( num );
638} 690}
639 691
640void CalculatorImpl::command_buttons(int i) { 692void CalculatorImpl::command_buttons(int i) {
641 if ( state == sError && i != 3 ) 693 if ( state == sError && i != 3 )
642 return; 694 return;
643 switch (i) { 695 switch (i) {
644 case 0: // M+ 696 case 0: // M+
645 mem += num; 697 mem += num;
646 if( mem != 0 ){ 698 if( mem != 0 ){
647 memMark->show(); 699 memMark->show();
648 PushButtonMR->setEnabled( TRUE ); }; 700 PushButtonMR->setEnabled( TRUE ); };
649 state = sNewNumber; 701 state = sNewNumber;
650 break; 702 break;
651 case 1: // MR 703 case 1: // MR
652 acc = num = mem; 704 acc = num = mem;
653 state = sNewNumber; 705 state = sNewNumber;
654 LCD->display( mem ); 706 LCD->display( mem );
655 break; 707 break;
656 case 2: // MC 708 case 2: // MC
657 mem = 0; 709 mem = 0;
658 memMark->hide(); 710 memMark->hide();
659 PushButtonMR->setEnabled( FALSE ); 711 PushButtonMR->setEnabled( FALSE );
660 break; 712 break;
661 case 3: // CE 713 case 3: // CE
662 if ( state == sStart ) { 714 if ( state == sStart ) {
663 // clear the entered number on the first press 715 // clear the entered number on the first press
664 state = sNewNumber; 716 state = sNewNumber;
665 num = acc = 0; 717 num = acc = 0;
666 flPoint = FALSE; 718 flPoint = FALSE;
667 LCD->display( 0 ); 719 LCD->display( 0 );
668 fake = QString::null; 720 fake = QString::null;
669 numDecimals = 0; 721 numDecimals = 0;
670 } else { 722 } else {
671 clear(); 723 clear();
672 } 724 }
673 break; 725 break;
674 }; 726 };
675 727
676} 728}
diff --git a/noncore/tools/calculator/calculatorimpl.h b/noncore/tools/calculator/calculatorimpl.h
index f0180c9..06ec829 100644
--- a/noncore/tools/calculator/calculatorimpl.h
+++ b/noncore/tools/calculator/calculatorimpl.h
@@ -1,137 +1,139 @@
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#ifndef CALCULATORIMPL_H 20#ifndef CALCULATORIMPL_H
21#define CALCULATORIMPL_H 21#define CALCULATORIMPL_H
22 22
23 23
24#include <qlcdnumber.h> 24#include <qlcdnumber.h>
25#include "calculator.h" 25#include "calculator.h"
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qvaluestack.h> 28#include <qvaluestack.h>
29 29
30// mode x functions 30// mode x functions
31enum Operation { 31enum Operation {
32 oNop, 32 oNop,
33 oOpenBrace, 33 oOpenBrace,
34 oCloseBrace, 34 oCloseBrace,
35 oSum, 35 oSum,
36 oPoint, 36 oPoint,
37 oAdd, 37 oAdd,
38 oSub, 38 oSub,
39 oDiv, 39 oDiv,
40 oMult, 40 oMult,
41 41
42// mode 0 functions 42// mode 0 functions
43 oSin, 43 oSin,
44 oCos, 44 oCos,
45 oTan, 45 oTan,
46 oDivX, 46 oDivX,
47 oPercent, 47 oPercent,
48 oXsquared, 48 oXsquared,
49 oRoot, 49 oRoot,
50 oLog, 50 oLog,
51 oLn, 51 oLn,
52 oChSign 52 oChSign
53}; 53};
54 54
55// states 55// states
56#define sStart 0 56#define sStart 0
57#define sNewNumber 1 57#define sNewNumber 1
58#define sError 2 58#define sError 2
59 59
60struct Op 60struct Op
61{ 61{
62 Op() { number = 0; operation = oNop; } 62 Op() { number = 0; operation = oNop; }
63 Op( double num, Operation op ) 63 Op( double num, Operation op )
64 { number = num; operation = op; } 64 { number = num; operation = op; }
65 double number; 65 double number;
66 Operation operation; 66 Operation operation;
67}; 67};
68 68
69class QLabel; 69class QLabel;
70class CalculatorImpl : public Calculator 70class CalculatorImpl : public Calculator
71{ 71{
72 Q_OBJECT 72 Q_OBJECT
73 73
74public: 74public:
75 CalculatorImpl( QWidget * parent = 0, const char * name = 0, 75 CalculatorImpl( QWidget * parent = 0, const char * name = 0,
76 WFlags f = 0 ); 76 WFlags f = 0 );
77 static QString appName() { return QString::fromLatin1("calculator"); }
78
77 79
78public slots: 80public slots:
79 void command_buttons(int); 81 void command_buttons(int);
80 void enterNumber(int i); 82 void enterNumber(int i);
81 void std_buttons(int); 83 void std_buttons(int);
82 void std_funcs(int); 84 void std_funcs(int);
83 void do_convert(int); 85 void do_convert(int);
84 void function_button(int); 86 void function_button(int);
85 87
86protected: 88protected:
87 virtual bool eventFilter( QObject *o, QEvent *e ); 89 virtual bool eventFilter( QObject *o, QEvent *e );
88 90
89private: 91private:
90 void clear(); 92 void clear();
91 93
92 void reset_conv(); 94 void reset_conv();
93 95
94 void processStack( int op ); 96 void processStack( int op );
95 97
96 QValueStack<Op> operationStack; 98 QValueStack<Op> operationStack;
97 int state; 99 int state;
98 100
99 double acc, num, mem; 101 double acc, num, mem;
100 int numDecimals; 102 int numDecimals;
101 bool flPoint; 103 bool flPoint;
102 int numOpenBraces; 104 int numOpenBraces;
103 105
104 void execOp( Operation i ); 106 void execOp( Operation i );
105 double evalExpr( int op ); 107 double evalExpr( int op );
106 QLabel * memMark; 108 QLabel * memMark;
107 QString fake; 109 QString fake;
108 110
109 // useful values for conversion stuff 111 // useful values for conversion stuff
110 int current_mode, max_mode, conversion_mode_count, last_conversion; 112 int current_mode, max_mode, conversion_mode_count, last_conversion;
111 113
112 // make adding new modes easier for ourselves 114 // make adding new modes easier for ourselves
113 static const int pre_conv_modes_count = 1; 115 static const int pre_conv_modes_count = 1;
114 static const int post_conv_modes_count = 0; 116 static const int post_conv_modes_count = 0;
115 117
116 // an array of pointers to the func buttons 118 // an array of pointers to the func buttons
117 static const int func_button_count = 12; 119 static const int func_button_count = 12;
118 // this is an abomination 120 // this is an abomination
119 static const int changeable_func_button_count = 10; 121 static const int changeable_func_button_count = 10;
120 QPushButton* func_buttons[func_button_count]; 122 QPushButton* func_buttons[func_button_count];
121 123
122 QButtonGroup bgr_function, bgr_digits, bgr_std, bgr_command; 124 QButtonGroup bgr_function, bgr_digits, bgr_std, bgr_command;
123 QStringList faces, captions; 125 QStringList faces, captions;
124 126
125 // an array of doubles holding the conversion ratios 127 // an array of doubles holding the conversion ratios
126 double* entry_list; 128 double* entry_list;
127 double* preoffset_list; 129 double* preoffset_list;
128 double* postoffset_list; 130 double* postoffset_list;
129 131
130 QPixmap xtopowerofy; 132 QPixmap xtopowerofy;
131 QPixmap ythrootofx; 133 QPixmap ythrootofx;
132 QPixmap oneoverx; 134 QPixmap oneoverx;
133 135
134 void display_pixmap_faces(void); 136 void display_pixmap_faces(void);
135}; 137};
136 138
137#endif 139#endif
diff --git a/noncore/tools/calculator/main.cpp b/noncore/tools/calculator/main.cpp
index 74cd5d3..c4d00b1 100644
--- a/noncore/tools/calculator/main.cpp
+++ b/noncore/tools/calculator/main.cpp
@@ -1,35 +1,26 @@
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#include "calculatorimpl.h" 21#include "calculatorimpl.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25int main( int argc, char ** argv ) 26OPIE_EXPORT_APP( OApplicationFactory<CalculatorImpl> )
26{
27 QPEApplication a( argc, argv );
28
29 CalculatorImpl mw;
30 QPEApplication::setInputMethodHint( &mw, QPEApplication::AlwaysOff );
31 mw.setCaption( CalculatorImpl::tr("Calculator") );
32 a.showMainWidget( &mw );
33
34 return a.exec();
35}
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index fa12b61..00d097d 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -1,109 +1,112 @@
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#ifndef CLOCK_H 20#ifndef CLOCK_H
21#define CLOCK_H 21#define CLOCK_H
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qvbox.h> 24#include <qvbox.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26 26
27class QLCDNumber; 27class QLCDNumber;
28class QLabel; 28class QLabel;
29class QTimer; 29class QTimer;
30class QRadioButton; 30class QRadioButton;
31class QPushButton; 31class QPushButton;
32class QDateTime; 32class QDateTime;
33 33
34class AnalogClock : public QFrame 34class AnalogClock : public QFrame
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38public: 38public:
39 AnalogClock( QWidget * parent = 0, const char * name = 0 ); 39 AnalogClock( QWidget * parent = 0, const char * name = 0 );
40 40
41 QSizePolicy sizePolicy() const; 41 QSizePolicy sizePolicy() const;
42 42
43 void display( const QTime& time ); 43 void display( const QTime& time );
44 44
45
45protected: 46protected:
46 void drawContents( QPainter *p ); 47 void drawContents( QPainter *p );
47 48
48private: 49private:
49 50
50 QPixmap bg; 51 QPixmap bg;
51 QTime currTime; 52 QTime currTime;
52 QTime prevTime; 53 QTime prevTime;
53 bool clear; 54 bool clear;
54 55
55 QPoint rotate( QPoint center, QPoint p, int angle ); 56 QPoint rotate( QPoint center, QPoint p, int angle );
56 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); 57 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 );
57 58
58}; 59};
59 60
60class Clock : public QVBox 61class Clock : public QVBox
61{ 62{
62 Q_OBJECT 63 Q_OBJECT
63 64
64public: 65public:
65 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); 66 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 );
66 ~Clock(); 67 ~Clock();
67 QDateTime when; 68 QDateTime when;
68 bool bSound; 69 bool bSound;
69 int hour, minute, snoozeTime; 70 int hour, minute, snoozeTime;
71 static QString appName() { return QString::fromLatin1("clock"); }
72
70private slots: 73private slots:
71 void slotSet(); 74 void slotSet();
72 void slotReset(); 75 void slotReset();
73 void modeSelect(int); 76 void modeSelect(int);
74 void updateClock(); 77 void updateClock();
75 void changeClock( bool ); 78 void changeClock( bool );
76 void slotSetAlarm(); 79 void slotSetAlarm();
77 void slotSnooze(); 80 void slotSnooze();
78 void slotToggleAlarm(); 81 void slotToggleAlarm();
79 void alarmOn(); 82 void alarmOn();
80 void alarmOff(); 83 void alarmOff();
81 void appMessage(const QCString& msg, const QByteArray& data); 84 void appMessage(const QCString& msg, const QByteArray& data);
82 void timerEvent( QTimerEvent *e ); 85 void timerEvent( QTimerEvent *e );
83 void slotAdjustTime(); 86 void slotAdjustTime();
84 87
85 void slotStartTimer(); 88 void slotStartTimer();
86 void slotStopTimer(); 89 void slotStopTimer();
87 void slotResetTimer(); 90 void slotResetTimer();
88 void setSwatchMode( int ); 91 void setSwatchMode( int );
89private: 92private:
90 bool alarmBool; 93 bool alarmBool;
91 QTimer *t; 94 QTimer *t;
92 QLCDNumber *lcd; 95 QLCDNumber *lcd;
93 QLabel *date; 96 QLabel *date;
94 QLabel *ampmLabel; 97 QLabel *ampmLabel;
95 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; 98 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn;
96 QRadioButton *clockRB, *swatchRB; 99 QRadioButton *clockRB, *swatchRB;
97 AnalogClock *aclock; 100 AnalogClock *aclock;
98 QTime swatch_start; 101 QTime swatch_start;
99 int swatch_totalms; 102 int swatch_totalms;
100 bool swatch_running; 103 bool swatch_running;
101 bool ampm; 104 bool ampm;
102 void clearClock(); 105 void clearClock();
103 void clearTimer(); 106 void clearTimer();
104 void startSWatch(); 107 void startSWatch();
105 void stopSWatch(); 108 void stopSWatch();
106}; 109};
107 110
108#endif 111#endif
109 112
diff --git a/noncore/tools/clock/clock.pro b/noncore/tools/clock/clock.pro
index 38ce2f8..9890b3a 100644
--- a/noncore/tools/clock/clock.pro
+++ b/noncore/tools/clock/clock.pro
@@ -1,33 +1,30 @@
1TEMPLATE = app 1CONFIG = qt warn_on release quick-app
2CONFIG = qt warn_on release
3DESTDIR = $(OPIEDIR)/bin
4HEADERS = clock.h setAlarm.h 2HEADERS = clock.h setAlarm.h
5SOURCES = clock.cpp setAlarm.cpp \ 3SOURCES = clock.cpp setAlarm.cpp \
6 main.cpp 4 main.cpp
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopie -lpthread 7LIBS += -lqpe -lopie -lpthread
10INTERFACES =
11TARGET = clock 8TARGET = clock
12 9
13TRANSLATIONS = ../../../i18n/de/clock.ts \ 10TRANSLATIONS = ../../../i18n/de/clock.ts \
14 ../../../i18n/nl/clock.ts \ 11 ../../../i18n/nl/clock.ts \
15 ../../../i18n/xx/clock.ts \ 12 ../../../i18n/xx/clock.ts \
16 ../../../i18n/en/clock.ts \ 13 ../../../i18n/en/clock.ts \
17 ../../../i18n/es/clock.ts \ 14 ../../../i18n/es/clock.ts \
18 ../../../i18n/fr/clock.ts \ 15 ../../../i18n/fr/clock.ts \
19 ../../../i18n/hu/clock.ts \ 16 ../../../i18n/hu/clock.ts \
20 ../../../i18n/ja/clock.ts \ 17 ../../../i18n/ja/clock.ts \
21 ../../../i18n/ko/clock.ts \ 18 ../../../i18n/ko/clock.ts \
22 ../../../i18n/no/clock.ts \ 19 ../../../i18n/no/clock.ts \
23 ../../../i18n/pl/clock.ts \ 20 ../../../i18n/pl/clock.ts \
24 ../../../i18n/pt/clock.ts \ 21 ../../../i18n/pt/clock.ts \
25 ../../../i18n/pt_BR/clock.ts \ 22 ../../../i18n/pt_BR/clock.ts \
26 ../../../i18n/sl/clock.ts \ 23 ../../../i18n/sl/clock.ts \
27 ../../../i18n/zh_CN/clock.ts \ 24 ../../../i18n/zh_CN/clock.ts \
28 ../../../i18n/zh_TW/clock.ts \ 25 ../../../i18n/zh_TW/clock.ts \
29 ../../../i18n/da/clock.ts 26 ../../../i18n/da/clock.ts
30 27
31 28
32 29
33include ( $(OPIEDIR)/include.pro ) 30include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/tools/clock/main.cpp b/noncore/tools/clock/main.cpp
index cbfb73b..4a5e523 100644
--- a/noncore/tools/clock/main.cpp
+++ b/noncore/tools/clock/main.cpp
@@ -1,34 +1,27 @@
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#include "clock.h" 21#include "clock.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25int main( int argc, char ** argv )
26{
27 QPEApplication a( argc, argv );
28 26
29 Clock mw; 27OPIE_EXPORT_APP( OApplicationFactory<Clock> )
30 mw.setCaption( Clock::tr("Clock") );
31 a.showMainWidget( &mw );
32
33 return a.exec();
34}
diff --git a/noncore/tools/euroconv/euroconv.pro b/noncore/tools/euroconv/euroconv.pro
index d817dd3..2b732da 100644
--- a/noncore/tools/euroconv/euroconv.pro
+++ b/noncore/tools/euroconv/euroconv.pro
@@ -1,14 +1,13 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on release
3 HEADERS = calcdisplay.h \ 2 HEADERS = calcdisplay.h \
4 calckeypad.h 3 calckeypad.h
5 SOURCES = calcdisplay.cpp \ 4 SOURCES = calcdisplay.cpp \
6 calckeypad.cpp \ 5 calckeypad.cpp \
7 main.cpp 6 main.cpp
8INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
9DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
10LIBS += -lqpe -lopie 9LIBS += -lqpe -lopie
11 DESTDIR = $(OPIEDIR)/bin
12 INTERFACES= 10 INTERFACES=
13TARGET = euroconv 11TARGET = euroconv
12
14include ( $(OPIEDIR)/include.pro ) 13include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/tools/euroconv/main.cpp b/noncore/tools/euroconv/main.cpp
index 7d69535..b765a5e 100644
--- a/noncore/tools/euroconv/main.cpp
+++ b/noncore/tools/euroconv/main.cpp
@@ -1,39 +1,37 @@
1/**************************************************************************** 1/****************************************************************************
2 * 2 *
3 * File: main.cpp 3 * File: main.cpp
4 * 4 *
5 * Description: main file for OPIE Euroconv aapp 5 * Description: main file for OPIE Euroconv aapp
6 * 6 *
7 * 7 *
8 * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> 8 * Authors: Eric Santonacci <Eric.Santonacci@talc.fr>
9 * 9 *
10 * Requirements: Qt 10 * Requirements: Qt
11 * 11 *
12 * $Id$
13 * 12 *
14 ***************************************************************************/ 13 ***************************************************************************/
15 14
16#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
17#include <qvbox.h> 16#include <qvbox.h>
18//#include <qapplication.h>
19 17
20#include "calcdisplay.h" 18#include "calcdisplay.h"
21#include "calckeypad.h" 19#include "calckeypad.h"
22 20
21#include <opie/oapplicationfactory.h>
23 22
24 23struct Layout : QVBox{
25int main( int argc, char **argv ) { 24 static QString appName() { return QString::fromLatin1("euroconv"); }
26 25 Layout(QWidget *p, const char* n, WFlags)
27 QPEApplication app( argc, argv ); 26 :QVBox(0,"fond" )
28 27 {
29 QVBox *layout = new QVBox(0, "fond"); 28 LCDDisplay *lcd = new LCDDisplay(this, "lcd");
29 KeyPad *num = new KeyPad(lcd, this, "keypad");
30 30
31 LCDDisplay lcd (layout, "lcd"); 31 setCaption( QObject::tr("Euroconv") );
32 KeyPad num(&lcd, layout, "keypad"); 32 };
33 app.setMainWidget(layout); 33
34 layout->setCaption( QObject::tr("Euroconv") ); 34};
35 layout->showMaximized (); 35
36 layout->show(); 36OPIE_EXPORT_APP( OApplicationFactory<Layout> )
37 return app.exec();
38}
39 37
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 49f6355..a8dd11c 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -1,569 +1,569 @@
1/**************************************************************************** 1/****************************************************************************
2 ** formatter.cpp 2 ** formatter.cpp
3 ** 3 **
4 ** Copyright: Thu Apr 11 11:01:13 2002 4 ** Copyright: Thu Apr 11 11:01:13 2002
5 ** by: L. J. Potter 5 ** by: L. J. Potter
6 ** 6 **
7 ****************************************************************************/ 7 ****************************************************************************/
8 8
9#include "formatter.h" 9#include "formatter.h"
10#include "inputDialog.h" 10#include "inputDialog.h"
11#include "output.h" 11#include "output.h"
12 12
13#include <qpe/qpemenubar.h> 13#include <qpe/qpemenubar.h>
14#include <qpe/qpetoolbar.h> 14#include <qpe/qpetoolbar.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/mimetype.h> 18#include <qpe/mimetype.h>
19#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
20#include <qpe/storage.h> 20#include <qpe/storage.h>
21 21
22#include <qmultilineedit.h> 22#include <qmultilineedit.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qlist.h> 24#include <qlist.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26#include <qdir.h> 26#include <qdir.h>
27#include <qfile.h> 27#include <qfile.h>
28 28
29#include <qtstream.h> 29#include <qtstream.h>
30 30
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qregexp.h> 34#include <qregexp.h>
35 35
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qvariant.h> 42#include <qvariant.h>
43 43
44#include <unistd.h> 44#include <unistd.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <sys/vfs.h> 47#include <sys/vfs.h>
48#include <mntent.h> 48#include <mntent.h>
49#include <string.h> 49#include <string.h>
50#include <errno.h> 50#include <errno.h>
51 51
52#define BLANK ' ' 52#define BLANK ' '
53#define DELIMITER '#' 53#define DELIMITER '#'
54 54
55/* 55/*
56 Blah blah blah blah */ 56 Blah blah blah blah */
57FormatterApp::FormatterApp( QWidget* parent, const char* name, bool , WFlags fl ) 57FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool modal )
58 : QMainWindow( parent, name, fl ) 58 : QMainWindow( parent, name, fl )
59// : QDialog( parent, name, modal, fl ) 59// : QDialog( parent, name, modal, fl )
60{ 60{
61 if ( !name ) 61 if ( !name )
62 setName( "FormatterApp" ); 62 setName( "FormatterApp" );
63 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 63 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
64 64
65 setCaption( tr( "Formatter" ) ); 65 setCaption( tr( "Formatter" ) );
66 FormatterAppLayout = new QGridLayout( this ); 66 FormatterAppLayout = new QGridLayout( this );
67 FormatterAppLayout->setSpacing( 2); 67 FormatterAppLayout->setSpacing( 2);
68 FormatterAppLayout->setMargin( 2 ); 68 FormatterAppLayout->setMargin( 2 );
69 69
70 TabWidget = new QTabWidget( this, "TabWidget" ); 70 TabWidget = new QTabWidget( this, "TabWidget" );
71 71
72 tab = new QWidget( TabWidget, "tab" ); 72 tab = new QWidget( TabWidget, "tab" );
73 tabLayout = new QGridLayout( tab ); 73 tabLayout = new QGridLayout( tab );
74 tabLayout->setSpacing( 3); 74 tabLayout->setSpacing( 3);
75 tabLayout->setMargin( 2); 75 tabLayout->setMargin( 2);
76 76
77 storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); 77 storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" );
78 storageComboBox->setMaximumWidth(220); 78 storageComboBox->setMaximumWidth(220);
79 79
80 tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1); 80 tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1);
81 81
82 TextLabel4 = new QLabel( tab, "TextLabel4" ); 82 TextLabel4 = new QLabel( tab, "TextLabel4" );
83 TextLabel4->setText( tr( "Storage Type" ) ); 83 TextLabel4->setText( tr( "Storage Type" ) );
84 84
85 tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1); 85 tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1);
86 86
87 TextLabel2 = new QLabel( tab, "TextLabel2" ); 87 TextLabel2 = new QLabel( tab, "TextLabel2" );
88 TextLabel2->setText( tr( "File Systems" ) ); 88 TextLabel2->setText( tr( "File Systems" ) );
89 89
90 tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1); 90 tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1);
91 91
92 fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); 92 fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" );
93 fileSystemsCombo->setMaximumWidth(220); 93 fileSystemsCombo->setMaximumWidth(220);
94 94
95 tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1); 95 tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1);
96 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); 96 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
97 tabLayout->addItem( spacer, 2, 0 ); 97 tabLayout->addItem( spacer, 2, 0 );
98 98
99 formatPushButton = new QPushButton( tab, "formatPushButton" ); 99 formatPushButton = new QPushButton( tab, "formatPushButton" );
100 formatPushButton->setText( tr( "Format" ) ); 100 formatPushButton->setText( tr( "Format" ) );
101 formatPushButton->setMaximumWidth(170); 101 formatPushButton->setMaximumWidth(170);
102 102
103 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1); 103 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1);
104 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); 104 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
105 tabLayout->addItem( spacer_2, 5, 0 ); 105 tabLayout->addItem( spacer_2, 5, 0 );
106 106
107 TabWidget->insertTab( tab, tr( "Main" ) ); 107 TabWidget->insertTab( tab, tr( "Main" ) );
108 108
109 tab_2 = new QWidget( TabWidget, "tab_2" ); 109 tab_2 = new QWidget( TabWidget, "tab_2" );
110 tabLayout_2 = new QGridLayout( tab_2 ); 110 tabLayout_2 = new QGridLayout( tab_2 );
111 tabLayout_2->setSpacing(3); 111 tabLayout_2->setSpacing(3);
112 tabLayout_2->setMargin(2); 112 tabLayout_2->setMargin(2);
113 113
114 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); 114 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" );
115 115
116 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1); 116 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1);
117 117
118 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); 118 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" );
119 119
120 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1); 120 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1);
121 121
122 TextLabel5 = new QLabel( tab_2, "TextLabel5" ); 122 TextLabel5 = new QLabel( tab_2, "TextLabel5" );
123 TextLabel5->setText( tr( "CAUTION:\n" 123 TextLabel5->setText( tr( "CAUTION:\n"
124 "Changing parameters on this\n" 124 "Changing parameters on this\n"
125 "page may cause your system\n" 125 "page may cause your system\n"
126 "to stop functioning properly!" ) );//idiot message 126 "to stop functioning properly!" ) );//idiot message
127 127
128 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1); 128 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1);
129 129
130 editPushButton = new QPushButton( tab_2, "editPushButton" ); 130 editPushButton = new QPushButton( tab_2, "editPushButton" );
131 editPushButton->setText( tr( "Edit fstab" ) ); 131 editPushButton->setText( tr( "Edit fstab" ) );
132 editPushButton->setMaximumWidth(100); 132 editPushButton->setMaximumWidth(100);
133 133
134 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); 134 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 );
135 135
136 fsckButton = new QPushButton( tab_2, "fsckPushButton" ); 136 fsckButton = new QPushButton( tab_2, "fsckPushButton" );
137 fsckButton->setText( tr( "Check Disk" ) ); 137 fsckButton->setText( tr( "Check Disk" ) );
138 fsckButton->setMaximumWidth(100); 138 fsckButton->setMaximumWidth(100);
139 139
140 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1); 140 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1);
141 141
142 TextLabel3 = new QLabel( tab_2, "TextLabel3" ); 142 TextLabel3 = new QLabel( tab_2, "TextLabel3" );
143 TextLabel3->setText( tr( "Device" ) ); 143 TextLabel3->setText( tr( "Device" ) );
144 144
145 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); 145 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 );
146 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 146 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
147 tabLayout_2->addItem( spacer_3, 5, 0 ); 147 tabLayout_2->addItem( spacer_3, 5, 0 );
148 148
149 TextLabel1 = new QLabel( tab_2, "TextLabel1" ); 149 TextLabel1 = new QLabel( tab_2, "TextLabel1" );
150 TextLabel1->setText( tr( "Mount Point" ) ); 150 TextLabel1->setText( tr( "Mount Point" ) );
151 151
152 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); 152 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 );
153 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 153 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
154 tabLayout_2->addItem( spacer_4, 2, 1 ); 154 tabLayout_2->addItem( spacer_4, 2, 1 );
155 TabWidget->insertTab( tab_2, tr( "Advanced" ) ); 155 TabWidget->insertTab( tab_2, tr( "Advanced" ) );
156 156
157 FormatterAppLayout->addWidget( TabWidget, 0, 1 ); 157 FormatterAppLayout->addWidget( TabWidget, 0, 1 );
158 158
159 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); 159 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) );
160 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); 160 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) );
161 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); 161 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) );
162 162
163 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); 163 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) ));
164 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); 164 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) ));
165 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); 165 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) ));
166 166
167 167
168 fillCombos(); 168 fillCombos();
169} 169}
170 170
171FormatterApp::~FormatterApp() { 171FormatterApp::~FormatterApp() {
172 172
173} 173}
174 174
175void FormatterApp::doFormat() { 175void FormatterApp::doFormat() {
176 int err=0; 176 int err=0;
177 Output *outDlg; 177 Output *outDlg;
178 QString umountS, remountS; 178 QString umountS, remountS;
179 QString text = storageComboBox->currentText(); 179 QString text = storageComboBox->currentText();
180 QString currentText = storageComboBox->currentText(); 180 QString currentText = storageComboBox->currentText();
181 QString cmd; 181 QString cmd;
182 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 182 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
183 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); 183 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE));
184 QString fs = fileSystemsCombo->currentText(); 184 QString fs = fileSystemsCombo->currentText();
185 185
186#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // lets test on something cheap 186#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // lets test on something cheap
187#else 187#else
188 currentText = diskDevice = "/dev/fd0"; 188 currentText = diskDevice = "/dev/fd0";
189 umountS = "umount -v /floppy 2>&1"; 189 umountS = "umount -v /floppy 2>&1";
190 remountS = "mount -v /floppy 2>&1"; 190 remountS = "mount -v /floppy 2>&1";
191#endif 191#endif
192 192
193 if( currentText.find("CF",0,TRUE) != -1) { 193 if( currentText.find("CF",0,TRUE) != -1) {
194 umountS = "umount "; 194 umountS = "umount ";
195 remountS = "mount "; 195 remountS = "mount ";
196 196
197// umountS = "/sbin/cardctl eject"; 197// umountS = "/sbin/cardctl eject";
198// remountS = "/sbin/cardctl insert"; 198// remountS = "/sbin/cardctl insert";
199 } 199 }
200 if( currentText.find("SD",0,TRUE) != -1) { 200 if( currentText.find("SD",0,TRUE) != -1) {
201 umountS = "umount "; 201 umountS = "umount ";
202 remountS = "mount "; 202 remountS = "mount ";
203// umountS = "/etc/sdcontrol compeject"; 203// umountS = "/etc/sdcontrol compeject";
204// remountS = "/etc/sdcontrol insert"; 204// remountS = "/etc/sdcontrol insert";
205 } 205 }
206 206
207 switch ( QMessageBox::warning(this,tr("Format?") 207 switch ( QMessageBox::warning(this,tr("Format?")
208 , tr("Really format\n") +diskName+" "+ currentText + 208 , tr("Really format\n") +diskName+" "+ currentText +
209 tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs ) 209 tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs )
210 ,tr("Yes") 210 ,tr("Yes")
211 ,tr("No") 211 ,tr("No")
212 ,0 212 ,0
213 ,1 213 ,1
214 ,1) ) { 214 ,1) ) {
215 case 0: { 215 case 0: {
216 if(fs == "vfat") 216 if(fs == "vfat")
217 cmd = "mkdosfs -v " + diskDevice+" 2>&1"; 217 cmd = "mkdosfs -v " + diskDevice+" 2>&1";
218 else if(fs == "ext2") 218 else if(fs == "ext2")
219 cmd = "mke2fs -v " + diskDevice+" 2>&1"; 219 cmd = "mke2fs -v " + diskDevice+" 2>&1";
220 else { 220 else {
221 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); 221 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok"));
222 break; 222 break;
223 } 223 }
224// cmd = "ls -l"; 224// cmd = "ls -l";
225 outDlg = new Output(this, tr("Formatter Output"),FALSE); 225 outDlg = new Output(this, tr("Formatter Output"),FALSE);
226 outDlg->showMaximized(); 226 outDlg->showMaximized();
227 outDlg->show(); 227 outDlg->show();
228 qApp->processEvents(); 228 qApp->processEvents();
229 FILE *fp; 229 FILE *fp;
230 char line[130]; 230 char line[130];
231 231
232 232
233 outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); 233 outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) );
234 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 234 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
235 235
236 sleep(1); 236 sleep(1);
237 qDebug("Command is "+umountS); 237 qDebug("Command is "+umountS);
238 fp = popen( (const char *) umountS, "r"); 238 fp = popen( (const char *) umountS, "r");
239 // qDebug("%d", fp); 239 // qDebug("%d", fp);
240 if ( !fp ) { 240 if ( !fp ) {
241 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); 241 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err);
242 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); 242 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
243 pclose(fp); 243 pclose(fp);
244 return; 244 return;
245 } else { 245 } else {
246// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 246// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
247// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 247// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
248 while ( fgets( line, sizeof line, fp)) { 248 while ( fgets( line, sizeof line, fp)) {
249 if( ((QString)line).find("busy",0,TRUE) != -1) { 249 if( ((QString)line).find("busy",0,TRUE) != -1) {
250 qDebug("Could not find '" + umountS); 250 qDebug("Could not find '" + umountS);
251 QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); 251 QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") );
252 pclose(fp); 252 pclose(fp);
253 return; 253 return;
254 } else { 254 } else {
255 QString lineStr = line; 255 QString lineStr = line;
256 lineStr=lineStr.left(lineStr.length()-1); 256 lineStr=lineStr.left(lineStr.length()-1);
257 outDlg->OutputEdit->append(lineStr); 257 outDlg->OutputEdit->append(lineStr);
258 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 258 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
259 } 259 }
260 } 260 }
261 } 261 }
262 pclose(fp); 262 pclose(fp);
263 263
264 qDebug("Command would be: "+cmd); 264 qDebug("Command would be: "+cmd);
265 outDlg->OutputEdit->append( tr("Trying to format.") ); 265 outDlg->OutputEdit->append( tr("Trying to format.") );
266 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 266 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
267 267
268 fp = popen( (const char *) cmd, "r"); 268 fp = popen( (const char *) cmd, "r");
269 while ( fgets( line, sizeof line, fp)) { 269 while ( fgets( line, sizeof line, fp)) {
270 if( ((QString)line).find("No such device",0,TRUE) != -1) { 270 if( ((QString)line).find("No such device",0,TRUE) != -1) {
271 qDebug("No such device '" + umountS); 271 qDebug("No such device '" + umountS);
272 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); 272 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") );
273 pclose(fp); 273 pclose(fp);
274// outDlg->OutputEdit->append("No such device"); 274// outDlg->OutputEdit->append("No such device");
275// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 275// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
276 return; 276 return;
277 } else { 277 } else {
278 QString lineStr = line; 278 QString lineStr = line;
279 lineStr=lineStr.left(lineStr.length()-1); 279 lineStr=lineStr.left(lineStr.length()-1);
280 outDlg->OutputEdit->append(lineStr); 280 outDlg->OutputEdit->append(lineStr);
281 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 281 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
282 } 282 }
283 } 283 }
284 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 284 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
285 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 285 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
286 pclose(fp); 286 pclose(fp);
287 287
288 outDlg->OutputEdit->append( tr("Trying to mount %1.").arg( currentText) ); 288 outDlg->OutputEdit->append( tr("Trying to mount %1.").arg( currentText) );
289 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 289 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
290 fp = popen( (const char *) remountS, "r"); 290 fp = popen( (const char *) remountS, "r");
291 if ( !fp) { 291 if ( !fp) {
292 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); 292 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err);
293 QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); 293 QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") );
294 294
295 } else { 295 } else {
296 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText )); 296 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText ));
297 while ( fgets( line, sizeof line, fp)) { 297 while ( fgets( line, sizeof line, fp)) {
298 QString lineStr = line; 298 QString lineStr = line;
299 lineStr=lineStr.left(lineStr.length()-1); 299 lineStr=lineStr.left(lineStr.length()-1);
300 outDlg->OutputEdit->append(lineStr); 300 outDlg->OutputEdit->append(lineStr);
301 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 301 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
302 } 302 }
303 } 303 }
304 pclose(fp); 304 pclose(fp);
305 sleep(1); 305 sleep(1);
306 306
307 outDlg->OutputEdit->append(tr("You can now close the output window.")); 307 outDlg->OutputEdit->append(tr("You can now close the output window."));
308 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 308 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
309// outDlg->close(); 309// outDlg->close();
310// if(outDlg) 310// if(outDlg)
311// delete outDlg; 311// delete outDlg;
312 } 312 }
313 break; 313 break;
314 }; 314 };
315} 315}
316 316
317bool FormatterApp::doFdisk() { 317bool FormatterApp::doFdisk() {
318 return FALSE; 318 return FALSE;
319 319
320} 320}
321 321
322void FormatterApp::fillCombos() { 322void FormatterApp::fillCombos() {
323 323
324 StorageInfo storageInfo; 324 StorageInfo storageInfo;
325 const QList<FileSystem> &fs = storageInfo.fileSystems(); 325 const QList<FileSystem> &fs = storageInfo.fileSystems();
326 QListIterator<FileSystem> it ( fs ); 326 QListIterator<FileSystem> it ( fs );
327 QString storage; 327 QString storage;
328 for( ; it.current(); ++it ){ 328 for( ; it.current(); ++it ){
329 const QString name = (*it)->name(); 329 const QString name = (*it)->name();
330 const QString path = (*it)->path(); 330 const QString path = (*it)->path();
331 const QString disk = (*it)->disk(); 331 const QString disk = (*it)->disk();
332 const QString options = (*it)->options(); 332 const QString options = (*it)->options();
333 if( name.find( tr("Internal"),0,TRUE) == -1) { 333 if( name.find( tr("Internal"),0,TRUE) == -1) {
334 storageComboBox->insertItem(name +" -> "+disk); 334 storageComboBox->insertItem(name +" -> "+disk);
335 } 335 }
336// deviceComboBox->insertItem(disk); 336// deviceComboBox->insertItem(disk);
337 } 337 }
338 parsetab("/etc/mtab"); 338 parsetab("/etc/mtab");
339// parsetab("/etc/fstab"); 339// parsetab("/etc/fstab");
340 fileSystemsCombo->insertStringList( fsList,-1); 340 fileSystemsCombo->insertStringList( fsList,-1);
341 deviceComboBox->insertStringList( deviceList,-1); 341 deviceComboBox->insertStringList( deviceList,-1);
342 storageComboSelected(0); 342 storageComboSelected(0);
343 deviceComboSelected(0); 343 deviceComboSelected(0);
344} 344}
345 345
346 346
347void FormatterApp::fsComboSelected(int ) { 347void FormatterApp::fsComboSelected(int ) {
348 348
349} 349}
350 350
351void FormatterApp::storageComboSelected(int index ) { 351void FormatterApp::storageComboSelected(int index ) {
352 352
353 QString currentText = storageComboBox->text(index); 353 QString currentText = storageComboBox->text(index);
354 QString nameS = currentText.left( currentText.find("->",0,TRUE)); 354 QString nameS = currentText.left( currentText.find("->",0,TRUE));
355 355
356 TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) ); 356 TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) );
357 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 357 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
358 358
359 QString fsType = getFileSystemType((const QString &) currentText); 359 QString fsType = getFileSystemType((const QString &) currentText);
360// qDebug(fsType); 360// qDebug(fsType);
361 for(int i = 0; i < fileSystemsCombo->count(); i++) { 361 for(int i = 0; i < fileSystemsCombo->count(); i++) {
362 if( fsType == fileSystemsCombo->text(i)) 362 if( fsType == fileSystemsCombo->text(i))
363 fileSystemsCombo->setCurrentItem(i); 363 fileSystemsCombo->setCurrentItem(i);
364 } 364 }
365// deviceComboSelected(index); 365// deviceComboSelected(index);
366} 366}
367 367
368void FormatterApp::deviceComboSelected(int index) { 368void FormatterApp::deviceComboSelected(int index) {
369 369
370 StorageInfo storageInfo; 370 StorageInfo storageInfo;
371 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; 371 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText;
372 372
373 selectedText = deviceComboBox->text(index); 373 selectedText = deviceComboBox->text(index);
374 374
375 const QList<FileSystem> &fs = storageInfo.fileSystems(); 375 const QList<FileSystem> &fs = storageInfo.fileSystems();
376 QListIterator<FileSystem> it ( fs ); 376 QListIterator<FileSystem> it ( fs );
377 QString storage; 377 QString storage;
378 for( ; it.current(); ++it ){ 378 for( ; it.current(); ++it ){
379 const QString name = (*it)->name(); 379 const QString name = (*it)->name();
380 const QString path = (*it)->path(); 380 const QString path = (*it)->path();
381 const QString disk = (*it)->disk(); 381 const QString disk = (*it)->disk();
382// const QString options = (*it)->options(); 382// const QString options = (*it)->options();
383 if( selectedText == disk) { 383 if( selectedText == disk) {
384 diskS = disk; nameS= name; 384 diskS = disk; nameS= name;
385 mountPointLineEdit->setText(path); 385 mountPointLineEdit->setText(path);
386 long mult = (*it)->blockSize() / 1024; 386 long mult = (*it)->blockSize() / 1024;
387 long div = 1024 / (*it)->blockSize(); 387 long div = 1024 / (*it)->blockSize();
388 if ( !mult ) mult = 1; 388 if ( !mult ) mult = 1;
389 if ( !div ) div = 1; 389 if ( !div ) div = 1;
390 long total = (*it)->totalBlocks() * mult / div; 390 long total = (*it)->totalBlocks() * mult / div;
391 long totalMb = total/1024; 391 long totalMb = total/1024;
392 long avail = (*it)->availBlocks() * mult / div; 392 long avail = (*it)->availBlocks() * mult / div;
393 long availMb = avail/1024; 393 long availMb = avail/1024;
394 long used = total - avail; 394 long used = total - avail;
395 long usedMb = used/1024; 395 long usedMb = used/1024;
396 totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); 396 totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb );
397 usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); 397 usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb);
398 avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); 398 avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb );
399 } 399 }
400 } 400 }
401 fsType = getFileSystemType((const QString &)selectedText); 401 fsType = getFileSystemType((const QString &)selectedText);
402 402
403 TextLabel5->setText(tr("Type: %1\nFormatted with %2\n%3, %4, %5").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS )); 403 TextLabel5->setText(tr("Type: %1\nFormatted with %2\n%3, %4, %5").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS ));
404 TextLabel5->setTextFormat( Qt::RichText ); 404 TextLabel5->setTextFormat( Qt::RichText );
405// storageComboSelected(0); 405// storageComboSelected(0);
406} 406}
407 407
408void FormatterApp::cleanUp() { 408void FormatterApp::cleanUp() {
409 409
410} 410}
411 411
412 412
413void FormatterApp::editFstab() { 413void FormatterApp::editFstab() {
414 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); 414 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)");
415 e << (const QString &)"/etc/fstab"; 415 e << (const QString &)"/etc/fstab";
416} 416}
417 417
418void FormatterApp::parsetab(const QString &fileName) { 418void FormatterApp::parsetab(const QString &fileName) {
419 419
420 fileSystemTypeList.clear(); 420 fileSystemTypeList.clear();
421 fsList.clear(); 421 fsList.clear();
422 struct mntent *me; 422 struct mntent *me;
423// if(fileName == "/etc/mtab") { 423// if(fileName == "/etc/mtab") {
424 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 424 FILE *mntfp = setmntent( fileName.latin1(), "r" );
425 if ( mntfp ) { 425 if ( mntfp ) {
426 while ( (me = getmntent( mntfp )) != 0 ) { 426 while ( (me = getmntent( mntfp )) != 0 ) {
427 QString deviceName = me->mnt_fsname; 427 QString deviceName = me->mnt_fsname;
428 QString filesystemType = me->mnt_type; 428 QString filesystemType = me->mnt_type;
429 if(deviceName != "none") { 429 if(deviceName != "none") {
430 if( fsList.contains(filesystemType) == 0 430 if( fsList.contains(filesystemType) == 0
431 & filesystemType.find("proc",0,TRUE) == -1 431 & filesystemType.find("proc",0,TRUE) == -1
432 & filesystemType.find("cramfs",0,TRUE) == -1 432 & filesystemType.find("cramfs",0,TRUE) == -1
433 & filesystemType.find("auto",0,TRUE) == -1) 433 & filesystemType.find("auto",0,TRUE) == -1)
434 fsList << filesystemType; 434 fsList << filesystemType;
435 deviceList << deviceName; 435 deviceList << deviceName;
436 qDebug(deviceName+"::"+filesystemType); 436 qDebug(deviceName+"::"+filesystemType);
437 fileSystemTypeList << deviceName+"::"+filesystemType; 437 fileSystemTypeList << deviceName+"::"+filesystemType;
438 } 438 }
439 } 439 }
440 } 440 }
441 endmntent( mntfp ); 441 endmntent( mntfp );
442// } else if(fileName == "/etc/fstab") { 442// } else if(fileName == "/etc/fstab") {
443// QFile f("/etc/fstab"); 443// QFile f("/etc/fstab");
444// if ( f.open(IO_ReadOnly) ) { 444// if ( f.open(IO_ReadOnly) ) {
445// QTextStream t (&f); 445// QTextStream t (&f);
446// QString s; 446// QString s;
447// while (! t.eof()) { 447// while (! t.eof()) {
448// s=t.readLine(); 448// s=t.readLine();
449// s=s.simplifyWhiteSpace(); 449// s=s.simplifyWhiteSpace();
450// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { 450// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) {
451// // = me->mnt_fsname; 451// // = me->mnt_fsname;
452// QString filesystemType = me->mnt_type; 452// QString filesystemType = me->mnt_type;
453// QString deviceName = s.left(0,s.find(BLANK) ); 453// QString deviceName = s.left(0,s.find(BLANK) );
454// s=s.remove(0,s.find(BLANK)+1 ); // devicename 454// s=s.remove(0,s.find(BLANK)+1 ); // devicename
455 455
456// s=s.remove(0,s.find(BLANK)+1 ); // mountpoint 456// s=s.remove(0,s.find(BLANK)+1 ); // mountpoint
457// QStringt mountPoint= s.left(0,s.find(BLANK) ); 457// QStringt mountPoint= s.left(0,s.find(BLANK) );
458// s=s.remove(0,s.find(BLANK)+1 ); // fs 458// s=s.remove(0,s.find(BLANK)+1 ); // fs
459// QString filesystemType= s.left(0,s.find(BLANK) ); 459// QString filesystemType= s.left(0,s.find(BLANK) );
460// } 460// }
461// } 461// }
462// } 462// }
463// f.close(); 463// f.close();
464// } 464// }
465} 465}
466 466
467QString FormatterApp::getFileSystemType(const QString &currentText) { 467QString FormatterApp::getFileSystemType(const QString &currentText) {
468 468
469 parsetab("/etc/mtab"); //why did TT forget filesystem type? 469 parsetab("/etc/mtab"); //why did TT forget filesystem type?
470 470
471 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 471 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
472 QString temp = (*it); 472 QString temp = (*it);
473 if( temp.find( currentText,0,TRUE) != -1) { 473 if( temp.find( currentText,0,TRUE) != -1) {
474 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 474 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
475// qDebug(fsType); 475// qDebug(fsType);
476 } 476 }
477 } 477 }
478 return ""; 478 return "";
479} 479}
480 480
481bool FormatterApp::doFsck() { 481bool FormatterApp::doFsck() {
482 482
483 Output *outDlg; 483 Output *outDlg;
484 QString selectedDevice; 484 QString selectedDevice;
485// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 485// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
486 selectedDevice = deviceComboBox->currentText(); 486 selectedDevice = deviceComboBox->currentText();
487 QString mountPoint = mountPointLineEdit->text(); 487 QString mountPoint = mountPointLineEdit->text();
488 QString umountS = "umount -v "+mountPoint+" 2>&1"; 488 QString umountS = "umount -v "+mountPoint+" 2>&1";
489 QString remountS = "mount -v "+mountPoint+" 2>&1"; 489 QString remountS = "mount -v "+mountPoint+" 2>&1";
490// #else 490// #else
491// // for testing 491// // for testing
492// // currentText = diskDevice = "/dev/fd0"; 492// // currentText = diskDevice = "/dev/fd0";
493// QString umountS = "umount -v /floppy 2>&1"; 493// QString umountS = "umount -v /floppy 2>&1";
494// QString remountS = "mount -v /floppy 2>&1"; 494// QString remountS = "mount -v /floppy 2>&1";
495// selectedDevice ="/dev/fd0"; 495// selectedDevice ="/dev/fd0";
496 496
497// #endif 497// #endif
498 498
499 QString fsType = getFileSystemType((const QString &)selectedDevice); 499 QString fsType = getFileSystemType((const QString &)selectedDevice);
500 QString cmd; 500 QString cmd;
501 qDebug( selectedDevice +" "+ fsType); 501 qDebug( selectedDevice +" "+ fsType);
502 if(fsType == "vfat") cmd = "dosfsck -vy "; 502 if(fsType == "vfat") cmd = "dosfsck -vy ";
503 if(fsType == "ext2") cmd = "e2fsck -cpvy "; 503 if(fsType == "ext2") cmd = "e2fsck -cpvy ";
504 cmd += selectedDevice + " 2>&1"; 504 cmd += selectedDevice + " 2>&1";
505 505
506 outDlg = new Output(this, tr("Formatter Output"),FALSE); 506 outDlg = new Output(this, tr("Formatter Output"),FALSE);
507 outDlg->showMaximized(); 507 outDlg->showMaximized();
508 outDlg->show(); 508 outDlg->show();
509 qApp->processEvents(); 509 qApp->processEvents();
510 FILE *fp; 510 FILE *fp;
511 char line[130]; 511 char line[130];
512 outDlg->OutputEdit->append( tr("Trying to umount.")); 512 outDlg->OutputEdit->append( tr("Trying to umount."));
513 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 513 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
514 514
515 sleep(1); 515 sleep(1);
516// qDebug("Command is "+umountS); 516// qDebug("Command is "+umountS);
517 fp = popen( (const char *) umountS, "r"); 517 fp = popen( (const char *) umountS, "r");
518// qDebug("%d", fp); 518// qDebug("%d", fp);
519 if ( !fp ) { 519 if ( !fp ) {
520 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); 520 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno));
521 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); 521 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
522 pclose(fp); 522 pclose(fp);
523 return false; 523 return false;
524 } else { 524 } else {
525// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 525// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
526// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 526// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
527 while ( fgets( line, sizeof line, fp)) { 527 while ( fgets( line, sizeof line, fp)) {
528 if( ((QString)line).find("busy",0,TRUE) != -1) { 528 if( ((QString)line).find("busy",0,TRUE) != -1) {
529 qDebug("Could not find '" + umountS); 529 qDebug("Could not find '" + umountS);
530 QMessageBox::warning( this, tr("Formatter"), 530 QMessageBox::warning( this, tr("Formatter"),
531 tr("Could not umount.\nDevice is busy!"), tr("&OK") ); 531 tr("Could not umount.\nDevice is busy!"), tr("&OK") );
532 pclose(fp); 532 pclose(fp);
533 return false; 533 return false;
534 } else { 534 } else {
535 QString lineStr = line; 535 QString lineStr = line;
536 lineStr=lineStr.left(lineStr.length()-1); 536 lineStr=lineStr.left(lineStr.length()-1);
537 outDlg->OutputEdit->append(lineStr); 537 outDlg->OutputEdit->append(lineStr);
538 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 538 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
539 } 539 }
540 } 540 }
541 } 541 }
542 pclose(fp); 542 pclose(fp);
543///////////////////////////////////// 543/////////////////////////////////////
544 fp = popen( (const char *) cmd, "r"); 544 fp = popen( (const char *) cmd, "r");
545 while ( fgets( line, sizeof line, fp)) { 545 while ( fgets( line, sizeof line, fp)) {
546 if( ((QString)line).find("No such device",0,TRUE) != -1) { 546 if( ((QString)line).find("No such device",0,TRUE) != -1) {
547 qDebug("No such device '" + umountS); 547 qDebug("No such device '" + umountS);
548 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); 548 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") );
549 pclose(fp); 549 pclose(fp);
550// outDlg->OutputEdit->append("No such device"); 550// outDlg->OutputEdit->append("No such device");
551// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 551// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
552 return false; 552 return false;
553 } else { 553 } else {
554 QString lineStr = line; 554 QString lineStr = line;
555 lineStr=lineStr.left(lineStr.length()-1); 555 lineStr=lineStr.left(lineStr.length()-1);
556 outDlg->OutputEdit->append(lineStr); 556 outDlg->OutputEdit->append(lineStr);
557 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 557 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
558 } 558 }
559 } 559 }
560 outDlg->OutputEdit->append(tr("You can now close the output window.")); 560 outDlg->OutputEdit->append(tr("You can now close the output window."));
561 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 561 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
562// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 562// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
563// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 563// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
564 pclose(fp); 564 pclose(fp);
565 565
566///////////////////////////////////////// 566/////////////////////////////////////////
567 567
568 return true; 568 return true;
569} 569}
diff --git a/noncore/tools/formatter/formatter.h b/noncore/tools/formatter/formatter.h
index 960a68a..faf0b30 100644
--- a/noncore/tools/formatter/formatter.h
+++ b/noncore/tools/formatter/formatter.h
@@ -1,65 +1,66 @@
1/**************************************************************************** 1/****************************************************************************
2** formatter.h 2** formatter.h
3** 3**
4** Copyright: Thu Apr 11 11:01:01 2002 4** Copyright: Thu Apr 11 11:01:01 2002
5** by: L.J. Potter 5** by: L.J. Potter
6** 6**
7****************************************************************************/ 7****************************************************************************/
8 8
9#ifndef FORMATTERAPP_H 9#ifndef FORMATTERAPP_H
10#define FORMATTERAPP_H 10#define FORMATTERAPP_H
11 11
12#include <qvariant.h> 12#include <qvariant.h>
13//#include <qdialog.h> 13//#include <qdialog.h>
14#include <qmainwindow.h> 14#include <qmainwindow.h>
15 15
16class QVBoxLayout; 16class QVBoxLayout;
17class QHBoxLayout; 17class QHBoxLayout;
18class QGridLayout; 18class QGridLayout;
19class QComboBox; 19class QComboBox;
20class QLabel; 20class QLabel;
21class QLineEdit; 21class QLineEdit;
22class QPushButton; 22class QPushButton;
23class QTabWidget; 23class QTabWidget;
24class QWidget; 24class QWidget;
25class QStringList; 25class QStringList;
26 26
27class FormatterApp : public QMainWindow 27class FormatterApp : public QMainWindow
28//public QDialog 28//public QDialog
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 31
32public: 32public:
33 FormatterApp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 33 static QString appName() { return QString::fromLatin1("formatter"); }
34 FormatterApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0, bool modal = FALSE );
34 ~FormatterApp(); 35 ~FormatterApp();
35 36
36 QTabWidget *TabWidget; 37 QTabWidget *TabWidget;
37 QWidget *tab, *tab_2;; 38 QWidget *tab, *tab_2;;
38 QLabel *TextLabel1, *TextLabel2, *TextLabel3, *TextLabel4, *TextLabel5; 39 QLabel *TextLabel1, *TextLabel2, *TextLabel3, *TextLabel4, *TextLabel5;
39 QComboBox *storageComboBox, *fileSystemsCombo, *deviceComboBox; 40 QComboBox *storageComboBox, *fileSystemsCombo, *deviceComboBox;
40 QPushButton *formatPushButton, *editPushButton, *fsckButton; 41 QPushButton *formatPushButton, *editPushButton, *fsckButton;
41 QLineEdit* mountPointLineEdit; 42 QLineEdit* mountPointLineEdit;
42 QStringList fileSystemTypeList, fsList, deviceList; 43 QStringList fileSystemTypeList, fsList, deviceList;
43protected: 44protected:
44 QGridLayout *FormatterAppLayout, *tabLayout, *tabLayout_2; 45 QGridLayout *FormatterAppLayout, *tabLayout, *tabLayout_2;
45 QString getFileSystemType(const QString &); 46 QString getFileSystemType(const QString &);
46 47
47 void fillCombos(); 48 void fillCombos();
48 void parsetab(const QString &); 49 void parsetab(const QString &);
49 bool doFdisk(); 50 bool doFdisk();
50 int formatCheck(const QString &); 51 int formatCheck(const QString &);
51 int runCommand(const QString &); 52 int runCommand(const QString &);
52 53
53protected slots: 54protected slots:
54 void cleanUp(); 55 void cleanUp();
55 void doFormat(); 56 void doFormat();
56 void editFstab(); 57 void editFstab();
57 bool doFsck(); 58 bool doFsck();
58 bool doFsckCheck(); 59 bool doFsckCheck();
59 60
60 void fsComboSelected(int); 61 void fsComboSelected(int);
61 void storageComboSelected(int ); 62 void storageComboSelected(int );
62 void deviceComboSelected(int ); 63 void deviceComboSelected(int );
63}; 64};
64 65
65#endif // FORMATTERAPP_H 66#endif // FORMATTERAPP_H
diff --git a/noncore/tools/formatter/formatter.pro b/noncore/tools/formatter/formatter.pro
index baf6ace..17aab57 100644
--- a/noncore/tools/formatter/formatter.pro
+++ b/noncore/tools/formatter/formatter.pro
@@ -1,31 +1,29 @@
1TEMPLATE = app 1CONFIG += qt warn_on release quick-app
2CONFIG += qt warn_on release
3HEADERS = formatter.h inputDialog.h output.h 2HEADERS = formatter.h inputDialog.h output.h
4SOURCES = formatter.cpp inputDialog.cpp output.cpp main.cpp 3SOURCES = formatter.cpp inputDialog.cpp output.cpp main.cpp
5TARGET = formatter 4TARGET = formatter
6DESTDIR = $(OPIEDIR)/bin
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe 7LIBS += -lqpe
10 8
11TRANSLATIONS = ../../../i18n/de/formatter.ts \ 9TRANSLATIONS = ../../../i18n/de/formatter.ts \
12 ../../../i18n/nl/formatter.ts \ 10 ../../../i18n/nl/formatter.ts \
13 ../../../i18n/da/formatter.ts \ 11 ../../../i18n/da/formatter.ts \
14 ../../../i18n/xx/formatter.ts \ 12 ../../../i18n/xx/formatter.ts \
15 ../../../i18n/en/formatter.ts \ 13 ../../../i18n/en/formatter.ts \
16 ../../../i18n/es/formatter.ts \ 14 ../../../i18n/es/formatter.ts \
17 ../../../i18n/fr/formatter.ts \ 15 ../../../i18n/fr/formatter.ts \
18 ../../../i18n/hu/formatter.ts \ 16 ../../../i18n/hu/formatter.ts \
19 ../../../i18n/ja/formatter.ts \ 17 ../../../i18n/ja/formatter.ts \
20 ../../../i18n/ko/formatter.ts \ 18 ../../../i18n/ko/formatter.ts \
21 ../../../i18n/no/formatter.ts \ 19 ../../../i18n/no/formatter.ts \
22 ../../../i18n/pl/formatter.ts \ 20 ../../../i18n/pl/formatter.ts \
23 ../../../i18n/pt/formatter.ts \ 21 ../../../i18n/pt/formatter.ts \
24 ../../../i18n/pt_BR/formatter.ts \ 22 ../../../i18n/pt_BR/formatter.ts \
25 ../../../i18n/sl/formatter.ts \ 23 ../../../i18n/sl/formatter.ts \
26 ../../../i18n/zh_CN/formatter.ts \ 24 ../../../i18n/zh_CN/formatter.ts \
27 ../../../i18n/zh_TW/formatter.ts 25 ../../../i18n/zh_TW/formatter.ts
28 26
29 27
30 28
31include ( $(OPIEDIR)/include.pro ) 29include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/tools/formatter/main.cpp b/noncore/tools/formatter/main.cpp
index f67c9f2..6228e55 100644
--- a/noncore/tools/formatter/main.cpp
+++ b/noncore/tools/formatter/main.cpp
@@ -1,25 +1,19 @@
1 1
2/*************************************************************************** 2/***************************************************************************
3 main.cpp - description 3 main.cpp - description
4 ------------------- 4 -------------------
5 begin : March 10, 2002 5 begin : March 10, 2002
6 copyright : (C) 2002 by llornkcor 6 copyright : (C) 2002 by llornkcor
7 email : ljp@llornkcor.com 7 email : ljp@llornkcor.com
8 * This program is free software; you can redistribute it and/or modify * 8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by * 9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or * 10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. * 11 * (at your option) any later version. *
12 ***************************************************************************/ 12 ***************************************************************************/
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14 14
15#include "formatter.h" 15#include "formatter.h"
16 16
17int main(int argc, char *argv[]) 17#include <opie/oapplicationfactory.h>
18{
19 QPEApplication a(argc, argv);
20
21 FormatterApp formatterApp;
22 a.showMainWidget( &formatterApp);
23 return a.exec();
24}
25 18
19OPIE_EXPORT_APP( OApplicationFactory<FormatterApp> )
diff --git a/noncore/tools/opie-sh/opie-sh.control b/noncore/tools/opie-sh/opie-sh.control
index a5619ce..f03e5ac 100644
--- a/noncore/tools/opie-sh/opie-sh.control
+++ b/noncore/tools/opie-sh/opie-sh.control
@@ -1,11 +1,11 @@
1Package: opie-sh 1Package: opie-sh
2Files: plugins/application/libopie-sh.so* bin/opie-sh bin/opie-sh-howto.sh apps/Opie-SH/opie-sh.desktop pics/opie-sh/*.png help/opie-sh/*.html 2Files: bin/opie-sh apps/Opie-SH/opie-sh.desktop pics/opie-sh/*.png help/opie-sh/*.html
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Thomas Stephens <spiralman@softhome.net> 5Maintainer: Thomas Stephens <spiralman@softhome.net>
6Architecture: arm 6Architecture: arm
7Version: 0.5-$SUB_VERSION 7Version: 0.5-$SUB_VERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9License: GPL 9License: GPL
10Description: a QDialog shell frontend 10Description: a QDialog shell frontend
11 A program to let you use various dialogs from the console (or a shell script) 11 A program to let you use various dialogs from the console (or a shell script)
diff --git a/noncore/tools/remote/opie-remote.control b/noncore/tools/remote/opie-remote.control
index 78bfbc9..d29bb06 100644
--- a/noncore/tools/remote/opie-remote.control
+++ b/noncore/tools/remote/opie-remote.control
@@ -1,11 +1,11 @@
1Package: opie-remote 1Package: opie-remote
2Files: plugins/application/libremote.so* bin/remote apps/Applications/remote.desktop pics/remote/*.png 2Files: bin/remote apps/Applications/remote.desktop pics/remote/*.png
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Thomas Stephens <spiralman@softhome.net> 5Maintainer: Thomas Stephens <spiralman@softhome.net>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION$EXTRAVERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, lirc 8Depends: task-opie-minimal, lirc
9License: GPL 9License: GPL
10Description: a remote control 10Description: a remote control
11 A remote control using irda. A frontend to lirc. 11 A remote control using irda. A frontend to lirc.