summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-02-23 03:47:07 (UTC)
committer llornkcor <llornkcor>2003-02-23 03:47:07 (UTC)
commit2678456bf180bcf0ab7cfa112f3c723cf1d87c84 (patch) (unidiff)
treeeb7edd83adc3204088f2f3e0ed3c0ff9e48f5040
parentd51ca116a8c4d234db93021ccad36506980c317f (diff)
downloadopie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.zip
opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.tar.gz
opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.tar.bz2
fix rename
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 2ddcabc..e7c0b6a 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -906,232 +906,232 @@ void AdvancedFm::del() {
906} 906}
907 907
908void AdvancedFm::mkSym() { 908void AdvancedFm::mkSym() {
909 QString cmd; 909 QString cmd;
910 QStringList curFileList = getPath(); 910 QStringList curFileList = getPath();
911 if( curFileList.count() > 0) { 911 if( curFileList.count() > 0) {
912 912
913 if (TabWidget->getCurrentTab() == 0) { 913 if (TabWidget->getCurrentTab() == 0) {
914 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 914 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
915 915
916 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 916 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
917 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 917 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
918 QString curFile = currentDir.canonicalPath()+"/"+(*it); 918 QString curFile = currentDir.canonicalPath()+"/"+(*it);
919 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 919 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
920 cmd = "ln -s "+curFile+" "+destName; 920 cmd = "ln -s "+curFile+" "+destName;
921 qDebug(cmd); 921 qDebug(cmd);
922 startProcess( (const QString)cmd ); 922 startProcess( (const QString)cmd );
923 } 923 }
924 populateRemoteView(); 924 populateRemoteView();
925 TabWidget->setCurrentTab(1); 925 TabWidget->setCurrentTab(1);
926 } else { 926 } else {
927 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 927 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
928 928
929 QString destName = currentDir.canonicalPath()+"/"+(*it); 929 QString destName = currentDir.canonicalPath()+"/"+(*it);
930 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 930 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
931 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 931 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
932 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 932 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
933 933
934 cmd = "ln -s "+curFile+" "+destName; 934 cmd = "ln -s "+curFile+" "+destName;
935 qDebug(cmd); 935 qDebug(cmd);
936 startProcess( (const QString)cmd ); 936 startProcess( (const QString)cmd );
937 } 937 }
938 populateLocalView(); 938 populateLocalView();
939 TabWidget->setCurrentTab(0); 939 TabWidget->setCurrentTab(0);
940 } 940 }
941 } 941 }
942} 942}
943 943
944void AdvancedFm::doBeam() { 944void AdvancedFm::doBeam() {
945 Ir ir; 945 Ir ir;
946 if(!ir.supported()){ 946 if(!ir.supported()){
947 } else { 947 } else {
948 948
949 QStringList curFileList = getPath(); 949 QStringList curFileList = getPath();
950 if( curFileList.count() > 0) { 950 if( curFileList.count() > 0) {
951 951
952 if (TabWidget->getCurrentTab() == 0) { 952 if (TabWidget->getCurrentTab() == 0) {
953 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 953 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
954 954
955 QString curFile = currentDir.canonicalPath()+"/"+(*it); 955 QString curFile = currentDir.canonicalPath()+"/"+(*it);
956 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 956 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
957 Ir *file = new Ir(this, "IR"); 957 Ir *file = new Ir(this, "IR");
958 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 958 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
959 file->send( curFile, curFile ); 959 file->send( curFile, curFile );
960 } 960 }
961 961
962 } else { 962 } else {
963 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 963 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
964 964
965 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 965 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
966 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 966 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
967 Ir *file = new Ir(this, "IR"); 967 Ir *file = new Ir(this, "IR");
968 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 968 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
969 file->send( curFile, curFile ); 969 file->send( curFile, curFile );
970 970
971 } 971 }
972 } 972 }
973 } 973 }
974 } 974 }
975 975
976} 976}
977 977
978void AdvancedFm::fileBeamFinished( Ir *) { 978void AdvancedFm::fileBeamFinished( Ir *) {
979 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 979 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
980 980
981} 981}
982 982
983void AdvancedFm::selectAll() { 983void AdvancedFm::selectAll() {
984 if (TabWidget->getCurrentTab() == 0) { 984 if (TabWidget->getCurrentTab() == 0) {
985 Local_View->selectAll(true); 985 Local_View->selectAll(true);
986 Local_View->setSelected( Local_View->firstChild(),false); 986 Local_View->setSelected( Local_View->firstChild(),false);
987 } else { 987 } else {
988 Remote_View->selectAll(true); 988 Remote_View->selectAll(true);
989 Remote_View->setSelected( Remote_View->firstChild(),false); 989 Remote_View->setSelected( Remote_View->firstChild(),false);
990 } 990 }
991} 991}
992 992
993void AdvancedFm::startProcess(const QString & cmd) { 993void AdvancedFm::startProcess(const QString & cmd) {
994 QStringList command; 994 QStringList command;
995 OProcess *process; 995 OProcess *process;
996 process = new OProcess(); 996 process = new OProcess();
997 connect(process, SIGNAL(processExited(OProcess *)), 997 connect(process, SIGNAL(processExited(OProcess *)),
998 this, SLOT( processEnded())); 998 this, SLOT( processEnded()));
999 999
1000 command << "/bin/sh"; 1000 command << "/bin/sh";
1001 command << "-c"; 1001 command << "-c";
1002 command << cmd.latin1(); 1002 command << cmd.latin1();
1003 *process << command; 1003 *process << command;
1004 if(!process->start(OProcess::NotifyOnExit) ) 1004 if(!process->start(OProcess::NotifyOnExit) )
1005 qDebug("could not start process"); 1005 qDebug("could not start process");
1006} 1006}
1007 1007
1008void AdvancedFm::processEnded() { 1008void AdvancedFm::processEnded() {
1009 populateLocalView(); 1009 populateLocalView();
1010 populateRemoteView(); 1010 populateRemoteView();
1011} 1011}
1012 1012
1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
1014 if ( o->inherits( "QLineEdit" ) ) { 1014 if ( o->inherits( "QLineEdit" ) ) {
1015 if ( e->type() == QEvent::KeyPress ) { 1015 if ( e->type() == QEvent::KeyPress ) {
1016 QKeyEvent *ke = (QKeyEvent*)e; 1016 QKeyEvent *ke = (QKeyEvent*)e;
1017 if ( ke->key() == Key_Return || 1017 if ( ke->key() == Key_Return ||
1018 ke->key() == Key_Enter ) { 1018 ke->key() == Key_Enter ) {
1019 okRename(); 1019 okRename();
1020 return true; 1020 return true;
1021 } else if ( ke->key() == Key_Escape ) { 1021 } else if ( ke->key() == Key_Escape ) {
1022 cancelRename(); 1022 cancelRename();
1023 return true; 1023 return true;
1024 } 1024 }
1025 } else if ( e->type() == QEvent::FocusOut ) { 1025 } else if ( e->type() == QEvent::FocusOut ) {
1026 cancelRename(); 1026 cancelRename();
1027 return true; 1027 return true;
1028 } 1028 }
1029 } 1029 }
1030 if ( o->inherits( "QListView" ) ) { 1030 if ( o->inherits( "QListView" ) ) {
1031 if ( e->type() == QEvent::FocusOut ) { 1031 if ( e->type() == QEvent::FocusOut ) {
1032 printf("focusIn\n"); 1032 printf("focusIn\n");
1033 1033
1034 } 1034 }
1035 } 1035 }
1036 1036
1037 return QWidget::eventFilter( o, e ); 1037 return QWidget::eventFilter( o, e );
1038} 1038}
1039 1039
1040 1040
1041void AdvancedFm::cancelRename() 1041void AdvancedFm::cancelRename()
1042{ 1042{
1043 qDebug("cancel rename"); 1043 qDebug("cancel rename");
1044 QListView * view; 1044 QListView * view;
1045 if (TabWidget->getCurrentTab() == 0) 1045 if (TabWidget->getCurrentTab() == 0)
1046 { 1046 {
1047 view = Local_View; 1047 view = Local_View;
1048 } 1048 }
1049 else 1049 else
1050 { 1050 {
1051 view = Remote_View; 1051 view = Remote_View;
1052 } 1052 }
1053 1053
1054 bool resetFocus = view->viewport()->focusProxy() == renameBox; 1054 bool resetFocus = view->viewport()->focusProxy() == renameBox;
1055 delete renameBox; 1055 delete renameBox;
1056 renameBox = 0; 1056 renameBox = 0;
1057 if ( resetFocus ) { 1057 if ( resetFocus ) {
1058 view->viewport()->setFocusProxy( view); 1058 view->viewport()->setFocusProxy( view);
1059 view->setFocus(); 1059 view->setFocus();
1060 } 1060 }
1061} 1061}
1062 1062
1063void AdvancedFm::doRename(QListView * view) 1063void AdvancedFm::doRename(QListView * view)
1064{ 1064{
1065 1065
1066 QRect r = view->itemRect( view->currentItem( )); 1066 QRect r = view->itemRect( view->currentItem( ));
1067 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 1067 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
1068 r.setX( view->contentsX() ); 1068 r.setX( view->contentsX() );
1069 if ( r.width() > view->visibleWidth() ) 1069 if ( r.width() > view->visibleWidth() )
1070 r.setWidth( view->visibleWidth() ); 1070 r.setWidth( view->visibleWidth() );
1071 1071
1072 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 1072 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
1073 renameBox->setFrame(true); 1073 renameBox->setFrame(true);
1074 1074
1075 renameBox->setText( view->currentItem()->text(0) ); 1075 renameBox->setText( view->currentItem()->text(0) );
1076 1076
1077 renameBox->selectAll(); 1077 renameBox->selectAll();
1078 renameBox->installEventFilter( this ); 1078 renameBox->installEventFilter( this );
1079 view->addChild( renameBox, r.x(), r.y() ); 1079 view->addChild( renameBox, r.x(), r.y() );
1080 renameBox->resize( r.size() ); 1080 renameBox->resize( r.size() );
1081 view->viewport()->setFocusProxy( renameBox ); 1081 view->viewport()->setFocusProxy( renameBox );
1082 renameBox->setFocus(); 1082 renameBox->setFocus();
1083 renameBox->show(); 1083 renameBox->show();
1084 1084
1085} 1085}
1086 1086
1087 1087
1088void AdvancedFm::localRename() 1088void AdvancedFm::localRename()
1089{ 1089{
1090 oldName = Local_View->currentItem()->text(0); 1090 oldName = Local_View->currentItem()->text(0);
1091 doRename(Local_View ); 1091 doRename(Local_View );
1092 populateLocalView(); 1092 populateLocalView();
1093} 1093}
1094 1094
1095void AdvancedFm::remoteRename() 1095void AdvancedFm::remoteRename()
1096{ 1096{
1097 oldName = Remote_View->currentItem()->text(0); 1097 oldName = Remote_View->currentItem()->text(0);
1098 doRename(Local_View ); 1098 doRename(Remote_View );
1099 populateRemoteView(); 1099 populateRemoteView();
1100} 1100}
1101 1101
1102void AdvancedFm::okRename() 1102void AdvancedFm::okRename()
1103{ 1103{
1104 QString newName = renameBox->text(); 1104 QString newName = renameBox->text();
1105 cancelRename(); 1105 cancelRename();
1106 int tabs=0; 1106 int tabs=0;
1107 QListView * view; 1107 QListView * view;
1108 tabs = TabWidget->getCurrentTab(); 1108 tabs = TabWidget->getCurrentTab();
1109 if ( tabs == 0) 1109 if ( tabs == 0)
1110 { 1110 {
1111 view = Local_View; 1111 view = Local_View;
1112 QString path = currentDir.canonicalPath() + "/"; 1112 QString path = currentDir.canonicalPath() + "/";
1113 oldName = path + oldName; 1113 oldName = path + oldName;
1114 newName = path + newName; 1114 newName = path + newName;
1115 } 1115 }
1116 else 1116 else
1117 { 1117 {
1118 view = Remote_View; 1118 view = Remote_View;
1119 QString path = currentRemoteDir.canonicalPath() + "/"; 1119 QString path = currentRemoteDir.canonicalPath() + "/";
1120 oldName = path + oldName; 1120 oldName = path + oldName;
1121 newName = path + newName; 1121 newName = path + newName;
1122 } 1122 }
1123 1123
1124 if( view->currentItem() == NULL) 1124 if( view->currentItem() == NULL)
1125 return; 1125 return;
1126 if( rename(oldName.latin1(), newName.latin1())== -1) 1126 if( rename(oldName.latin1(), newName.latin1())== -1)
1127 QMessageBox::message(tr("Note"),tr("Could not rename")); 1127 QMessageBox::message(tr("Note"),tr("Could not rename"));
1128 else 1128 else
1129 oldName = ""; 1129 oldName = "";
1130 1130
1131 view->takeItem( view->currentItem() ); 1131 view->takeItem( view->currentItem() );
1132 delete view->currentItem(); 1132 delete view->currentItem();
1133 if ( tabs == 0) 1133 if ( tabs == 0)
1134 populateLocalView(); 1134 populateLocalView();
1135 else 1135 else
1136 populateRemoteView(); 1136 populateRemoteView();
1137} 1137}