summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/formatter/formatter.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 2b8ce7f..ed0ced1 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -32,171 +32,174 @@
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 modal, WFlags fl ) 57FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl )
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, 0 ); 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, 0 ); 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, 0 ); 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, 0 ); 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, 0 ); 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 TabWidget->insertTab( tab, tr( "Main" ) ); 107 TabWidget->insertTab( tab, tr( "Main" ) );
107 108
108 tab_2 = new QWidget( TabWidget, "tab_2" ); 109 tab_2 = new QWidget( TabWidget, "tab_2" );
109 tabLayout_2 = new QGridLayout( tab_2 ); 110 tabLayout_2 = new QGridLayout( tab_2 );
110 tabLayout_2->setSpacing(3); 111 tabLayout_2->setSpacing(3);
111 tabLayout_2->setMargin(2); 112 tabLayout_2->setMargin(2);
112 113
113 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); 114 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" );
114 115
115 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 0 ); 116 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1);
116 117
117 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); 118 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" );
118 119
119 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 0 ); 120 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1);
120 121
121 TextLabel5 = new QLabel( tab_2, "TextLabel5" ); 122 TextLabel5 = new QLabel( tab_2, "TextLabel5" );
122 TextLabel5->setText( tr( "CAUTION:\n" 123 TextLabel5->setText( tr( "CAUTION:\n"
123 "Changing parameters on this \n" 124 "Changing parameters on this \n"
124 "page may cause your system \n" 125 "page may cause your system \n"
125 "to stop functioning properly!!" ) );//idiot message 126 "to stop functioning properly!!" ) );//idiot message
126 127
127 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 0 ); 128 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1);
128 129
129 editPushButton = new QPushButton( tab_2, "editPushButton" ); 130 editPushButton = new QPushButton( tab_2, "editPushButton" );
130 editPushButton->setText( tr( "Edit fstab" ) ); 131 editPushButton->setText( tr( "Edit fstab" ) );
131 132 editPushButton->setMaximumWidth(100);
133
132 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); 134 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 );
133 135
134 fsckButton = new QPushButton( tab_2, "fsckPushButton" ); 136 fsckButton = new QPushButton( tab_2, "fsckPushButton" );
135 fsckButton->setText( tr( "Check Disk" ) ); 137 fsckButton->setText( tr( "Check Disk" ) );
138 fsckButton->setMaximumWidth(100);
136 139
137 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 0 ); 140 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1);
138 141
139 TextLabel3 = new QLabel( tab_2, "TextLabel3" ); 142 TextLabel3 = new QLabel( tab_2, "TextLabel3" );
140 TextLabel3->setText( tr( "Device" ) ); 143 TextLabel3->setText( tr( "Device" ) );
141 144
142 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 0 ); 145 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 );
143 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 146 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
144 tabLayout_2->addItem( spacer_3, 5, 0 ); 147 tabLayout_2->addItem( spacer_3, 5, 0 );
145 148
146 TextLabel1 = new QLabel( tab_2, "TextLabel1" ); 149 TextLabel1 = new QLabel( tab_2, "TextLabel1" );
147 TextLabel1->setText( tr( "Mount Point" ) ); 150 TextLabel1->setText( tr( "Mount Point" ) );
148 151
149 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 0 ); 152 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 );
150 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 153 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
151 tabLayout_2->addItem( spacer_4, 2, 1 ); 154 tabLayout_2->addItem( spacer_4, 2, 1 );
152 TabWidget->insertTab( tab_2, tr( "Advanced" ) ); 155 TabWidget->insertTab( tab_2, tr( "Advanced" ) );
153 156
154 FormatterAppLayout->addWidget( TabWidget, 0, 0 ); 157 FormatterAppLayout->addWidget( TabWidget, 0, 1 );
155 158
156 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); 159 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) );
157 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); 160 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) );
158 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); 161 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) );
159 162
160 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); 163 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) ));
161 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); 164 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) ));
162 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); 165 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) ));
163 166
164 167
165 fillCombos(); 168 fillCombos();
166} 169}
167 170
168FormatterApp::~FormatterApp() { 171FormatterApp::~FormatterApp() {
169 172
170} 173}
171 174
172void FormatterApp::doFormat() { 175void FormatterApp::doFormat() {
173 int err=0; 176 int err=0;
174 Output *outDlg; 177 Output *outDlg;
175 QString umountS, remountS; 178 QString umountS, remountS;
176 QString text = storageComboBox->currentText(); 179 QString text = storageComboBox->currentText();
177 QString currentText = storageComboBox->currentText(); 180 QString currentText = storageComboBox->currentText();
178 QString cmd; 181 QString cmd;
179 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 182 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
180 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); 183 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE));
181 QString fs = fileSystemsCombo->currentText(); 184 QString fs = fileSystemsCombo->currentText();
182 185
183#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap 186#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap
184#else 187#else
185 currentText = diskDevice = "/dev/fd0"; 188 currentText = diskDevice = "/dev/fd0";
186 umountS = "umount -v /floppy 2>&1"; 189 umountS = "umount -v /floppy 2>&1";
187 remountS = "mount -v /floppy 2>&1"; 190 remountS = "mount -v /floppy 2>&1";
188#endif 191#endif
189 192
190 if( currentText.find("CF",0,TRUE) != -1) { 193 if( currentText.find("CF",0,TRUE) != -1) {
191 umountS = "umount "; 194 umountS = "umount ";
192 remountS = "mount "; 195 remountS = "mount ";
193 196
194// umountS = "/sbin/cardctl eject"; 197// umountS = "/sbin/cardctl eject";
195// remountS = "/sbin/cardctl insert"; 198// remountS = "/sbin/cardctl insert";
196 } 199 }
197 if( currentText.find("SD",0,TRUE) != -1) { 200 if( currentText.find("SD",0,TRUE) != -1) {
198 umountS = "umount "; 201 umountS = "umount ";
199 remountS = "mount "; 202 remountS = "mount ";
200// umountS = "/etc/sdcontrol compeject"; 203// umountS = "/etc/sdcontrol compeject";
201// remountS = "/etc/sdcontrol insert"; 204// remountS = "/etc/sdcontrol insert";
202 } 205 }