summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-27 05:25:47 (UTC)
committer llornkcor <llornkcor>2002-03-27 05:25:47 (UTC)
commit531e1365f5ae7ffcbfc9c9ebe92274282358025e (patch) (unidiff)
treedc597d8bc5a5a2ada4acbe695f2e48604e9b85f2
parent7d6828df281631bce0aaa2aaa229b69b9329e03c (diff)
downloadopie-531e1365f5ae7ffcbfc9c9ebe92274282358025e.zip
opie-531e1365f5ae7ffcbfc9c9ebe92274282358025e.tar.gz
opie-531e1365f5ae7ffcbfc9c9ebe92274282358025e.tar.bz2
added some icon handling code, and added combo (?), fixed some goofy thing.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp204
-rw-r--r--noncore/net/opieftp/opieftp.h11
2 files changed, 113 insertions, 102 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 37e2134..fd6b028 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -20,8 +20,9 @@
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/mimetype.h>
24 25
25#include <qstringlist.h> 26#include <qstringlist.h>
26#include <qtextstream.h> 27#include <qtextstream.h>
27#include <qpushbutton.h> 28#include <qpushbutton.h>
@@ -201,8 +202,9 @@ OpieFtp::OpieFtp( )
201 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 202 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
202 TextLabel5->setText( tr( "Remote path" ) ); 203 TextLabel5->setText( tr( "Remote path" ) );
203 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 204 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
204 205
206
205 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 207 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
206 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 208 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
207 209
208 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 210 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
@@ -224,9 +226,8 @@ OpieFtp::OpieFtp( )
224 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 226 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
225 connectServerBtn->setToggleButton(TRUE); 227 connectServerBtn->setToggleButton(TRUE);
226 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 228 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
227 229
228
229 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 230 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
230 tabLayout_3->addItem( spacer, 5, 0 ); 231 tabLayout_3->addItem( spacer, 5, 0 );
231 232
232 TabWidget->insertTab( tab_3, tr( "Config" ) ); 233 TabWidget->insertTab( tab_3, tr( "Config" ) );
@@ -239,13 +240,13 @@ OpieFtp::OpieFtp( )
239// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 240// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
240 241
241 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 242 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
242 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); 243 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 );
243 244 currentPathCombo->setEditable(TRUE);
244 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 245 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
245 246
246 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 247 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
247 this, SLOT( currentPathComboChanged()currentPathCombo( const QString & ) ) ); 248 this, SLOT( currentPathComboActivated( const QString & ) ) );
248 249
249 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 250 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
250 this,SLOT(currentPathComboChanged())); 251 this,SLOT(currentPathComboChanged()));
251 252
@@ -264,8 +265,9 @@ OpieFtp::OpieFtp( )
264// PortSpinBox->setValue( 21); 265// PortSpinBox->setValue( 21);
265// remotePath->setText( currentRemoteDir = "/home/llornkcor"); 266// remotePath->setText( currentRemoteDir = "/home/llornkcor");
266 PasswordEdit->setText( tr( "" ) ); 267 PasswordEdit->setText( tr( "" ) );
267#endif 268#endif
269
268 filterStr="*"; 270 filterStr="*";
269 b=FALSE; 271 b=FALSE;
270 populateLocalView(); 272 populateLocalView();
271 readConfig(); 273 readConfig();
@@ -325,9 +327,9 @@ void OpieFtp::newConnection()
325 327
326void OpieFtp::serverComboEdited(const QString & edit) { 328void OpieFtp::serverComboEdited(const QString & edit) {
327 if( !edit.isEmpty() ) { 329 if( !edit.isEmpty() ) {
328 currentServerConfig = -1; 330 currentServerConfig = -1;
329 qDebug("comboedited"); 331// qDebug("comboedited");
330 } 332 }
331} 333}
332 334
333void OpieFtp::connectorBtnToggled(bool On) 335void OpieFtp::connectorBtnToggled(bool On)
@@ -549,26 +551,32 @@ void OpieFtp::populateLocalView()
549 isDir=TRUE; 551 isDir=TRUE;
550// qDebug( fileL); 552// qDebug( fileL);
551 } 553 }
552 } 554 }
553 if(fileL !="./") { 555 if(fileL !="./" && fi->exists()) {
554 item= new QListViewItem( ListView,fileL,fileS , fileDate); 556 item= new QListViewItem( Local_View,fileL,fileS , fileDate);
555 QPixmap pm; 557 QPixmap pm;
556 pm= Resource::loadPixmap( "folder" );
557 558
558 if(isDir || fileL.find("/",0,TRUE) != -1) { 559 if(isDir || fileL.find("/",0,TRUE) != -1) {
559 if( !QDir( fi->filePath() ).isReadable()) 560 if( !QDir( fi->filePath() ).isReadable())
560 pm = Resource::loadPixmap( "lockedfolder" ); 561 pm = Resource::loadPixmap( "lockedfolder" );
562 else
563 pm= Resource::loadPixmap( "folder" );
561 item->setPixmap( 0,pm ); 564 item->setPixmap( 0,pm );
562 } else { 565 } else {
563 if( !fi->isReadable() ) 566 if( !fi->isReadable() )
564 pm = Resource::loadPixmap( "locked" ); 567 pm = Resource::loadPixmap( "locked" );
565 else 568 else {
566 pm = Resource::loadPixmap( "fileopen" ); 569 MimeType mt(fi->filePath());
567 item->setPixmap( 0,pm); 570 pm=mt.pixmap();
571 if(pm.isNull())
572 pm = Resource::loadPixmap( "UnknownDocument-14" );
573 item->setPixmap( 0,pm);
574 }
568 } 575 }
569 if( fileL.find("->",0,TRUE) != -1) { 576 if( fileL.find("->",0,TRUE) != -1) {
570 // overlay link image 577 // overlay link image
578 pm= Resource::loadPixmap( "folder" );
571 QPixmap lnk = Resource::loadPixmap( "symlink" ); 579 QPixmap lnk = Resource::loadPixmap( "symlink" );
572 QPainter painter( &pm ); 580 QPainter painter( &pm );
573 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 581 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
574 pm.setMask( pm.createHeuristicMask( FALSE ) ); 582 pm.setMask( pm.createHeuristicMask( FALSE ) );
@@ -639,94 +647,98 @@ bool OpieFtp::populateRemoteView( )
639} 647}
640 648
641void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 649void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
642{ 650{
643 QCopEnvelope ( "QPE/System", "busy()" ); 651 if(item) {
644 QString oldRemoteCurrentDir = currentRemoteDir; 652 QCopEnvelope ( "QPE/System", "busy()" );
645 QString strItem=selectedItem->text(0); 653 QString oldRemoteCurrentDir = currentRemoteDir;
646 strItem=strItem.simplifyWhiteSpace(); 654 QString strItem=selectedItem->text(0);
647 if(strItem == "../") { // the user wants to go ^ 655 strItem=strItem.simplifyWhiteSpace();
648 if( FtpCDUp( conn) == 0) { 656 if(strItem == "../") { // the user wants to go ^
649 QString msg; 657 if( FtpCDUp( conn) == 0) {
650 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 658 QString msg;
651 msg.replace(QRegExp(":"),"\n"); 659 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
652 QMessageBox::message(tr("Note"),msg); 660 msg.replace(QRegExp(":"),"\n");
653 qDebug(msg); 661 QMessageBox::message(tr("Note"),msg);
654 } 662 qDebug(msg);
655 char path[256];
656 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
657 QString msg;
658 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
659 msg.replace(QRegExp(":"),"\n");
660 QMessageBox::message(tr("Note"),msg);
661 qDebug(msg);
662 }
663 currentRemoteDir=path;
664 } else {
665 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
666 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
667 strItem = strItem.stripWhiteSpace();
668 currentRemoteDir = strItem;
669 if( !remoteChDir( (const QString &)strItem)) {
670 currentRemoteDir = oldRemoteCurrentDir;
671 strItem="";
672 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
673 } 663 }
674 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 664 char path[256];
675 qDebug("trying directory"); 665 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
676 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 666 QString msg;
677 currentRemoteDir = oldRemoteCurrentDir; 667 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
678 strItem=""; 668 msg.replace(QRegExp(":"),"\n");
679 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 669 QMessageBox::message(tr("Note"),msg);
670 qDebug(msg);
671 }
672 currentRemoteDir=path;
673 } else {
674 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
675 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
676 strItem = strItem.stripWhiteSpace();
677 currentRemoteDir = strItem;
678 if( !remoteChDir( (const QString &)strItem)) {
679 currentRemoteDir = oldRemoteCurrentDir;
680 strItem="";
681 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
682 }
683 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
684 qDebug("trying directory");
685 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
686 currentRemoteDir = oldRemoteCurrentDir;
687 strItem="";
688 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
680 689
690 } else {
691 currentRemoteDir = currentRemoteDir+strItem;
692 }
681 } else { 693 } else {
682 currentRemoteDir = currentRemoteDir+strItem; 694 qDebug("download "+strItem);
683 } 695 }
684 } else {
685 qDebug("download "+strItem);
686 } 696 }
697 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
698 if(currentRemoteDir.right(1) !="/")
699 currentRemoteDir +="/";
700 currentPathCombo->lineEdit()->setText( currentRemoteDir );
701 fillRemoteCombo( (const QString &)currentDir);
702 QCopEnvelope ( "QPE/System", "notBusy()" );
687 } 703 }
688 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
689 if(currentRemoteDir.right(1) !="/")
690 currentRemoteDir +="/";
691 currentPathCombo->lineEdit()->setText( currentRemoteDir );
692 fillRemoteCombo( (const QString &)currentDir);
693 QCopEnvelope ( "QPE/System", "notBusy()" );
694} 704}
695 705
696void OpieFtp::localListClicked(QListViewItem *selectedItem) 706void OpieFtp::localListClicked(QListViewItem *selectedItem)
697{ 707{
698 QString strItem=selectedItem->text(0); 708 if(item) {
699 QString strSize=selectedItem->text(1); 709 QString strItem=selectedItem->text(0);
700 strSize=strSize.stripWhiteSpace(); 710 QString strSize=selectedItem->text(1);
701 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 711 strSize=strSize.stripWhiteSpace();
702 // is symlink 712 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
703 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 713 // is symlink
704 if(QDir(strItem2).exists() ) { 714 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
705 currentDir.cd(strItem2, TRUE); 715 if(QDir(strItem2).exists() ) {
706 populateLocalView(); 716 currentDir.cd(strItem2, TRUE);
707 }
708 } else { // not a symlink
709 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
710 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
711 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
712 currentDir.cd(strItem,FALSE);
713 populateLocalView();
714 } else {
715 currentDir.cdUp();
716 populateLocalView(); 717 populateLocalView();
717 } 718 }
718 if(QDir(strItem).exists()){ 719 } else { // not a symlink
719 currentDir.cd(strItem, TRUE); 720 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
720 populateLocalView(); 721 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
721 } 722 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
722 } else { 723 currentDir.cd(strItem,FALSE);
723 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 724 populateLocalView();
724 if( QFile::exists(strItem ) ) { 725 } else {
725 qDebug("upload "+strItem); 726 currentDir.cdUp();
726 } 727 populateLocalView();
727 } //end not symlink 728 }
728 chdir(strItem.latin1()); 729 if(QDir(strItem).exists()){
730 currentDir.cd(strItem, TRUE);
731 populateLocalView();
732 }
733 } else {
734 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
735 if( QFile::exists(strItem ) ) {
736 qDebug("upload "+strItem);
737 }
738 } //end not symlink
739 chdir(strItem.latin1());
740 }
729 } 741 }
730} 742}
731 743
732void OpieFtp::doLocalCd() 744void OpieFtp::doLocalCd()
@@ -963,9 +975,9 @@ void OpieFtp::localRename()
963void OpieFtp::currentPathComboActivated(const QString & currentPath) { 975void OpieFtp::currentPathComboActivated(const QString & currentPath) {
964 if (TabWidget->currentPageIndex() == 0) { 976 if (TabWidget->currentPageIndex() == 0) {
965 chdir( currentPath.latin1() ); 977 chdir( currentPath.latin1() );
966 currentDir.cd( currentPath, TRUE); 978 currentDir.cd( currentPath, TRUE);
967 populateLocalList(); 979 populateLocalView();
968 update(); 980 update();
969 } else { 981 } else {
970// chdir( currentPath.latin1() ); 982// chdir( currentPath.latin1() );
971// currentDir.cd( currentPath, TRUE); 983// currentDir.cd( currentPath, TRUE);
@@ -976,29 +988,29 @@ void OpieFtp::currentPathComboActivated(const QString & currentPath) {
976} 988}
977 989
978void OpieFtp::fillCombo(const QString &currentPath) { 990void OpieFtp::fillCombo(const QString &currentPath) {
979 991
980 currentPathComboBox->lineEdit()->setText(currentPath); 992 currentPathCombo->lineEdit()->setText(currentPath);
981 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 993 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
982 currentPathComboBox->clear(); 994 currentPathCombo->clear();
983 localDirPathStringList.prepend(currentPath ); 995 localDirPathStringList.prepend(currentPath );
984 currentPathComboBox->insertStringList( localDirPathStringList,-1); 996 currentPathCombo->insertStringList( localDirPathStringList,-1);
985 } 997 }
986 currentPathComboBox->lineEdit()->setText(currentPath); 998 currentPathCombo->lineEdit()->setText(currentPath);
987 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 999 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
988 currentPathComboBox->clear(); 1000 currentPathCombo->clear();
989 remoteDirPathStringList.prepend(currentPath ); 1001 remoteDirPathStringList.prepend(currentPath );
990 currentPathComboBox->insertStringList( remoteDirPathStringList,-1); 1002 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
991 } 1003 }
992} 1004}
993 1005
994void OpieFtp::fillRemoteCombo(const QString &currentPath) { 1006void OpieFtp::fillRemoteCombo(const QString &currentPath) {
995 1007
996 dirPathCombo->lineEdit()->setText(currentPath); 1008 currentPathCombo->lineEdit()->setText(currentPath);
997 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1009 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
998 dirPathCombo->clear(); 1010 currentPathCombo->clear();
999 remoteDirPathStringList.prepend(currentPath ); 1011 remoteDirPathStringList.prepend(currentPath );
1000 dirPathCombo->insertStringList( remoteDirPathStringList,-1); 1012 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1001 } 1013 }
1002} 1014}
1003 1015
1004void OpieFtp::currentPathComboChanged() 1016void OpieFtp::currentPathComboChanged()
@@ -1126,9 +1138,9 @@ void OpieFtp::serverComboSelected(int index)
1126 1138
1127 temp.setNum(index+1); 1139 temp.setNum(index+1);
1128 remoteServerStr = cfg.readEntry( temp,""); 1140 remoteServerStr = cfg.readEntry( temp,"");
1129 cfg.setGroup(temp); 1141 cfg.setGroup(temp);
1130 qDebug(temp); 1142// qDebug(temp);
1131 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1143 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1132 port = remoteServerStr.right( divider - 1); 1144 port = remoteServerStr.right( divider - 1);
1133 bool ok; 1145 bool ok;
1134 int portInt = port.toInt(&ok,10); 1146 int portInt = port.toInt(&ok,10);
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 57599b7..32862c7 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -51,9 +51,9 @@ public:
51 QWidget *tab, *tab_2, *tab_3; 51 QWidget *tab, *tab_2, *tab_3;
52 QListView *Local_View, *Remote_View; 52 QListView *Local_View, *Remote_View;
53 53
54 QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; 54 QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo;
55 QLineEdit *PasswordEdit, *remotePath, *currentPathEdit; 55 QLineEdit *PasswordEdit, *remotePath;
56 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; 56 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
57 QSpinBox* PortSpinBox; 57 QSpinBox* PortSpinBox;
58 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu; 58 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu;
59 QDir currentDir; 59 QDir currentDir;
@@ -93,16 +93,15 @@ protected slots:
93 void cleanUp(); 93 void cleanUp();
94 void remoteRename(); 94 void remoteRename();
95 void localRename(); 95 void localRename();
96 void currentPathComboChanged(); 96 void currentPathComboChanged();
97 void fillCombos(); 97 void currentPathComboActivated(const QString &);
98 void fillCombo(const QString &);
99 void currentPathComboActivated(const QString &);
100 void switchToLocalTab(); 98 void switchToLocalTab();
101 void switchToRemoteTab(); 99 void switchToRemoteTab();
102 void switchToConfigTab(); 100 void switchToConfigTab();
103 void fillCombo(); 101 void fillCombos();
104 void fillRemoteCombo(); 102 void fillRemoteCombo(const QString&);
103 void fillCombo(const QString &);
105 void serverComboSelected(int); 104 void serverComboSelected(int);
106 void deleteServer(); 105 void deleteServer();
107 void connectorBtnToggled(bool); 106 void connectorBtnToggled(bool);
108protected: 107protected: