summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/output.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/output.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/output.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index a60cea6..33abdfc 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,34 +1,28 @@
1/**************************************************************************** 1/****************************************************************************
2** outputEdit.cpp 2** outputEdit.cpp
3** 3**
4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> 4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6#include "output.h" 6#include "output.h"
7 7
8#include <opie/oprocess.h> 8#include <opie/oprocess.h>
9 9
10#include <qpe/filemanager.h>
11#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
12#include <qpe/applnk.h> 11#include <qpe/applnk.h>
13 12
14#include <qmessagebox.h>
15#include <qstringlist.h>
16#include <qfile.h> 13#include <qfile.h>
17#include <qcstring.h>
18#include <qlineedit.h>
19#include <qmultilineedit.h> 14#include <qmultilineedit.h>
20#include <qpushbutton.h> 15#include <qpushbutton.h>
21#include <qlayout.h> 16#include <qlayout.h>
22#include <qvariant.h>
23 17
24#include <errno.h> 18#include <errno.h>
25 19
26/* XPM */ 20/* XPM */
27static char * filesave_xpm[] = { 21static char * filesave_xpm[] = {
28"16 16 78 1", 22"16 16 78 1",
29" c None", 23" c None",
30". c #343434", 24". c #343434",
31"+ c #A0A0A0", 25"+ c #A0A0A0",
32"@ c #565656", 26"@ c #565656",
33"# c #9E9E9E", 27"# c #9E9E9E",
34"$ c #525252", 28"$ c #525252",
@@ -118,31 +112,31 @@ static char * filesave_xpm[] = {
118"CzDEvEv;;DssF$ ", 112"CzDEvEv;;DssF$ ",
119"G.H{E{E{IxsJ$+ ", 113"G.H{E{E{IxsJ$+ ",
120" +...vEKxzLM ", 114" +...vEKxzLM ",
121" +...z]n$ ", 115" +...z]n$ ",
122" +... "}; 116" +... "};
123 117
124Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) 118Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
125 : QDialog( parent, name, modal, fl ) 119 : QDialog( parent, name, modal, fl )
126{ 120{
127 QStringList cmmds; 121 QStringList cmmds;
128// cmmds=QStringList::split( " ", commands, false); 122// cmmds=QStringList::split( " ", commands, false);
129 cmmds=commands; 123 cmmds=commands;
130// qDebug("count %d", cmmds.count()); 124// qDebug("count %d", cmmds.count());
131 if ( !name ) 125 if ( !name )
132 setName( tr("Output")); 126 setName( tr("Output"));
133 resize( 196, 269 ); 127 resize( 196, 269 );
134 setCaption( name ); 128 setCaption( name );
135 129
136 OutputLayout = new QGridLayout( this ); 130 OutputLayout = new QGridLayout( this );
137 OutputLayout->setSpacing( 2); 131 OutputLayout->setSpacing( 2);
138 OutputLayout->setMargin( 2); 132 OutputLayout->setMargin( 2);
139 133
140 QPushButton *docButton; 134 QPushButton *docButton;
141 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); 135 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
142 docButton->setFixedSize( QSize( 20, 20 ) ); 136 docButton->setFixedSize( QSize( 20, 20 ) );
143 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); 137 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
144 // docButton->setFlat(TRUE); 138 // docButton->setFlat(TRUE);
145 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); 139 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
146 140
147 OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); 141 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
148 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); 142 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
@@ -152,51 +146,51 @@ Output::Output( const QStringList commands, QWidget* parent, const char* name,
152 connect(proc, SIGNAL(processExited(OProcess *)), 146 connect(proc, SIGNAL(processExited(OProcess *)),
153 this, SLOT( processFinished())); 147 this, SLOT( processFinished()));
154 148
155 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 149 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
156 this, SLOT(commandStdout(OProcess *, char *, int))); 150 this, SLOT(commandStdout(OProcess *, char *, int)));
157 151
158 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 152 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
159 this, SLOT(commandStderr(OProcess *, char *, int))); 153 this, SLOT(commandStderr(OProcess *, char *, int)));
160 154
161// connect( , SIGNAL(received(const QByteArray &)), 155// connect( , SIGNAL(received(const QByteArray &)),
162// this, SLOT(commandStdin(const QByteArray &))); 156// this, SLOT(commandStdin(const QByteArray &)));
163 157
164// * proc << commands.latin1(); 158// * proc << commands.latin1();
165 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { 159 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
166 qDebug( "%s", (*it).latin1() ); 160 qDebug( "%s", (*it).latin1() );
167 * proc << (*it).latin1(); 161 * proc << (*it).latin1();
168 } 162 }
169 163
170 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { 164 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
171 165
172 OutputEdit->append("Process could not start"); 166 OutputEdit->append(tr("Process could not start") );
173 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 167 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
174 perror("Error: "); 168 perror("Error: ");
175 QString errorMsg="Error\n"+(QString)strerror(errno); 169 QString errorMsg=tr("Error\n")+(QString)strerror(errno);
176 OutputEdit->append( errorMsg); 170 OutputEdit->append( errorMsg);
177 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 171 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
178 } 172 }
179} 173}
180 174
181Output::~Output() { 175Output::~Output() {
182} 176}
183 177
184void Output::saveOutput() { 178void Output::saveOutput() {
185 179
186 InputDialog *fileDlg; 180 InputDialog *fileDlg;
187 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); 181 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
188 fileDlg->exec(); 182 fileDlg->exec();
189 if( fileDlg->result() == 1 ) { 183 if( fileDlg->result() == 1 ) {
190 QString filename = QPEApplication::documentDir(); 184 QString filename = QPEApplication::documentDir();
191 if(filename.right(1).find('/') == -1) 185 if(filename.right(1).find('/') == -1)
192 filename+="/"; 186 filename+="/";
193 QString name = fileDlg->LineEdit1->text(); 187 QString name = fileDlg->LineEdit1->text();
194 filename+="text/plain/"+name; 188 filename+="text/plain/"+name;
195 qDebug(filename); 189 qDebug(filename);
196 190
197 QFile f(filename); 191 QFile f(filename);
198 f.open( IO_WriteOnly); 192 f.open( IO_WriteOnly);
199 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { 193 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
200 DocLnk lnk; 194 DocLnk lnk;
201 lnk.setName(name); //sets file name 195 lnk.setName(name); //sets file name
202 lnk.setFile(filename); //sets File property 196 lnk.setFile(filename); //sets File property
@@ -236,39 +230,39 @@ void Output::commandStdin( const QByteArray &data) {
236void Output::commandStderr(OProcess*, char *buffer, int buflen) { 230void Output::commandStderr(OProcess*, char *buffer, int buflen) {
237 qWarning("received stderrt %d bytes", buflen); 231 qWarning("received stderrt %d bytes", buflen);
238 232
239 QString lineStr = buffer; 233 QString lineStr = buffer;
240// lineStr=lineStr.left(lineStr.length()-1); 234// lineStr=lineStr.left(lineStr.length()-1);
241 OutputEdit->append(lineStr); 235 OutputEdit->append(lineStr);
242 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 236 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
243} 237}
244 238
245void Output::processFinished() { 239void Output::processFinished() {
246 240
247 delete proc; 241 delete proc;
248 OutputEdit->append( "\nFinished\n"); 242 OutputEdit->append( tr("\nFinished\n") );
249 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 243 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
250// close(); 244// close();
251// disconnect( layer(), SIGNAL(received(const QByteArray &)), 245// disconnect( layer(), SIGNAL(received(const QByteArray &)),
252// this, SLOT(commandStdin(const QByteArray &))); 246// this, SLOT(commandStdin(const QByteArray &)));
253} 247}
254 248
255//============================== 249//==============================
256 250
257InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 251InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
258 : QDialog( parent, name, modal, fl ) 252 : QDialog( parent, name, modal, fl )
259{ 253{
260 if ( !name ) 254 if ( !name )
261 setName( "InputDialog" ); 255 setName( "InputDialog" );
262 resize( 234, 50 ); 256 resize( 234, 50 );
263 setMaximumSize( QSize( 240, 50 ) ); 257 setMaximumSize( QSize( 240, 50 ) );
264 setCaption( tr(name ) ); 258 setCaption( tr(name ) );
265 259
266 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 260 LineEdit1 = new QLineEdit( this, "LineEdit1" );
267 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 261 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
268 LineEdit1->setFocus(); 262 LineEdit1->setFocus();
269 LineEdit1->setFocus(); 263 LineEdit1->setFocus();
270 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); 264 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
271} 265}
272 266
273InputDialog::~InputDialog() { 267InputDialog::~InputDialog() {
274 inputText = LineEdit1->text(); 268 inputText = LineEdit1->text();