summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp256
1 files changed, 141 insertions, 115 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index fb57193..7f5d71c 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -157,4 +157,6 @@ OpieFtp::OpieFtp( )
157 Local_View->setAllColumnsShowFocus(TRUE); 157 Local_View->setAllColumnsShowFocus(TRUE);
158 Local_View->setMultiSelection( TRUE ); 158
159 Local_View->setMultiSelection( TRUE);
159 Local_View->setSelectionMode(QListView::Extended); 160 Local_View->setSelectionMode(QListView::Extended);
161 Local_View->setFocusPolicy(QWidget::ClickFocus);
160 162
@@ -187,4 +189,6 @@ OpieFtp::OpieFtp( )
187 Remote_View->setAllColumnsShowFocus(TRUE); 189 Remote_View->setAllColumnsShowFocus(TRUE);
188 Remote_View->setMultiSelection( TRUE ); 190
191 Remote_View->setMultiSelection( FALSE);
189 Remote_View->setSelectionMode(QListView::Extended); 192 Remote_View->setSelectionMode(QListView::Extended);
193 Remote_View->setFocusPolicy(QWidget::ClickFocus);
190 194
@@ -380,3 +384,3 @@ void OpieFtp::connector()
380{ 384{
381// QCopEnvelope ( "QPE/System", "busy()" ); 385 QCopEnvelope ( "QPE/System", "busy()" );
382// qApp->processEvents(); 386// qApp->processEvents();
@@ -423,3 +427,3 @@ void OpieFtp::connector()
423 connectServerBtn->setText( tr("Disconnect")); 427 connectServerBtn->setText( tr("Disconnect"));
424// QCopEnvelope ( "QPE/System", "notBusy()" ); 428 QCopEnvelope ( "QPE/System", "notBusy()" );
425} 429}
@@ -471,9 +475,12 @@ void OpieFtp::localUpload()
471 nullifyCallBack(); 475 nullifyCallBack();
472 } //end currentSelected
473 it.current()->setSelected(FALSE); 476 it.current()->setSelected(FALSE);
477 } //end currentSelected
478 }
479 for ( ; it.current(); ++it ) {
480 Local_View->clearSelection();
474 } 481 }
482 Local_View->clearFocus();
475 TabWidget->setCurrentPage(1); 483 TabWidget->setCurrentPage(1);
476 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 484 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
477// QCopEnvelope ( "QPE/System", "notBusy()" ); 485 QCopEnvelope ( "QPE/System", "notBusy()" );
478
479} 486}
@@ -492,3 +499,3 @@ void OpieFtp::remoteDownload()
492 int fsz; 499 int fsz;
493// QCopEnvelope ( "QPE/System", "busy()" ); 500 QCopEnvelope ( "QPE/System", "busy()" );
494 501
@@ -526,9 +533,12 @@ void OpieFtp::remoteDownload()
526 nullifyCallBack(); 533 nullifyCallBack();
527 }
528 it.current()->setSelected(FALSE); 534 it.current()->setSelected(FALSE);
535 }
536 }
537 for ( ; it.current(); ++it ) {
538 Remote_View->clearSelection();
529 } 539 }
540 Remote_View->setFocus();
530 TabWidget->setCurrentPage(0); 541 TabWidget->setCurrentPage(0);
531 populateLocalView(); 542 populateLocalView();
532// QCopEnvelope ( "QPE/System", "notBusy()" ); 543 QCopEnvelope ( "QPE/System", "notBusy()" );
533
534} 544}
@@ -543,3 +553,3 @@ bool OpieFtp::remoteDirList(const QString &dir)
543// qDebug("Listing remote dir "+tmp); 553// qDebug("Listing remote dir "+tmp);
544// QCopEnvelope ( "QPE/System", "busy()" ); 554 QCopEnvelope ( "QPE/System", "busy()" );
545 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 555 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
@@ -552,3 +562,3 @@ bool OpieFtp::remoteDirList(const QString &dir)
552 populateRemoteView() ; 562 populateRemoteView() ;
553// QCopEnvelope ( "QPE/System", "notBusy()" ); 563 QCopEnvelope ( "QPE/System", "notBusy()" );
554 return true; 564 return true;
@@ -558,3 +568,3 @@ bool OpieFtp::remoteChDir(const QString &dir)
558{ 568{
559// QCopEnvelope ( "QPE/System", "busy()" ); 569 QCopEnvelope ( "QPE/System", "busy()" );
560 if (!FtpChdir( dir.latin1(), conn )) { 570 if (!FtpChdir( dir.latin1(), conn )) {
@@ -565,6 +575,6 @@ bool OpieFtp::remoteChDir(const QString &dir)
565// qDebug(msg); 575// qDebug(msg);
566// QCopEnvelope ( "QPE/System", "notBusy()" ); 576 QCopEnvelope ( "QPE/System", "notBusy()" );
567 return FALSE; 577 return FALSE;
568 } 578 }
569// QCopEnvelope ( "QPE/System", "notBusy()" ); 579 QCopEnvelope ( "QPE/System", "notBusy()" );
570 return TRUE; 580 return TRUE;
@@ -639,3 +649,2 @@ void OpieFtp::populateLocalView()
639 fillCombo( (const QString &)currentDir); 649 fillCombo( (const QString &)currentDir);
640
641} 650}
@@ -740,3 +749,3 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
740 } else { 749 } else {
741// QCopEnvelope ( "QPE/System", "notBusy()" ); 750 QCopEnvelope ( "QPE/System", "notBusy()" );
742 return; 751 return;
@@ -792,3 +801,2 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem)
792 } 801 }
793
794} 802}
@@ -840,12 +848,14 @@ void OpieFtp::showRemoteMenu(QListViewItem * item)
840{ 848{
841 QPopupMenu m;// = new QPopupMenu( Local_View ); 849 QPopupMenu * m;// = new QPopupMenu( Local_View );
850 m = new QPopupMenu(this);
842 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 851 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
843 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 852 m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
844 else 853 else
845 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 854 m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
846 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 855 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
847 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 856 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
848 m.insertSeparator(); 857 m->insertSeparator();
849 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 858 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
850 m.exec( QCursor::pos() ); 859 m->exec( QCursor::pos() );
860 delete m;
851} 861}
@@ -855,20 +865,22 @@ void OpieFtp::showLocalMenu(QListViewItem * item)
855 865
856 QPopupMenu m; 866 QPopupMenu *m;
857 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 867 m = new QPopupMenu( this);
858 m.insertSeparator(); 868 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
869 m->insertSeparator();
859 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 870 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
860 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 871 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
861 else 872 else
862 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 873 m->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
863 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 874 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
864 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 875 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
865 m.insertSeparator(); 876 m->insertSeparator();
866 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 877 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
867 m.setCheckable(TRUE); 878 m->setCheckable(TRUE);
868 if (b) 879 if (b)
869 m.setItemChecked(m.idAt(0),TRUE); 880 m->setItemChecked(m->idAt(0),TRUE);
870 else 881 else
871 m.setItemChecked(m.idAt(0),FALSE); 882 m->setItemChecked(m->idAt(0),FALSE);
872 883
873 m.exec( QCursor::pos() ); 884 m->exec( QCursor::pos() );
885 delete m;
874} 886}
@@ -889,33 +901,42 @@ void OpieFtp::localDelete()
889{ 901{
890 QString f = Local_View->currentItem()->text(0); 902 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
891 if(QDir(f).exists() ) { 903 QListViewItemIterator it( Local_View );
892 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 904 for ( ; it.current(); ++it ) {
893 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 905 if ( it.current()->isSelected() ) {
894 case 0: { 906 QString f = it.current()->text(0);
895 f=currentDir.canonicalPath()+"/"+f; 907 it.current()->setSelected(FALSE);
896 QString cmd="rmdir "+f; 908
897 system( cmd.latin1()); 909// QString f = Local_View->currentItem()->text(0);
898 populateLocalView(); 910 if(QDir(f).exists() ) {
899 } 911 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
900 break; 912 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
901 case 1: 913 case 0: {
902 // exit 914 f=currentDir.canonicalPath()+"/"+f;
903 break; 915 QString cmd="rmdir "+f;
904 }; 916 system( cmd.latin1());
917 }
918 break;
919 case 1:
920 // exit
921 break;
922 };
905 923
906 } else { 924 } else {
907 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 925 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
908 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 926 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
909 case 0: { 927 case 0: {
910 f=currentDir.canonicalPath()+"/"+f; 928 f=currentDir.canonicalPath()+"/"+f;
911 QString cmd="rm "+f; 929 QString cmd="rm "+f;
912 system( cmd.latin1()); 930 system( cmd.latin1());
913 populateLocalView(); 931 }
914 } 932 break;
915 break; 933 case 1:
916 case 1: 934 // exit
917 // exit 935 break;
918 break; 936 };
919 }; 937 }
938 }
920 } 939 }
940 populateLocalView();
941
921} 942}
@@ -930,3 +951,3 @@ void OpieFtp::remoteMakDir()
930 QString tmp=currentRemoteDir+filename; 951 QString tmp=currentRemoteDir+filename;
931// QCopEnvelope ( "QPE/System", "busy()" ); 952 QCopEnvelope ( "QPE/System", "busy()" );
932 if(FtpMkdir( tmp.latin1(), conn) == 0) { 953 if(FtpMkdir( tmp.latin1(), conn) == 0) {
@@ -937,3 +958,3 @@ void OpieFtp::remoteMakDir()
937 } 958 }
938// QCopEnvelope ( "QPE/System", "notBusy()" ); 959 QCopEnvelope ( "QPE/System", "notBusy()" );
939 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 960 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
@@ -944,37 +965,44 @@ void OpieFtp::remoteDelete()
944{ 965{
945 QString f = Remote_View->currentItem()->text(0); 966 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
946// QCopEnvelope ( "QPE/System", "busy()" ); 967 QListViewItemIterator it( Remote_View );
947 if( f.right(1) =="/") { 968 for ( ; it.current(); ++it ) {
948 QString path= currentRemoteDir+f; 969 if ( it.current()->isSelected() ) {
949 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 970 QString f = it.current()->text(0);
950 ,tr("Yes"),tr("No"),0,0,1) ) { 971// QString f = Remote_View->currentItem()->text(0);
951 case 0: { 972 QCopEnvelope ( "QPE/System", "busy()" );
952 f=currentDir.canonicalPath()+"/"+f; 973 if( f.right(1) =="/") {
953 if(FtpRmdir( path.latin1(), conn) ==0) { 974 QString path= currentRemoteDir+f;
954 QString msg; 975 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
955 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 976 ,tr("Yes"),tr("No"),0,0,1) ) {
956 msg.replace(QRegExp(":"),"\n"); 977 case 0: {
957 QMessageBox::message(tr("Note"),msg); 978 f=currentDir.canonicalPath()+"/"+f;
958 } 979 if(FtpRmdir( path.latin1(), conn) ==0) {
959 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 980 QString msg;
960 } 981 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
961 break; 982 msg.replace(QRegExp(":"),"\n");
962 }; 983 QMessageBox::message(tr("Note"),msg);
963 } else { 984 }
964 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 985 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
965 ,tr("Yes"),tr("No"),0,0,1) ) { 986 }
966 case 0: { 987 break;
967 QString path= currentRemoteDir+f; 988 };
968 if(FtpDelete( path.latin1(), conn)==0) { 989 } else {
969 QString msg; 990 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
970 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 991 ,tr("Yes"),tr("No"),0,0,1) ) {
971 msg.replace(QRegExp(":"),"\n"); 992 case 0: {
972 QMessageBox::message(tr("Note"),msg); 993 QString path= currentRemoteDir+f;
973 } 994 if(FtpDelete( path.latin1(), conn)==0) {
974 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 995 QString msg;
975 } 996 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
976 break; 997 msg.replace(QRegExp(":"),"\n");
977 }; 998 QMessageBox::message(tr("Note"),msg);
999 }
1000 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1001 }
1002 break;
1003 };
1004 }
1005 }
978 } 1006 }
979// QCopEnvelope ( "QPE/System", "notBusy()" ); 1007 QCopEnvelope ( "QPE/System", "notBusy()" );
980} 1008}
@@ -991,3 +1019,3 @@ void OpieFtp::remoteRename()
991 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 1019 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
992// QCopEnvelope ( "QPE/System", "busy()" ); 1020 QCopEnvelope ( "QPE/System", "busy()" );
993 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 1021 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
@@ -998,3 +1026,3 @@ void OpieFtp::remoteRename()
998 } 1026 }
999// QCopEnvelope ( "QPE/System", "notBusy()" ); 1027 QCopEnvelope ( "QPE/System", "notBusy()" );
1000 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1028 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
@@ -1267,3 +1295,3 @@ void OpieFtp::upDir()
1267 fillRemoteCombo( (const QString &)currentRemoteDir); 1295 fillRemoteCombo( (const QString &)currentRemoteDir);
1268 populateRemoteView( ); 1296
1269 } 1297 }
@@ -1281,9 +1309,7 @@ void OpieFtp::docButtonPushed() {
1281void OpieFtp::homeButtonPushed() { 1309void OpieFtp::homeButtonPushed() {
1282 if (TabWidget->currentPageIndex() == 0) { 1310 QString current = QDir::homeDirPath();
1283 QString current = QDir::homeDirPath(); 1311 chdir( current.latin1() );
1284 chdir( current.latin1() ); 1312 currentDir.cd( current, TRUE);
1285 currentDir.cd( current, TRUE); 1313 populateLocalView();
1286 populateLocalView(); 1314 update();
1287 update();
1288 }
1289} 1315}