summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 8b98898..e770304 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,817 +1,820 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12 12
13#include "advancedfm.h" 13#include "advancedfm.h"
14#include "output.h" 14#include "output.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16 16
17/* OPIE */ 17/* OPIE */
18#include <opie2/odebug.h> 18#include <opie2/odebug.h>
19#include <qpe/lnkproperties.h> 19#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/applnk.h> 21#include <qpe/applnk.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT*/ 24/* QT*/
25 25
26#include <qmessagebox.h> 26#include <qmessagebox.h>
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qlistview.h> 28#include <qlistview.h>
29 29
30/* STD */ 30/* STD */
31 31
32#include <errno.h> 32#include <errno.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <sys/stat.h> 35#include <sys/stat.h>
36#include <dirent.h> 36#include <dirent.h>
37#include <sys/sendfile.h> 37#include <sys/sendfile.h>
38#include <fcntl.h> 38#include <fcntl.h>
39 39
40void AdvancedFm::doDirChange() { 40void AdvancedFm::doDirChange() {
41 QString pathItem = CurrentView()->currentItem()->text(0); 41 QString pathItem = CurrentView()->currentItem()->text(0);
42 if( pathItem == "../") { 42 if( pathItem == "../") {
43 ListClicked( CurrentView()->currentItem()); 43 ListClicked( CurrentView()->currentItem());
44 } else { 44 } else {
45 if( pathItem.find(" -> ",0,TRUE) != -1) 45 if( pathItem.find(" -> ",0,TRUE) != -1)
46 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 46 pathItem = dealWithSymName((const QString&)pathItem)+"/";
47// owarn << pathItem << oendl; 47// owarn << pathItem << oendl;
48 changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 48 changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
49 } 49 }
50} 50}
51 51
52void AdvancedFm::showMenuHidden() { 52void AdvancedFm::showMenuHidden() {
53 if (b) { 53 if (b) {
54 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 54 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
55 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 55 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
56 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 56 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
57 } else { 57 } else {
58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
59 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 59 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
60 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 60 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
61 } 61 }
62 b = !b; 62 b = !b;
63 populateView(); 63 populateView();
64} 64}
65 65
66void AdvancedFm::showHidden() { 66void AdvancedFm::showHidden() {
67 if (b) { 67 if (b) {
68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
69 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 69 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
70 } else { 70 } else {
71 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 71 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
72 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 72 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
73 } 73 }
74 populateView(); 74 populateView();
75} 75}
76 76
77QString AdvancedFm::dealWithSymName(const QString &fileName) { 77QString AdvancedFm::dealWithSymName(const QString &fileName) {
78 QString strItem = fileName; 78 QString strItem = fileName;
79 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 79 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
80} 80}
81 81
82void AdvancedFm::runThis() { 82void AdvancedFm::runThis() {
83 if( !CurrentView()->currentItem()) return; 83 if( !CurrentView()->currentItem()) return;
84 QString fs; 84 QString fs;
85 QDir *thisDir = CurrentDir(); 85 QDir *thisDir = CurrentDir();
86 86
87 QString curFile = CurrentView()->currentItem()->text(0); 87 QString curFile = CurrentView()->currentItem()->text(0);
88 QString path = thisDir->canonicalPath(); 88 QString path = thisDir->canonicalPath();
89 89
90 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 90 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
91 91
92 curFile = dealWithSymName((const QString&)curFile); 92 curFile = dealWithSymName((const QString&)curFile);
93 93
94 if(curFile != "../") { 94 if(curFile != "../") {
95 95
96 fs = getFileSystemType((const QString &) path); 96 fs = getFileSystemType((const QString &) path);
97 QFileInfo fileInfo( path + "/" + curFile); 97 QFileInfo fileInfo( path + "/" + curFile);
98// odebug << fileInfo.owner() << oendl; 98// odebug << fileInfo.owner() << oendl;
99 99
100 if( (fileInfo.permission( QFileInfo::ExeUser) 100 if( (fileInfo.permission( QFileInfo::ExeUser)
101 | fileInfo.permission( QFileInfo::ExeGroup) 101 | fileInfo.permission( QFileInfo::ExeGroup)
102 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 102 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
103 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 103 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
104 QCopEnvelope e("QPE/System", "execute(QString)" ); 104 QCopEnvelope e("QPE/System", "execute(QString)" );
105 e << curFile; 105 e << curFile;
106 } else { 106 } else {
107 curFile = path + "/" + curFile; 107 curFile = path + "/" + curFile;
108 DocLnk nf(curFile); 108 DocLnk nf(curFile);
109 QString execStr = nf.exec(); 109 QString execStr = nf.exec();
110// odebug << execStr << oendl; 110// odebug << execStr << oendl;
111 if( execStr.isEmpty() ) { 111 if( execStr.isEmpty() ) {
112 } else { 112 } else {
113 nf.execute(); 113 nf.execute();
114 } 114 }
115 } 115 }
116 } 116 }
117} 117}
118 118
119void AdvancedFm::runText() { 119void AdvancedFm::runText() {
120 if( !CurrentView()->currentItem()) return; 120 if( !CurrentView()->currentItem()) return;
121 QString curFile = CurrentView()->currentItem()->text(0); 121 QString curFile = CurrentView()->currentItem()->text(0);
122 if(curFile != "../") { 122 if(curFile != "../") {
123 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 123 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
124 curFile = dealWithSymName((const QString&)curFile); 124 curFile = dealWithSymName((const QString&)curFile);
125 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 125 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
126 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 126 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
127 e << curFile; 127 e << curFile;
128 } 128 }
129} 129}
130 130
131void AdvancedFm::makeDir() { 131void AdvancedFm::makeDir() {
132 InputDialog *fileDlg; 132 InputDialog *fileDlg;
133 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 133 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
134 fileDlg->exec(); 134 fileDlg->exec();
135 if( fileDlg->result() == 1 ) { 135 if( fileDlg->result() == 1 ) {
136 QDir *thisDir = CurrentDir(); 136 QDir *thisDir = CurrentDir();
137 QString filename = fileDlg->LineEdit1->text(); 137 QString filename = fileDlg->LineEdit1->text();
138 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 138 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
139 } 139 }
140 populateView(); 140 populateView();
141} 141}
142 142
143void AdvancedFm::doDelete() { 143void AdvancedFm::doDelete() {
144 QStringList curFileList = getPath(); 144 QStringList curFileList = getPath();
145 bool doMsg=true; 145 bool doMsg=true;
146 int count = curFileList.count(); 146 int count = curFileList.count();
147 if( count > 0) { 147 if( count > 0) {
148 if(count > 1 ) { 148 if(count > 1 ) {
149 QString msg; 149 QString msg;
150 msg=tr("<p>Really delete %1 files?</p>").arg(count); 150 msg=tr("<p>Really delete %1 files?</p>").arg(count);
151 switch ( QMessageBox::warning(this,tr("Delete"),msg 151 switch ( QMessageBox::warning(this,tr("Delete"),msg
152 ,tr("Yes"),tr("No"),0,0,1) ) 152 ,tr("Yes"),tr("No"),0,0,1) )
153 { 153 {
154 case 0: 154 case 0:
155 doMsg=false; 155 doMsg=false;
156 break; 156 break;
157 case 1: 157 case 1:
158 return; 158 return;
159 break; 159 break;
160 default: 160 default:
161 return; 161 return;
162 break; 162 break;
163 }; 163 };
164 } 164 }
165 165
166 QString myFile; 166 QString myFile;
167 167
168 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 168 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
169 myFile = (*it); 169 myFile = (*it);
170 if( myFile.find(" -> ",0,TRUE) != -1) 170 if( myFile.find(" -> ",0,TRUE) != -1)
171 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 171 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
172 172
173 QString f = CurrentDir()->canonicalPath(); 173 QString f = CurrentDir()->canonicalPath();
174 if(f.right(1).find("/",0,TRUE) == -1) 174 if(f.right(1).find("/",0,TRUE) == -1)
175 f += "/"; 175 f += "/";
176 f += myFile; 176 f += myFile;
177 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 177 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
178 //if file is a directory 178 //if file is a directory
179 179
180 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 180 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
181 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , 181 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) ,
182 tr("Yes"), tr("No"), 0, 0, 1) ) { 182 tr("Yes"), tr("No"), 0, 0, 1) ) {
183 case 0: 183 case 0:
184 { 184 {
185 f=f.left(f.length()-1); 185 f=f.left(f.length()-1);
186 QString cmd="rm -rf "+f; 186 QString cmd="rm -rf "+f;
187 startProcess( (const QString)cmd.latin1() ); 187 startProcess( (const QString)cmd.latin1() );
188 populateView(); 188 populateView();
189 } 189 }
190 break; 190 break;
191 case 1: 191 case 1:
192 // exit 192 // exit
193 break; 193 break;
194 default: 194 default:
195 break; 195 break;
196 }; 196 };
197 197
198 } else { 198 } else {
199 if(doMsg) { 199 if(doMsg) {
200 switch ( QMessageBox::warning(this,tr("Delete"), 200 switch ( QMessageBox::warning(this,tr("Delete"),
201 tr("<p>Really delete %1?</p>").arg( myFile ), 201 tr("<p>Really delete %1?</p>").arg( myFile ),
202 tr("Yes"), tr("No"), 0, 0, 1) ) { 202 tr("Yes"), tr("No"), 0, 0, 1) ) {
203 case 1: 203 case 0;
204 return; 204 break;
205 break; 205 case 1:
206 default: 206 return;
207 return; 207 break;
208 break; 208 default:
209 }; 209 return;
210 } 210 break;
211 };
212 }
211 213
212 QString cmd="rm "+f; 214 QString cmd="rm "+f;
213 QFile file(f); 215 QFile file(f);
214 QFileInfo fi(myFile); 216 QFileInfo fi(myFile);
215 if( fi.fileName().find("../",0,TRUE)==-1) { 217 if( fi.fileName().find("../",0,TRUE)==-1) {
216// odebug << "remove link files "+myFile << oendl; 218// odebug << "remove link files "+myFile << oendl;
217 219
218// DocLnk lnk(f); 220// DocLnk lnk(f);
219 DocLnk *lnk; 221 DocLnk *lnk;
220 lnk = new DocLnk(f); 222 lnk = new DocLnk(f);
221// odebug << "Deleting doclnk " + lnk->linkFile() << oendl; 223// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
222 if(lnk->isValid()) 224 if(lnk->isValid())
223 lnk->removeLinkFile(); 225 lnk->removeLinkFile();
224 // delete lnk; 226 // delete lnk;
225 file.remove(); 227 file.remove();
226 } 228 }
227 } 229 }
228 } 230 }
229 } 231 }
230 populateView(); 232 populateView();
231} 233}
232 234
233void AdvancedFm::filePerms() { 235void AdvancedFm::filePerms() {
234 QStringList curFileList = getPath(); 236 QStringList curFileList = getPath();
235 QString filePath; 237 QString filePath;
236 238
237 filePath = CurrentDir()->canonicalPath()+"/"; 239 filePath = CurrentDir()->canonicalPath()+"/";
238 240
239 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 241 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
240 filePermissions *filePerm; 242 filePermissions *filePerm;
241 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 243 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
242 QPEApplication::execDialog( filePerm ); 244 QPEApplication::execDialog( filePerm );
243 if( filePerm ) 245 if( filePerm )
244 delete filePerm; 246 delete filePerm;
245 } 247 }
246 populateView(); 248 populateView();
247} 249}
248 250
249void AdvancedFm::doProperties() { 251void AdvancedFm::doProperties() {
250#if defined(QT_QWS_OPIE) 252#if defined(QT_QWS_OPIE)
251 253
252 QStringList curFileList = getPath(); 254 QStringList curFileList = getPath();
253 255
254 QString filePath; 256 QString filePath;
255 filePath = CurrentDir()->canonicalPath()+"/"; 257 filePath = CurrentDir()->canonicalPath()+"/";
256 258
257// odebug << "" << curFileList.count() << "" << oendl; 259// odebug << "" << curFileList.count() << "" << oendl;
258 260
259 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 261 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
260// odebug << (filePath+*it) << oendl; 262// odebug << (filePath+*it) << oendl;
261 DocLnk lnk( (filePath+*it)); 263 DocLnk lnk( (filePath+*it));
262 LnkProperties prop( &lnk ); 264 LnkProperties prop( &lnk );
263 QPEApplication::execDialog( &prop ); 265 QPEApplication::execDialog( &prop );
264 } 266 }
265#endif 267#endif
266 268
267} 269}
268 270
269void AdvancedFm::upDir() { 271void AdvancedFm::upDir() {
270 272
271 QDir dir( CurrentDir()->canonicalPath()); 273 QDir dir( CurrentDir()->canonicalPath());
272 dir.cdUp(); 274 dir.cdUp();
273 changeTo(dir.canonicalPath()); 275 changeTo(dir.canonicalPath());
274} 276}
275 277
276void AdvancedFm::copyTimer() { 278void AdvancedFm::copyTimer() {
277 QTimer::singleShot(125,this,SLOT(copy())); 279 QTimer::singleShot(125,this,SLOT(copy()));
278} 280}
279 281
280void AdvancedFm::copy() { 282void AdvancedFm::copy() {
281 QStringList curFileList = getPath(); 283 QStringList curFileList = getPath();
282 284
283 QDir *thisDir = CurrentDir(); 285 QDir *thisDir = CurrentDir();
284 QDir *thatDir = OtherDir(); 286 QDir *thatDir = OtherDir();
285 287
286 bool doMsg = true; 288 bool doMsg = true;
287 int count = curFileList.count(); 289 int count = curFileList.count();
288 if( count > 0) { 290 if( count > 0) {
289 if(count > 1 ){ 291 if(count > 1 ){
290 QString msg; 292 QString msg;
291 msg=tr("<p>Really copy %1 files?</p>").arg(count); 293 msg=tr("<p>Really copy %1 files?</p>").arg(count);
292 switch ( QMessageBox::warning(this,tr("Copy"),msg 294 switch ( QMessageBox::warning(this,tr("Copy"),msg
293 ,tr("Yes"),tr("No"),0,0,1) ) 295 ,tr("Yes"),tr("No"),0,0,1) )
294 { 296 {
295 case 0: 297 case 0:
296 doMsg=false; 298 doMsg=false;
297 break; 299 break;
298 case 1: 300 case 1:
299 return; 301 return;
300 break; 302 break;
301 default: 303 default:
302 return; 304 return;
303 break; 305 break;
304 }; 306 };
305 } 307 }
306 308
307 QString curFile, item, destFile; 309 QString curFile, item, destFile;
308 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 310 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
309 item=(*it); 311 item=(*it);
310 if(item.find("->",0,TRUE)) //symlink 312 if(item.find("->",0,TRUE)) //symlink
311 item = item.left(item.find("->",0,TRUE)); 313 item = item.left(item.find("->",0,TRUE));
312 314
313 curFile = thisDir->canonicalPath()+"/"+ item; 315 curFile = thisDir->canonicalPath()+"/"+ item;
314 destFile = thatDir->canonicalPath()+"/"+ item; 316 destFile = thatDir->canonicalPath()+"/"+ item;
315 317
316// odebug << "Destination file is "+destFile << oendl; 318// odebug << "Destination file is "+destFile << oendl;
317// odebug << "CurrentFile file is " + curFile << oendl; 319// odebug << "CurrentFile file is " + curFile << oendl;
318 320
319 QFile f(destFile); 321 QFile f(destFile);
320 if( f.exists()) { 322 if( f.exists()) {
321 if(doMsg) { 323 if(doMsg) {
322 switch ( QMessageBox::warning(this,tr("File Exists!"), 324 switch ( QMessageBox::warning(this,tr("File Exists!"),
323 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), 325 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item),
324 tr("Yes"),tr("No"),0,0,1)) { 326 tr("Yes"),tr("No"),0,0,1)) {
327 case 0;
328 break;
325 case 1: 329 case 1:
326 return; 330 return;
327 break; 331 break;
328 default: 332 default:
329 return; 333 return;
330 break; 334 break;
331 }; 335 };
332 } 336 }
333 f.remove(); 337 f.remove();
334 } 338 }
335 339
336 if( !copyFile( curFile, destFile) ) { 340 if( !copyFile( curFile, destFile) ) {
337 QMessageBox::message("AdvancedFm", 341 QMessageBox::message("AdvancedFm",
338 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 342 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
339 return; 343 return;
340 } 344 }
341 } 345 }
342 rePopulate(); 346 rePopulate();
343 } 347 }
344} 348}
345 349
346void AdvancedFm::copyAsTimer() { 350void AdvancedFm::copyAsTimer() {
347 QTimer::singleShot(125,this,SLOT(copyAs())); 351 QTimer::singleShot(125,this,SLOT(copyAs()));
348} 352}
349 353
350void AdvancedFm::copyAs() { 354void AdvancedFm::copyAs() {
351 355
352 QStringList curFileList = getPath(); 356 QStringList curFileList = getPath();
353 QString curFile, item; 357 QString curFile, item;
354 InputDialog *fileDlg; 358 InputDialog *fileDlg;
355 359
356 QDir *thisDir = CurrentDir(); 360 QDir *thisDir = CurrentDir();
357 QDir *thatDir = OtherDir(); 361 QDir *thatDir = OtherDir();
358 362
359 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 363 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
360 QString destFile; 364 QString destFile;
361 item=(*it); 365 item=(*it);
362 curFile = thisDir->canonicalPath()+"/"+(*it); 366 curFile = thisDir->canonicalPath()+"/"+(*it);
363 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); 367 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0);
364 368
365 fileDlg->setInputText((const QString &) destFile ); 369 fileDlg->setInputText((const QString &) destFile );
366 fileDlg->exec(); 370 fileDlg->exec();
367 371
368 if( fileDlg->result() == 1 ) { 372 if( fileDlg->result() == 1 ) {
369 QString filename = fileDlg->LineEdit1->text(); 373 QString filename = fileDlg->LineEdit1->text();
370 destFile = thatDir->canonicalPath()+"/"+filename; 374 destFile = thatDir->canonicalPath()+"/"+filename;
371 375
372 QFile f( destFile); 376 QFile f( destFile);
373 if( f.exists()) { 377 if( f.exists()) {
374 switch (QMessageBox::warning(this,tr("File Exists!"), 378 switch (QMessageBox::warning(this,tr("File Exists!"),
375 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), 379 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item),
376 tr("Yes"),tr("No"),0,0,1) ) { 380 tr("Yes"),tr("No"),0,0,1) ) {
377 case 0: 381 case 0:
378 f.remove(); 382 f.remove();
379 break; 383 break;
380 case 1: 384 case 1:
381 return; 385 return;
382 break; 386 break;
383 default: 387 default:
384 return; 388 return;
385 break; 389 break;
386 }; 390 };
387 } 391 }
388 if( !copyFile( curFile, destFile) ) { 392 if( !copyFile( curFile, destFile) ) {
389 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 393 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
390 return; 394 return;
391 } 395 }
392 } 396 }
393 delete fileDlg; 397 delete fileDlg;
394 398
395 } 399 }
396 rePopulate(); 400 rePopulate();
397 // setOtherTabCurrent(); 401 // setOtherTabCurrent();
398 qApp->processEvents(); 402 qApp->processEvents();
399 403
400} 404}
401 405
402void AdvancedFm::copySameDirTimer() { 406void AdvancedFm::copySameDirTimer() {
403 QTimer::singleShot(125,this,SLOT(copySameDir())); 407 QTimer::singleShot(125,this,SLOT(copySameDir()));
404} 408}
405 409
406void AdvancedFm::copySameDir() { 410void AdvancedFm::copySameDir() {
407 qApp->processEvents(); 411 qApp->processEvents();
408 QStringList curFileList = getPath(); 412 QStringList curFileList = getPath();
409 QString curFile, item, destFile; 413 QString curFile, item, destFile;
410 InputDialog *fileDlg; 414 InputDialog *fileDlg;
411 415
412 QDir *thisDir = CurrentDir(); 416 QDir *thisDir = CurrentDir();
413 417
414 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 418 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
415 item=(*it); 419 item=(*it);
416 curFile = thisDir->canonicalPath()+"/"+ item; 420 curFile = thisDir->canonicalPath()+"/"+ item;
417 421
418 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 422 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
419 fileDlg->setInputText((const QString &) destFile ); 423 fileDlg->setInputText((const QString &) destFile );
420 fileDlg->exec(); 424 fileDlg->exec();
421 425
422 if( fileDlg->result() == 1 ) { 426 if( fileDlg->result() == 1 ) {
423 427
424 QString filename = fileDlg->LineEdit1->text(); 428 QString filename = fileDlg->LineEdit1->text();
425 destFile = thisDir->canonicalPath()+"/"+filename; 429 destFile = thisDir->canonicalPath()+"/"+filename;
426 430
427 QFile f(destFile); 431 QFile f(destFile);
428 if( f.exists()) { 432 if( f.exists()) {
429 switch (QMessageBox::warning(this,tr("Delete"), 433 switch (QMessageBox::warning(this,tr("Delete"),
430 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), 434 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile),
431 tr("Yes"),tr("No"),0,0,1) ) { 435 tr("Yes"),tr("No"),0,0,1) ) {
432 case 0: 436 case 0:
433
434 f.remove(); 437 f.remove();
435 break; 438 break;
436 case 1: 439 case 1:
437 return; 440 return;
438 break; 441 break;
439 default: 442 default:
440 return; 443 return;
441 break; 444 break;
442 }; 445 };
443 } 446 }
444 if(!copyFile( curFile,destFile) ) { 447 if(!copyFile( curFile,destFile) ) {
445 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 448 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
446 return; 449 return;
447 } 450 }
448 451
449// odebug << "copy "+curFile+" as "+destFile << oendl; 452// odebug << "copy "+curFile+" as "+destFile << oendl;
450 } 453 }
451 delete fileDlg; 454 delete fileDlg;
452 } 455 }
453 rePopulate(); 456 rePopulate();
454} 457}
455 458
456void AdvancedFm::moveTimer() { 459void AdvancedFm::moveTimer() {
457 QTimer::singleShot(125,this,SLOT(move())); 460 QTimer::singleShot(125,this,SLOT(move()));
458} 461}
459 462
460void AdvancedFm::move() { 463void AdvancedFm::move() {
461 464
462 QStringList curFileList = getPath(); 465 QStringList curFileList = getPath();
463 if( curFileList.count() > 0) { 466 if( curFileList.count() > 0) {
464 QString curFile, destFile, item; 467 QString curFile, destFile, item;
465 468
466 QDir *thisDir = CurrentDir(); 469 QDir *thisDir = CurrentDir();
467 QDir *thatDir = OtherDir(); 470 QDir *thatDir = OtherDir();
468 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 471 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
469 item=(*it); 472 item=(*it);
470 QString destFile = thatDir->canonicalPath(); 473 QString destFile = thatDir->canonicalPath();
471 474
472 if(destFile.right(1).find("/",0,TRUE) == -1) 475 if(destFile.right(1).find("/",0,TRUE) == -1)
473 destFile+="/"; 476 destFile+="/";
474 destFile += item; 477 destFile += item;
475// odebug << "Destination file is "+destFile << oendl; 478// odebug << "Destination file is "+destFile << oendl;
476 479
477 curFile = thisDir->canonicalPath(); 480 curFile = thisDir->canonicalPath();
478 if(curFile.right(1).find("/",0,TRUE) == -1) 481 if(curFile.right(1).find("/",0,TRUE) == -1)
479 curFile +="/"; 482 curFile +="/";
480 curFile+= item; 483 curFile+= item;
481// odebug << "CurrentFile file is " + curFile << oendl; 484// odebug << "CurrentFile file is " + curFile << oendl;
482 485
483 if(QFileInfo(curFile).isDir()) { 486 if(QFileInfo(curFile).isDir()) {
484 moveDirectory( curFile, destFile ); 487 moveDirectory( curFile, destFile );
485 rePopulate(); 488 rePopulate();
486 return; 489 return;
487 } 490 }
488 QFile f( destFile); 491 QFile f( destFile);
489 if( f.exists()) { 492 if( f.exists()) {
490 switch ( QMessageBox::warning(this,tr("File Exists!"), 493 switch ( QMessageBox::warning(this,tr("File Exists!"),
491 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), 494 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile),
492 tr("Yes"),tr("No"),0,0,1)) { 495 tr("Yes"),tr("No"),0,0,1)) {
493 case 0: 496 case 0:
494 break; 497 break;
495 case 1: 498 case 1:
496 return; 499 return;
497 break; 500 break;
498 default: 501 default:
499 return; 502 return;
500 break; 503 break;
501 }; 504 };
502 } 505 }
503 if( !copyFile( curFile, destFile) ) { 506 if( !copyFile( curFile, destFile) ) {
504 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); 507 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile));
505 return; 508 return;
506 } else 509 } else
507 QFile::remove(curFile); 510 QFile::remove(curFile);
508 } 511 }
509 } 512 }
510 rePopulate(); 513 rePopulate();
511 //setOtherTabCurrent(); 514 //setOtherTabCurrent();
512} 515}
513 516
514bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 517bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
515 int err = 0; 518 int err = 0;
516 if( copyDirectory( src, dest ) ) { 519 if( copyDirectory( src, dest ) ) {
517 QString cmd = "rm -rf " + src; 520 QString cmd = "rm -rf " + src;
518 err = system((const char*)cmd); 521 err = system((const char*)cmd);
519 } else 522 } else
520 err = -1; 523 err = -1;
521 524
522 if(err!=0) { 525 if(err!=0) {
523 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); 526 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src));
524 return false; 527 return false;
525 } 528 }
526 return true; 529 return true;
527} 530}
528 531
529bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 532bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
530 533
531 QString cmd = "/bin/cp -fpR " + src + " " + dest; 534 QString cmd = "/bin/cp -fpR " + src + " " + dest;
532 owarn << cmd << oendl; 535 owarn << cmd << oendl;
533 int err = system( (const char *) cmd ); 536 int err = system( (const char *) cmd );
534 if ( err != 0 ) { 537 if ( err != 0 ) {
535 QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); 538 QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) );
536 return false; 539 return false;
537 } 540 }
538 541
539 return true; 542 return true;
540} 543}
541 544
542 545
543bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 546bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
544 if(QFileInfo(src).isDir()) { 547 if(QFileInfo(src).isDir()) {
545 if( copyDirectory( src, dest )) { 548 if( copyDirectory( src, dest )) {
546 // setOtherTabCurrent(); 549 // setOtherTabCurrent();
547 rePopulate(); 550 rePopulate();
548 return true; 551 return true;
549 } 552 }
550 else 553 else
551 return false; 554 return false;
552 } 555 }
553 556
554 557
555 bool success = true; 558 bool success = true;
556 struct stat status; 559 struct stat status;
557 QFile srcFile(src); 560 QFile srcFile(src);
558 QFile destFile(dest); 561 QFile destFile(dest);
559 int err=0; 562 int err=0;
560 int read_fd=0; 563 int read_fd=0;
561 int write_fd=0; 564 int write_fd=0;
562 struct stat stat_buf; 565 struct stat stat_buf;
563 off_t offset = 0; 566 off_t offset = 0;
564 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 567 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
565// owarn << "open failed" << oendl; 568// owarn << "open failed" << oendl;
566 return success = false; 569 return success = false;
567 } 570 }
568 read_fd = srcFile.handle(); 571 read_fd = srcFile.handle();
569 if(read_fd != -1) { 572 if(read_fd != -1) {
570 fstat (read_fd, &stat_buf); 573 fstat (read_fd, &stat_buf);
571 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 574 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
572// owarn << "destfile open failed" << oendl; 575// owarn << "destfile open failed" << oendl;
573 return success = false; 576 return success = false;
574 } 577 }
575 write_fd = destFile.handle(); 578 write_fd = destFile.handle();
576 if(write_fd != -1) { 579 if(write_fd != -1) {
577 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 580 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
578 if( err == -1) { 581 if( err == -1) {
579 QString msg; 582 QString msg;
580 switch(err) { 583 switch(err) {
581 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 584 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
582 case EINVAL: msg = "Descriptor is not valid or locked. "; 585 case EINVAL: msg = "Descriptor is not valid or locked. ";
583 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 586 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
584 case EIO: msg = "Unspecified error while reading from in_fd."; 587 case EIO: msg = "Unspecified error while reading from in_fd.";
585 }; 588 };
586 success = false; 589 success = false;
587// owarn << msg << oendl; 590// owarn << msg << oendl;
588 } 591 }
589 } else { 592 } else {
590 success = false; 593 success = false;
591 } 594 }
592 } else { 595 } else {
593 success = false; 596 success = false;
594 } 597 }
595 srcFile.close(); 598 srcFile.close();
596 destFile.close(); 599 destFile.close();
597 // Set file permissions 600 // Set file permissions
598 if( stat( QFile::encodeName(src), &status ) == 0 ) { 601 if( stat( QFile::encodeName(src), &status ) == 0 ) {
599 chmod( QFile::encodeName(dest), status.st_mode ); 602 chmod( QFile::encodeName(dest), status.st_mode );
600 } 603 }
601 604
602 return success; 605 return success;
603} 606}
604 607
605void AdvancedFm::runCommand() { 608void AdvancedFm::runCommand() {
606 if( !CurrentView()->currentItem()) return; 609 if( !CurrentView()->currentItem()) return;
607 QDir *thisDir = CurrentDir(); 610 QDir *thisDir = CurrentDir();
608 611
609 QString curFile; 612 QString curFile;
610 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 613 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
611 614
612 InputDialog *fileDlg; 615 InputDialog *fileDlg;
613 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 616 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
614 fileDlg->setInputText(curFile); 617 fileDlg->setInputText(curFile);
615 fileDlg->exec(); 618 fileDlg->exec();
616 //QString command; 619 //QString command;
617 620
618 if( fileDlg->result() == 1 ) { 621 if( fileDlg->result() == 1 ) {
619// odebug << fileDlg->LineEdit1->text() << oendl; 622// odebug << fileDlg->LineEdit1->text() << oendl;
620 QStringList command; 623 QStringList command;
621 624
622 command << "/bin/sh"; 625 command << "/bin/sh";
623 command << "-c"; 626 command << "-c";
624 command << fileDlg->LineEdit1->text(); 627 command << fileDlg->LineEdit1->text();
625 Output *outDlg; 628 Output *outDlg;
626 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 629 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
627 QPEApplication::execDialog( outDlg ); 630 QPEApplication::execDialog( outDlg );
628 qApp->processEvents(); 631 qApp->processEvents();
629 632
630 } 633 }
631} 634}
632 635
633void AdvancedFm::runCommandStd() { 636void AdvancedFm::runCommandStd() {
634 if( !CurrentView()->currentItem()) return; 637 if( !CurrentView()->currentItem()) return;
635 QString curFile; 638 QString curFile;
636 QDir *thisDir = CurrentDir(); 639 QDir *thisDir = CurrentDir();
637 QListView *thisView = CurrentView(); 640 QListView *thisView = CurrentView();
638 if( thisView->currentItem()) 641 if( thisView->currentItem())
639 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 642 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
640 643
641 InputDialog *fileDlg; 644 InputDialog *fileDlg;
642 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 645 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
643 fileDlg->setInputText(curFile); 646 fileDlg->setInputText(curFile);
644 fileDlg->exec(); 647 fileDlg->exec();
645 648
646 if( fileDlg->result() == 1 ) { 649 if( fileDlg->result() == 1 ) {
647 qApp->processEvents(); 650 qApp->processEvents();
648 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 651 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
649 } 652 }
650} 653}
651 654
652void AdvancedFm::fileStatus() { 655void AdvancedFm::fileStatus() {
653 if( !CurrentView()->currentItem()) return; 656 if( !CurrentView()->currentItem()) return;
654 QString curFile; 657 QString curFile;
655 curFile = CurrentView()->currentItem()->text(0); 658 curFile = CurrentView()->currentItem()->text(0);
656 659
657 QStringList command; 660 QStringList command;
658 command << "/bin/sh"; 661 command << "/bin/sh";
659 command << "-c"; 662 command << "-c";
660 command << "stat -l "+ curFile; 663 command << "stat -l "+ curFile;
661 664
662 Output *outDlg; 665 Output *outDlg;
663 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 666 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
664 QPEApplication::execDialog( outDlg ); 667 QPEApplication::execDialog( outDlg );
665 qApp->processEvents(); 668 qApp->processEvents();
666} 669}
667 670
668 671
669void AdvancedFm::mkDir() { 672void AdvancedFm::mkDir() {
670 makeDir(); 673 makeDir();
671} 674}
672 675
673void AdvancedFm::rn() { 676void AdvancedFm::rn() {
674 renameIt(); 677 renameIt();
675} 678}
676 679
677void AdvancedFm::del() { 680void AdvancedFm::del() {
678 doDelete(); 681 doDelete();
679} 682}
680 683
681void AdvancedFm::mkSym() { 684void AdvancedFm::mkSym() {
682 QString cmd; 685 QString cmd;
683 QStringList curFileList = getPath(); 686 QStringList curFileList = getPath();
684 if( curFileList.count() > 0) { 687 if( curFileList.count() > 0) {
685 QDir *thisDir = CurrentDir(); 688 QDir *thisDir = CurrentDir();
686 QDir * thatDir = OtherDir(); 689 QDir * thatDir = OtherDir();
687 690
688 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 691 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
689 692
690 QString destName = thatDir->canonicalPath()+"/"+(*it); 693 QString destName = thatDir->canonicalPath()+"/"+(*it);
691 if(destName.right(1) == "/") { 694 if(destName.right(1) == "/") {
692 destName = destName.left( destName.length() -1); 695 destName = destName.left( destName.length() -1);
693 } 696 }
694 697
695 QString curFile = thisDir->canonicalPath()+"/"+(*it); 698 QString curFile = thisDir->canonicalPath()+"/"+(*it);
696 699
697 if( curFile.right(1) == "/") { 700 if( curFile.right(1) == "/") {
698 curFile = curFile.left( curFile.length() -1); 701 curFile = curFile.left( curFile.length() -1);
699 } 702 }
700 703
701 cmd = "ln -s "+curFile+" "+destName; 704 cmd = "ln -s "+curFile+" "+destName;
702// odebug << cmd << oendl; 705// odebug << cmd << oendl;
703 startProcess( (const QString)cmd ); 706 startProcess( (const QString)cmd );
704 } 707 }
705 rePopulate(); 708 rePopulate();
706 setOtherTabCurrent(); 709 setOtherTabCurrent();
707 } 710 }
708} 711}
709 712
710void AdvancedFm::doBeam() { 713void AdvancedFm::doBeam() {
711 Ir ir; 714 Ir ir;
712 if(!ir.supported()) { 715 if(!ir.supported()) {
713 } else { 716 } else {
714 QStringList curFileList = getPath(); 717 QStringList curFileList = getPath();
715 if( curFileList.count() > 0) { 718 if( curFileList.count() > 0) {
716 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 719 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
717 QString curFile = (*it); 720 QString curFile = (*it);
718 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 721 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
719 if( curFilePath.right(1) == "/") { 722 if( curFilePath.right(1) == "/") {
720 curFilePath = curFilePath.left( curFilePath.length() -1); 723 curFilePath = curFilePath.left( curFilePath.length() -1);
721 } 724 }
722 Ir *file = new Ir(this, "IR"); 725 Ir *file = new Ir(this, "IR");
723 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); 726 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
724 file->send( curFilePath, curFile ); 727 file->send( curFilePath, curFile );
725 } 728 }
726 } 729 }
727 } 730 }
728} 731}
729 732
730void AdvancedFm::fileBeamFinished( Ir *) { 733void AdvancedFm::fileBeamFinished( Ir *) {
731 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 734 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
732} 735}
733 736
734void AdvancedFm::selectAll() { 737void AdvancedFm::selectAll() {
735 QListView *thisView = CurrentView(); 738 QListView *thisView = CurrentView();
736 thisView->selectAll(true); 739 thisView->selectAll(true);
737 thisView->setSelected( thisView->firstChild(),false); 740 thisView->setSelected( thisView->firstChild(),false);
738} 741}
739 742
740void AdvancedFm::startProcess(const QString & cmd) { 743void AdvancedFm::startProcess(const QString & cmd) {
741 QStringList command; 744 QStringList command;
742 OProcess *process; 745 OProcess *process;
743 process = new OProcess(); 746 process = new OProcess();
744 connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); 747 connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*)));
745 connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); 748 connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int)));
746 749
747 command << "/bin/sh"; 750 command << "/bin/sh";
748 command << "-c"; 751 command << "-c";
749 command << cmd.latin1(); 752 command << cmd.latin1();
750 *process << command; 753 *process << command;
751 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 754 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
752 odebug << "could not start process" << oendl; 755 odebug << "could not start process" << oendl;
753} 756}
754 757
755void AdvancedFm::processEnded(OProcess *) { 758void AdvancedFm::processEnded(OProcess *) {
756 rePopulate(); 759 rePopulate();
757} 760}
758 761
759void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 762void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
760// owarn << "received stderrt " << buflen << " bytes" << oendl; 763// owarn << "received stderrt " << buflen << " bytes" << oendl;
761 764
762 QString lineStr = buffer; 765 QString lineStr = buffer;
763 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 766 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
764} 767}
765 768
766bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 769bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
767 if ( o->inherits( "QLineEdit" ) ) { 770 if ( o->inherits( "QLineEdit" ) ) {
768 if ( e->type() == QEvent::KeyPress ) { 771 if ( e->type() == QEvent::KeyPress ) {
769 QKeyEvent *ke = (QKeyEvent*)e; 772 QKeyEvent *ke = (QKeyEvent*)e;
770 if ( ke->key() == Key_Return || 773 if ( ke->key() == Key_Return ||
771 ke->key() == Key_Enter ) { 774 ke->key() == Key_Enter ) {
772 okRename(); 775 okRename();
773 return true; 776 return true;
774 } 777 }
775 else if ( ke->key() == Key_Escape ) { 778 else if ( ke->key() == Key_Escape ) {
776 cancelRename(); 779 cancelRename();
777 return true; 780 return true;
778 } 781 }
779 } 782 }
780 else if ( e->type() == QEvent::FocusOut ) { 783 else if ( e->type() == QEvent::FocusOut ) {
781 cancelRename(); 784 cancelRename();
782 return true; 785 return true;
783 } 786 }
784 } 787 }
785 if ( o->inherits( "QListView" ) ) { 788 if ( o->inherits( "QListView" ) ) {
786 if ( e->type() == QEvent::FocusIn ) { 789 if ( e->type() == QEvent::FocusIn ) {
787 if( o == Local_View) { //keep track of which view 790 if( o == Local_View) { //keep track of which view
788 whichTab = 1; 791 whichTab = 1;
789 viewMenu->setItemChecked(viewMenu->idAt(0), true); 792 viewMenu->setItemChecked(viewMenu->idAt(0), true);
790 viewMenu->setItemChecked(viewMenu->idAt(1), false); 793 viewMenu->setItemChecked(viewMenu->idAt(1), false);
791 } else { 794 } else {
792 whichTab = 2; 795 whichTab = 2;
793 viewMenu->setItemChecked(viewMenu->idAt(0), false); 796 viewMenu->setItemChecked(viewMenu->idAt(0), false);
794 viewMenu->setItemChecked(viewMenu->idAt(1), true); 797 viewMenu->setItemChecked(viewMenu->idAt(1), true);
795 } 798 }
796 } 799 }
797 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 800 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
798 } 801 }
799 802
800 return QWidget::eventFilter( o, e ); 803 return QWidget::eventFilter( o, e );
801} 804}
802 805
803 806
804void AdvancedFm::cancelRename() { 807void AdvancedFm::cancelRename() {
805// odebug << "cancel rename" << oendl; 808// odebug << "cancel rename" << oendl;
806 QListView * view; 809 QListView * view;
807 view = CurrentView(); 810 view = CurrentView();
808 811
809 bool resetFocus = view->viewport()->focusProxy() == renameBox; 812 bool resetFocus = view->viewport()->focusProxy() == renameBox;
810 delete renameBox; 813 delete renameBox;
811 renameBox = 0; 814 renameBox = 0;
812 if ( resetFocus ) { 815 if ( resetFocus ) {
813 view->viewport()->setFocusProxy( view); 816 view->viewport()->setFocusProxy( view);
814 view->setFocus(); 817 view->setFocus();
815 } 818 }
816} 819}
817 820