summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp37
-rw-r--r--noncore/net/opieftp/opieftp.h6
2 files changed, 32 insertions, 11 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 523a36c..ed7f4bb 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -410,54 +410,55 @@ void OpieFtp::populateLocalView()
fileL.sprintf( "%s",fi->fileName().data() );
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
// qDebug( fileL);
}
}
item= new QListViewItem( Local_View,fileL,fileS, fileDate);
++it;
}
Local_View->setSorting( 3,FALSE);
currentPathEdit->setText( currentDir.canonicalPath() );
}
bool OpieFtp::populateRemoteView()
{
- Remote_View->clear();
+ Remote_View->clear();
QFile tmp("./._temp");
QString s, File_Name;
QString fileL, fileS, fileDate;
new QListViewItem( Remote_View, "../");
if (tmp.open(IO_ReadOnly)) {
QTextStream t( &tmp ); // use a text stream
while ( !t.eof()) {
s = t.readLine();
fileL = s.right(s.length()-55);
fileL = fileL.stripWhiteSpace();
if(s.left(1) == "d")
fileL = fileL+"/";
fileS = s.mid( 30, 42-30);
fileS = fileS.stripWhiteSpace();
fileDate = s.mid( 42, 55-42);
fileDate = fileDate.stripWhiteSpace();
if(fileL.find("total",0,TRUE) == -1)
new QListViewItem( Remote_View, fileL, fileS, fileDate);
}
tmp.close();
- }
+ } else
+ qDebug("temp file not opened successfullly");
return true;
}
void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
{
QCopEnvelope ( "QPE/System", "busy()" );
QString oldRemoteCurrentDir = currentRemoteDir;
QString strItem=selectedItem->text(0);
strItem=strItem.simplifyWhiteSpace();
if(strItem == "../") { // the user wants to go ^
if( FtpCDUp( conn) == 0) {
QString msg;
msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
qDebug(msg);
@@ -491,33 +492,33 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
populateRemoteView();
} else {
currentRemoteDir = currentRemoteDir+strItem;
}
} else {
qDebug("download "+strItem);
}
}
if(currentRemoteDir.right(1) !="/")
currentRemoteDir +="/";
currentPathEdit->setText( currentRemoteDir );
remoteDirList( (const QString &)currentRemoteDir);
QCopEnvelope ( "QPE/System", "notBusy()" );
}
- void OpieFtp::localListClicked(QListViewItem *selectedItem)
+void OpieFtp::localListClicked(QListViewItem *selectedItem)
{
QString strItem=selectedItem->text(0);
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
// is symlink
QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
if(QDir(strItem2).exists() ) {
currentDir.cd(strItem2, TRUE);
populateLocalView();
}
} else { // not a symlink
if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
currentDir.cd(strItem,FALSE);
@@ -527,84 +528,102 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
populateLocalView();
}
if(QDir(strItem).exists()){
currentDir.cd(strItem, TRUE);
populateLocalView();
}
} else {
strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
if( QFile::exists(strItem ) ) {
qDebug("upload "+strItem);
}
} //end not symlink
chdir(strItem.latin1());
}
}
+void OpieFtp::doLocalCd()
+{
+ localListClicked( Local_View->currentItem());
+}
+
+void OpieFtp:: doRemoteCd()
+{
+ remoteListClicked( Remote_View->currentItem());
+
+}
+
void OpieFtp::showHidden()
{
if (!b) {
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
b=TRUE;
} else {
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
b=FALSE;
}
populateLocalView();
}
void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
{
switch (mouse) {
case 1:
break;
- case 2:
- showLocalMenu();
+ case 2:
+ showLocalMenu(item);
break;
};
}
void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
{
switch (mouse) {
case 1:
break;
- case 2:
- showRemoteMenu();
+ case 2:
+ showRemoteMenu(item);
break;
};
}
-void OpieFtp::showRemoteMenu()
+void OpieFtp::showRemoteMenu(QListViewItem * item)
{
QPopupMenu m;// = new QPopupMenu( Local_View );
+ if(item->text(0).right(1) == "/")
+ m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
+ else
m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
m.insertSeparator();
m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
m.exec( QCursor::pos() );
}
-void OpieFtp::showLocalMenu()
+void OpieFtp::showLocalMenu(QListViewItem * item)
{
QPopupMenu m;
m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
+ m.insertSeparator();
+ if(item->text(0).right(1) == "/")
+ m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
+ else
m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
m.insertSeparator();
m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
m.exec( QCursor::pos() );
}
void OpieFtp::localMakDir()
{
InputDialog *fileDlg;
fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index e00a398..5d1c63d 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -48,34 +48,36 @@ public:
QTabWidget *TabWidget;
QWidget *tab, *tab_2, *tab_3;;
QListView *Local_View, *Remote_View;
QComboBox *UsernameComboBox, *ServerComboBox;
QLineEdit *PasswordEdit, *remotePath, *currentPathEdit;
QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
QSpinBox* PortSpinBox;
QPopupMenu *connectionMenu, *localMenu, *remoteMenu;
QDir currentDir;
QString currentRemoteDir;
QString filterStr;
QListViewItem * item;
bool b;
protected slots:
- void showLocalMenu( );
- void showRemoteMenu( );
+ void showLocalMenu( QListViewItem *);
+ void showRemoteMenu( QListViewItem *);
+ void doLocalCd();
+ void doRemoteCd();
void localUpload();
void remoteDownload();
void newConnection();
void connector();
void disConnector();
void populateLocalView();
bool populateRemoteView();
void showHidden();
void localListClicked(QListViewItem *);
void remoteListClicked(QListViewItem *);
void ListPressed( int, QListViewItem *, const QPoint&, int);
void RemoteListPressed( int, QListViewItem *, const QPoint&, int);
void localMakDir();
void localDelete();
void remoteMakDir();