author | llornkcor <llornkcor> | 2004-07-07 21:05:21 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-07-07 21:05:21 (UTC) |
commit | 8ff360bd5e136aba5a9c1b340040ecaf0fc6e0d4 (patch) (unidiff) | |
tree | 6fb3a67204a063e5031d1b4d98707b960ca2d806 | |
parent | 30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d (diff) | |
download | opie-8ff360bd5e136aba5a9c1b340040ecaf0fc6e0d4.zip opie-8ff360bd5e136aba5a9c1b340040ecaf0fc6e0d4.tar.gz opie-8ff360bd5e136aba5a9c1b340040ecaf0fc6e0d4.tar.bz2 |
fix combo filling with real QString instead of QDir object
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 817943b..58ffe3a 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -620,193 +620,193 @@ bool OpieFtp::remoteDirList(const QString &dir) | |||
620 | // QCopEnvelope ( "QPE/System", "busy()" ); | 620 | // QCopEnvelope ( "QPE/System", "busy()" ); |
621 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 621 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
622 | QString msg; | 622 | QString msg; |
623 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 623 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
624 | msg.replace(QRegExp(":"),"\n"); | 624 | msg.replace(QRegExp(":"),"\n"); |
625 | QMessageBox::message(tr("Note"),msg); | 625 | QMessageBox::message(tr("Note"),msg); |
626 | return false; | 626 | return false; |
627 | } | 627 | } |
628 | populateRemoteView() ; | 628 | populateRemoteView() ; |
629 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 629 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
630 | return true; | 630 | return true; |
631 | } | 631 | } |
632 | 632 | ||
633 | bool OpieFtp::remoteChDir(const QString &dir) | 633 | bool OpieFtp::remoteChDir(const QString &dir) |
634 | { | 634 | { |
635 | // QCopEnvelope ( "QPE/System", "busy()" ); | 635 | // QCopEnvelope ( "QPE/System", "busy()" ); |
636 | if (!FtpChdir( dir.latin1(), conn )) { | 636 | if (!FtpChdir( dir.latin1(), conn )) { |
637 | QString msg; | 637 | QString msg; |
638 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 638 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
639 | msg.replace(QRegExp(":"),"\n"); | 639 | msg.replace(QRegExp(":"),"\n"); |
640 | QMessageBox::message(tr("Note"),msg); | 640 | QMessageBox::message(tr("Note"),msg); |
641 | // odebug << msg << oendl; | 641 | // odebug << msg << oendl; |
642 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 642 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
643 | return FALSE; | 643 | return FALSE; |
644 | } | 644 | } |
645 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 645 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
646 | return TRUE; | 646 | return TRUE; |
647 | } | 647 | } |
648 | 648 | ||
649 | void OpieFtp::populateLocalView() | 649 | void OpieFtp::populateLocalView() |
650 | { | 650 | { |
651 | Local_View->clear(); | 651 | Local_View->clear(); |
652 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 652 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
653 | currentDir.setMatchAllDirs(TRUE); | 653 | currentDir.setMatchAllDirs(TRUE); |
654 | currentDir.setNameFilter(filterStr); | 654 | currentDir.setNameFilter(filterStr); |
655 | QString fileL, fileS, fileDate; | 655 | QString fileL, fileS, fileDate; |
656 | bool isDir=FALSE; | 656 | bool isDir=FALSE; |
657 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 657 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
658 | QFileInfoListIterator it(*list); | 658 | QFileInfoListIterator it(*list); |
659 | QFileInfo *fi; | 659 | QFileInfo *fi; |
660 | while ( (fi=it.current()) ) { | 660 | while ( (fi=it.current()) ) { |
661 | if (fi->isSymLink() ){ | 661 | if (fi->isSymLink() ){ |
662 | QString symLink=fi->readLink(); | 662 | QString symLink=fi->readLink(); |
663 | // odebug << "Symlink detected "+symLink << oendl; | 663 | // odebug << "Symlink detected "+symLink << oendl; |
664 | QFileInfo sym( symLink); | 664 | QFileInfo sym( symLink); |
665 | fileS.sprintf( "%10i", sym.size() ); | 665 | fileS.sprintf( "%10i", sym.size() ); |
666 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 666 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
667 | fileDate = sym.lastModified().toString(); | 667 | fileDate = sym.lastModified().toString(); |
668 | } else { | 668 | } else { |
669 | // odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl; | 669 | // odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl; |
670 | fileS.sprintf( "%10i", fi->size() ); | 670 | fileS.sprintf( "%10i", fi->size() ); |
671 | fileL.sprintf( "%s",fi->fileName().data() ); | 671 | fileL.sprintf( "%s",fi->fileName().data() ); |
672 | fileDate= fi->lastModified().toString(); | 672 | fileDate= fi->lastModified().toString(); |
673 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 673 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
674 | fileL+="/"; | 674 | fileL+="/"; |
675 | isDir=TRUE; | 675 | isDir=TRUE; |
676 | // odebug << fileL << oendl; | 676 | // odebug << fileL << oendl; |
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
680 | 680 | ||
681 | if(fileL !="./" && fi->exists()) { | 681 | if(fileL !="./" && fi->exists()) { |
682 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); | 682 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); |
683 | QPixmap pm; | 683 | QPixmap pm; |
684 | 684 | ||
685 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 685 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
686 | if( !QDir( fi->filePath() ).isReadable()) | 686 | if( !QDir( fi->filePath() ).isReadable()) |
687 | pm = Resource::loadPixmap( "lockedfolder" ); | 687 | pm = Resource::loadPixmap( "lockedfolder" ); |
688 | else | 688 | else |
689 | pm= Resource::loadPixmap( "folder" ); | 689 | pm= Resource::loadPixmap( "folder" ); |
690 | item->setPixmap( 0,pm ); | 690 | item->setPixmap( 0,pm ); |
691 | } else { | 691 | } else { |
692 | if( !fi->isReadable() ) | 692 | if( !fi->isReadable() ) |
693 | pm = Resource::loadPixmap( "locked" ); | 693 | pm = Resource::loadPixmap( "locked" ); |
694 | else { | 694 | else { |
695 | MimeType mt(fi->filePath()); | 695 | MimeType mt(fi->filePath()); |
696 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 696 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
697 | if(pm.isNull()) | 697 | if(pm.isNull()) |
698 | pm = unknownXpm; | 698 | pm = unknownXpm; |
699 | } | 699 | } |
700 | } | 700 | } |
701 | if( fileL.find("->",0,TRUE) != -1) { | 701 | if( fileL.find("->",0,TRUE) != -1) { |
702 | // overlay link image | 702 | // overlay link image |
703 | pm= Resource::loadPixmap( "folder" ); | 703 | pm= Resource::loadPixmap( "folder" ); |
704 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 704 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
705 | QPainter painter( &pm ); | 705 | QPainter painter( &pm ); |
706 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 706 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
707 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 707 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
708 | } | 708 | } |
709 | item->setPixmap( 0,pm); | 709 | item->setPixmap( 0,pm); |
710 | } | 710 | } |
711 | isDir=FALSE; | 711 | isDir=FALSE; |
712 | ++it; | 712 | ++it; |
713 | } | 713 | } |
714 | Local_View->setSorting( 3,FALSE); | 714 | Local_View->setSorting( 3,FALSE); |
715 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 715 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
716 | // fillCombo( (const QString &)currentDir); | 716 | fillCombo( (const QString &)currentDir.canonicalPath()); |
717 | } | 717 | } |
718 | 718 | ||
719 | bool OpieFtp::populateRemoteView( ) | 719 | bool OpieFtp::populateRemoteView( ) |
720 | { | 720 | { |
721 | // odebug << "populate remoteview" << oendl; | 721 | // odebug << "populate remoteview" << oendl; |
722 | QString sfile=QDir::homeDirPath(); | 722 | QString sfile=QDir::homeDirPath(); |
723 | if(sfile.right(1) != "/") | 723 | if(sfile.right(1) != "/") |
724 | sfile+="/._temp"; | 724 | sfile+="/._temp"; |
725 | else | 725 | else |
726 | sfile+="._temp"; | 726 | sfile+="._temp"; |
727 | QFile file( sfile); | 727 | QFile file( sfile); |
728 | Remote_View->clear(); | 728 | Remote_View->clear(); |
729 | QString s, File_Name; | 729 | QString s, File_Name; |
730 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 730 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
731 | QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); | 731 | QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); |
732 | QString fileL, fileS, fileDate; | 732 | QString fileL, fileS, fileDate; |
733 | if ( file.open(IO_ReadOnly)) { | 733 | if ( file.open(IO_ReadOnly)) { |
734 | QTextStream t( &file ); // use a text stream | 734 | QTextStream t( &file ); // use a text stream |
735 | while ( !t.eof()) { | 735 | while ( !t.eof()) { |
736 | s = t.readLine(); | 736 | s = t.readLine(); |
737 | 737 | ||
738 | if(s.find("total",0,TRUE) == 0) | 738 | if(s.find("total",0,TRUE) == 0) |
739 | continue; | 739 | continue; |
740 | 740 | ||
741 | int len, month = monthRe.match(s, 0, &len); | 741 | int len, month = monthRe.match(s, 0, &len); |
742 | fileDate = s.mid(month + 1, len - 2); // minus spaces | 742 | fileDate = s.mid(month + 1, len - 2); // minus spaces |
743 | fileL = s.right(s.length() - month - len); | 743 | fileL = s.right(s.length() - month - len); |
744 | if(s.left(1) == "d") | 744 | if(s.left(1) == "d") |
745 | fileL = fileL+"/"; | 745 | fileL = fileL+"/"; |
746 | fileS = s.mid(month - 8, 8); // FIXME | 746 | fileS = s.mid(month - 8, 8); // FIXME |
747 | fileS = fileS.stripWhiteSpace(); | 747 | fileS = fileS.stripWhiteSpace(); |
748 | 748 | ||
749 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 749 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
750 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); | 750 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); |
751 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 751 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
752 | // if(itemDir) | 752 | // if(itemDir) |
753 | item->moveItem(itemDir); | 753 | item->moveItem(itemDir); |
754 | itemDir=item; | 754 | itemDir=item; |
755 | } else { | 755 | } else { |
756 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); | 756 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); |
757 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 757 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
758 | // if(itemFile) | 758 | // if(itemFile) |
759 | item->moveItem(itemDir); | 759 | item->moveItem(itemDir); |
760 | item->moveItem(itemFile); | 760 | item->moveItem(itemFile); |
761 | itemFile=item; | 761 | itemFile=item; |
762 | } | 762 | } |
763 | } | 763 | } |
764 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 764 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
765 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 765 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
766 | file.close(); | 766 | file.close(); |
767 | if( file.exists()) | 767 | if( file.exists()) |
768 | file. remove(); | 768 | file. remove(); |
769 | } else | 769 | } else |
770 | odebug << "temp file not opened successfully "+sfile << oendl; | 770 | odebug << "temp file not opened successfully "+sfile << oendl; |
771 | Remote_View->setSorting( 4,TRUE); | 771 | Remote_View->setSorting( 4,TRUE); |
772 | return true; | 772 | return true; |
773 | } | 773 | } |
774 | 774 | ||
775 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 775 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
776 | { | 776 | { |
777 | if( selectedItem) { | 777 | if( selectedItem) { |
778 | // if(selectedItem!= NULL) { | 778 | // if(selectedItem!= NULL) { |
779 | // QCopEnvelope ( "QPE/System", "busy()" ); | 779 | // QCopEnvelope ( "QPE/System", "busy()" ); |
780 | QString oldRemoteCurrentDir = currentRemoteDir; | 780 | QString oldRemoteCurrentDir = currentRemoteDir; |
781 | QString strItem=selectedItem->text(0); | 781 | QString strItem=selectedItem->text(0); |
782 | strItem=strItem.simplifyWhiteSpace(); | 782 | strItem=strItem.simplifyWhiteSpace(); |
783 | if(strItem == "../") { // the user wants to go ^ | 783 | if(strItem == "../") { // the user wants to go ^ |
784 | if( FtpCDUp( conn) == 0) { | 784 | if( FtpCDUp( conn) == 0) { |
785 | QString msg; | 785 | QString msg; |
786 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 786 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
787 | msg.replace(QRegExp(":"),"\n"); | 787 | msg.replace(QRegExp(":"),"\n"); |
788 | QMessageBox::message(tr("Note"),msg); | 788 | QMessageBox::message(tr("Note"),msg); |
789 | // odebug << msg << oendl; | 789 | // odebug << msg << oendl; |
790 | } | 790 | } |
791 | char path[256]; | 791 | char path[256]; |
792 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 792 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
793 | QString msg; | 793 | QString msg; |
794 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 794 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
795 | msg.replace(QRegExp(":"),"\n"); | 795 | msg.replace(QRegExp(":"),"\n"); |
796 | QMessageBox::message(tr("Note"),msg); | 796 | QMessageBox::message(tr("Note"),msg); |
797 | // odebug << msg << oendl; | 797 | // odebug << msg << oendl; |
798 | } | 798 | } |
799 | currentRemoteDir=path; | 799 | currentRemoteDir=path; |
800 | } else { | 800 | } else { |
801 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 801 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
802 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 802 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
803 | strItem = strItem.stripWhiteSpace(); | 803 | strItem = strItem.stripWhiteSpace(); |
804 | currentRemoteDir = strItem; | 804 | currentRemoteDir = strItem; |
805 | if( !remoteChDir( (const QString &)strItem)) { | 805 | if( !remoteChDir( (const QString &)strItem)) { |
806 | currentRemoteDir = oldRemoteCurrentDir; | 806 | currentRemoteDir = oldRemoteCurrentDir; |
807 | strItem=""; | 807 | strItem=""; |
808 | // odebug << "RemoteCurrentDir1 "+oldRemoteCurrentDir << oendl; | 808 | // odebug << "RemoteCurrentDir1 "+oldRemoteCurrentDir << oendl; |
809 | } | 809 | } |
810 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 810 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
811 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 811 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
812 | currentRemoteDir = oldRemoteCurrentDir; | 812 | currentRemoteDir = oldRemoteCurrentDir; |
@@ -1047,193 +1047,192 @@ void OpieFtp::remoteDelete() | |||
1047 | for ( ; it.current(); ++it ) { | 1047 | for ( ; it.current(); ++it ) { |
1048 | if ( it.current()->isSelected() ) { | 1048 | if ( it.current()->isSelected() ) { |
1049 | QString f = it.current()->text(0); | 1049 | QString f = it.current()->text(0); |
1050 | // QString f = Remote_View->currentItem()->text(0); | 1050 | // QString f = Remote_View->currentItem()->text(0); |
1051 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1051 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1052 | if( f.right(1) =="/") { | 1052 | if( f.right(1) =="/") { |
1053 | QString path= currentRemoteDir+f; | 1053 | QString path= currentRemoteDir+f; |
1054 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1054 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1055 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1055 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1056 | case 0: { | 1056 | case 0: { |
1057 | f=currentDir.canonicalPath()+"/"+f; | 1057 | f=currentDir.canonicalPath()+"/"+f; |
1058 | if(FtpRmdir( path.latin1(), conn) ==0) { | 1058 | if(FtpRmdir( path.latin1(), conn) ==0) { |
1059 | QString msg; | 1059 | QString msg; |
1060 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); | 1060 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); |
1061 | msg.replace(QRegExp(":"),"\n"); | 1061 | msg.replace(QRegExp(":"),"\n"); |
1062 | QMessageBox::message(tr("Note"),msg); | 1062 | QMessageBox::message(tr("Note"),msg); |
1063 | } | 1063 | } |
1064 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1064 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1065 | } | 1065 | } |
1066 | break; | 1066 | break; |
1067 | }; | 1067 | }; |
1068 | } else { | 1068 | } else { |
1069 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1069 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1070 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1070 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1071 | case 0: { | 1071 | case 0: { |
1072 | QString path= currentRemoteDir+f; | 1072 | QString path= currentRemoteDir+f; |
1073 | if(FtpDelete( path.latin1(), conn)==0) { | 1073 | if(FtpDelete( path.latin1(), conn)==0) { |
1074 | QString msg; | 1074 | QString msg; |
1075 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 1075 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
1076 | msg.replace(QRegExp(":"),"\n"); | 1076 | msg.replace(QRegExp(":"),"\n"); |
1077 | QMessageBox::message(tr("Note"),msg); | 1077 | QMessageBox::message(tr("Note"),msg); |
1078 | } | 1078 | } |
1079 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1079 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1080 | } | 1080 | } |
1081 | break; | 1081 | break; |
1082 | }; | 1082 | }; |
1083 | } | 1083 | } |
1084 | } | 1084 | } |
1085 | } | 1085 | } |
1086 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1086 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | void OpieFtp::remoteRename() | 1089 | void OpieFtp::remoteRename() |
1090 | { | 1090 | { |
1091 | QString curFile = Remote_View->currentItem()->text(0); | 1091 | QString curFile = Remote_View->currentItem()->text(0); |
1092 | InputDialog *fileDlg; | 1092 | InputDialog *fileDlg; |
1093 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1093 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1094 | fileDlg->setTextEdit((const QString &)curFile); | 1094 | fileDlg->setTextEdit((const QString &)curFile); |
1095 | fileDlg->exec(); | 1095 | fileDlg->exec(); |
1096 | if( fileDlg->result() == 1 ) { | 1096 | if( fileDlg->result() == 1 ) { |
1097 | QString oldName = currentRemoteDir +"/"+ curFile; | 1097 | QString oldName = currentRemoteDir +"/"+ curFile; |
1098 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 1098 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
1099 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1099 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1100 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 1100 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
1101 | QString msg; | 1101 | QString msg; |
1102 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 1102 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
1103 | msg.replace(QRegExp(":"),"\n"); | 1103 | msg.replace(QRegExp(":"),"\n"); |
1104 | QMessageBox::message(tr("Note"),msg); | 1104 | QMessageBox::message(tr("Note"),msg); |
1105 | } | 1105 | } |
1106 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1106 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1107 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1107 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | void OpieFtp::localRename() | 1111 | void OpieFtp::localRename() |
1112 | { | 1112 | { |
1113 | QString curFile = Local_View->currentItem()->text(0); | 1113 | QString curFile = Local_View->currentItem()->text(0); |
1114 | InputDialog *fileDlg; | 1114 | InputDialog *fileDlg; |
1115 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1115 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1116 | fileDlg->setTextEdit((const QString &)curFile); | 1116 | fileDlg->setTextEdit((const QString &)curFile); |
1117 | fileDlg->exec(); | 1117 | fileDlg->exec(); |
1118 | if( fileDlg->result() == 1 ) { | 1118 | if( fileDlg->result() == 1 ) { |
1119 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 1119 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
1120 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 1120 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
1121 | if( rename(oldname.latin1(), newName.latin1())== -1) | 1121 | if( rename(oldname.latin1(), newName.latin1())== -1) |
1122 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1122 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1123 | } | 1123 | } |
1124 | populateLocalView(); | 1124 | populateLocalView(); |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { | 1127 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { |
1128 | if (TabWidget->currentPageIndex() == 0) { | 1128 | if (TabWidget->currentPageIndex() == 0) { |
1129 | chdir( currentPath.latin1() ); | 1129 | chdir( currentPath.latin1() ); |
1130 | currentDir.cd( currentPath, TRUE); | 1130 | currentDir.cd( currentPath, TRUE); |
1131 | populateLocalView(); | 1131 | populateLocalView(); |
1132 | update(); | 1132 | update(); |
1133 | } else { | 1133 | } else { |
1134 | // chdir( currentPath.latin1() ); | 1134 | // chdir( currentPath.latin1() ); |
1135 | // currentDir.cd( currentPath, TRUE); | 1135 | // currentDir.cd( currentPath, TRUE); |
1136 | // populateList(); | 1136 | // populateList(); |
1137 | // update(); | 1137 | // update(); |
1138 | 1138 | ||
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1142 | void OpieFtp::fillCombo(const QString ¤tPath) { |
1143 | qDebug("Fill Combo "+currentPath); | ||
1144 | currentPathCombo->lineEdit()->setText(currentPath); | 1143 | currentPathCombo->lineEdit()->setText(currentPath); |
1145 | 1144 | ||
1146 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1145 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1147 | qDebug("Clearing local"); | 1146 | qDebug("Clearing local"); |
1148 | currentPathCombo->clear(); | 1147 | currentPathCombo->clear(); |
1149 | localDirPathStringList.prepend(currentPath ); | 1148 | localDirPathStringList.prepend(currentPath ); |
1150 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1149 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1151 | } | 1150 | } |
1152 | 1151 | ||
1153 | currentPathCombo->lineEdit()->setText(currentPath); | 1152 | currentPathCombo->lineEdit()->setText(currentPath); |
1154 | 1153 | ||
1155 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1154 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1156 | qDebug("Clearing remote"); | 1155 | qDebug("Clearing remote"); |
1157 | currentPathCombo->clear(); | 1156 | currentPathCombo->clear(); |
1158 | remoteDirPathStringList.prepend(currentPath ); | 1157 | remoteDirPathStringList.prepend(currentPath ); |
1159 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1158 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1160 | } | 1159 | } |
1161 | } | 1160 | } |
1162 | 1161 | ||
1163 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1162 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
1164 | 1163 | ||
1165 | currentPathCombo->lineEdit()->setText(currentPath); | 1164 | currentPathCombo->lineEdit()->setText(currentPath); |
1166 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1165 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1167 | currentPathCombo->clear(); | 1166 | currentPathCombo->clear(); |
1168 | remoteDirPathStringList.prepend(currentPath ); | 1167 | remoteDirPathStringList.prepend(currentPath ); |
1169 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1168 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | 1171 | ||
1173 | void OpieFtp::currentPathComboChanged() | 1172 | void OpieFtp::currentPathComboChanged() |
1174 | { | 1173 | { |
1175 | QString oldRemoteCurrentDir = currentRemoteDir; | 1174 | QString oldRemoteCurrentDir = currentRemoteDir; |
1176 | // odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl; | 1175 | // odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl; |
1177 | if (TabWidget->currentPageIndex() == 0) { | 1176 | if (TabWidget->currentPageIndex() == 0) { |
1178 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1177 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1179 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1178 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1180 | populateLocalView(); | 1179 | populateLocalView(); |
1181 | } else { | 1180 | } else { |
1182 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1181 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1183 | } | 1182 | } |
1184 | } | 1183 | } |
1185 | if (TabWidget->currentPageIndex() == 1) { | 1184 | if (TabWidget->currentPageIndex() == 1) { |
1186 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1185 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1187 | if(currentRemoteDir.right(1) !="/") { | 1186 | if(currentRemoteDir.right(1) !="/") { |
1188 | currentRemoteDir = currentRemoteDir +"/"; | 1187 | currentRemoteDir = currentRemoteDir +"/"; |
1189 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1188 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1190 | } | 1189 | } |
1191 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1190 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1192 | currentRemoteDir = oldRemoteCurrentDir; | 1191 | currentRemoteDir = oldRemoteCurrentDir; |
1193 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1192 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1194 | } | 1193 | } |
1195 | 1194 | ||
1196 | remoteDirList( (const QString &)currentRemoteDir); | 1195 | remoteDirList( (const QString &)currentRemoteDir); |
1197 | } | 1196 | } |
1198 | } | 1197 | } |
1199 | 1198 | ||
1200 | void OpieFtp::switchToLocalTab() | 1199 | void OpieFtp::switchToLocalTab() |
1201 | { | 1200 | { |
1202 | TabWidget->setCurrentPage(0); | 1201 | TabWidget->setCurrentPage(0); |
1203 | } | 1202 | } |
1204 | 1203 | ||
1205 | void OpieFtp::switchToRemoteTab() | 1204 | void OpieFtp::switchToRemoteTab() |
1206 | { | 1205 | { |
1207 | TabWidget->setCurrentPage(1); | 1206 | TabWidget->setCurrentPage(1); |
1208 | } | 1207 | } |
1209 | 1208 | ||
1210 | void OpieFtp::switchToConfigTab() | 1209 | void OpieFtp::switchToConfigTab() |
1211 | { | 1210 | { |
1212 | TabWidget->setCurrentPage(2); | 1211 | TabWidget->setCurrentPage(2); |
1213 | } | 1212 | } |
1214 | 1213 | ||
1215 | void OpieFtp::readConfig() | 1214 | void OpieFtp::readConfig() |
1216 | { | 1215 | { |
1217 | fillCombos(); | 1216 | fillCombos(); |
1218 | Config cfg("opieftp"); | 1217 | Config cfg("opieftp"); |
1219 | cfg.setGroup("Server"); | 1218 | cfg.setGroup("Server"); |
1220 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1219 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1221 | 1220 | ||
1222 | // odebug << "Reading " << currentServerConfig << "" << oendl; | 1221 | // odebug << "Reading " << currentServerConfig << "" << oendl; |
1223 | serverComboSelected( currentServerConfig-1); | 1222 | serverComboSelected( currentServerConfig-1); |
1224 | 1223 | ||
1225 | } | 1224 | } |
1226 | 1225 | ||
1227 | void OpieFtp::writeConfig() | 1226 | void OpieFtp::writeConfig() |
1228 | { | 1227 | { |
1229 | odebug << "write config" << oendl; | 1228 | odebug << "write config" << oendl; |
1230 | Config cfg("opieftp"); | 1229 | Config cfg("opieftp"); |
1231 | cfg.setGroup("Server"); | 1230 | cfg.setGroup("Server"); |
1232 | 1231 | ||
1233 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1232 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1234 | 1233 | ||
1235 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1234 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1236 | 1235 | ||
1237 | if( currentServerConfig == -1) { | 1236 | if( currentServerConfig == -1) { |
1238 | 1237 | ||
1239 | for (int i = 1; i <= numberOfEntries; i++) { | 1238 | for (int i = 1; i <= numberOfEntries; i++) { |