author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/advancedfm/output.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/apps/advancedfm/output.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/output.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 7dc2416..0bba1d8 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp | |||
@@ -96,181 +96,181 @@ static char * filesave_xpm[] = { | |||
96 | "K c #323232", | 96 | "K c #323232", |
97 | "L c #D0D0D0", | 97 | "L c #D0D0D0", |
98 | "M c #1C1C1C", | 98 | "M c #1C1C1C", |
99 | " ...+ ", | 99 | " ...+ ", |
100 | " @#$%&..+ ", | 100 | " @#$%&..+ ", |
101 | " .*=-;;>,..+ ", | 101 | " .*=-;;>,..+ ", |
102 | " ')!~;;;;;;{]..", | 102 | " ')!~;;;;;;{]..", |
103 | " ^/(-;;;;;;;_:<", | 103 | " ^/(-;;;;;;;_:<", |
104 | " [}|;;;;;;;{12$", | 104 | " [}|;;;;;;;{12$", |
105 | " #34-55;;;;678$+", | 105 | " #34-55;;;;678$+", |
106 | " 90ab=c;dd;e1fg ", | 106 | " 90ab=c;dd;e1fg ", |
107 | " [ahij((kbl0mn$ ", | 107 | " [ahij((kbl0mn$ ", |
108 | " op^q^^7r&]s/$+ ", | 108 | " op^q^^7r&]s/$+ ", |
109 | "@btu;vbwxy]zAB ", | 109 | "@btu;vbwxy]zAB ", |
110 | "CzDEvEv;;DssF$ ", | 110 | "CzDEvEv;;DssF$ ", |
111 | "G.H{E{E{IxsJ$+ ", | 111 | "G.H{E{E{IxsJ$+ ", |
112 | " +...vEKxzLM ", | 112 | " +...vEKxzLM ", |
113 | " +...z]n$ ", | 113 | " +...z]n$ ", |
114 | " +... "}; | 114 | " +... "}; |
115 | 115 | ||
116 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) | 116 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) |
117 | : QDialog( parent, name, modal, fl ) | 117 | : QDialog( parent, name, modal, fl ) |
118 | { | 118 | { |
119 | QStringList cmmds; | 119 | QStringList cmmds; |
120 | // cmmds=QStringList::split( " ", commands, false); | 120 | // cmmds=QStringList::split( " ", commands, false); |
121 | cmmds=commands; | 121 | cmmds=commands; |
122 | // qDebug("count %d", cmmds.count()); | 122 | // qDebug("count %d", cmmds.count()); |
123 | if ( !name ) | 123 | if ( !name ) |
124 | setName( tr("Output")); | 124 | setName( tr("Output")); |
125 | resize( 196, 269 ); | 125 | resize( 196, 269 ); |
126 | setCaption( name ); | 126 | setCaption( name ); |
127 | 127 | ||
128 | OutputLayout = new QGridLayout( this ); | 128 | OutputLayout = new QGridLayout( this ); |
129 | OutputLayout->setSpacing( 2); | 129 | OutputLayout->setSpacing( 2); |
130 | OutputLayout->setMargin( 2); | 130 | OutputLayout->setMargin( 2); |
131 | 131 | ||
132 | QPushButton *docButton; | 132 | QPushButton *docButton; |
133 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); | 133 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); |
134 | docButton->setFixedSize( QSize( 20, 20 ) ); | 134 | docButton->setFixedSize( QSize( 20, 20 ) ); |
135 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); | 135 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); |
136 | // docButton->setFlat(TRUE); | 136 | // docButton->setFlat(TRUE); |
137 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); | 137 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); |
138 | 138 | ||
139 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); | 139 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); |
140 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); | 140 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); |
141 | 141 | ||
142 | proc = new OProcess(); | 142 | proc = new OProcess(); |
143 | 143 | ||
144 | connect(proc, SIGNAL(processExited(OProcess *)), | 144 | connect(proc, SIGNAL(processExited(OProcess*)), |
145 | this, SLOT( processFinished())); | 145 | this, SLOT( processFinished())); |
146 | 146 | ||
147 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 147 | connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), |
148 | this, SLOT(commandStdout(OProcess *, char *, int))); | 148 | this, SLOT(commandStdout(OProcess*,char*,int))); |
149 | 149 | ||
150 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 150 | connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), |
151 | this, SLOT(commandStderr(OProcess *, char *, int))); | 151 | this, SLOT(commandStderr(OProcess*,char*,int))); |
152 | 152 | ||
153 | // connect( , SIGNAL(received(const QByteArray &)), | 153 | // connect( , SIGNAL(received(const QByteArray&)), |
154 | // this, SLOT(commandStdin(const QByteArray &))); | 154 | // this, SLOT(commandStdin(const QByteArray&))); |
155 | 155 | ||
156 | // * proc << commands.latin1(); | 156 | // * proc << commands.latin1(); |
157 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { | 157 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { |
158 | qDebug( "%s", (*it).latin1() ); | 158 | qDebug( "%s", (*it).latin1() ); |
159 | * proc << (*it).latin1(); | 159 | * proc << (*it).latin1(); |
160 | } | 160 | } |
161 | 161 | ||
162 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { | 162 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { |
163 | 163 | ||
164 | OutputEdit->append(tr("Process could not start") ); | 164 | OutputEdit->append(tr("Process could not start") ); |
165 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 165 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
166 | perror("Error: "); | 166 | perror("Error: "); |
167 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); | 167 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); |
168 | OutputEdit->append( errorMsg); | 168 | OutputEdit->append( errorMsg); |
169 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 169 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | Output::~Output() { | 173 | Output::~Output() { |
174 | } | 174 | } |
175 | 175 | ||
176 | void Output::saveOutput() { | 176 | void Output::saveOutput() { |
177 | 177 | ||
178 | InputDialog *fileDlg; | 178 | InputDialog *fileDlg; |
179 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); | 179 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); |
180 | fileDlg->exec(); | 180 | fileDlg->exec(); |
181 | if( fileDlg->result() == 1 ) { | 181 | if( fileDlg->result() == 1 ) { |
182 | QString filename = QPEApplication::documentDir(); | 182 | QString filename = QPEApplication::documentDir(); |
183 | if(filename.right(1).find('/') == -1) | 183 | if(filename.right(1).find('/') == -1) |
184 | filename+="/"; | 184 | filename+="/"; |
185 | QString name = fileDlg->LineEdit1->text(); | 185 | QString name = fileDlg->LineEdit1->text(); |
186 | filename+="text/plain/"+name; | 186 | filename+="text/plain/"+name; |
187 | qDebug(filename); | 187 | qDebug(filename); |
188 | 188 | ||
189 | QFile f(filename); | 189 | QFile f(filename); |
190 | f.open( IO_WriteOnly); | 190 | f.open( IO_WriteOnly); |
191 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { | 191 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { |
192 | DocLnk lnk; | 192 | DocLnk lnk; |
193 | lnk.setName(name); //sets file name | 193 | lnk.setName(name); //sets file name |
194 | lnk.setFile(filename); //sets File property | 194 | lnk.setFile(filename); //sets File property |
195 | lnk.setType("text/plain"); | 195 | lnk.setType("text/plain"); |
196 | if(!lnk.writeLink()) { | 196 | if(!lnk.writeLink()) { |
197 | qDebug("Writing doclink did not work"); | 197 | qDebug("Writing doclink did not work"); |
198 | } | 198 | } |
199 | } else | 199 | } else |
200 | qWarning("Could not write file"); | 200 | qWarning("Could not write file"); |
201 | f.close(); | 201 | f.close(); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { | 205 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { |
206 | qWarning("received stdout %d bytes", buflen); | 206 | qWarning("received stdout %d bytes", buflen); |
207 | 207 | ||
208 | // QByteArray data(buflen); | 208 | // QByteArray data(buflen); |
209 | // data.fill(*buffer, buflen); | 209 | // data.fill(*buffer, buflen); |
210 | // for (uint i = 0; i < data.count(); i++ ) { | 210 | // for (uint i = 0; i < data.count(); i++ ) { |
211 | // printf("%c", buffer[i] ); | 211 | // printf("%c", buffer[i] ); |
212 | // } | 212 | // } |
213 | // printf("\n"); | 213 | // printf("\n"); |
214 | 214 | ||
215 | QString lineStr = buffer; | 215 | QString lineStr = buffer; |
216 | lineStr=lineStr.left(lineStr.length()-1); | 216 | lineStr=lineStr.left(lineStr.length()-1); |
217 | OutputEdit->append(lineStr); | 217 | OutputEdit->append(lineStr); |
218 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 218 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | void Output::commandStdin( const QByteArray &data) { | 222 | void Output::commandStdin( const QByteArray &data) { |
223 | qWarning("received stdin %d bytes", data.size()); | 223 | qWarning("received stdin %d bytes", data.size()); |
224 | // recieved data from the io layer goes to sz | 224 | // recieved data from the io layer goes to sz |
225 | proc->writeStdin(data.data(), data.size()); | 225 | proc->writeStdin(data.data(), data.size()); |
226 | } | 226 | } |
227 | 227 | ||
228 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { | 228 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { |
229 | qWarning("received stderrt %d bytes", buflen); | 229 | qWarning("received stderrt %d bytes", buflen); |
230 | 230 | ||
231 | QString lineStr = buffer; | 231 | QString lineStr = buffer; |
232 | // lineStr=lineStr.left(lineStr.length()-1); | 232 | // lineStr=lineStr.left(lineStr.length()-1); |
233 | OutputEdit->append(lineStr); | 233 | OutputEdit->append(lineStr); |
234 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 234 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
235 | } | 235 | } |
236 | 236 | ||
237 | void Output::processFinished() { | 237 | void Output::processFinished() { |
238 | 238 | ||
239 | delete proc; | 239 | delete proc; |
240 | OutputEdit->append( tr("\nFinished\n") ); | 240 | OutputEdit->append( tr("\nFinished\n") ); |
241 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 241 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
242 | // close(); | 242 | // close(); |
243 | // disconnect( layer(), SIGNAL(received(const QByteArray &)), | 243 | // disconnect( layer(), SIGNAL(received(const QByteArray&)), |
244 | // this, SLOT(commandStdin(const QByteArray &))); | 244 | // this, SLOT(commandStdin(const QByteArray&))); |
245 | } | 245 | } |
246 | 246 | ||
247 | //============================== | 247 | //============================== |
248 | 248 | ||
249 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 249 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
250 | : QDialog( parent, name, modal, fl ) | 250 | : QDialog( parent, name, modal, fl ) |
251 | { | 251 | { |
252 | if ( !name ) | 252 | if ( !name ) |
253 | setName( "InputDialog" ); | 253 | setName( "InputDialog" ); |
254 | resize( 234, 50 ); | 254 | resize( 234, 50 ); |
255 | setMaximumSize( QSize( 240, 50 ) ); | 255 | setMaximumSize( QSize( 240, 50 ) ); |
256 | setCaption( tr(name ) ); | 256 | setCaption( tr(name ) ); |
257 | 257 | ||
258 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 258 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
259 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); | 259 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); |
260 | LineEdit1->setFocus(); | 260 | LineEdit1->setFocus(); |
261 | LineEdit1->setFocus(); | 261 | LineEdit1->setFocus(); |
262 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); | 262 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); |
263 | } | 263 | } |
264 | 264 | ||
265 | InputDialog::~InputDialog() { | 265 | InputDialog::~InputDialog() { |
266 | inputText = LineEdit1->text(); | 266 | inputText = LineEdit1->text(); |
267 | } | 267 | } |
268 | 268 | ||
269 | void InputDialog::setInputText(const QString &string) { | 269 | void InputDialog::setInputText(const QString &string) { |
270 | LineEdit1->setText( string); | 270 | LineEdit1->setText( string); |
271 | } | 271 | } |
272 | 272 | ||
273 | void InputDialog::returned() { | 273 | void InputDialog::returned() { |
274 | inputText = LineEdit1->text(); | 274 | inputText = LineEdit1->text(); |
275 | this->accept(); | 275 | this->accept(); |
276 | } | 276 | } |