Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index a694b70..6d41ac3 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,84 +1,84 @@ | |||
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 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qpe/lnkproperties.h> | 16 | #include <qpe/lnkproperties.h> |
17 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
18 | #include <qpe/applnk.h> | 18 | #include <qpe/applnk.h> |
19 | 19 | ||
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | 21 | ||
22 | 22 | ||
23 | #include <qpopupmenu.h> | 23 | #include <qpopupmenu.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | 25 | ||
26 | #include <errno.h> | 26 | #include <errno.h> |
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <dirent.h> | 30 | #include <dirent.h> |
31 | #include <sys/sendfile.h> | 31 | #include <sys/sendfile.h> |
32 | #include <fcntl.h> | 32 | #include <fcntl.h> |
33 | 33 | ||
34 | 34 | ||
35 | using namespace Opie::Core; | 35 | using namespace Opie::Core; |
36 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
37 | void AdvancedFm::doDirChange() { | 37 | void AdvancedFm::doDirChange() { |
38 | QString pathItem = CurrentView()->currentItem()->text(0); | 38 | QString pathItem = CurrentView()->currentItem()->text(0); |
39 | if( pathItem == "../") { | 39 | if( pathItem == "../") { |
40 | ListClicked( CurrentView()->currentItem()); | 40 | ListClicked( CurrentView()->currentItem()); |
41 | } else { | 41 | } else { |
42 | if( pathItem.find(" -> ",0,TRUE) != -1) | 42 | if( pathItem.find(" -> ",0,TRUE) != -1) |
43 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | 43 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; |
44 | // qWarning(pathItem); | 44 | // qWarning(pathItem); |
45 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | 45 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | void AdvancedFm::showMenuHidden() { | 49 | void AdvancedFm::showMenuHidden() { |
50 | if (b) { | 50 | if (b) { |
51 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 51 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
52 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 52 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
53 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 53 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
54 | } else { | 54 | } else { |
55 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 55 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
56 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 56 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
57 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 57 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
58 | } | 58 | } |
59 | b = !b; | 59 | b = !b; |
60 | populateView(); | 60 | populateView(); |
61 | } | 61 | } |
62 | 62 | ||
63 | void AdvancedFm::showHidden() { | 63 | void AdvancedFm::showHidden() { |
64 | if (b) { | 64 | if (b) { |
65 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 65 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
66 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 66 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
67 | } else { | 67 | } else { |
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 | } | 70 | } |
71 | populateView(); | 71 | populateView(); |
72 | } | 72 | } |
73 | 73 | ||
74 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 74 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
75 | QString strItem = fileName; | 75 | QString strItem = fileName; |
76 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 76 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
77 | } | 77 | } |
78 | 78 | ||
79 | void AdvancedFm::runThis() { | 79 | void AdvancedFm::runThis() { |
80 | if( !CurrentView()->currentItem()) return; | 80 | if( !CurrentView()->currentItem()) return; |
81 | QString fs; | 81 | QString fs; |
82 | QDir *thisDir = CurrentDir(); | 82 | QDir *thisDir = CurrentDir(); |
83 | 83 | ||
84 | QString curFile = CurrentView()->currentItem()->text(0); | 84 | QString curFile = CurrentView()->currentItem()->text(0); |
@@ -660,100 +660,100 @@ void AdvancedFm::mkSym() { | |||
660 | if( curFile.right(1) == "/") { | 660 | if( curFile.right(1) == "/") { |
661 | curFile = curFile.left( curFile.length() -1); | 661 | curFile = curFile.left( curFile.length() -1); |
662 | } | 662 | } |
663 | 663 | ||
664 | cmd = "ln -s "+curFile+" "+destName; | 664 | cmd = "ln -s "+curFile+" "+destName; |
665 | // qDebug(cmd); | 665 | // qDebug(cmd); |
666 | startProcess( (const QString)cmd ); | 666 | startProcess( (const QString)cmd ); |
667 | } | 667 | } |
668 | rePopulate(); | 668 | rePopulate(); |
669 | setOtherTabCurrent(); | 669 | setOtherTabCurrent(); |
670 | } | 670 | } |
671 | } | 671 | } |
672 | 672 | ||
673 | void AdvancedFm::doBeam() { | 673 | void AdvancedFm::doBeam() { |
674 | Ir ir; | 674 | Ir ir; |
675 | if(!ir.supported()) { | 675 | if(!ir.supported()) { |
676 | } else { | 676 | } else { |
677 | QStringList curFileList = getPath(); | 677 | QStringList curFileList = getPath(); |
678 | if( curFileList.count() > 0) { | 678 | if( curFileList.count() > 0) { |
679 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 679 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
680 | QString curFile = (*it); | 680 | QString curFile = (*it); |
681 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 681 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
682 | if( curFilePath.right(1) == "/") { | 682 | if( curFilePath.right(1) == "/") { |
683 | curFilePath = curFilePath.left( curFilePath.length() -1); | 683 | curFilePath = curFilePath.left( curFilePath.length() -1); |
684 | } | 684 | } |
685 | Ir *file = new Ir(this, "IR"); | 685 | Ir *file = new Ir(this, "IR"); |
686 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 686 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
687 | file->send( curFilePath, curFile ); | 687 | file->send( curFilePath, curFile ); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | } | 690 | } |
691 | } | 691 | } |
692 | 692 | ||
693 | void AdvancedFm::fileBeamFinished( Ir *) { | 693 | void AdvancedFm::fileBeamFinished( Ir *) { |
694 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 694 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
695 | } | 695 | } |
696 | 696 | ||
697 | void AdvancedFm::selectAll() { | 697 | void AdvancedFm::selectAll() { |
698 | QListView *thisView = CurrentView(); | 698 | QListView *thisView = CurrentView(); |
699 | thisView->selectAll(true); | 699 | thisView->selectAll(true); |
700 | thisView->setSelected( thisView->firstChild(),false); | 700 | thisView->setSelected( thisView->firstChild(),false); |
701 | } | 701 | } |
702 | 702 | ||
703 | void AdvancedFm::startProcess(const QString & cmd) { | 703 | void AdvancedFm::startProcess(const QString & cmd) { |
704 | QStringList command; | 704 | QStringList command; |
705 | OProcess *process; | 705 | OProcess *process; |
706 | process = new OProcess(); | 706 | process = new OProcess(); |
707 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 707 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
708 | this, SLOT( processEnded(OProcess*))); | 708 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
709 | 709 | ||
710 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 710 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
711 | this, SLOT( oprocessStderr(OProcess*,char*,int))); | 711 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
712 | 712 | ||
713 | command << "/bin/sh"; | 713 | command << "/bin/sh"; |
714 | command << "-c"; | 714 | command << "-c"; |
715 | command << cmd.latin1(); | 715 | command << cmd.latin1(); |
716 | *process << command; | 716 | *process << command; |
717 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 717 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
718 | qDebug("could not start process"); | 718 | qDebug("could not start process"); |
719 | } | 719 | } |
720 | 720 | ||
721 | void AdvancedFm::processEnded(OProcess *) { | 721 | void AdvancedFm::processEnded(OProcess *) { |
722 | rePopulate(); | 722 | rePopulate(); |
723 | } | 723 | } |
724 | 724 | ||
725 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 725 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
726 | // qWarning("received stderrt %d bytes", buflen); | 726 | // qWarning("received stderrt %d bytes", buflen); |
727 | 727 | ||
728 | QString lineStr = buffer; | 728 | QString lineStr = buffer; |
729 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 729 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
730 | } | 730 | } |
731 | 731 | ||
732 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 732 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
733 | if ( o->inherits( "QLineEdit" ) ) { | 733 | if ( o->inherits( "QLineEdit" ) ) { |
734 | if ( e->type() == QEvent::KeyPress ) { | 734 | if ( e->type() == QEvent::KeyPress ) { |
735 | QKeyEvent *ke = (QKeyEvent*)e; | 735 | QKeyEvent *ke = (QKeyEvent*)e; |
736 | if ( ke->key() == Key_Return || | 736 | if ( ke->key() == Key_Return || |
737 | ke->key() == Key_Enter ) { | 737 | ke->key() == Key_Enter ) { |
738 | okRename(); | 738 | okRename(); |
739 | return true; | 739 | return true; |
740 | } | 740 | } |
741 | else if ( ke->key() == Key_Escape ) { | 741 | else if ( ke->key() == Key_Escape ) { |
742 | cancelRename(); | 742 | cancelRename(); |
743 | return true; | 743 | return true; |
744 | } | 744 | } |
745 | } | 745 | } |
746 | else if ( e->type() == QEvent::FocusOut ) { | 746 | else if ( e->type() == QEvent::FocusOut ) { |
747 | cancelRename(); | 747 | cancelRename(); |
748 | return true; | 748 | return true; |
749 | } | 749 | } |
750 | } | 750 | } |
751 | if ( o->inherits( "QListView" ) ) { | 751 | if ( o->inherits( "QListView" ) ) { |
752 | if ( e->type() == QEvent::FocusIn ) { | 752 | if ( e->type() == QEvent::FocusIn ) { |
753 | if( o == Local_View) { //keep track of which view | 753 | if( o == Local_View) { //keep track of which view |
754 | whichTab=1; | 754 | whichTab=1; |
755 | } | 755 | } |
756 | else { | 756 | else { |
757 | whichTab=2; | 757 | whichTab=2; |
758 | } | 758 | } |
759 | } | 759 | } |