-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 4e14946..3d97ecb 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -169,51 +169,52 @@ OpieFtp::OpieFtp( ) Local_View->setSelectionMode(QListView::Extended); Local_View->setFocusPolicy(QWidget::ClickFocus); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); connect( Local_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( localListClicked(QListViewItem *)) ); // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), // this,SLOT( localListClicked(QListViewItem *)) ); connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); TabWidget->insertTab( tab, tr( "Local" ) ); tab_2 = new QWidget( TabWidget, "tab_2" ); tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing( 2); tabLayout_2->setMargin( 2); Remote_View = new QListView( tab_2, "Remote_View" ); Remote_View->addColumn( tr("File"),150); Remote_View->addColumn( tr("Date"),-1); - Remote_View->setColumnAlignment(1,QListView::AlignRight); +// Remote_View->setColumnAlignment(1,QListView::AlignRight); Remote_View->addColumn( tr("Size"),-1); Remote_View->setColumnAlignment(2,QListView::AlignRight); + Remote_View->setColumnAlignment(3,QListView::AlignCenter); Remote_View->addColumn( tr("Dir"),-1); Remote_View->setColumnAlignment(4,QListView::AlignRight); Remote_View->setAllColumnsShowFocus(TRUE); Remote_View->setMultiSelection( FALSE); Remote_View->setSelectionMode(QListView::Extended); Remote_View->setFocusPolicy(QWidget::ClickFocus); QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); connect( Remote_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( remoteListClicked(QListViewItem *)) ); connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); tabLayout_2->addWidget( Remote_View, 0, 0 ); TabWidget->insertTab( tab_2, tr( "Remote" ) ); tab_3 = new QWidget( TabWidget, "tab_3" ); tabLayout_3 = new QGridLayout( tab_3 ); tabLayout_3->setSpacing( 2); tabLayout_3->setMargin( 2); @@ -700,78 +701,80 @@ void OpieFtp::populateLocalView() pm.setMask( pm.createHeuristicMask( FALSE ) ); item->setPixmap( 0, pm); } } isDir=FALSE; ++it; } Local_View->setSorting( 3,FALSE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); fillCombo( (const QString &)currentDir); } bool OpieFtp::populateRemoteView( ) { // qDebug("populate remoteview"); QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); Remote_View->clear(); QString s, File_Name; QListViewItem *itemDir=NULL, *itemFile=NULL; + QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); QString fileL, fileS, fileDate; 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.find("total",0,TRUE) == 0) + continue; + + int len, month = monthRe.match(s, 0, &len); + fileDate = s.mid(month + 1, len - 2); // minus spaces + fileL = s.right(s.length() - month - len); if(s.left(1) == "d") fileL = fileL+"/"; -// fileL = "/"+fileL+"/"; - fileS = s.mid( 30, 42-30); + fileS = s.mid(month - 8, 8); // FIXME fileS = fileS.stripWhiteSpace(); - fileDate = s.mid( 42, 55-42); - fileDate = fileDate.stripWhiteSpace(); - if(fileL.find("total",0,TRUE) == -1) { - if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { - QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); - item->setPixmap( 0, Resource::loadPixmap( "folder" )); + + if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { + QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); + item->setPixmap( 0, Resource::loadPixmap( "folder" )); // if(itemDir) - item->moveItem(itemDir); - itemDir=item; - } else { - QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); - item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); + item->moveItem(itemDir); + itemDir=item; + } else { + QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); + item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); // if(itemFile) - item->moveItem(itemDir); - item->moveItem(itemFile); - itemFile=item; - } - } + item->moveItem(itemDir); + 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) { if( 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(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); |