summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp57
1 files changed, 48 insertions, 9 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 118275b..a3b29a1 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -42,12 +42,13 @@
#include <qlineedit.h>
#include <qregexp.h>
#include <unistd.h>
#include <stdlib.h>
+
QProgressBar *ProgressBar;
static netbuf *conn=NULL;
static int log_progress(netbuf *ctl, int xfered, void *arg)
{
int fsz = *(int *)arg;
@@ -91,13 +92,14 @@ OpieFtp::OpieFtp( )
localMenu->insertSeparator();
localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
localMenu->insertSeparator();
localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
-
+ localMenu->setCheckable(TRUE);
+
remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
remoteMenu->insertSeparator();
remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
@@ -198,14 +200,14 @@ OpieFtp::OpieFtp( )
QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
TextLabel5->setText( tr( "Remote path" ) );
tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
remotePath = new QLineEdit( "/", tab_3, "remotePath" );
remotePath->setText( currentRemoteDir = "/");
- tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
+ tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
TextLabel4 = new QLabel( tab_3, "TextLabel4" );
TextLabel4->setText( tr( "Port" ) );
tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
@@ -233,12 +235,13 @@ OpieFtp::OpieFtp( )
connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
ProgressBar = new QProgressBar( this, "ProgressBar" );
layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
filterStr="*";
+ b=FALSE;
populateLocalView();
}
OpieFtp::~OpieFtp()
{
}
@@ -326,13 +329,16 @@ void OpieFtp::nullifyCallBack()
void OpieFtp::remoteDownload()
{
int fsz;
QCopEnvelope ( "QPE/System", "busy()" );
qApp->processEvents();
QString strItem = Remote_View->currentItem()->text(0);
- QString localFile = currentDir.canonicalPath()+"/"+strItem;
+// strItem=strItem.right(strItem.length()-1);
+
+ QString localFile = currentDir.canonicalPath()+strItem;
+// QString localFile = currentDir.canonicalPath()+"/"+strItem;
QString remoteFile= currentRemoteDir+strItem;
if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
fsz = 0;
QString temp;
temp.sprintf( remoteFile+" "+" %dkb", fsz);
@@ -453,12 +459,13 @@ void OpieFtp::populateLocalView()
{
Local_View->clear();
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
currentDir.setNameFilter(filterStr);
QString fileL, fileS, fileDate;
+ bool isDir=FALSE;
const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ){
QString symLink=fi->readLink();
@@ -471,16 +478,24 @@ void OpieFtp::populateLocalView()
// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
fileS.sprintf( "%10li", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
+ isDir=TRUE;
// qDebug( fileL);
}
}
- item= new QListViewItem( Local_View,fileL,fileS, fileDate);
+ if(fileL !="./") {
+ item = new QListViewItem( Local_View,fileL,fileS, fileDate);
+ if(isDir)
+ item->setPixmap( 0, Resource::loadPixmap( "folder" ));
+ else
+ item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
+ }
+ isDir=FALSE;
++it;
}
Local_View->setSorting( 3,FALSE);
currentPathEdit->setText( currentDir.canonicalPath() );
}
@@ -492,34 +507,50 @@ bool OpieFtp::populateRemoteView( )
sfile+="/._temp";
else
sfile+="._temp";
QFile file( sfile);
Remote_View->clear();
QString s, File_Name;
+ QListViewItem *itemDir=NULL, *itemFile=NULL;
QString fileL, fileS, fileDate;
- new QListViewItem( Remote_View, "../");
if ( file.open(IO_ReadOnly)) {
QTextStream t( &file ); // use a text stream
while ( !t.eof()) {
s = t.readLine();
fileL = s.right(s.length()-55);
fileL = fileL.stripWhiteSpace();
- if(s.left(1) == "d")
+ if(s.left(1) == "d")
fileL = fileL+"/";
+// 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);
+ if(fileL.find("total",0,TRUE) == -1) {
+ QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate);
+ if(s.left(1) == "d") {
+ item->setPixmap( 0, Resource::loadPixmap( "folder" ));
+ if(itemDir)
+ item->moveItem(itemDir);
+ itemDir=item;
+ } else {
+ item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
+ if(itemFile)
+ item->moveItem(itemFile);
+ itemFile=item;
+ }
+ }
}
+ QListViewItem * item1 = new QListViewItem( Remote_View, "../");
+ item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
file.close();
if( file.exists())
file. remove();
} else
qDebug("temp file not opened successfullly "+sfile);
+ Remote_View->setSorting( 4,TRUE);
return true;
}
void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
{
@@ -623,17 +654,19 @@ void OpieFtp:: doRemoteCd()
}
void OpieFtp::showHidden()
{
if (!b) {
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
+ localMenu->setItemChecked(localMenu->idAt(0),TRUE);
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
b=TRUE;
} else {
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
+ localMenu->setItemChecked(localMenu->idAt(0),FALSE);
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
b=FALSE;
}
populateLocalView();
}
@@ -683,12 +716,18 @@ void OpieFtp::showLocalMenu(QListViewItem * item)
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.setCheckable(TRUE);
+ if (b)
+ m.setItemChecked(m.idAt(0),TRUE);
+ else
+ m.setItemChecked(m.idAt(0),FALSE);
+
m.exec( QCursor::pos() );
}
void OpieFtp::localMakDir()
{
InputDialog *fileDlg;
@@ -834,13 +873,13 @@ void OpieFtp::localRename()
populateLocalView();
}
void OpieFtp::currentPathEditChanged()
{
QString oldRemoteCurrentDir = currentRemoteDir;
- qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
+// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
if (TabWidget->currentPageIndex() == 0) {
if(QDir( currentPathEdit->text()).exists()) {
currentDir.setPath( currentPathEdit->text() );
populateLocalView();
} else {
QMessageBox::message("Note","That directory does not exist");