summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-16 20:37:12 (UTC)
committer llornkcor <llornkcor>2002-03-16 20:37:12 (UTC)
commitd7203a29593bd5cd21339c67fa094d67283a8525 (patch) (side-by-side diff)
tree50c2112d7b9127fb0a5754d09a7f089fb3b63522
parent1d20ca78752b9da597950087438daa9ff8cb7951 (diff)
downloadopie-d7203a29593bd5cd21339c67fa094d67283a8525.zip
opie-d7203a29593bd5cd21339c67fa094d67283a8525.tar.gz
opie-d7203a29593bd5cd21339c67fa094d67283a8525.tar.bz2
made opieftp resizable
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp105
-rw-r--r--noncore/net/opieftp/opieftp.h10
2 files changed, 89 insertions, 26 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index ed7f4bb..042ed59 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -17,293 +17,335 @@
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include <qtextstream.h>
#include <qtoolbutton.h>
#include <qdatetime.h>
#include <qdir.h>
#include <qfile.h>
#include <qstring.h>
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qlistview.h>
#include <qmainwindow.h>
#include <qlabel.h>
#include <qprogressbar.h>
#include <qspinbox.h>
#include <qtabwidget.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qmessagebox.h>
#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;
int pct = (xfered * 100) / fsz;
// printf("%3d%%\r", pct);
// fflush(stdout);
ProgressBar->setProgress(xfered);
qApp->processEvents();
return 1;
}
OpieFtp::OpieFtp( )
: QMainWindow( )
{
- resize( 236, 290 );
- setMaximumSize( QSize( 240, 320 ) );
setCaption( tr( "OpieFtp" ) );
+ QGridLayout *layout = new QGridLayout( this );
+ layout->setSpacing( 2);
+ layout->setMargin( 2);
+
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
QPEMenuBar *menuBar = new QPEMenuBar( this );
connectionMenu = new QPopupMenu( this );
localMenu = new QPopupMenu( this );
remoteMenu = new QPopupMenu( this );
+ tabMenu = new QPopupMenu( this );
+
+ layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 );
+
menuBar->insertItem( tr( "Connection" ), connectionMenu);
menuBar->insertItem( tr( "Local" ), localMenu);
menuBar->insertItem( tr( "Remote" ), remoteMenu);
+ menuBar->insertItem( tr( "View" ), tabMenu);
connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
+ 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() ));
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() ));
- ProgressBar = new QProgressBar( this, "ProgressBar" );
- ProgressBar->setGeometry( QRect( 5, 268, 231, 15 ) );
+ tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
+ tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
+ tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
+
+ TabWidget = new QTabWidget( this, "TabWidget" );
+ layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
- TabWidget = new QTabWidget( this, "TabWidget2" );
- TabWidget->setGeometry( QRect( 3, 25, 240, 220 ) );
TabWidget->setTabShape(QTabWidget::Triangular);
tab = new QWidget( TabWidget, "tab" );
+ tabLayout = new QGridLayout( tab );
+ tabLayout->setSpacing( 2);
+ tabLayout->setMargin( 2);
Local_View = new QListView( tab, "Local_View" );
- Local_View->setGeometry( QRect( 3, 2, 225, 195 ) );
+// Local_View->setResizePolicy( QListView::AutoOneFit );
Local_View->addColumn( "File",120);
Local_View->addColumn( "Size",-1);
Local_View->setColumnAlignment(1,QListView::AlignRight);
Local_View->addColumn( "Date",-1);
Local_View->setColumnAlignment(2,QListView::AlignRight);
Local_View->setAllColumnsShowFocus(TRUE);
QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
+ tabLayout->addWidget( Local_View, 0, 0 );
+
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->setGeometry( QRect( 3, 2, 225, 195 ) );
Remote_View->addColumn( "File",120);
Remote_View->addColumn( "Size",-1);
Remote_View->setColumnAlignment(1,QListView::AlignRight);
Remote_View->addColumn( "Date",-1);
Remote_View->setColumnAlignment(2,QListView::AlignRight);
Remote_View->setAllColumnsShowFocus(TRUE);
QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
connect( Remote_View, SIGNAL( doubleClicked( 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);
TextLabel1 = new QLabel( tab_3, "TextLabel1" );
- TextLabel1->setGeometry( QRect( 10, 10, 60, 16 ) );
TextLabel1->setText( tr( "Username" ) );
+ tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
+
UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
- UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) );
UsernameComboBox->setEditable(TRUE);
- UsernameComboBox->lineEdit()->setText("anonymous");
+// UsernameComboBox->lineEdit()->setText("anonymous");
+ UsernameComboBox->lineEdit()->setText("root");
// UsernameComboBox->lineEdit()->setText("llornkcor");
+ tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
TextLabel2 = new QLabel( tab_3, "TextLabel2" );
- TextLabel2->setGeometry( QRect( 10, 50, 65, 16 ) );
TextLabel2->setText( tr( "Password" ) );
+ tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
+
PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
- PasswordEdit->setGeometry( QRect( 10, 65, 195, 16 ) );
PasswordEdit->setEchoMode(QLineEdit::Password);
- PasswordEdit->setText( tr( "me@opieftp.org" ) );
+// PasswordEdit->setText( tr( "me@opieftp.org" ) );
+// PasswordEdit->setText( tr( "" ) );
+ tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
TextLabel3 = new QLabel( tab_3, "TextLabel3" );
- TextLabel3->setGeometry( QRect( 10, 90, 95, 16 ) );
TextLabel3->setText( tr( "Remote server" ) );
+ tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
+
ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
- ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) );
ServerComboBox->setEditable(TRUE);
ServerComboBox->lineEdit()->setText( tr( "" ) );
+ tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
+ ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
- TextLabel5->setGeometry( QRect( 10, 130, 95, 16 ) );
TextLabel5->setText( tr( "Remote path" ) );
+ tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
+
remotePath = new QLineEdit( "/", tab_3, "remotePath" );
- remotePath->setGeometry( QRect( 10, 145, 195, 16 ) );
remotePath->setText( currentRemoteDir = "/");
+ tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
TextLabel4 = new QLabel( tab_3, "TextLabel4" );
- TextLabel4->setGeometry( QRect( 10, 170, 30, 21 ) );
TextLabel4->setText( tr( "Port" ) );
+ tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
+
PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
- PortSpinBox->setGeometry( QRect( 40, 175, 75, 20 ) );
PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
PortSpinBox->setMaxValue(32786);
- PortSpinBox->setValue( 21);
+ PortSpinBox->setValue( 4242);
+// PortSpinBox->setValue( 21);
+ tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
+
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ tabLayout_3->addItem( spacer, 5, 0 );
TabWidget->insertTab( tab_3, tr( "Config" ) );
connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
this,SLOT(tabChanged(QWidget*)));
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
currentDir.setPath( QDir::currentDirPath());
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
- currentPathEdit->setGeometry( QRect( 5, 248, 220, 18 ) );
+ layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 );
+
currentPathEdit->setText( currentDir.canonicalPath());
connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
+ ProgressBar = new QProgressBar( this, "ProgressBar" );
+ layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
+
filterStr="*";
populateLocalView();
}
OpieFtp::~OpieFtp()
{
}
void OpieFtp::cleanUp()
{
if(conn)
FtpQuit(conn);
QFile f("./._temp");
if(f.exists())
f. remove();
}
void OpieFtp::tabChanged(QWidget *w)
{
if (TabWidget->currentPageIndex() == 0) {
currentPathEdit->setText( currentDir.canonicalPath());
- } else if (TabWidget->currentPageIndex() == 1) {
+ }
+ if (TabWidget->currentPageIndex() == 1) {
currentPathEdit->setText( currentRemoteDir );
}
+ if (TabWidget->currentPageIndex() == 2) {
+ }
}
void OpieFtp::localUpload()
{
int fsz;
QCopEnvelope ( "QPE/System", "busy()" );
qApp->processEvents();
QString strItem = Local_View->currentItem()->text(0);
QString localFile = currentDir.canonicalPath()+"/"+strItem;
QString remoteFile= currentRemoteDir+strItem;
QFileInfo fi(localFile);
if( !fi.isDir()) {
fsz=fi.size();
ProgressBar->setTotalSteps(fsz);
FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
QString msg;
msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
// FtpQuit(conn);
}
ProgressBar->reset();
nullifyCallBack();
} else {
QMessageBox::message("Note","Cannot upload directories");
}
TabWidget->setCurrentPage(1);
populateRemoteView();
QCopEnvelope ( "QPE/System", "notBusy()" );
}
-void OpieFtp::nullifyCallBack() {
+void OpieFtp::nullifyCallBack()
+{
FtpOptions(FTPLIB_CALLBACK, NULL, conn);
FtpOptions(FTPLIB_IDLETIME, NULL, conn);
FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
}
void OpieFtp::remoteDownload()
{
int fsz;
QCopEnvelope ( "QPE/System", "busy()" );
qApp->processEvents();
QString strItem = Remote_View->currentItem()->text(0);
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);
ProgressBar->setTotalSteps(fsz);
FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
QString msg;
msg.sprintf("Unable to download \n%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
// FtpQuit(conn);
}
ProgressBar->reset();
nullifyCallBack();
TabWidget->setCurrentPage(0);
populateLocalView();
QCopEnvelope ( "QPE/System", "notBusy()" );
}
void OpieFtp::newConnection()
{
TabWidget->setCurrentPage(2);
}
void OpieFtp::connector()
@@ -742,48 +784,63 @@ void OpieFtp::remoteRename()
}
QCopEnvelope ( "QPE/System", "notBusy()" );
}
populateRemoteView();
}
void OpieFtp::localRename()
{
QString curFile = Local_View->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,"Rename",TRUE, 0);
fileDlg->inputText = curFile;
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldname = currentDir.canonicalPath() + "/" + curFile;
QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
QMessageBox::message("Note","Could not rename");
}
populateLocalView();
}
void OpieFtp::currentPathEditChanged()
{
QString oldRemoteCurrentDir = currentRemoteDir;
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");
}
}
if (TabWidget->currentPageIndex() == 1) {
currentRemoteDir = currentPathEdit->text();
if(currentRemoteDir.right(1) !="/") {
currentRemoteDir = currentRemoteDir +"/";
currentPathEdit->setText( currentRemoteDir );
}
if( !remoteChDir( (const QString &)currentRemoteDir) ) {
currentRemoteDir = oldRemoteCurrentDir;
currentPathEdit->setText( currentRemoteDir );
}
remoteDirList( (const QString &)currentRemoteDir);
}
}
+
+void OpieFtp::switchToLocalTab()
+{
+TabWidget->setCurrentPage(0);
+}
+
+void OpieFtp::switchToRemoteTab()
+{
+TabWidget->setCurrentPage(1);
+}
+
+void OpieFtp::switchToConfigTab()
+{
+TabWidget->setCurrentPage(2);
+}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 5d1c63d..e3ff334 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -1,97 +1,103 @@
/***************************************************************************
opieftp.h
-------------------
** Created: Sat Mar 9 23:33:09 2002
copyright : (C) 2002 by ljp
email : ljp@llornkcor.com
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef OPIEFTP_H
#define OPIEFTP_H
#include <qvariant.h>
#include <qdialog.h>
#include <qmainwindow.h>
#include <qdir.h>
#include <qstring.h>
#include <qpoint.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QComboBox;
class QListView;
class QListviewItem;
class QLabel;
class QProgressBar;
class QSpinBox;
class QTabWidget;
class QWidget;
class QPEToolBar;
class QPEMenuBar;
class QPopupMenu;
class QFile;
class QListViewItem;
class QLineEdit;
class OpieFtp : public QMainWindow
{
Q_OBJECT
public:
OpieFtp( );
~OpieFtp();
QTabWidget *TabWidget;
- QWidget *tab, *tab_2, *tab_3;;
+ 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;
+ QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu;
QDir currentDir;
QString currentRemoteDir;
QString filterStr;
QListViewItem * item;
bool b;
protected slots:
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();
void remoteDelete();
bool remoteDirList(const QString &);
bool remoteChDir(const QString &);
void tabChanged(QWidget*);
void cleanUp();
void remoteRename();
void localRename();
void currentPathEditChanged();
+ void switchToLocalTab();
+ void switchToRemoteTab();
+ void switchToConfigTab();
protected:
void nullifyCallBack();
+ QGridLayout* tabLayout;
+ QGridLayout* tabLayout_2;
+ QGridLayout* tabLayout_3;
};
#endif // OPIEFTP_H