Diffstat (limited to 'noncore/apps/advancedfm/output.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/output.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 0bba1d8..16a0992 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp | |||
@@ -1,66 +1,68 @@ | |||
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 <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/applnk.h> | 9 | #include <qpe/applnk.h> |
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qmultilineedit.h> | 12 | #include <qmultilineedit.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qlayout.h> | 14 | #include <qlayout.h> |
15 | 15 | ||
16 | #include <errno.h> | 16 | #include <errno.h> |
17 | 17 | ||
18 | /* XPM */ | 18 | /* XPM */ |
19 | using namespace Opie::Core; | ||
20 | using namespace Opie::Core; | ||
19 | static char * filesave_xpm[] = { | 21 | static char * filesave_xpm[] = { |
20 | "16 16 78 1", | 22 | "16 16 78 1", |
21 | " c None", | 23 | " c None", |
22 | ". c #343434", | 24 | ". c #343434", |
23 | "+ c #A0A0A0", | 25 | "+ c #A0A0A0", |
24 | "@ c #565656", | 26 | "@ c #565656", |
25 | "# c #9E9E9E", | 27 | "# c #9E9E9E", |
26 | "$ c #525252", | 28 | "$ c #525252", |
27 | "% c #929292", | 29 | "% c #929292", |
28 | "& c #676767", | 30 | "& c #676767", |
29 | "* c #848484", | 31 | "* c #848484", |
30 | "= c #666666", | 32 | "= c #666666", |
31 | "- c #D8D8D8", | 33 | "- c #D8D8D8", |
32 | "; c #FFFFFF", | 34 | "; c #FFFFFF", |
33 | "> c #DBDBDB", | 35 | "> c #DBDBDB", |
34 | ", c #636363", | 36 | ", c #636363", |
35 | "' c #989898", | 37 | "' c #989898", |
36 | ") c #2D2D2D", | 38 | ") c #2D2D2D", |
37 | "! c #909090", | 39 | "! c #909090", |
38 | "~ c #AEAEAE", | 40 | "~ c #AEAEAE", |
39 | "{ c #EAEAEA", | 41 | "{ c #EAEAEA", |
40 | "] c #575757", | 42 | "] c #575757", |
41 | "^ c #585858", | 43 | "^ c #585858", |
42 | "/ c #8A8A8A", | 44 | "/ c #8A8A8A", |
43 | "( c #828282", | 45 | "( c #828282", |
44 | "_ c #6F6F6F", | 46 | "_ c #6F6F6F", |
45 | ": c #C9C9C9", | 47 | ": c #C9C9C9", |
46 | "< c #050505", | 48 | "< c #050505", |
47 | "[ c #292929", | 49 | "[ c #292929", |
48 | "} c #777777", | 50 | "} c #777777", |
49 | "| c #616161", | 51 | "| c #616161", |
50 | "1 c #3A3A3A", | 52 | "1 c #3A3A3A", |
51 | "2 c #BEBEBE", | 53 | "2 c #BEBEBE", |
52 | "3 c #2C2C2C", | 54 | "3 c #2C2C2C", |
53 | "4 c #7C7C7C", | 55 | "4 c #7C7C7C", |
54 | "5 c #F6F6F6", | 56 | "5 c #F6F6F6", |
55 | "6 c #FCFCFC", | 57 | "6 c #FCFCFC", |
56 | "7 c #6B6B6B", | 58 | "7 c #6B6B6B", |
57 | "8 c #959595", | 59 | "8 c #959595", |
58 | "9 c #4F4F4F", | 60 | "9 c #4F4F4F", |
59 | "0 c #808080", | 61 | "0 c #808080", |
60 | "a c #767676", | 62 | "a c #767676", |
61 | "b c #818181", | 63 | "b c #818181", |
62 | "c c #B8B8B8", | 64 | "c c #B8B8B8", |
63 | "d c #FBFBFB", | 65 | "d c #FBFBFB", |
64 | "e c #F9F9F9", | 66 | "e c #F9F9F9", |
65 | "f c #CCCCCC", | 67 | "f c #CCCCCC", |
66 | "g c #030303", | 68 | "g c #030303", |
@@ -96,103 +98,103 @@ static char * filesave_xpm[] = { | |||
96 | "K c #323232", | 98 | "K c #323232", |
97 | "L c #D0D0D0", | 99 | "L c #D0D0D0", |
98 | "M c #1C1C1C", | 100 | "M c #1C1C1C", |
99 | " ...+ ", | 101 | " ...+ ", |
100 | " @#$%&..+ ", | 102 | " @#$%&..+ ", |
101 | " .*=-;;>,..+ ", | 103 | " .*=-;;>,..+ ", |
102 | " ')!~;;;;;;{]..", | 104 | " ')!~;;;;;;{]..", |
103 | " ^/(-;;;;;;;_:<", | 105 | " ^/(-;;;;;;;_:<", |
104 | " [}|;;;;;;;{12$", | 106 | " [}|;;;;;;;{12$", |
105 | " #34-55;;;;678$+", | 107 | " #34-55;;;;678$+", |
106 | " 90ab=c;dd;e1fg ", | 108 | " 90ab=c;dd;e1fg ", |
107 | " [ahij((kbl0mn$ ", | 109 | " [ahij((kbl0mn$ ", |
108 | " op^q^^7r&]s/$+ ", | 110 | " op^q^^7r&]s/$+ ", |
109 | "@btu;vbwxy]zAB ", | 111 | "@btu;vbwxy]zAB ", |
110 | "CzDEvEv;;DssF$ ", | 112 | "CzDEvEv;;DssF$ ", |
111 | "G.H{E{E{IxsJ$+ ", | 113 | "G.H{E{E{IxsJ$+ ", |
112 | " +...vEKxzLM ", | 114 | " +...vEKxzLM ", |
113 | " +...z]n$ ", | 115 | " +...z]n$ ", |
114 | " +... "}; | 116 | " +... "}; |
115 | 117 | ||
116 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) | 118 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) |
117 | : QDialog( parent, name, modal, fl ) | 119 | : QDialog( parent, name, modal, fl ) |
118 | { | 120 | { |
119 | QStringList cmmds; | 121 | QStringList cmmds; |
120 | // cmmds=QStringList::split( " ", commands, false); | 122 | // cmmds=QStringList::split( " ", commands, false); |
121 | cmmds=commands; | 123 | cmmds=commands; |
122 | // qDebug("count %d", cmmds.count()); | 124 | // qDebug("count %d", cmmds.count()); |
123 | if ( !name ) | 125 | if ( !name ) |
124 | setName( tr("Output")); | 126 | setName( tr("Output")); |
125 | resize( 196, 269 ); | 127 | resize( 196, 269 ); |
126 | setCaption( name ); | 128 | setCaption( name ); |
127 | 129 | ||
128 | OutputLayout = new QGridLayout( this ); | 130 | OutputLayout = new QGridLayout( this ); |
129 | OutputLayout->setSpacing( 2); | 131 | OutputLayout->setSpacing( 2); |
130 | OutputLayout->setMargin( 2); | 132 | OutputLayout->setMargin( 2); |
131 | 133 | ||
132 | QPushButton *docButton; | 134 | QPushButton *docButton; |
133 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); | 135 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); |
134 | docButton->setFixedSize( QSize( 20, 20 ) ); | 136 | docButton->setFixedSize( QSize( 20, 20 ) ); |
135 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); | 137 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); |
136 | // docButton->setFlat(TRUE); | 138 | // docButton->setFlat(TRUE); |
137 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); | 139 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); |
138 | 140 | ||
139 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); | 141 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); |
140 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); | 142 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); |
141 | 143 | ||
142 | proc = new OProcess(); | 144 | proc = new OProcess(); |
143 | 145 | ||
144 | connect(proc, SIGNAL(processExited(OProcess*)), | 146 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), |
145 | this, SLOT( processFinished())); | 147 | this, SLOT( processFinished())); |
146 | 148 | ||
147 | connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), | 149 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
148 | this, SLOT(commandStdout(OProcess*,char*,int))); | 150 | this, SLOT(commandStdout(OProcess*,char*,int))); |
149 | 151 | ||
150 | connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), | 152 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
151 | this, SLOT(commandStderr(OProcess*,char*,int))); | 153 | this, SLOT(commandStderr(OProcess*,char*,int))); |
152 | 154 | ||
153 | // connect( , SIGNAL(received(const QByteArray&)), | 155 | // connect( , SIGNAL(received(const QByteArray&)), |
154 | // this, SLOT(commandStdin(const QByteArray&))); | 156 | // this, SLOT(commandStdin(const QByteArray&))); |
155 | 157 | ||
156 | // * proc << commands.latin1(); | 158 | // * proc << commands.latin1(); |
157 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { | 159 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { |
158 | qDebug( "%s", (*it).latin1() ); | 160 | qDebug( "%s", (*it).latin1() ); |
159 | * proc << (*it).latin1(); | 161 | * proc << (*it).latin1(); |
160 | } | 162 | } |
161 | 163 | ||
162 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { | 164 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { |
163 | 165 | ||
164 | OutputEdit->append(tr("Process could not start") ); | 166 | OutputEdit->append(tr("Process could not start") ); |
165 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 167 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
166 | perror("Error: "); | 168 | perror("Error: "); |
167 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); | 169 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); |
168 | OutputEdit->append( errorMsg); | 170 | OutputEdit->append( errorMsg); |
169 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 171 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
170 | } | 172 | } |
171 | } | 173 | } |
172 | 174 | ||
173 | Output::~Output() { | 175 | Output::~Output() { |
174 | } | 176 | } |
175 | 177 | ||
176 | void Output::saveOutput() { | 178 | void Output::saveOutput() { |
177 | 179 | ||
178 | InputDialog *fileDlg; | 180 | InputDialog *fileDlg; |
179 | 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); |
180 | fileDlg->exec(); | 182 | fileDlg->exec(); |
181 | if( fileDlg->result() == 1 ) { | 183 | if( fileDlg->result() == 1 ) { |
182 | QString filename = QPEApplication::documentDir(); | 184 | QString filename = QPEApplication::documentDir(); |
183 | if(filename.right(1).find('/') == -1) | 185 | if(filename.right(1).find('/') == -1) |
184 | filename+="/"; | 186 | filename+="/"; |
185 | QString name = fileDlg->LineEdit1->text(); | 187 | QString name = fileDlg->LineEdit1->text(); |
186 | filename+="text/plain/"+name; | 188 | filename+="text/plain/"+name; |
187 | qDebug(filename); | 189 | qDebug(filename); |
188 | 190 | ||
189 | QFile f(filename); | 191 | QFile f(filename); |
190 | f.open( IO_WriteOnly); | 192 | f.open( IO_WriteOnly); |
191 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { | 193 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { |
192 | DocLnk lnk; | 194 | DocLnk lnk; |
193 | lnk.setName(name); //sets file name | 195 | lnk.setName(name); //sets file name |
194 | lnk.setFile(filename); //sets File property | 196 | lnk.setFile(filename); //sets File property |
195 | lnk.setType("text/plain"); | 197 | lnk.setType("text/plain"); |
196 | if(!lnk.writeLink()) { | 198 | if(!lnk.writeLink()) { |
197 | qDebug("Writing doclink did not work"); | 199 | qDebug("Writing doclink did not work"); |
198 | } | 200 | } |