Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 942 |
1 files changed, 34 insertions, 908 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 8f49a53..3aa516c 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -9,19 +9,14 @@ | |||
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 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | ||
14 | 13 | ||
15 | #include "advancedfm.h" | 14 | #include "advancedfm.h" |
16 | #include "inputDialog.h" | ||
17 | #include "filePermissions.h" | ||
18 | #include "output.h" | ||
19 | 15 | ||
20 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
21 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
22 | 18 | ||
23 | #include <qpe/lnkproperties.h> | ||
24 | #include <qpe/filemanager.h> | 19 | #include <qpe/filemanager.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
27 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
@@ -32,11 +27,8 @@ | |||
32 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
33 | #include <qpe/ir.h> | 28 | #include <qpe/ir.h> |
34 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
35 | 30 | ||
36 | //#include <opie/ofileselector.h> | ||
37 | #include <qmultilineedit.h> | ||
38 | |||
39 | #include <qtabwidget.h> | 31 | #include <qtabwidget.h> |
40 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
41 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
42 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
@@ -72,14 +64,14 @@ | |||
72 | #include <mntent.h> | 64 | #include <mntent.h> |
73 | #include <sys/utsname.h> | 65 | #include <sys/utsname.h> |
74 | 66 | ||
75 | AdvancedFm::AdvancedFm( ) | 67 | AdvancedFm::AdvancedFm( ) |
76 | : QMainWindow( ) { | 68 | : QMainWindow( ) { |
77 | init(); | 69 | init(); |
78 | 70 | initConnections(); | |
79 | populateLocalView(); | 71 | populateLocalView(); |
80 | populateRemoteView(); | 72 | populateRemoteView(); |
81 | currentPathCombo->setFocus(); | 73 | currentPathCombo->setFocus(); |
82 | } | 74 | } |
83 | 75 | ||
84 | AdvancedFm::~AdvancedFm() { | 76 | AdvancedFm::~AdvancedFm() { |
85 | } | 77 | } |
@@ -100,17 +92,19 @@ void AdvancedFm::tabChanged(QWidget *) { | |||
100 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 92 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
101 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 93 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
102 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 94 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
103 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 95 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
104 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 96 | setCaption("AdvancedFm :: "+fs+" :: " |
97 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | ||
105 | 98 | ||
106 | } | 99 | } |
107 | if (TabWidget->currentPageIndex() == 1) { | 100 | if (TabWidget->currentPageIndex() == 1) { |
108 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 101 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
109 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 102 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
110 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 103 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
111 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 104 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
112 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 105 | setCaption("AdvancedFm :: "+fs+" :: " |
106 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | ||
113 | } | 107 | } |
114 | } | 108 | } |
115 | 109 | ||
116 | 110 | ||
@@ -121,9 +115,10 @@ void AdvancedFm::populateLocalView() { | |||
121 | currentDir.setMatchAllDirs(TRUE); | 115 | currentDir.setMatchAllDirs(TRUE); |
122 | currentDir.setNameFilter(filterStr); | 116 | currentDir.setNameFilter(filterStr); |
123 | QString fileL, fileS, fileDate; | 117 | QString fileL, fileS, fileDate; |
124 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 118 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
125 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 119 | setCaption("AdvancedFm :: "+fs+" :: " |
120 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | ||
126 | bool isDir=FALSE; | 121 | bool isDir=FALSE; |
127 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 122 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
128 | QFileInfoListIterator it(*list); | 123 | QFileInfoListIterator it(*list); |
129 | QFileInfo *fi; | 124 | QFileInfo *fi; |
@@ -131,9 +126,9 @@ void AdvancedFm::populateLocalView() { | |||
131 | if (fi->isSymLink() ) { | 126 | if (fi->isSymLink() ) { |
132 | QString symLink=fi->readLink(); | 127 | QString symLink=fi->readLink(); |
133 | QFileInfo sym( symLink); | 128 | QFileInfo sym( symLink); |
134 | fileS.sprintf( "%10i", sym.size() ); | 129 | fileS.sprintf( "%10i", sym.size() ); |
135 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 130 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
136 | fileDate = sym.lastModified().toString(); | 131 | fileDate = sym.lastModified().toString(); |
137 | } else { | 132 | } else { |
138 | fileS.sprintf( "%10i", fi->size() ); | 133 | fileS.sprintf( "%10i", fi->size() ); |
139 | fileL.sprintf( "%s",fi->fileName().data() ); | 134 | fileL.sprintf( "%s",fi->fileName().data() ); |
@@ -218,9 +213,10 @@ void AdvancedFm::populateRemoteView() { | |||
218 | currentRemoteDir.setNameFilter(filterStr); | 213 | currentRemoteDir.setNameFilter(filterStr); |
219 | QString fileL, fileS, fileDate; | 214 | QString fileL, fileS, fileDate; |
220 | 215 | ||
221 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 216 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
222 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 217 | setCaption("AdvancedFm :: "+fs+" :: " |
218 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | ||
223 | bool isDir=FALSE; | 219 | bool isDir=FALSE; |
224 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 220 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
225 | QFileInfoListIterator it(*list); | 221 | QFileInfoListIterator it(*list); |
226 | QFileInfo *fi; | 222 | QFileInfo *fi; |
@@ -229,9 +225,9 @@ void AdvancedFm::populateRemoteView() { | |||
229 | QString symLink=fi->readLink(); | 225 | QString symLink=fi->readLink(); |
230 | // qDebug("Symlink detected "+symLink); | 226 | // qDebug("Symlink detected "+symLink); |
231 | QFileInfo sym( symLink); | 227 | QFileInfo sym( symLink); |
232 | fileS.sprintf( "%10i", sym.size() ); | 228 | fileS.sprintf( "%10i", sym.size() ); |
233 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 229 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
234 | fileDate = sym.lastModified().toString(); | 230 | fileDate = sym.lastModified().toString(); |
235 | } else { | 231 | } else { |
236 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 232 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
237 | fileS.sprintf( "%10i", fi->size() ); | 233 | fileS.sprintf( "%10i", fi->size() ); |
@@ -311,13 +307,13 @@ void AdvancedFm::localListClicked(QListViewItem *selectedItem) { | |||
311 | QString strItem=selectedItem->text(0); | 307 | QString strItem=selectedItem->text(0); |
312 | QString strSize=selectedItem->text(1); | 308 | QString strSize=selectedItem->text(1); |
313 | strSize=strSize.stripWhiteSpace(); | 309 | strSize=strSize.stripWhiteSpace(); |
314 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 310 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
315 | // is symlink | ||
316 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 311 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
317 | if(QDir(strItem2).exists() ) { | 312 | if(QDir(strItem2).exists() ) { |
318 | currentDir.cd(strItem2, TRUE); | 313 | currentDir.cd(strItem2, TRUE); |
319 | populateLocalView(); | 314 | populateLocalView(); |
315 | |||
320 | } | 316 | } |
321 | } else { // not a symlink | 317 | } else { // not a symlink |
322 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 318 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
323 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 319 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
@@ -342,8 +338,10 @@ void AdvancedFm::localListClicked(QListViewItem *selectedItem) { | |||
342 | } | 338 | } |
343 | } //end not symlink | 339 | } //end not symlink |
344 | chdir(strItem.latin1()); | 340 | chdir(strItem.latin1()); |
345 | } | 341 | } |
342 | Local_View->ensureItemVisible(Local_View->firstChild()); | ||
343 | |||
346 | } | 344 | } |
347 | } | 345 | } |
348 | 346 | ||
349 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { | 347 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { |
@@ -352,14 +350,11 @@ void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { | |||
352 | QString strItem=selectedItem->text(0); | 350 | QString strItem=selectedItem->text(0); |
353 | QString strSize=selectedItem->text(1); | 351 | QString strSize=selectedItem->text(1); |
354 | strSize=strSize.stripWhiteSpace(); | 352 | strSize=strSize.stripWhiteSpace(); |
355 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 353 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
356 | // is symlink | ||
357 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 354 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
358 | if(QDir(strItem2).exists() ) { | ||
359 | currentRemoteDir.cd(strItem2, TRUE); | 355 | currentRemoteDir.cd(strItem2, TRUE); |
360 | populateRemoteView(); | 356 | populateRemoteView(); |
361 | } | ||
362 | } else { // not a symlink | 357 | } else { // not a symlink |
363 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 358 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
364 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 359 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
365 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 360 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
@@ -383,48 +378,15 @@ void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { | |||
383 | } | 378 | } |
384 | } //end not symlink | 379 | } //end not symlink |
385 | chdir(strItem.latin1()); | 380 | chdir(strItem.latin1()); |
386 | } | 381 | } |
382 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | ||
387 | } | 383 | } |
388 | } | 384 | } |
389 | 385 | ||
390 | void AdvancedFm::doLocalCd() { | ||
391 | localListClicked( Local_View->currentItem()); | ||
392 | } | ||
393 | |||
394 | void AdvancedFm::doRemoteCd() { | ||
395 | localListClicked( Remote_View->currentItem()); | ||
396 | } | ||
397 | |||
398 | void AdvancedFm::showHidden() { | ||
399 | if (b) { | ||
400 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
401 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | ||
402 | b=FALSE; | ||
403 | |||
404 | } else { | ||
405 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
406 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | ||
407 | b=TRUE; | ||
408 | } | ||
409 | populateLocalView(); | ||
410 | |||
411 | } | ||
412 | |||
413 | void AdvancedFm::showRemoteHidden() { | ||
414 | if (b) { | ||
415 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
416 | b=TRUE; | ||
417 | |||
418 | } else { | ||
419 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
420 | b=FALSE; | ||
421 | } | ||
422 | populateRemoteView(); | ||
423 | } | ||
424 | 386 | ||
425 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 387 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
426 | qDebug("list pressed"); | 388 | // qDebug("list pressed"); |
427 | switch (mouse) { | 389 | switch (mouse) { |
428 | case 1: | 390 | case 1: |
429 | break; | 391 | break; |
430 | case 2: | 392 | case 2: |
@@ -445,235 +407,8 @@ void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, in | |||
445 | break; | 407 | break; |
446 | }; | 408 | }; |
447 | } | 409 | } |
448 | 410 | ||
449 | void AdvancedFm::runThis() { | ||
450 | QString fs; | ||
451 | if (TabWidget->currentPageIndex() == 0) { | ||
452 | QString curFile = Local_View->currentItem()->text(0); | ||
453 | if(curFile != "../") { | ||
454 | |||
455 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | ||
456 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | ||
457 | qDebug( fileInfo.owner()); | ||
458 | if( (fileInfo.permission( QFileInfo::ExeUser) | ||
459 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
460 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
461 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
462 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
463 | e << curFile; | ||
464 | } else { | ||
465 | curFile = currentDir.canonicalPath()+"/"+curFile; | ||
466 | DocLnk nf(curFile); | ||
467 | QString execStr = nf.exec(); | ||
468 | qDebug( execStr); | ||
469 | if( execStr.isEmpty() ) { | ||
470 | } else { | ||
471 | nf.execute(); | ||
472 | } | ||
473 | } | ||
474 | } | ||
475 | } else { | ||
476 | QString curFile = Remote_View->currentItem()->text(0); | ||
477 | if(curFile != "../") { | ||
478 | |||
479 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | ||
480 | qDebug("Filesystemtype is "+fs); | ||
481 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | ||
482 | if( (fileInfo.permission( QFileInfo::ExeUser) | ||
483 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
484 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
485 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
486 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
487 | e << curFile; | ||
488 | } else { | ||
489 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | ||
490 | DocLnk nf(curFile); | ||
491 | QString execStr = nf.exec(); | ||
492 | qDebug(execStr); | ||
493 | if( execStr.isEmpty() ) { | ||
494 | } else { | ||
495 | nf.execute(); | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | } | ||
501 | |||
502 | void AdvancedFm::runText() { | ||
503 | if (TabWidget->currentPageIndex() == 0) { | ||
504 | QString curFile = Local_View->currentItem()->text(0); | ||
505 | if(curFile != "../") { | ||
506 | curFile = currentDir.canonicalPath()+"/"+curFile; | ||
507 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | ||
508 | e << curFile; | ||
509 | } | ||
510 | } else { | ||
511 | QString curFile = Remote_View->currentItem()->text(0); | ||
512 | if(curFile != "../") { | ||
513 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | ||
514 | DocLnk nf(curFile); | ||
515 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | ||
516 | e << curFile; | ||
517 | } | ||
518 | } | ||
519 | } | ||
520 | |||
521 | void AdvancedFm::localMakDir() { | ||
522 | InputDialog *fileDlg; | ||
523 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | ||
524 | fileDlg->exec(); | ||
525 | if( fileDlg->result() == 1 ) { | ||
526 | QString filename = fileDlg->LineEdit1->text(); | ||
527 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | ||
528 | } | ||
529 | populateLocalView(); | ||
530 | } | ||
531 | |||
532 | void AdvancedFm::remoteMakDir() { | ||
533 | InputDialog *fileDlg; | ||
534 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | ||
535 | fileDlg->exec(); | ||
536 | if( fileDlg->result() == 1 ) { | ||
537 | QString filename = fileDlg->LineEdit1->text(); | ||
538 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | ||
539 | } | ||
540 | populateRemoteView(); | ||
541 | } | ||
542 | |||
543 | void AdvancedFm::localDelete() { | ||
544 | QStringList curFileList = getPath(); | ||
545 | if(curFileList.count() > 0) { | ||
546 | QString myFile; | ||
547 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
548 | myFile = (*it); | ||
549 | if( myFile.find(" -> ",0,TRUE) != -1) | ||
550 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | ||
551 | |||
552 | QString f = currentDir.canonicalPath(); | ||
553 | if(f.right(1).find("/",0,TRUE) == -1) | ||
554 | f+="/"; | ||
555 | f+=myFile; | ||
556 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | ||
557 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | ||
558 | "\nand all it's contents ?" | ||
559 | ,tr("Yes"),tr("No"),0,0,1) ) { | ||
560 | case 0: { | ||
561 | f=f.left(f.length()-1); | ||
562 | QString cmd="rm -rf "+f; | ||
563 | system( cmd.latin1()); | ||
564 | populateLocalView(); | ||
565 | } | ||
566 | break; | ||
567 | case 1: | ||
568 | // exit | ||
569 | break; | ||
570 | }; | ||
571 | |||
572 | } else { | ||
573 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | ||
574 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | ||
575 | case 0: { | ||
576 | QString cmd="rm "+f; | ||
577 | QFile file(f); | ||
578 | file.remove(); | ||
579 | // system( cmd.latin1()); | ||
580 | populateLocalView(); | ||
581 | } | ||
582 | break; | ||
583 | case 1: | ||
584 | // exit | ||
585 | break; | ||
586 | }; | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | } | ||
591 | |||
592 | void AdvancedFm::remoteDelete() { | ||
593 | QStringList curFileList = getPath(); | ||
594 | if( curFileList.count() > 0) { | ||
595 | QString myFile; | ||
596 | |||
597 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
598 | myFile = (*it); | ||
599 | if(myFile.find(" -> ",0,TRUE) != -1) | ||
600 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | ||
601 | QString f = currentRemoteDir.canonicalPath(); | ||
602 | if(f.right(1).find("/",0,TRUE) == -1) | ||
603 | f+="/"; | ||
604 | f+=myFile; | ||
605 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | ||
606 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | ||
607 | "\nand all it's contents ?", | ||
608 | tr("Yes"),tr("No"),0,0,1) ) { | ||
609 | case 0: { | ||
610 | f=f.left(f.length()-1); | ||
611 | QString cmd="rm -rf "+f; | ||
612 | system( cmd.latin1()); | ||
613 | populateRemoteView(); | ||
614 | } | ||
615 | break; | ||
616 | case 1: | ||
617 | // exit | ||
618 | break; | ||
619 | }; | ||
620 | |||
621 | } else { | ||
622 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | ||
623 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | ||
624 | case 0: { | ||
625 | QString cmd="rm "+f; | ||
626 | QFile file(f); | ||
627 | file.remove(); | ||
628 | // system( cmd.latin1()); | ||
629 | populateRemoteView(); | ||
630 | } | ||
631 | break; | ||
632 | case 1: | ||
633 | // exit | ||
634 | break; | ||
635 | }; | ||
636 | } | ||
637 | } | ||
638 | } | ||
639 | } | ||
640 | |||
641 | void AdvancedFm::localRename() { | ||
642 | QString curFile = Local_View->currentItem()->text(0); | ||
643 | qDebug("currentItem "+curFile); | ||
644 | if( curFile !="../") { | ||
645 | InputDialog *fileDlg; | ||
646 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
647 | fileDlg->setInputText((const QString &)curFile); | ||
648 | fileDlg->exec(); | ||
649 | if( fileDlg->result() == 1 ) { | ||
650 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | ||
651 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | ||
652 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
653 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
654 | } | ||
655 | populateLocalView(); | ||
656 | } | ||
657 | } | ||
658 | |||
659 | void AdvancedFm::remoteRename() | ||
660 | { | ||
661 | QString curFile = Remote_View->currentItem()->text(0); | ||
662 | if( curFile !="../") { | ||
663 | InputDialog *fileDlg; | ||
664 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
665 | fileDlg->setInputText((const QString &)curFile); | ||
666 | fileDlg->exec(); | ||
667 | if( fileDlg->result() == 1 ) { | ||
668 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | ||
669 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | ||
670 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
671 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
672 | } | ||
673 | populateRemoteView(); | ||
674 | } | ||
675 | } | ||
676 | 411 | ||
677 | void AdvancedFm::switchToLocalTab() { | 412 | void AdvancedFm::switchToLocalTab() { |
678 | TabWidget->setCurrentPage(0); | 413 | TabWidget->setCurrentPage(0); |
679 | Local_View->setFocus(); | 414 | Local_View->setFocus(); |
@@ -743,52 +478,8 @@ void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | |||
743 | update(); | 478 | update(); |
744 | } | 479 | } |
745 | } | 480 | } |
746 | 481 | ||
747 | void AdvancedFm::filePerms() { | ||
748 | |||
749 | QStringList curFileList = getPath(); | ||
750 | QString filePath; | ||
751 | |||
752 | if (TabWidget->currentPageIndex() == 0) { | ||
753 | filePath = currentDir.canonicalPath()+"/"; | ||
754 | } else { | ||
755 | filePath= currentRemoteDir.canonicalPath()+"/"; | ||
756 | } | ||
757 | |||
758 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
759 | filePermissions *filePerm; | ||
760 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | ||
761 | filePerm->showMaximized(); | ||
762 | filePerm->exec(); | ||
763 | if( filePerm) | ||
764 | delete filePerm; | ||
765 | } | ||
766 | if (TabWidget->currentPageIndex() == 0) { | ||
767 | populateLocalView(); | ||
768 | } else { | ||
769 | populateRemoteView(); | ||
770 | } | ||
771 | } | ||
772 | |||
773 | void AdvancedFm::doProperties() { | ||
774 | QStringList curFileList = getPath(); | ||
775 | QString filePath; | ||
776 | if (TabWidget->currentPageIndex() == 0) { | ||
777 | filePath = currentDir.canonicalPath()+"/"; | ||
778 | } else { | ||
779 | filePath= currentRemoteDir.canonicalPath()+"/"; | ||
780 | } | ||
781 | // qDebug("%d",curFileList.count()); | ||
782 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
783 | qDebug((filePath+*it)); | ||
784 | DocLnk lnk( (filePath+*it)); | ||
785 | LnkProperties prop( &lnk ); | ||
786 | prop.showMaximized(); | ||
787 | prop.exec(); | ||
788 | } | ||
789 | } | ||
790 | |||
791 | QStringList AdvancedFm::getPath() { | 482 | QStringList AdvancedFm::getPath() { |
792 | QStringList strList; | 483 | QStringList strList; |
793 | if (TabWidget->currentPageIndex() == 0) { | 484 | if (TabWidget->currentPageIndex() == 0) { |
794 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 485 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
@@ -840,9 +531,9 @@ void AdvancedFm::docButtonPushed() { | |||
840 | update(); | 531 | update(); |
841 | } | 532 | } |
842 | 533 | ||
843 | void AdvancedFm::SDButtonPushed() { | 534 | void AdvancedFm::SDButtonPushed() { |
844 | QString current = "/mnt/card"; | 535 | QString current = "/mnt/card";// this can change so fix |
845 | chdir( current.latin1() ); | 536 | chdir( current.latin1() ); |
846 | if (TabWidget->currentPageIndex() == 0) { | 537 | if (TabWidget->currentPageIndex() == 0) { |
847 | currentDir.cd( current, TRUE); | 538 | currentDir.cd( current, TRUE); |
848 | populateLocalView(); | 539 | populateLocalView(); |
@@ -856,11 +547,11 @@ void AdvancedFm::SDButtonPushed() { | |||
856 | 547 | ||
857 | void AdvancedFm::CFButtonPushed() { | 548 | void AdvancedFm::CFButtonPushed() { |
858 | QString current; | 549 | QString current; |
859 | if(zaurusDevice) | 550 | if(zaurusDevice) |
860 | current= "/mnt/cf"; | 551 | current= "/mnt/cf"; //zaurus |
861 | else | 552 | else |
862 | current = "/mnt/hda"; | 553 | current = "/mnt/hda"; //ipaq |
863 | 554 | ||
864 | chdir( current.latin1() ); | 555 | chdir( current.latin1() ); |
865 | if (TabWidget->currentPageIndex() == 0) { | 556 | if (TabWidget->currentPageIndex() == 0) { |
866 | currentDir.cd( current, TRUE); | 557 | currentDir.cd( current, TRUE); |
@@ -869,509 +560,17 @@ void AdvancedFm::CFButtonPushed() { | |||
869 | currentRemoteDir.cd( current, TRUE); | 560 | currentRemoteDir.cd( current, TRUE); |
870 | populateRemoteView(); | 561 | populateRemoteView(); |
871 | } | 562 | } |
872 | update(); | 563 | update(); |
873 | |||
874 | } | ||
875 | |||
876 | |||
877 | void AdvancedFm::upDir() { | ||
878 | if (TabWidget->currentPageIndex() == 0) { | ||
879 | QString current = currentDir.canonicalPath(); | ||
880 | QDir dir(current); | ||
881 | dir.cdUp(); | ||
882 | current = dir.canonicalPath(); | ||
883 | chdir( current.latin1() ); | ||
884 | currentDir.cd( current, TRUE); | ||
885 | populateLocalView(); | ||
886 | update(); | ||
887 | } else { | ||
888 | QString current = currentRemoteDir.canonicalPath(); | ||
889 | QDir dir(current); | ||
890 | dir.cdUp(); | ||
891 | current = dir.canonicalPath(); | ||
892 | chdir( current.latin1() ); | ||
893 | currentRemoteDir.cd( current, TRUE); | ||
894 | populateRemoteView(); | ||
895 | update(); | ||
896 | } | ||
897 | } | ||
898 | |||
899 | void AdvancedFm::copy() { | ||
900 | qApp->processEvents(); | ||
901 | QStringList curFileList = getPath(); | ||
902 | if( curFileList.count() > 0) { | ||
903 | QString curFile; | ||
904 | if (TabWidget->currentPageIndex() == 0) { | ||
905 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
906 | |||
907 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
908 | qDebug("Destination file is "+destFile); | ||
909 | |||
910 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
911 | qDebug("CurrentFile file is " + curFile); | ||
912 | |||
913 | QFile f(destFile); | ||
914 | if( f.exists()) { | ||
915 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
916 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
917 | tr("Yes"),tr("No"),0,0,1) ) { | ||
918 | case 0: | ||
919 | f.remove(); | ||
920 | break; | ||
921 | case 1: | ||
922 | return; | ||
923 | break; | ||
924 | }; | ||
925 | } | ||
926 | if(!copyFile(destFile, curFile) ) { | ||
927 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | ||
928 | qWarning("nothin doing"); | ||
929 | } | ||
930 | } | ||
931 | populateRemoteView(); | ||
932 | TabWidget->setCurrentPage(1); | ||
933 | |||
934 | } else { | ||
935 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
936 | |||
937 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | ||
938 | qDebug("Destination file is "+destFile); | ||
939 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
940 | qDebug("CurrentFile file is " + curFile); | ||
941 | |||
942 | QFile f(destFile); | ||
943 | if( f.exists()) { | ||
944 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
945 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
946 | tr("Yes"),tr("No"),0,0,1) ) { | ||
947 | case 0: | ||
948 | f.remove(); | ||
949 | break; | ||
950 | case 1: | ||
951 | return; | ||
952 | break; | ||
953 | }; | ||
954 | } | ||
955 | if(!copyFile(destFile, curFile) ) { | ||
956 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
957 | |||
958 | qWarning("nothin doing"); | ||
959 | } | ||
960 | } | ||
961 | populateLocalView(); | ||
962 | TabWidget->setCurrentPage(0); | ||
963 | } | ||
964 | |||
965 | } | ||
966 | } | ||
967 | |||
968 | void AdvancedFm::copyAs() { | ||
969 | qApp->processEvents(); | ||
970 | |||
971 | QStringList curFileList = getPath(); | ||
972 | QString curFile; | ||
973 | InputDialog *fileDlg; | ||
974 | if (TabWidget->currentPageIndex() == 0) { | ||
975 | qDebug("tab 1"); | ||
976 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
977 | QString destFile; | ||
978 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
979 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
980 | |||
981 | fileDlg->setInputText((const QString &) destFile ); | ||
982 | fileDlg->exec(); | ||
983 | |||
984 | if( fileDlg->result() == 1 ) { | ||
985 | QString filename = fileDlg->LineEdit1->text(); | ||
986 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
987 | |||
988 | QFile f(destFile); | ||
989 | if( f.exists()) { | ||
990 | switch (QMessageBox::warning(this,tr("Delete"), | ||
991 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
992 | tr("Yes"),tr("No"),0,0,1) ) { | ||
993 | case 0: | ||
994 | f.remove(); | ||
995 | break; | ||
996 | case 1: | ||
997 | return; | ||
998 | break; | ||
999 | }; | ||
1000 | } | ||
1001 | if(!copyFile(destFile, curFile) ) { | ||
1002 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1003 | qWarning("nothin doing"); | ||
1004 | } | ||
1005 | } | ||
1006 | delete fileDlg; | ||
1007 | |||
1008 | } | ||
1009 | populateRemoteView(); | ||
1010 | TabWidget->setCurrentPage(1); | ||
1011 | |||
1012 | } else { | ||
1013 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1014 | |||
1015 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1016 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
1017 | |||
1018 | QString destFile; | ||
1019 | fileDlg->setInputText((const QString &) destFile); | ||
1020 | fileDlg->exec(); | ||
1021 | |||
1022 | if( fileDlg->result() == 1 ) { | ||
1023 | QString filename = fileDlg->LineEdit1->text(); | ||
1024 | destFile = currentDir.canonicalPath()+"/"+filename; | ||
1025 | |||
1026 | QFile f( destFile); | ||
1027 | if( f.exists()) { | ||
1028 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
1029 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1030 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1031 | case 0: | ||
1032 | f.remove(); | ||
1033 | break; | ||
1034 | case 1: | ||
1035 | return; | ||
1036 | break; | ||
1037 | }; | ||
1038 | } | ||
1039 | if(!copyFile(destFile, curFile) ) { | ||
1040 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1041 | qWarning("nothin doing"); | ||
1042 | } | ||
1043 | |||
1044 | } | ||
1045 | delete fileDlg; | ||
1046 | |||
1047 | } | ||
1048 | populateLocalView(); | ||
1049 | TabWidget->setCurrentPage(0); | ||
1050 | } | ||
1051 | } | ||
1052 | |||
1053 | void AdvancedFm::copySameDir() { | ||
1054 | qApp->processEvents(); | ||
1055 | QStringList curFileList = getPath(); | ||
1056 | QString curFile; | ||
1057 | InputDialog *fileDlg; | ||
1058 | |||
1059 | if (TabWidget->currentPageIndex() == 0) { | ||
1060 | |||
1061 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1062 | |||
1063 | QString destFile; | ||
1064 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
1065 | |||
1066 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | ||
1067 | fileDlg->setInputText((const QString &) destFile ); | ||
1068 | fileDlg->exec(); | ||
1069 | |||
1070 | if( fileDlg->result() == 1 ) { | ||
1071 | |||
1072 | QString filename = fileDlg->LineEdit1->text(); | ||
1073 | destFile = currentDir.canonicalPath()+"/"+filename; | ||
1074 | |||
1075 | QFile f(destFile); | ||
1076 | if( f.exists()) { | ||
1077 | switch (QMessageBox::warning(this,tr("Delete"), | ||
1078 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1079 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1080 | case 0: | ||
1081 | |||
1082 | f.remove(); | ||
1083 | break; | ||
1084 | case 1: | ||
1085 | return; | ||
1086 | break; | ||
1087 | }; | ||
1088 | } | ||
1089 | if(!copyFile(destFile, curFile) ) { | ||
1090 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1091 | qWarning("nothin doing"); | ||
1092 | } | ||
1093 | |||
1094 | qDebug("copy "+curFile+" as "+destFile); | ||
1095 | } | ||
1096 | delete fileDlg; | ||
1097 | } | ||
1098 | populateLocalView(); | ||
1099 | |||
1100 | } else { | ||
1101 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1102 | |||
1103 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1104 | |||
1105 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | ||
1106 | QString destFile; | ||
1107 | fileDlg->setInputText((const QString &) destFile); | ||
1108 | fileDlg->exec(); | ||
1109 | if( fileDlg->result() == 1 ) { | ||
1110 | QString filename = fileDlg->LineEdit1->text(); | ||
1111 | |||
1112 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
1113 | |||
1114 | QFile f(destFile); | ||
1115 | if( f.exists()) { | ||
1116 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
1117 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1118 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1119 | case 0: | ||
1120 | f.remove(); | ||
1121 | break; | ||
1122 | case 1: | ||
1123 | return; | ||
1124 | break; | ||
1125 | }; | ||
1126 | } | ||
1127 | if(!copyFile(destFile, curFile) ) { | ||
1128 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1129 | qWarning("nothin doing"); | ||
1130 | } | ||
1131 | qDebug("copy "+curFile+" as "+destFile); | ||
1132 | } | ||
1133 | delete fileDlg; | ||
1134 | } | ||
1135 | populateRemoteView(); | ||
1136 | } | ||
1137 | } | ||
1138 | |||
1139 | void AdvancedFm::move() { | ||
1140 | qApp->processEvents(); | ||
1141 | |||
1142 | QStringList curFileList = getPath(); | ||
1143 | if( curFileList.count() > 0) { | ||
1144 | QString curFile; | ||
1145 | QString destFile; | ||
1146 | |||
1147 | if (TabWidget->currentPageIndex() == 0) { | ||
1148 | |||
1149 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1150 | |||
1151 | QString destFile = currentRemoteDir.canonicalPath(); | ||
1152 | |||
1153 | if(destFile.right(1).find("/",0,TRUE) == -1) | ||
1154 | destFile+="/"; | ||
1155 | destFile +=(*it); | ||
1156 | curFile = currentDir.canonicalPath(); | ||
1157 | |||
1158 | qDebug("Destination file is "+destFile); | ||
1159 | |||
1160 | if(curFile.right(1).find("/",0,TRUE) == -1) | ||
1161 | curFile +="/"; | ||
1162 | |||
1163 | curFile+=(*it); | ||
1164 | qDebug("CurrentFile file is " + curFile); | ||
1165 | |||
1166 | QFile f( curFile); | ||
1167 | if( f.exists()) { | ||
1168 | if(!copyFile( destFile, curFile) ) { | ||
1169 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | ||
1170 | return; | ||
1171 | } else | ||
1172 | QFile::remove(curFile); | ||
1173 | } | ||
1174 | } | ||
1175 | |||
1176 | TabWidget->setCurrentPage(1); | ||
1177 | |||
1178 | } else { //view 2 | ||
1179 | |||
1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1181 | |||
1182 | QString destFile = currentDir.canonicalPath(); | ||
1183 | |||
1184 | if(destFile.right(1).find("/",0,TRUE) == -1) | ||
1185 | destFile+="/"; | ||
1186 | |||
1187 | destFile +=(*it); | ||
1188 | |||
1189 | qDebug("Destination file is "+destFile); | ||
1190 | |||
1191 | curFile = currentRemoteDir.canonicalPath(); | ||
1192 | |||
1193 | if(curFile.right(1).find("/",0,TRUE) == -1) | ||
1194 | curFile +="/"; | ||
1195 | curFile+=(*it); | ||
1196 | qDebug("CurrentFile file is " + curFile); | ||
1197 | |||
1198 | QFile f( curFile); | ||
1199 | if( f.exists()) { | ||
1200 | if(!copyFile( destFile, curFile) ) { | ||
1201 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | ||
1202 | return; | ||
1203 | } else | ||
1204 | QFile::remove( curFile); | ||
1205 | } | ||
1206 | TabWidget->setCurrentPage(0); | ||
1207 | } | ||
1208 | } | ||
1209 | populateRemoteView(); | ||
1210 | populateLocalView(); | ||
1211 | } | ||
1212 | } | ||
1213 | |||
1214 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { | ||
1215 | char bf[ 50000 ]; | ||
1216 | int bytesRead; | ||
1217 | bool success = TRUE; | ||
1218 | struct stat status; | ||
1219 | |||
1220 | QFile s( src ); | ||
1221 | QFile d( dest ); | ||
1222 | |||
1223 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | ||
1224 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | ||
1225 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | ||
1226 | success = FALSE; | ||
1227 | break; | ||
1228 | } | ||
1229 | } | ||
1230 | if( success && (bytesRead > 0) ){ | ||
1231 | d.writeBlock( bf, bytesRead ); | ||
1232 | } | ||
1233 | } else { | ||
1234 | success = FALSE; | ||
1235 | } | ||
1236 | |||
1237 | // Set file permissions | ||
1238 | if( stat( (const char *) src, &status ) == 0 ){ | ||
1239 | chmod( (const char *) dest, status.st_mode ); | ||
1240 | } | ||
1241 | |||
1242 | return success; | ||
1243 | } | ||
1244 | |||
1245 | void AdvancedFm::runCommand() { | ||
1246 | QString curFile; | ||
1247 | if (TabWidget->currentPageIndex() == 0) { | ||
1248 | if( Local_View->currentItem()) | ||
1249 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | ||
1250 | } else { | ||
1251 | if(Remote_View->currentItem()) | ||
1252 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | ||
1253 | } | ||
1254 | |||
1255 | InputDialog *fileDlg; | ||
1256 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
1257 | fileDlg->setInputText(curFile); | ||
1258 | fileDlg->exec(); | ||
1259 | QString command; | ||
1260 | if( fileDlg->result() == 1 ) { | ||
1261 | command = fileDlg->LineEdit1->text(); | ||
1262 | |||
1263 | Output *outDlg; | ||
1264 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
1265 | outDlg->showMaximized(); | ||
1266 | outDlg->show(); | ||
1267 | qApp->processEvents(); | ||
1268 | FILE *fp; | ||
1269 | char line[130]; | ||
1270 | sleep(1); | ||
1271 | command +=" 2>&1"; | ||
1272 | fp = popen( (const char *) command, "r"); | ||
1273 | if ( !fp ) { | ||
1274 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
1275 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
1276 | pclose(fp); | ||
1277 | return; | ||
1278 | } else { | ||
1279 | while ( fgets( line, sizeof line, fp)) { | ||
1280 | QString lineStr = line; | ||
1281 | lineStr=lineStr.left(lineStr.length()-1); | ||
1282 | outDlg->OutputEdit->append(lineStr); | ||
1283 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
1284 | } | ||
1285 | } | ||
1286 | pclose(fp); | ||
1287 | |||
1288 | } | ||
1289 | } | ||
1290 | |||
1291 | void AdvancedFm::runCommandStd() { | ||
1292 | QString curFile; | ||
1293 | if (TabWidget->currentPageIndex() == 0) { | ||
1294 | if( Local_View->currentItem()) | ||
1295 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | ||
1296 | } else { | ||
1297 | if(Remote_View->currentItem()) | ||
1298 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); | ||
1299 | } | ||
1300 | |||
1301 | InputDialog *fileDlg; | ||
1302 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
1303 | fileDlg->setInputText(curFile); | ||
1304 | fileDlg->exec(); | ||
1305 | QString command; | ||
1306 | if( fileDlg->result() == 1 ) { | ||
1307 | qApp->processEvents(); | ||
1308 | command = fileDlg->LineEdit1->text() + " &"; | ||
1309 | system(command.latin1()); | ||
1310 | } | ||
1311 | } | ||
1312 | |||
1313 | void AdvancedFm::fileStatus() { | ||
1314 | QString curFile; | ||
1315 | if (TabWidget->currentPageIndex() == 0) { | ||
1316 | curFile = Local_View->currentItem()->text(0); | ||
1317 | } else { | ||
1318 | curFile = Remote_View->currentItem()->text(0); | ||
1319 | } | ||
1320 | QString command = " stat -l "+ curFile +" 2>&1"; | ||
1321 | Output *outDlg; | ||
1322 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
1323 | outDlg->showMaximized(); | ||
1324 | outDlg->show(); | ||
1325 | qApp->processEvents(); | ||
1326 | FILE *fp; | ||
1327 | char line[130]; | ||
1328 | sleep(1); | ||
1329 | fp = popen( (const char *) command, "r"); | ||
1330 | if ( !fp ) { | ||
1331 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
1332 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
1333 | pclose(fp); | ||
1334 | return; | ||
1335 | } else { | ||
1336 | while ( fgets( line, sizeof line, fp)) { | ||
1337 | outDlg->OutputEdit->append(line); | ||
1338 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
1339 | |||
1340 | } | ||
1341 | |||
1342 | } | ||
1343 | pclose(fp); | ||
1344 | } | 564 | } |
1345 | 565 | ||
1346 | void AdvancedFm::mkDir() { | ||
1347 | if (TabWidget->currentPageIndex() == 0) | ||
1348 | localMakDir(); | ||
1349 | else | ||
1350 | remoteMakDir(); | ||
1351 | |||
1352 | } | ||
1353 | 566 | ||
1354 | void AdvancedFm::rn() { | ||
1355 | if (TabWidget->currentPageIndex() == 0) | ||
1356 | localRename(); | ||
1357 | else | ||
1358 | remoteRename(); | ||
1359 | |||
1360 | } | ||
1361 | |||
1362 | void AdvancedFm::del() { | ||
1363 | if (TabWidget->currentPageIndex() == 0) | ||
1364 | localDelete(); | ||
1365 | else | ||
1366 | remoteDelete(); | ||
1367 | } | ||
1368 | 567 | ||
1369 | void AdvancedFm::doAbout() { | 568 | void AdvancedFm::doAbout() { |
1370 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 569 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
1371 | "is copyright 2002 by\n" | 570 | "is copyright 2002 by\n" |
1372 | "L.J.Potter<llornkcor@handhelds.org>\n" | 571 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1373 | "and is licensed by the GPL")); | 572 | "and is licensed by the GPL")); |
1374 | } | 573 | } |
1375 | 574 | ||
1376 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 575 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
1377 | if( TabWidget->hasFocus()) | 576 | if( TabWidget->hasFocus()) |
@@ -1437,43 +636,8 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | |||
1437 | break; | 636 | break; |
1438 | } | 637 | } |
1439 | } | 638 | } |
1440 | 639 | ||
1441 | void AdvancedFm::mkSym() { | ||
1442 | QString cmd; | ||
1443 | QStringList curFileList = getPath(); | ||
1444 | if( curFileList.count() > 0) { | ||
1445 | |||
1446 | if (TabWidget->currentPageIndex() == 0) { | ||
1447 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1448 | |||
1449 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1450 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | ||
1451 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
1452 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1453 | cmd = "ln -s "+curFile+" "+destName; | ||
1454 | qDebug(cmd); | ||
1455 | system(cmd.latin1() ); | ||
1456 | } | ||
1457 | populateRemoteView(); | ||
1458 | TabWidget->setCurrentPage(1); | ||
1459 | } else { | ||
1460 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1461 | |||
1462 | QString destName = currentDir.canonicalPath()+"/"+(*it); | ||
1463 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | ||
1464 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1465 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1466 | |||
1467 | cmd = "ln -s "+curFile+" "+destName; | ||
1468 | qDebug(cmd); | ||
1469 | system(cmd.latin1() ); | ||
1470 | } | ||
1471 | populateLocalView(); | ||
1472 | TabWidget->setCurrentPage(0); | ||
1473 | } | ||
1474 | } | ||
1475 | } | ||
1476 | 640 | ||
1477 | void AdvancedFm::QPEButtonPushed() { | 641 | void AdvancedFm::QPEButtonPushed() { |
1478 | QString current = QPEApplication::qpeDir(); | 642 | QString current = QPEApplication::qpeDir(); |
1479 | chdir( current.latin1() ); | 643 | chdir( current.latin1() ); |
@@ -1543,46 +707,8 @@ QString AdvancedFm::getDiskSpace( const QString &path) { | |||
1543 | } | 707 | } |
1544 | return ""; | 708 | return ""; |
1545 | } | 709 | } |
1546 | 710 | ||
1547 | void AdvancedFm::doBeam() { | ||
1548 | Ir ir; | ||
1549 | if(!ir.supported()){ | ||
1550 | } else { | ||
1551 | |||
1552 | QStringList curFileList = getPath(); | ||
1553 | if( curFileList.count() > 0) { | ||
1554 | |||
1555 | if (TabWidget->currentPageIndex() == 0) { | ||
1556 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1557 | |||
1558 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
1559 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1560 | Ir *file = new Ir(this, "IR"); | ||
1561 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | ||
1562 | file->send( curFile, curFile ); | ||
1563 | } | ||
1564 | |||
1565 | } else { | ||
1566 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1567 | |||
1568 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1569 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1570 | Ir *file = new Ir(this, "IR"); | ||
1571 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | ||
1572 | file->send( curFile, curFile ); | ||
1573 | |||
1574 | } | ||
1575 | } | ||
1576 | } | ||
1577 | } | ||
1578 | |||
1579 | } | ||
1580 | |||
1581 | void AdvancedFm::fileBeamFinished( Ir *) { | ||
1582 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | ||
1583 | |||
1584 | } | ||
1585 | 711 | ||
1586 | void AdvancedFm::showFileMenu() { | 712 | void AdvancedFm::showFileMenu() { |
1587 | 713 | ||
1588 | QString curApp; | 714 | QString curApp; |
@@ -1600,17 +726,18 @@ void AdvancedFm::showFileMenu() { | |||
1600 | 726 | ||
1601 | QPopupMenu *m = new QPopupMenu(0); | 727 | QPopupMenu *m = new QPopupMenu(0); |
1602 | 728 | ||
1603 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 729 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
730 | if ( !QFileInfo(fi).isDir() ) { | ||
1604 | m->insertSeparator(); | 731 | m->insertSeparator(); |
1605 | if ( QFileInfo(fi).isDir() ) { | 732 | // m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
1606 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 733 | // } else { |
1607 | } else { | ||
1608 | 734 | ||
1609 | if ( app ) | 735 | if ( app ) |
1610 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); | 736 | m->insertItem( app->pixmap(), tr( "Open in " |
737 | + app->name() ), this, SLOT( runThis() ) ); | ||
1611 | else if( QFileInfo(fi).isExecutable() ) | 738 | else if( QFileInfo(fi).isExecutable() ) |
1612 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 739 | m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) ); |
1613 | 740 | ||
1614 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 741 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
1615 | } | 742 | } |
1616 | m->insertSeparator(); | 743 | m->insertSeparator(); |
@@ -1652,10 +779,9 @@ void AdvancedFm::showFileMenu() { | |||
1652 | 779 | ||
1653 | m->insertSeparator(); | 780 | m->insertSeparator(); |
1654 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 781 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
1655 | 782 | ||
1656 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings | 783 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1657 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | ||
1658 | m->setCheckable(TRUE); | 784 | m->setCheckable(TRUE); |
1659 | if (!b) | 785 | if (!b) |
1660 | m->setItemChecked(m->idAt(0),TRUE); | 786 | m->setItemChecked(m->idAt(0),TRUE); |
1661 | else | 787 | else |
@@ -1671,9 +797,9 @@ void AdvancedFm::showFileMenu() { | |||
1671 | 797 | ||
1672 | 798 | ||
1673 | void AdvancedFm::cancelMenuTimer() { | 799 | void AdvancedFm::cancelMenuTimer() { |
1674 | 800 | ||
1675 | qDebug("selectionChanged: cancel menu timer"); | 801 | // qDebug("selectionChanged: cancel menu timer"); |
1676 | if( menuTimer.isActive() ) | 802 | if( menuTimer.isActive() ) |
1677 | menuTimer.stop(); | 803 | menuTimer.stop(); |
1678 | } | 804 | } |
1679 | 805 | ||