summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp862
1 files changed, 438 insertions, 424 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index a82d69a..eac13f6 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -54,20 +54,20 @@ void AdvancedFm::doDirChange()
54void AdvancedFm::showMenuHidden() 54void AdvancedFm::showMenuHidden()
55{ 55{
56 if (b) 56 if (b)
57 { 57 {
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),TRUE); 60 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
61// b=FALSE; 61// b=FALSE;
62 62
63 } 63 }
64 else 64 else
65 { 65 {
66 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 66 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
67 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 67 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
68 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 68 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
69// b=TRUE; 69// b=TRUE;
70 } 70 }
71 rePopulate(); 71 rePopulate();
72// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); 72// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
73 if(b) b = false; else b = true; 73 if(b) b = false; else b = true;
@@ -76,20 +76,20 @@ void AdvancedFm::showMenuHidden()
76void AdvancedFm::showHidden() 76void AdvancedFm::showHidden()
77{ 77{
78 if (b) 78 if (b)
79 { 79 {
80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
81 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 81 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
83// b=FALSE; 83// b=FALSE;
84 84
85 } 85 }
86 else 86 else
87 { 87 {
88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
89 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 89 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
90// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 90// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
91// b=TRUE; 91// b=TRUE;
92 } 92 }
93 rePopulate(); 93 rePopulate();
94} 94}
95 95
@@ -101,53 +101,53 @@ QString AdvancedFm::dealWithSymName(const QString &fileName)
101 101
102void AdvancedFm::runThis() 102void AdvancedFm::runThis()
103{ 103{
104 QString fs; 104 QString fs;
105 QDir *thisDir = CurrentDir(); 105 QDir *thisDir = CurrentDir();
106 106
107 QString curFile = CurrentView()->currentItem()->text(0); 107 QString curFile = CurrentView()->currentItem()->text(0);
108 QString path = thisDir->canonicalPath(); 108 QString path = thisDir->canonicalPath();
109 109
110 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 110 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
111 111
112 curFile = dealWithSymName((const QString&)curFile); 112 curFile = dealWithSymName((const QString&)curFile);
113 113
114 if(curFile != "../") 114 if(curFile != "../")
115 { 115 {
116 116
117 fs = getFileSystemType((const QString &) path); 117 fs = getFileSystemType((const QString &) path);
118 QFileInfo fileInfo( path + "/" + curFile); 118 QFileInfo fileInfo( path + "/" + curFile);
119 qDebug( fileInfo.owner()); 119 qDebug( fileInfo.owner());
120 120
121 if( (fileInfo.permission( QFileInfo::ExeUser) 121 if( (fileInfo.permission( QFileInfo::ExeUser)
122 | fileInfo.permission( QFileInfo::ExeGroup) 122 | fileInfo.permission( QFileInfo::ExeGroup)
123 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 123 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
124 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 124 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
125 QCopEnvelope e("QPE/System", "execute(QString)" ); 125 QCopEnvelope e("QPE/System", "execute(QString)" );
126 e << curFile; 126 e << curFile;
127 } 127 }
128 else 128 else
129 { 129 {
130 curFile = path + "/" + curFile; 130 curFile = path + "/" + curFile;
131 DocLnk nf(curFile); 131 DocLnk nf(curFile);
132 QString execStr = nf.exec(); 132 QString execStr = nf.exec();
133 qDebug( execStr); 133 qDebug( execStr);
134 if( execStr.isEmpty() ) 134 if( execStr.isEmpty() )
135 { 135 {
136 } 136 }
137 else 137 else
138 { 138 {
139 nf.execute(); 139 nf.execute();
140 } 140 }
141 } 141 }
142 } 142 }
143} 143}
144 144
145void AdvancedFm::runText() 145void AdvancedFm::runText()
146{ 146{
147 QString curFile = CurrentView()->currentItem()->text(0); 147 QString curFile = CurrentView()->currentItem()->text(0);
148 if(curFile != "../") 148 if(curFile != "../")
149 { 149 {
150 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 150 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
151 curFile = dealWithSymName((const QString&)curFile); 151 curFile = dealWithSymName((const QString&)curFile);
152 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 152 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
153 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 153 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
@@ -161,10 +161,10 @@ void AdvancedFm::makeDir()
161 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 161 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
162 fileDlg->exec(); 162 fileDlg->exec();
163 if( fileDlg->result() == 1 ) 163 if( fileDlg->result() == 1 )
164 { 164 {
165 QDir *thisDir = CurrentDir(); 165 QDir *thisDir = CurrentDir();
166 QString filename = fileDlg->LineEdit1->text(); 166 QString filename = fileDlg->LineEdit1->text();
167 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 167 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
168 } 168 }
169 populateView(); 169 populateView();
170} 170}
@@ -176,14 +176,14 @@ void AdvancedFm::doDelete()
176 bool doMsg=true; 176 bool doMsg=true;
177 int count = curFileList.count(); 177 int count = curFileList.count();
178 if( count > 0) 178 if( count > 0)
179 { 179 {
180 if(count > 1 ) 180 if(count > 1 )
181 { 181 {
182 QString msg; 182 QString msg;
183 msg=tr("Really delete\n%1 files?").arg(count); 183 msg=tr("Really delete\n%1 files?").arg(count);
184 switch ( QMessageBox::warning(this,tr("Delete"),msg 184 switch ( QMessageBox::warning(this,tr("Delete"),msg
185 ,tr("Yes"),tr("No"),0,0,1) ) 185 ,tr("Yes"),tr("No"),0,0,1) )
186 { 186 {
187 case 0: 187 case 0:
188 doMsg=false; 188 doMsg=false;
189 break; 189 break;
@@ -195,7 +195,7 @@ void AdvancedFm::doDelete()
195 195
196 QString myFile; 196 QString myFile;
197 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 197 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
198 { 198 {
199 myFile = (*it); 199 myFile = (*it);
200 if( myFile.find(" -> ",0,TRUE) != -1) 200 if( myFile.find(" -> ",0,TRUE) != -1)
201 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 201 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
@@ -205,13 +205,13 @@ void AdvancedFm::doDelete()
205 f += "/"; 205 f += "/";
206 f += myFile; 206 f += myFile;
207 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) 207 if(QDir(f).exists() && !QFileInfo(f).isSymLink() )
208 { 208 {
209 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + 209 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f +
210 "\nand all it's contents ?" 210 "\nand all it's contents ?"
211 ,tr("Yes"),tr("No"),0,0,1) ) 211 ,tr("Yes"),tr("No"),0,0,1) )
212 { 212 {
213 case 0: 213 case 0:
214 { 214 {
215 f=f.left(f.length()-1); 215 f=f.left(f.length()-1);
216 QString cmd="rm -rf "+f; 216 QString cmd="rm -rf "+f;
217 startProcess( (const QString)cmd.latin1() ); 217 startProcess( (const QString)cmd.latin1() );
@@ -244,21 +244,21 @@ void AdvancedFm::doDelete()
244 244
245void AdvancedFm::filePerms() 245void AdvancedFm::filePerms()
246{ 246{
247 QStringList curFileList = getPath(); 247 QStringList curFileList = getPath();
248 QString filePath; 248 QString filePath;
249 249
250 filePath = CurrentDir()->canonicalPath()+"/"; 250 filePath = CurrentDir()->canonicalPath()+"/";
251 251
252 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 252 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
253 { 253 {
254 filePermissions *filePerm; 254 filePermissions *filePerm;
255 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 255 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
256 filePerm->showMaximized(); 256 filePerm->showMaximized();
257 filePerm->exec(); 257 filePerm->exec();
258 if( filePerm) 258 if( filePerm)
259 delete filePerm; 259 delete filePerm;
260 } 260 }
261 populateView(); 261 populateView();
262} 262}
263 263
264void AdvancedFm::doProperties() 264void AdvancedFm::doProperties()
@@ -270,10 +270,10 @@ void AdvancedFm::doProperties()
270 QString filePath; 270 QString filePath;
271 filePath = CurrentDir()->canonicalPath()+"/"; 271 filePath = CurrentDir()->canonicalPath()+"/";
272 272
273 qDebug("%d",curFileList.count()); 273 qDebug("%d",curFileList.count());
274 274
275 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 275 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
276 { 276 {
277 qDebug((filePath+*it)); 277 qDebug((filePath+*it));
278 DocLnk lnk( (filePath+*it)); 278 DocLnk lnk( (filePath+*it));
279 LnkProperties prop( &lnk ); 279 LnkProperties prop( &lnk );
@@ -286,16 +286,16 @@ void AdvancedFm::doProperties()
286 286
287void AdvancedFm::upDir() 287void AdvancedFm::upDir()
288{ 288{
289 QDir *thisDir = CurrentDir(); 289 QDir *thisDir = CurrentDir();
290 QString current = thisDir->canonicalPath(); 290 QString current = thisDir->canonicalPath();
291 QDir dir(current); 291 QDir dir(current);
292 dir.cdUp(); 292 dir.cdUp();
293 current = dir.canonicalPath(); 293 current = dir.canonicalPath();
294 chdir( current.latin1() ); 294 chdir( current.latin1() );
295 thisDir->cd( current, TRUE); 295 thisDir->cd( current, TRUE);
296 296
297 populateView(); 297 populateView();
298 update(); 298 update();
299} 299}
300 300
301void AdvancedFm::copy() 301void AdvancedFm::copy()
@@ -304,65 +304,65 @@ void AdvancedFm::copy()
304 QStringList curFileList = getPath(); 304 QStringList curFileList = getPath();
305 305
306 QDir *thisDir = CurrentDir(); 306 QDir *thisDir = CurrentDir();
307 QDir *thatDir = OtherDir(); 307 QDir *thatDir = OtherDir();
308 308
309 bool doMsg=true; 309 bool doMsg=true;
310 int count=curFileList.count(); 310 int count=curFileList.count();
311 if( count > 0) { 311 if( count > 0) {
312 if(count > 1 ){ 312 if(count > 1 ){
313 QString msg; 313 QString msg;
314 msg=tr("Really copy\n%1 files?").arg(count); 314 msg=tr("Really copy\n%1 files?").arg(count);
315 switch ( QMessageBox::warning(this,tr("Delete"),msg 315 switch ( QMessageBox::warning(this,tr("Delete"),msg
316 ,tr("Yes"),tr("No"),0,0,1) ) 316 ,tr("Yes"),tr("No"),0,0,1) )
317 { 317 {
318 case 0: 318 case 0:
319 doMsg=false; 319 doMsg=false;
320 break; 320 break;
321 case 1: 321 case 1:
322 return; 322 return;
323 break; 323 break;
324 }; 324 };
325 } 325 }
326 326
327 QString curFile, item, destFile; 327 QString curFile, item, destFile;
328 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 328 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
329 { 329 {
330 item=(*it); 330 item=(*it);
331 if(item.find("->",0,TRUE)) //symlink 331 if(item.find("->",0,TRUE)) //symlink
332 item = item.left(item.find("->",0,TRUE)); 332 item = item.left(item.find("->",0,TRUE));
333 333
334 curFile = thisDir->canonicalPath()+"/"+ item; 334 curFile = thisDir->canonicalPath()+"/"+ item;
335 destFile = thatDir->canonicalPath()+"/"+ item; 335 destFile = thatDir->canonicalPath()+"/"+ item;
336 336
337 qDebug("Destination file is "+destFile); 337 qDebug("Destination file is "+destFile);
338 qDebug("CurrentFile file is " + curFile); 338 qDebug("CurrentFile file is " + curFile);
339 339
340 QFile f(destFile); 340 QFile f(destFile);
341 if( f.exists()) 341 if( f.exists())
342 { 342 {
343 if(doMsg) 343 if(doMsg)
344 { 344 {
345 switch ( QMessageBox::warning(this,tr("File Exists!"), 345 switch ( QMessageBox::warning(this,tr("File Exists!"),
346 tr("%1 exists. Ok to overwrite?").arg( item ), 346 tr("%1 exists. Ok to overwrite?").arg( item ),
347 tr("Yes"),tr("No"),0,0,1) ) 347 tr("Yes"),tr("No"),0,0,1) )
348 { 348 {
349 case 1: 349 case 1:
350 return; 350 return;
351 break; 351 break;
352 }; 352 };
353 } 353 }
354 f.remove(); 354 f.remove();
355 } 355 }
356 356
357 if( !copyFile( curFile, destFile) ) 357 if( !copyFile( curFile, destFile) )
358 { 358 {
359 QMessageBox::message("AdvancedFm", 359 QMessageBox::message("AdvancedFm",
360 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 360 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
361 return; 361 return;
362 } 362 }
363 } 363 }
364 setOtherTabCurrent(); 364 setOtherTabCurrent();
365 populateView(); 365 populateView();
366 } 366 }
367} 367}
368 368
@@ -374,12 +374,12 @@ void AdvancedFm::copyAs()
374 QString curFile, item; 374 QString curFile, item;
375 InputDialog *fileDlg; 375 InputDialog *fileDlg;
376 376
377 QDir *thisDir = CurrentDir(); 377 QDir *thisDir = CurrentDir();
378 QDir *thatDir = OtherDir(); 378 QDir *thatDir = OtherDir();
379 379
380 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 380 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
381 { 381 {
382 QString destFile; 382 QString destFile;
383 item=(*it); 383 item=(*it);
384 curFile = thisDir->canonicalPath()+"/"+(*it); 384 curFile = thisDir->canonicalPath()+"/"+(*it);
385 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 385 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
@@ -388,37 +388,37 @@ void AdvancedFm::copyAs()
388 fileDlg->exec(); 388 fileDlg->exec();
389 389
390 if( fileDlg->result() == 1 ) 390 if( fileDlg->result() == 1 )
391 { 391 {
392 QString filename = fileDlg->LineEdit1->text(); 392 QString filename = fileDlg->LineEdit1->text();
393 destFile = thatDir->canonicalPath()+"/"+filename; 393 destFile = thatDir->canonicalPath()+"/"+filename;
394 394
395 QFile f( destFile); 395 QFile f( destFile);
396 if( f.exists()) 396 if( f.exists())
397 { 397 {
398 switch (QMessageBox::warning(this,tr("File Exists!"), 398 switch (QMessageBox::warning(this,tr("File Exists!"),
399 item+tr("\nexists. Ok to overwrite?"), 399 item+tr("\nexists. Ok to overwrite?"),
400 tr("Yes"),tr("No"),0,0,1) ) 400 tr("Yes"),tr("No"),0,0,1) )
401 { 401 {
402 case 0: 402 case 0:
403 f.remove(); 403 f.remove();
404 break; 404 break;
405 case 1: 405 case 1:
406 return; 406 return;
407 break; 407 break;
408 }; 408 };
409 } 409 }
410 if( !copyFile( curFile, destFile) ) 410 if( !copyFile( curFile, destFile) )
411 { 411 {
412 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 412 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
413 +curFile +tr("to\n")+destFile); 413 +curFile +tr("to\n")+destFile);
414 return; 414 return;
415 } 415 }
416 } 416 }
417 delete fileDlg; 417 delete fileDlg;
418 418
419 } 419 }
420 setOtherTabCurrent(); 420 setOtherTabCurrent();
421 populateView(); 421 populateView();
422} 422}
423 423
424void AdvancedFm::copySameDir() 424void AdvancedFm::copySameDir()
@@ -428,11 +428,11 @@ void AdvancedFm::copySameDir()
428 QString curFile, item, destFile; 428 QString curFile, item, destFile;
429 InputDialog *fileDlg; 429 InputDialog *fileDlg;
430 430
431 QDir *thisDir = CurrentDir(); 431 QDir *thisDir = CurrentDir();
432 432
433 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 433 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
434 { 434 {
435 item=(*it); 435 item=(*it);
436 curFile = thisDir->canonicalPath()+"/"+ item; 436 curFile = thisDir->canonicalPath()+"/"+ item;
437 437
438 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 438 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
@@ -440,38 +440,38 @@ void AdvancedFm::copySameDir()
440 fileDlg->exec(); 440 fileDlg->exec();
441 441
442 if( fileDlg->result() == 1 ) 442 if( fileDlg->result() == 1 )
443 { 443 {
444 444
445 QString filename = fileDlg->LineEdit1->text(); 445 QString filename = fileDlg->LineEdit1->text();
446 destFile = thisDir->canonicalPath()+"/"+filename; 446 destFile = thisDir->canonicalPath()+"/"+filename;
447 447
448 QFile f(destFile); 448 QFile f(destFile);
449 if( f.exists()) 449 if( f.exists())
450 { 450 {
451 switch (QMessageBox::warning(this,tr("Delete"), 451 switch (QMessageBox::warning(this,tr("Delete"),
452 destFile+tr(" already exists.\nDo you really want to delete it?"), 452 destFile+tr(" already exists.\nDo you really want to delete it?"),
453 tr("Yes"),tr("No"),0,0,1) ) { 453 tr("Yes"),tr("No"),0,0,1) ) {
454 case 0: 454 case 0:
455 455
456 f.remove(); 456 f.remove();
457 break; 457 break;
458 case 1: 458 case 1:
459 return; 459 return;
460 break; 460 break;
461 }; 461 };
462 } 462 }
463 if(!copyFile( curFile,destFile) ) 463 if(!copyFile( curFile,destFile) )
464 { 464 {
465 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 465 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
466 +curFile +tr("to\n")+destFile); 466 +curFile +tr("to\n")+destFile);
467 return; 467 return;
468 } 468 }
469 469
470 qDebug("copy "+curFile+" as "+destFile); 470 qDebug("copy "+curFile+" as "+destFile);
471 } 471 }
472 delete fileDlg; 472 delete fileDlg;
473 } 473 }
474 populateView(); 474 populateView();
475} 475}
476 476
477void AdvancedFm::move() 477void AdvancedFm::move()
@@ -480,42 +480,42 @@ void AdvancedFm::move()
480 480
481 QStringList curFileList = getPath(); 481 QStringList curFileList = getPath();
482 if( curFileList.count() > 0) 482 if( curFileList.count() > 0)
483 { 483 {
484 QString curFile, destFile, item; 484 QString curFile, destFile, item;
485 485
486 QDir *thisDir = CurrentDir(); 486 QDir *thisDir = CurrentDir();
487 QDir *thatDir = OtherDir(); 487 QDir *thatDir = OtherDir();
488 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 488 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
489 { 489 {
490 item=(*it); 490 item=(*it);
491 QString destFile = thatDir->canonicalPath(); 491 QString destFile = thatDir->canonicalPath();
492 492
493 if(destFile.right(1).find("/",0,TRUE) == -1) 493 if(destFile.right(1).find("/",0,TRUE) == -1)
494 destFile+="/"; 494 destFile+="/";
495 destFile += item; 495 destFile += item;
496 qDebug("Destination file is "+destFile); 496 qDebug("Destination file is "+destFile);
497 497
498 curFile = thisDir->canonicalPath(); 498 curFile = thisDir->canonicalPath();
499 if(curFile.right(1).find("/",0,TRUE) == -1) 499 if(curFile.right(1).find("/",0,TRUE) == -1)
500 curFile +="/"; 500 curFile +="/";
501 curFile+= item; 501 curFile+= item;
502 qDebug("CurrentFile file is " + curFile); 502 qDebug("CurrentFile file is " + curFile);
503 503
504 QFile f( curFile); 504 QFile f( curFile);
505 if( f.exists()) { 505 if( f.exists()) {
506 if( !copyFile( curFile, destFile) ) 506 if( !copyFile( curFile, destFile) )
507 { 507 {
508 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 508 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
509 return; 509 return;
510 } else 510 } else
511 QFile::remove(curFile); 511 QFile::remove(curFile);
512 } 512 }
513 } 513 }
514 514
515 } 515 }
516 setOtherTabCurrent(); 516 setOtherTabCurrent();
517 populateView(); 517 populateView();
518 // populateLocalView(); 518// populateLocalView();
519} 519}
520 520
521bool AdvancedFm::copyFile( const QString & src, const QString & dest ) 521bool AdvancedFm::copyFile( const QString & src, const QString & dest )
@@ -529,59 +529,59 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest )
529 QFile d( dest ); 529 QFile d( dest );
530 530
531 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) 531 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) )
532 { 532 {
533 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) 533 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) )
534 { 534 {
535 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 535 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
536 success = FALSE; 536 success = FALSE;
537 break; 537 break;
538 } 538 }
539 } 539 }
540 if( success && (bytesRead > 0) ) 540 if( success && (bytesRead > 0) )
541 { 541 {
542 d.writeBlock( bf, bytesRead ); 542 d.writeBlock( bf, bytesRead );
543 } 543 }
544 } 544 }
545 else 545 else
546 { 546 {
547 success = FALSE; 547 success = FALSE;
548 } 548 }
549 549
550 // Set file permissions 550 // Set file permissions
551 if( stat( (const char *) src, &status ) == 0 ) 551 if( stat( (const char *) src, &status ) == 0 )
552 { 552 {
553 chmod( (const char *) dest, status.st_mode ); 553 chmod( (const char *) dest, status.st_mode );
554 } 554 }
555 555
556 return success; 556 return success;
557} 557}
558 558
559void AdvancedFm::runCommand() 559void AdvancedFm::runCommand()
560{ 560{
561 QDir *thisDir = CurrentDir(); 561 QDir *thisDir = CurrentDir();
562
563 QString curFile;
564 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
565 562
566 InputDialog *fileDlg; 563 QString curFile;
567 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 564 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
568 fileDlg->setInputText(curFile);
569 fileDlg->exec();
570 //QString command;
571 565
572 if( fileDlg->result() == 1 ) 566 InputDialog *fileDlg;
573 { 567 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
574 qDebug(fileDlg->LineEdit1->text()); 568 fileDlg->setInputText(curFile);
575 QStringList command; 569 fileDlg->exec();
570 //QString command;
576 571
577 command << "/bin/sh"; 572 if( fileDlg->result() == 1 )
578 command << "-c"; 573 {
579 command << fileDlg->LineEdit1->text(); 574 qDebug(fileDlg->LineEdit1->text());
580 Output *outDlg; 575 QStringList command;
581 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 576
582 outDlg->showMaximized(); 577 command << "/bin/sh";
583 outDlg->exec(); 578 command << "-c";
584 qApp->processEvents(); 579 command << fileDlg->LineEdit1->text();
580 Output *outDlg;
581 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
582 outDlg->showMaximized();
583 outDlg->exec();
584 qApp->processEvents();
585 585
586 } 586 }
587} 587}
@@ -589,10 +589,10 @@ void AdvancedFm::runCommand()
589void AdvancedFm::runCommandStd() 589void AdvancedFm::runCommandStd()
590{ 590{
591 QString curFile; 591 QString curFile;
592 QDir *thisDir = CurrentDir(); 592 QDir *thisDir = CurrentDir();
593 QListView *thisView = CurrentView(); 593 QListView *thisView = CurrentView();
594 if( thisView->currentItem()) 594 if( thisView->currentItem())
595 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 595 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
596 596
597 InputDialog *fileDlg; 597 InputDialog *fileDlg;
598 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 598 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
@@ -600,27 +600,27 @@ void AdvancedFm::runCommandStd()
600 fileDlg->exec(); 600 fileDlg->exec();
601 601
602 if( fileDlg->result() == 1 ) 602 if( fileDlg->result() == 1 )
603 { 603 {
604 qApp->processEvents(); 604 qApp->processEvents();
605 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 605 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
606 } 606 }
607} 607}
608 608
609void AdvancedFm::fileStatus() 609void AdvancedFm::fileStatus()
610{ 610{
611 QString curFile; 611 QString curFile;
612 curFile = CurrentView()->currentItem()->text(0); 612 curFile = CurrentView()->currentItem()->text(0);
613 613
614 QStringList command; 614 QStringList command;
615 command << "/bin/sh"; 615 command << "/bin/sh";
616 command << "-c"; 616 command << "-c";
617 command << "stat -l "+ curFile; 617 command << "stat -l "+ curFile;
618 618
619 Output *outDlg; 619 Output *outDlg;
620 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 620 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
621 outDlg->showMaximized(); 621 outDlg->showMaximized();
622 outDlg->exec(); 622 outDlg->exec();
623 qApp->processEvents(); 623 qApp->processEvents();
624} 624}
625 625
626 626
@@ -631,7 +631,7 @@ void AdvancedFm::mkDir()
631 631
632void AdvancedFm::rn() 632void AdvancedFm::rn()
633{ 633{
634 renameIt(); 634 renameIt();
635} 635}
636 636
637void AdvancedFm::del() 637void AdvancedFm::del()
@@ -641,63 +641,63 @@ void AdvancedFm::del()
641 641
642void AdvancedFm::mkSym() 642void AdvancedFm::mkSym()
643{ 643{
644 QString cmd; 644 QString cmd;
645 QStringList curFileList = getPath(); 645 QStringList curFileList = getPath();
646 if( curFileList.count() > 0) 646 if( curFileList.count() > 0)
647 { 647 {
648 QDir *thisDir = CurrentDir(); 648 QDir *thisDir = CurrentDir();
649 QDir * thatDir = OtherDir(); 649 QDir * thatDir = OtherDir();
650 650
651 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 651 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
652 { 652 {
653 653
654 QString destName = thatDir->canonicalPath()+"/"+(*it); 654 QString destName = thatDir->canonicalPath()+"/"+(*it);
655 if(destName.right(1) == "/") 655 if(destName.right(1) == "/")
656 { 656 {
657 destName = destName.left( destName.length() -1); 657 destName = destName.left( destName.length() -1);
658 } 658 }
659 659
660 QString curFile = thisDir->canonicalPath()+"/"+(*it); 660 QString curFile = thisDir->canonicalPath()+"/"+(*it);
661 661
662 if( curFile.right(1) == "/") 662 if( curFile.right(1) == "/")
663 { 663 {
664 curFile = curFile.left( curFile.length() -1); 664 curFile = curFile.left( curFile.length() -1);
665 } 665 }
666 666
667 cmd = "ln -s "+curFile+" "+destName; 667 cmd = "ln -s "+curFile+" "+destName;
668 qDebug(cmd); 668 qDebug(cmd);
669 startProcess( (const QString)cmd ); 669 startProcess( (const QString)cmd );
670 } 670 }
671 setOtherTabCurrent(); 671 setOtherTabCurrent();
672 populateView(); 672 populateView();
673 } 673 }
674} 674}
675 675
676void AdvancedFm::doBeam() 676void AdvancedFm::doBeam()
677{ 677{
678 Ir ir; 678 Ir ir;
679 if(!ir.supported()) 679 if(!ir.supported())
680 { 680 {
681 } 681 }
682 else 682 else
683 { 683 {
684 QStringList curFileList = getPath(); 684 QStringList curFileList = getPath();
685 if( curFileList.count() > 0) 685 if( curFileList.count() > 0)
686 { 686 {
687 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 687 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
688 { 688 {
689 689
690 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); 690 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it);
691 if( curFile.right(1) == "/") 691 if( curFile.right(1) == "/")
692 { 692 {
693 curFile = curFile.left( curFile.length() -1); 693 curFile = curFile.left( curFile.length() -1);
694 } 694 }
695 Ir *file = new Ir(this, "IR"); 695 Ir *file = new Ir(this, "IR");
696 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 696 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
697 file->send( curFile, curFile ); 697 file->send( curFile, curFile );
698 } 698 }
699 } 699 }
700 } 700 }
701 701
702} 702}
703 703
@@ -709,9 +709,9 @@ void AdvancedFm::fileBeamFinished( Ir *)
709void AdvancedFm::selectAll() 709void AdvancedFm::selectAll()
710{ 710{
711// if (TabWidget->getCurrentTab() == 0) { 711// if (TabWidget->getCurrentTab() == 0) {
712 QListView *thisView = CurrentView(); 712 QListView *thisView = CurrentView();
713 thisView->selectAll(true); 713 thisView->selectAll(true);
714 thisView->setSelected( thisView->firstChild(),false); 714 thisView->setSelected( thisView->firstChild(),false);
715// } else { 715// } else {
716// Remote_View->selectAll(true); 716// Remote_View->selectAll(true);
717// Remote_View->setSelected( Remote_View->firstChild(),false); 717// Remote_View->setSelected( Remote_View->firstChild(),false);
@@ -720,77 +720,91 @@ void AdvancedFm::selectAll()
720 720
721void AdvancedFm::startProcess(const QString & cmd) 721void AdvancedFm::startProcess(const QString & cmd)
722{ 722{
723 QStringList command; 723 QStringList command;
724 OProcess *process; 724 OProcess *process;
725 process = new OProcess(); 725 process = new OProcess();
726 connect(process, SIGNAL(processExited(OProcess *)), 726 connect(process, SIGNAL(processExited(OProcess *)),
727 this, SLOT( processEnded())); 727 this, SLOT( processEnded(OProcess *)));
728
729 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
730 this, SLOT( oprocessStderr(OProcess *, char *, int)));
728 731
729 command << "/bin/sh"; 732 command << "/bin/sh";
730 command << "-c"; 733 command << "-c";
731 command << cmd.latin1(); 734 command << cmd.latin1();
732 *process << command; 735 *process << command;
733 if(!process->start(OProcess::NotifyOnExit) ) 736 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
734 qDebug("could not start process"); 737 qDebug("could not start process");
735} 738}
736 739
737void AdvancedFm::processEnded() 740void AdvancedFm::processEnded(OProcess *)
738{ 741{
739// populateLocalView(); 742// populateLocalView();
740 populateView(); 743 populateView();
741} 744}
742 745
746void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) {
747 qWarning("received stderrt %d bytes", buflen);
748
749 QString lineStr = buffer;
750// lineStr=lineStr.left(lineStr.length()-1);
751 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
752
753// OutputEdit->append(lineStr);
754// OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
755}
756
743bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) 757bool AdvancedFm::eventFilter( QObject * o, QEvent * e )
744{ 758{
745 if ( o->inherits( "QLineEdit" ) ) 759 if ( o->inherits( "QLineEdit" ) )
746 { 760 {
747 if ( e->type() == QEvent::KeyPress ) 761 if ( e->type() == QEvent::KeyPress )
748 { 762 {
749 QKeyEvent *ke = (QKeyEvent*)e; 763 QKeyEvent *ke = (QKeyEvent*)e;
750 if ( ke->key() == Key_Return || 764 if ( ke->key() == Key_Return ||
751 ke->key() == Key_Enter ) 765 ke->key() == Key_Enter )
752 { 766 {
753 okRename(); 767 okRename();
754 return true; 768 return true;
755 } 769 }
756 else if ( ke->key() == Key_Escape ) 770 else if ( ke->key() == Key_Escape )
757 { 771 {
758 cancelRename(); 772 cancelRename();
759 return true; 773 return true;
760 } 774 }
761 } 775 }
762 else if ( e->type() == QEvent::FocusOut ) 776 else if ( e->type() == QEvent::FocusOut )
763 { 777 {
764 cancelRename(); 778 cancelRename();
765 return true; 779 return true;
766 } 780 }
767 } 781 }
768 if ( o->inherits( "QListView" ) ) 782 if ( o->inherits( "QListView" ) )
769 { 783 {
770 if ( e->type() == QEvent::FocusOut ) 784 if ( e->type() == QEvent::FocusOut )
771 { 785 {
772 printf("focusIn\n"); 786 printf("focusIn\n");
773 787
774 } 788 }
775 } 789 }
776 790
777 return QWidget::eventFilter( o, e ); 791 return QWidget::eventFilter( o, e );
778} 792}
779 793
780 794
781void AdvancedFm::cancelRename() 795void AdvancedFm::cancelRename()
782{ 796{
783 qDebug("cancel rename"); 797 qDebug("cancel rename");
784 QListView * view; 798 QListView * view;
785 view = CurrentView(); 799 view = CurrentView();
786 800
787 bool resetFocus = view->viewport()->focusProxy() == renameBox; 801 bool resetFocus = view->viewport()->focusProxy() == renameBox;
788 delete renameBox; 802 delete renameBox;
789 renameBox = 0; 803 renameBox = 0;
790 if ( resetFocus ) 804 if ( resetFocus )
791 { 805 {
792 view->viewport()->setFocusProxy( view); 806 view->viewport()->setFocusProxy( view);
793 view->setFocus(); 807 view->setFocus();
794 } 808 }
795} 809}
796 810
@@ -821,7 +835,7 @@ void AdvancedFm::doRename(QListView * view)
821 835
822void AdvancedFm::renameIt() 836void AdvancedFm::renameIt()
823{ 837{
824 QListView *thisView = CurrentView(); 838 QListView *thisView = CurrentView();
825 oldName = thisView->currentItem()->text(0); 839 oldName = thisView->currentItem()->text(0);
826 doRename( thisView ); 840 doRename( thisView );
827 populateView(); 841 populateView();
@@ -829,22 +843,22 @@ void AdvancedFm::renameIt()
829 843
830void AdvancedFm::okRename() 844void AdvancedFm::okRename()
831{ 845{
832 QString newName = renameBox->text(); 846 QString newName = renameBox->text();
833 cancelRename(); 847 cancelRename();
834 //int tabs=0; 848// int tabs=0;
835 QListView * view = CurrentView(); 849 QListView * view = CurrentView();
836 QString path = CurrentDir()->canonicalPath() + "/"; 850 QString path = CurrentDir()->canonicalPath() + "/";
837 oldName = path + oldName; 851 oldName = path + oldName;
838 newName = path + newName; 852 newName = path + newName;
839 853
840 if( view->currentItem() == NULL) 854 if( view->currentItem() == NULL)
841 return; 855 return;
842 if( rename( oldName.latin1(), newName.latin1())== -1) 856 if( rename( oldName.latin1(), newName.latin1())== -1)
843 QMessageBox::message(tr("Note"),tr("Could not rename")); 857 QMessageBox::message(tr("Note"),tr("Could not rename"));
844 else 858 else
845 oldName = ""; 859 oldName = "";
846 860
847 view->takeItem( view->currentItem() ); 861 view->takeItem( view->currentItem() );
848 delete view->currentItem(); 862 delete view->currentItem();
849 populateView(); 863 populateView();
850} 864}