author | llornkcor <llornkcor> | 2002-03-28 02:18:16 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-28 02:18:16 (UTC) |
commit | a2cd4f6515e590ef2e818929843e2923b75beef5 (patch) (unidiff) | |
tree | 918bcd4c46acd2c63ea7fa7ad40c212e1002e457 | |
parent | d360439051f476cd847c4d8cec27a52addcd72a2 (diff) | |
download | opie-a2cd4f6515e590ef2e818929843e2923b75beef5.zip opie-a2cd4f6515e590ef2e818929843e2923b75beef5.tar.gz opie-a2cd4f6515e590ef2e818929843e2923b75beef5.tar.bz2 |
wishy-washy on single vs double click
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 907a812..efcaf84 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -12,282 +12,284 @@ | |||
12 | //#define DEVELOPERS_VERSION | 12 | //#define DEVELOPERS_VERSION |
13 | 13 | ||
14 | #include "opieftp.h" | 14 | #include "opieftp.h" |
15 | #include "ftplib.h" | 15 | #include "ftplib.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | 17 | ||
18 | #include <qpe/qpemenubar.h> | 18 | #include <qpe/qpemenubar.h> |
19 | #include <qpe/qpetoolbar.h> | 19 | #include <qpe/qpetoolbar.h> |
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 | #include <qpe/mimetype.h> |
25 | 25 | ||
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qtextstream.h> | 27 | #include <qtextstream.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qlistview.h> | 36 | #include <qlistview.h> |
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qprogressbar.h> | 39 | #include <qprogressbar.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
42 | #include <qwidget.h> | 42 | #include <qwidget.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qimage.h> | 44 | #include <qimage.h> |
45 | #include <qpixmap.h> | 45 | #include <qpixmap.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
48 | #include <qregexp.h> | 48 | #include <qregexp.h> |
49 | 49 | ||
50 | #include <unistd.h> | 50 | #include <unistd.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | 52 | ||
53 | 53 | ||
54 | QProgressBar *ProgressBar; | 54 | QProgressBar *ProgressBar; |
55 | static netbuf *conn=NULL; | 55 | static netbuf *conn=NULL; |
56 | 56 | ||
57 | static int log_progress(netbuf *ctl, int xfered, void *arg) | 57 | static int log_progress(netbuf *ctl, int xfered, void *arg) |
58 | { | 58 | { |
59 | int fsz = *(int *)arg; | 59 | int fsz = *(int *)arg; |
60 | int pct = (xfered * 100) / fsz; | 60 | int pct = (xfered * 100) / fsz; |
61 | // printf("%3d%%\r", pct); | 61 | // printf("%3d%%\r", pct); |
62 | // fflush(stdout); | 62 | // fflush(stdout); |
63 | ProgressBar->setProgress(xfered); | 63 | ProgressBar->setProgress(xfered); |
64 | qApp->processEvents(); | 64 | qApp->processEvents(); |
65 | return 1; | 65 | return 1; |
66 | } | 66 | } |
67 | 67 | ||
68 | OpieFtp::OpieFtp( ) | 68 | OpieFtp::OpieFtp( ) |
69 | : QMainWindow( ) | 69 | : QMainWindow( ) |
70 | { | 70 | { |
71 | setCaption( tr( "OpieFtp" ) ); | 71 | setCaption( tr( "OpieFtp" ) ); |
72 | 72 | ||
73 | QGridLayout *layout = new QGridLayout( this ); | 73 | QGridLayout *layout = new QGridLayout( this ); |
74 | layout->setSpacing( 2); | 74 | layout->setSpacing( 2); |
75 | layout->setMargin( 2); | 75 | layout->setMargin( 2); |
76 | 76 | ||
77 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 77 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
78 | 78 | ||
79 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 79 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
80 | connectionMenu = new QPopupMenu( this ); | 80 | connectionMenu = new QPopupMenu( this ); |
81 | localMenu = new QPopupMenu( this ); | 81 | localMenu = new QPopupMenu( this ); |
82 | remoteMenu = new QPopupMenu( this ); | 82 | remoteMenu = new QPopupMenu( this ); |
83 | tabMenu = new QPopupMenu( this ); | 83 | tabMenu = new QPopupMenu( this ); |
84 | 84 | ||
85 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); | 85 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); |
86 | 86 | ||
87 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 87 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
88 | menuBar->insertItem( tr( "Local" ), localMenu); | 88 | menuBar->insertItem( tr( "Local" ), localMenu); |
89 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 89 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
90 | menuBar->insertItem( tr( "View" ), tabMenu); | 90 | menuBar->insertItem( tr( "View" ), tabMenu); |
91 | 91 | ||
92 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 92 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
93 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 93 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
94 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 94 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
95 | 95 | ||
96 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 96 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
97 | localMenu->insertSeparator(); | 97 | localMenu->insertSeparator(); |
98 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 98 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
99 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 99 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
100 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 100 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
101 | localMenu->insertSeparator(); | 101 | localMenu->insertSeparator(); |
102 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 102 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
103 | localMenu->setCheckable(TRUE); | 103 | localMenu->setCheckable(TRUE); |
104 | 104 | ||
105 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 105 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
106 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 106 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
107 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 107 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
108 | remoteMenu->insertSeparator(); | 108 | remoteMenu->insertSeparator(); |
109 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 109 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
110 | 110 | ||
111 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 111 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
112 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 112 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
113 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 113 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
114 | tabMenu->setCheckable(TRUE); | 114 | tabMenu->setCheckable(TRUE); |
115 | 115 | ||
116 | TabWidget = new QTabWidget( this, "TabWidget" ); | 116 | TabWidget = new QTabWidget( this, "TabWidget" ); |
117 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); | 117 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); |
118 | 118 | ||
119 | TabWidget->setTabShape(QTabWidget::Triangular); | 119 | TabWidget->setTabShape(QTabWidget::Triangular); |
120 | 120 | ||
121 | tab = new QWidget( TabWidget, "tab" ); | 121 | tab = new QWidget( TabWidget, "tab" ); |
122 | tabLayout = new QGridLayout( tab ); | 122 | tabLayout = new QGridLayout( tab ); |
123 | tabLayout->setSpacing( 2); | 123 | tabLayout->setSpacing( 2); |
124 | tabLayout->setMargin( 2); | 124 | tabLayout->setMargin( 2); |
125 | 125 | ||
126 | Local_View = new QListView( tab, "Local_View" ); | 126 | Local_View = new QListView( tab, "Local_View" ); |
127 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 127 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
128 | Local_View->addColumn( tr("File"),150); | 128 | Local_View->addColumn( tr("File"),150); |
129 | Local_View->addColumn( tr("Size"),-1); | 129 | Local_View->addColumn( tr("Size"),-1); |
130 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 130 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
131 | Local_View->addColumn( tr("Date"),-1); | 131 | Local_View->addColumn( tr("Date"),-1); |
132 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 132 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
133 | Local_View->setAllColumnsShowFocus(TRUE); | 133 | Local_View->setAllColumnsShowFocus(TRUE); |
134 | Local_View->setMultiSelection( TRUE ); | 134 | Local_View->setMultiSelection( TRUE ); |
135 | 135 | ||
136 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 136 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
137 | 137 | ||
138 | tabLayout->addWidget( Local_View, 0, 0 ); | 138 | tabLayout->addWidget( Local_View, 0, 0 ); |
139 | 139 | ||
140 | connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 140 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
141 | this,SLOT( localListClicked(QListViewItem *)) ); | 141 | this,SLOT( localListClicked(QListViewItem *)) ); |
142 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | ||
143 | // this,SLOT( localListClicked(QListViewItem *)) ); | ||
142 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 144 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
143 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 145 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
144 | 146 | ||
145 | TabWidget->insertTab( tab, tr( "Local" ) ); | 147 | TabWidget->insertTab( tab, tr( "Local" ) ); |
146 | 148 | ||
147 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 149 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
148 | tabLayout_2 = new QGridLayout( tab_2 ); | 150 | tabLayout_2 = new QGridLayout( tab_2 ); |
149 | tabLayout_2->setSpacing( 2); | 151 | tabLayout_2->setSpacing( 2); |
150 | tabLayout_2->setMargin( 2); | 152 | tabLayout_2->setMargin( 2); |
151 | 153 | ||
152 | Remote_View = new QListView( tab_2, "Remote_View" ); | 154 | Remote_View = new QListView( tab_2, "Remote_View" ); |
153 | Remote_View->addColumn( tr("File"),150); | 155 | Remote_View->addColumn( tr("File"),150); |
154 | Remote_View->addColumn( tr("Size"),-1); | 156 | Remote_View->addColumn( tr("Size"),-1); |
155 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 157 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
156 | Remote_View->addColumn( tr("Date"),-1); | 158 | Remote_View->addColumn( tr("Date"),-1); |
157 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 159 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
158 | Remote_View->addColumn( tr("Dir"),-1); | 160 | Remote_View->addColumn( tr("Dir"),-1); |
159 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | 161 | Remote_View->setColumnAlignment(4,QListView::AlignRight); |
160 | Remote_View->setAllColumnsShowFocus(TRUE); | 162 | Remote_View->setAllColumnsShowFocus(TRUE); |
161 | Remote_View->setMultiSelection( TRUE ); | 163 | Remote_View->setMultiSelection( TRUE ); |
162 | 164 | ||
163 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 165 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
164 | 166 | ||
165 | connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), | 167 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
166 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 168 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
167 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 169 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
168 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 170 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
169 | 171 | ||
170 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 172 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
171 | 173 | ||
172 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 174 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
173 | 175 | ||
174 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 176 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
175 | tabLayout_3 = new QGridLayout( tab_3 ); | 177 | tabLayout_3 = new QGridLayout( tab_3 ); |
176 | tabLayout_3->setSpacing( 2); | 178 | tabLayout_3->setSpacing( 2); |
177 | tabLayout_3->setMargin( 2); | 179 | tabLayout_3->setMargin( 2); |
178 | 180 | ||
179 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 181 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
180 | TextLabel1->setText( tr( "Username" ) ); | 182 | TextLabel1->setText( tr( "Username" ) ); |
181 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 183 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
182 | 184 | ||
183 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 185 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
184 | UsernameComboBox->setEditable(TRUE); | 186 | UsernameComboBox->setEditable(TRUE); |
185 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 187 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
186 | 188 | ||
187 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 189 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
188 | TextLabel2->setText( tr( "Password" ) ); | 190 | TextLabel2->setText( tr( "Password" ) ); |
189 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 191 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
190 | 192 | ||
191 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 193 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
192 | PasswordEdit->setEchoMode(QLineEdit::Password); | 194 | PasswordEdit->setEchoMode(QLineEdit::Password); |
193 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 195 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
194 | 196 | ||
195 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 197 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
196 | TextLabel3->setText( tr( "Remote server" ) ); | 198 | TextLabel3->setText( tr( "Remote server" ) ); |
197 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 199 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
198 | 200 | ||
199 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 201 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
200 | ServerComboBox->setEditable(TRUE); | 202 | ServerComboBox->setEditable(TRUE); |
201 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 203 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
202 | 204 | ||
203 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); | 205 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); |
204 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); | 206 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); |
205 | 207 | ||
206 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 208 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
207 | TextLabel5->setText( tr( "Remote path" ) ); | 209 | TextLabel5->setText( tr( "Remote path" ) ); |
208 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 210 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
209 | 211 | ||
210 | 212 | ||
211 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 213 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
212 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 214 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
213 | 215 | ||
214 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 216 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
215 | TextLabel4->setText( tr( "Port" ) ); | 217 | TextLabel4->setText( tr( "Port" ) ); |
216 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 218 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
217 | 219 | ||
218 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 220 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
219 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 221 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
220 | PortSpinBox->setMaxValue(32786); | 222 | PortSpinBox->setMaxValue(32786); |
221 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 223 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
222 | 224 | ||
223 | QPushButton *deleteServerBtn; | 225 | QPushButton *deleteServerBtn; |
224 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); | 226 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); |
225 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); | 227 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); |
226 | 228 | ||
227 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 229 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
228 | 230 | ||
229 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 231 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
230 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); | 232 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); |
231 | connectServerBtn->setToggleButton(TRUE); | 233 | connectServerBtn->setToggleButton(TRUE); |
232 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 234 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
233 | 235 | ||
234 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 236 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
235 | tabLayout_3->addItem( spacer, 5, 0 ); | 237 | tabLayout_3->addItem( spacer, 5, 0 ); |
236 | 238 | ||
237 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 239 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
238 | 240 | ||
239 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 241 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
240 | this,SLOT(tabChanged(QWidget*))); | 242 | this,SLOT(tabChanged(QWidget*))); |
241 | 243 | ||
242 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 244 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
243 | currentDir.setPath( QDir::currentDirPath()); | 245 | currentDir.setPath( QDir::currentDirPath()); |
244 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 246 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
245 | 247 | ||
246 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 248 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
247 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); | 249 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); |
248 | currentPathCombo->setEditable(TRUE); | 250 | currentPathCombo->setEditable(TRUE); |
249 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 251 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
250 | 252 | ||
251 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 253 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
252 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 254 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
253 | 255 | ||
254 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 256 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
255 | this,SLOT(currentPathComboChanged())); | 257 | this,SLOT(currentPathComboChanged())); |
256 | 258 | ||
257 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 259 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
258 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); | 260 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); |
259 | 261 | ||
260 | // fillCombos(); | 262 | // fillCombos(); |
261 | 263 | ||
262 | #ifdef DEVELOPERS_VERSION | 264 | #ifdef DEVELOPERS_VERSION |
263 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 265 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
264 | UsernameComboBox->lineEdit()->setText("root"); | 266 | UsernameComboBox->lineEdit()->setText("root"); |
265 | PortSpinBox->setValue( 4242); | 267 | PortSpinBox->setValue( 4242); |
266 | remotePath->setText( currentRemoteDir = "/"); | 268 | remotePath->setText( currentRemoteDir = "/"); |
267 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); | 269 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); |
268 | // UsernameComboBox->lineEdit()->setText("llornkcor"); | 270 | // UsernameComboBox->lineEdit()->setText("llornkcor"); |
269 | // PortSpinBox->setValue( 21); | 271 | // PortSpinBox->setValue( 21); |
270 | // remotePath->setText( currentRemoteDir = "/home/llornkcor"); | 272 | // remotePath->setText( currentRemoteDir = "/home/llornkcor"); |
271 | PasswordEdit->setText( tr( "" ) ); | 273 | PasswordEdit->setText( tr( "" ) ); |
272 | #endif | 274 | #endif |
273 | 275 | ||
274 | filterStr="*"; | 276 | filterStr="*"; |
275 | b=FALSE; | 277 | b=FALSE; |
276 | populateLocalView(); | 278 | populateLocalView(); |
277 | readConfig(); | 279 | readConfig(); |
278 | ServerComboBox->setCurrentItem(currentServerConfig); | 280 | ServerComboBox->setCurrentItem(currentServerConfig); |
279 | TabWidget->setCurrentPage(2); | 281 | TabWidget->setCurrentPage(2); |
280 | } | 282 | } |
281 | 283 | ||
282 | OpieFtp::~OpieFtp() | 284 | OpieFtp::~OpieFtp() |
283 | { | 285 | { |
284 | } | 286 | } |
285 | 287 | ||
286 | void OpieFtp::cleanUp() | 288 | void OpieFtp::cleanUp() |
287 | { | 289 | { |
288 | if(conn) | 290 | if(conn) |
289 | FtpQuit(conn); | 291 | FtpQuit(conn); |
290 | QString sfile=QDir::homeDirPath(); | 292 | QString sfile=QDir::homeDirPath(); |
291 | if(sfile.right(1) != "/") | 293 | if(sfile.right(1) != "/") |
292 | sfile+="/._temp"; | 294 | sfile+="/._temp"; |
293 | else | 295 | else |
@@ -315,566 +317,566 @@ void OpieFtp::tabChanged(QWidget *w) | |||
315 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); | 317 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); |
316 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 318 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
317 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 319 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
318 | } | 320 | } |
319 | } | 321 | } |
320 | 322 | ||
321 | void OpieFtp::newConnection() | 323 | void OpieFtp::newConnection() |
322 | { | 324 | { |
323 | UsernameComboBox->lineEdit()->setText(""); | 325 | UsernameComboBox->lineEdit()->setText(""); |
324 | PasswordEdit->setText( "" ); | 326 | PasswordEdit->setText( "" ); |
325 | ServerComboBox->lineEdit()->setText( ""); | 327 | ServerComboBox->lineEdit()->setText( ""); |
326 | remotePath->setText( currentRemoteDir = "/"); | 328 | remotePath->setText( currentRemoteDir = "/"); |
327 | PortSpinBox->setValue( 21); | 329 | PortSpinBox->setValue( 21); |
328 | TabWidget->setCurrentPage(2); | 330 | TabWidget->setCurrentPage(2); |
329 | currentServerConfig = -1; | 331 | currentServerConfig = -1; |
330 | } | 332 | } |
331 | 333 | ||
332 | void OpieFtp::serverComboEdited(const QString & edit) { | 334 | void OpieFtp::serverComboEdited(const QString & edit) { |
333 | if( !edit.isEmpty() ) { | 335 | if( !edit.isEmpty() ) { |
334 | currentServerConfig = -1; | 336 | currentServerConfig = -1; |
335 | // qDebug("comboedited"); | 337 | // qDebug("comboedited"); |
336 | } | 338 | } |
337 | } | 339 | } |
338 | 340 | ||
339 | void OpieFtp::connectorBtnToggled(bool On) | 341 | void OpieFtp::connectorBtnToggled(bool On) |
340 | { | 342 | { |
341 | if(On) { | 343 | if(On) { |
342 | connector(); | 344 | connector(); |
343 | } else { | 345 | } else { |
344 | disConnector(); | 346 | disConnector(); |
345 | } | 347 | } |
346 | 348 | ||
347 | } | 349 | } |
348 | 350 | ||
349 | void OpieFtp::connector() | 351 | void OpieFtp::connector() |
350 | { | 352 | { |
351 | QCopEnvelope ( "QPE/System", "busy()" ); | 353 | QCopEnvelope ( "QPE/System", "busy()" ); |
352 | // qApp->processEvents(); | 354 | // qApp->processEvents(); |
353 | currentRemoteDir=remotePath->text(); | 355 | currentRemoteDir=remotePath->text(); |
354 | if(ServerComboBox->currentText().isEmpty()) { | 356 | if(ServerComboBox->currentText().isEmpty()) { |
355 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 357 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
356 | TabWidget->setCurrentPage(2); | 358 | TabWidget->setCurrentPage(2); |
357 | ServerComboBox->setFocus(); | 359 | ServerComboBox->setFocus(); |
358 | connectServerBtn->setOn(FALSE); | 360 | connectServerBtn->setOn(FALSE); |
359 | connectServerBtn->setText( tr("Connect")); | 361 | connectServerBtn->setText( tr("Connect")); |
360 | return; | 362 | return; |
361 | } | 363 | } |
362 | FtpInit(); | 364 | FtpInit(); |
363 | TabWidget->setCurrentPage(1); | 365 | TabWidget->setCurrentPage(1); |
364 | QString ftp_host = ServerComboBox->currentText(); | 366 | QString ftp_host = ServerComboBox->currentText(); |
365 | QString ftp_user = UsernameComboBox->currentText(); | 367 | QString ftp_user = UsernameComboBox->currentText(); |
366 | QString ftp_pass = PasswordEdit->text(); | 368 | QString ftp_pass = PasswordEdit->text(); |
367 | QString port=PortSpinBox->cleanText(); | 369 | QString port=PortSpinBox->cleanText(); |
368 | port.stripWhiteSpace(); | 370 | port.stripWhiteSpace(); |
369 | 371 | ||
370 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 372 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
371 | ftp_host=ftp_host.right(ftp_host.length()-6); | 373 | ftp_host=ftp_host.right(ftp_host.length()-6); |
372 | ftp_host+=":"+port; | 374 | ftp_host+=":"+port; |
373 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 375 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
374 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 376 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
375 | connectServerBtn->setOn(FALSE); | 377 | connectServerBtn->setOn(FALSE); |
376 | connectServerBtn->setText( tr("Connect")); | 378 | connectServerBtn->setText( tr("Connect")); |
377 | return ; | 379 | return ; |
378 | } | 380 | } |
379 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 381 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
380 | QString msg; | 382 | QString msg; |
381 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); | 383 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); |
382 | msg.replace(QRegExp(":"),"\n"); | 384 | msg.replace(QRegExp(":"),"\n"); |
383 | QMessageBox::message(tr("Note"),msg); | 385 | QMessageBox::message(tr("Note"),msg); |
384 | if(conn) | 386 | if(conn) |
385 | FtpQuit(conn); | 387 | FtpQuit(conn); |
386 | connectServerBtn->setOn(FALSE); | 388 | connectServerBtn->setOn(FALSE); |
387 | connectServerBtn->setText( tr("Connect")); | 389 | connectServerBtn->setText( tr("Connect")); |
388 | return ; | 390 | return ; |
389 | } | 391 | } |
390 | remoteDirList("/") ; | 392 | remoteDirList("/") ; |
391 | setCaption(ftp_host); | 393 | setCaption(ftp_host); |
392 | writeConfig(); | 394 | writeConfig(); |
393 | connectServerBtn->setText( tr("Disconnect")); | 395 | connectServerBtn->setText( tr("Disconnect")); |
394 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 396 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
395 | } | 397 | } |
396 | 398 | ||
397 | void OpieFtp::disConnector() | 399 | void OpieFtp::disConnector() |
398 | { | 400 | { |
399 | if(conn) | 401 | if(conn) |
400 | FtpQuit(conn); | 402 | FtpQuit(conn); |
401 | setCaption("OpieFtp"); | 403 | setCaption("OpieFtp"); |
402 | currentRemoteDir="/"; | 404 | currentRemoteDir="/"; |
403 | Remote_View->clear(); | 405 | Remote_View->clear(); |
404 | connectServerBtn->setText( tr("Connect")); | 406 | connectServerBtn->setText( tr("Connect")); |
405 | connectServerBtn->setOn(FALSE); | 407 | connectServerBtn->setOn(FALSE); |
406 | 408 | ||
407 | } | 409 | } |
408 | 410 | ||
409 | void OpieFtp::localUpload() | 411 | void OpieFtp::localUpload() |
410 | { | 412 | { |
411 | int fsz; | 413 | int fsz; |
412 | QCopEnvelope ( "QPE/System", "busy()" ); | 414 | QCopEnvelope ( "QPE/System", "busy()" ); |
413 | // qApp->processEvents(); | 415 | // qApp->processEvents(); |
414 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 416 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
415 | QListViewItemIterator it( Local_View ); | 417 | QListViewItemIterator it( Local_View ); |
416 | for ( ; it.current(); ++it ) { | 418 | for ( ; it.current(); ++it ) { |
417 | if ( it.current()->isSelected() ) { | 419 | if ( it.current()->isSelected() ) { |
418 | QString strItem = it.current()->text(0); | 420 | QString strItem = it.current()->text(0); |
419 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 421 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
420 | QString remoteFile= currentRemoteDir+strItem; | 422 | QString remoteFile= currentRemoteDir+strItem; |
421 | QFileInfo fi(localFile); | 423 | QFileInfo fi(localFile); |
422 | if( !fi.isDir()) { | 424 | if( !fi.isDir()) { |
423 | fsz=fi.size(); | 425 | fsz=fi.size(); |
424 | ProgressBar->setTotalSteps(fsz); | 426 | ProgressBar->setTotalSteps(fsz); |
425 | 427 | ||
426 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 428 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
427 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 429 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
428 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 430 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
429 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 431 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
430 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 432 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
431 | 433 | ||
432 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 434 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
433 | QString msg; | 435 | QString msg; |
434 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); | 436 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); |
435 | msg.replace(QRegExp(":"),"\n"); | 437 | msg.replace(QRegExp(":"),"\n"); |
436 | QMessageBox::message(tr("Note"),msg); | 438 | QMessageBox::message(tr("Note"),msg); |
437 | } | 439 | } |
438 | } else { | 440 | } else { |
439 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 441 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
440 | } | 442 | } |
441 | ProgressBar->reset(); | 443 | ProgressBar->reset(); |
442 | nullifyCallBack(); | 444 | nullifyCallBack(); |
443 | it.current()->setSelected(FALSE); | 445 | it.current()->setSelected(FALSE); |
444 | } //end currentSelected | 446 | } //end currentSelected |
445 | } | 447 | } |
446 | TabWidget->setCurrentPage(1); | 448 | TabWidget->setCurrentPage(1); |
447 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 449 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
448 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 450 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
449 | } | 451 | } |
450 | 452 | ||
451 | void OpieFtp::nullifyCallBack() | 453 | void OpieFtp::nullifyCallBack() |
452 | { | 454 | { |
453 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 455 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); |
454 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | 456 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); |
455 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | 457 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); |
456 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | 458 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); |
457 | } | 459 | } |
458 | 460 | ||
459 | void OpieFtp::remoteDownload() | 461 | void OpieFtp::remoteDownload() |
460 | { | 462 | { |
461 | // qApp->processEvents(); | 463 | // qApp->processEvents(); |
462 | int fsz; | 464 | int fsz; |
463 | QCopEnvelope ( "QPE/System", "busy()" ); | 465 | QCopEnvelope ( "QPE/System", "busy()" ); |
464 | 466 | ||
465 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 467 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
466 | QListViewItemIterator it( Remote_View ); | 468 | QListViewItemIterator it( Remote_View ); |
467 | for ( ; it.current(); ++it ) { | 469 | for ( ; it.current(); ++it ) { |
468 | if ( it.current()->isSelected() ) { | 470 | if ( it.current()->isSelected() ) { |
469 | QString strItem = it.current()->text(0); | 471 | QString strItem = it.current()->text(0); |
470 | // strItem=strItem.right(strItem.length()-1); | 472 | // strItem=strItem.right(strItem.length()-1); |
471 | QString localFile = currentDir.canonicalPath(); | 473 | QString localFile = currentDir.canonicalPath(); |
472 | if(localFile.right(1).find("/",0,TRUE) == -1) | 474 | if(localFile.right(1).find("/",0,TRUE) == -1) |
473 | localFile += "/"; | 475 | localFile += "/"; |
474 | localFile += strItem; | 476 | localFile += strItem; |
475 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 477 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
476 | QString remoteFile= currentRemoteDir+strItem; | 478 | QString remoteFile= currentRemoteDir+strItem; |
477 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 479 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
478 | fsz = 0; | 480 | fsz = 0; |
479 | QString temp; | 481 | QString temp; |
480 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 482 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
481 | 483 | ||
482 | ProgressBar->setTotalSteps(fsz); | 484 | ProgressBar->setTotalSteps(fsz); |
483 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 485 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
484 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 486 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
485 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 487 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
486 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 488 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
487 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 489 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
488 | 490 | ||
489 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 491 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
490 | QString msg; | 492 | QString msg; |
491 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 493 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
492 | msg.replace(QRegExp(":"),"\n"); | 494 | msg.replace(QRegExp(":"),"\n"); |
493 | QMessageBox::message(tr("Note"),msg); | 495 | QMessageBox::message(tr("Note"),msg); |
494 | } | 496 | } |
495 | ProgressBar->reset(); | 497 | ProgressBar->reset(); |
496 | nullifyCallBack(); | 498 | nullifyCallBack(); |
497 | it.current()->setSelected(FALSE); | 499 | it.current()->setSelected(FALSE); |
498 | } | 500 | } |
499 | } | 501 | } |
500 | TabWidget->setCurrentPage(0); | 502 | TabWidget->setCurrentPage(0); |
501 | populateLocalView(); | 503 | populateLocalView(); |
502 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 504 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
503 | } | 505 | } |
504 | 506 | ||
505 | bool OpieFtp::remoteDirList(const QString &dir) | 507 | bool OpieFtp::remoteDirList(const QString &dir) |
506 | { | 508 | { |
507 | QString tmp = QDir::homeDirPath(); | 509 | QString tmp = QDir::homeDirPath(); |
508 | if(tmp.right(1) != "/") | 510 | if(tmp.right(1) != "/") |
509 | tmp+="/._temp"; | 511 | tmp+="/._temp"; |
510 | else | 512 | else |
511 | tmp+="._temp"; | 513 | tmp+="._temp"; |
512 | // qDebug("Listing remote dir "+tmp); | 514 | // qDebug("Listing remote dir "+tmp); |
513 | QCopEnvelope ( "QPE/System", "busy()" ); | 515 | QCopEnvelope ( "QPE/System", "busy()" ); |
514 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 516 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
515 | QString msg; | 517 | QString msg; |
516 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 518 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
517 | msg.replace(QRegExp(":"),"\n"); | 519 | msg.replace(QRegExp(":"),"\n"); |
518 | QMessageBox::message(tr("Note"),msg); | 520 | QMessageBox::message(tr("Note"),msg); |
519 | return false; | 521 | return false; |
520 | } | 522 | } |
521 | populateRemoteView() ; | 523 | populateRemoteView() ; |
522 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 524 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
523 | return true; | 525 | return true; |
524 | } | 526 | } |
525 | 527 | ||
526 | bool OpieFtp::remoteChDir(const QString &dir) | 528 | bool OpieFtp::remoteChDir(const QString &dir) |
527 | { | 529 | { |
528 | QCopEnvelope ( "QPE/System", "busy()" ); | 530 | QCopEnvelope ( "QPE/System", "busy()" ); |
529 | if (!FtpChdir( dir.latin1(), conn )) { | 531 | if (!FtpChdir( dir.latin1(), conn )) { |
530 | QString msg; | 532 | QString msg; |
531 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 533 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
532 | msg.replace(QRegExp(":"),"\n"); | 534 | msg.replace(QRegExp(":"),"\n"); |
533 | QMessageBox::message(tr("Note"),msg); | 535 | QMessageBox::message(tr("Note"),msg); |
534 | qDebug(msg); | 536 | qDebug(msg); |
535 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 537 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
536 | return FALSE; | 538 | return FALSE; |
537 | } | 539 | } |
538 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 540 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
539 | return TRUE; | 541 | return TRUE; |
540 | } | 542 | } |
541 | 543 | ||
542 | void OpieFtp::populateLocalView() | 544 | void OpieFtp::populateLocalView() |
543 | { | 545 | { |
544 | Local_View->clear(); | 546 | Local_View->clear(); |
545 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 547 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
546 | currentDir.setMatchAllDirs(TRUE); | 548 | currentDir.setMatchAllDirs(TRUE); |
547 | currentDir.setNameFilter(filterStr); | 549 | currentDir.setNameFilter(filterStr); |
548 | QString fileL, fileS, fileDate; | 550 | QString fileL, fileS, fileDate; |
549 | bool isDir=FALSE; | 551 | bool isDir=FALSE; |
550 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 552 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
551 | QFileInfoListIterator it(*list); | 553 | QFileInfoListIterator it(*list); |
552 | QFileInfo *fi; | 554 | QFileInfo *fi; |
553 | while ( (fi=it.current()) ) { | 555 | while ( (fi=it.current()) ) { |
554 | if (fi->isSymLink() ){ | 556 | if (fi->isSymLink() ){ |
555 | QString symLink=fi->readLink(); | 557 | QString symLink=fi->readLink(); |
556 | // qDebug("Symlink detected "+symLink); | 558 | // qDebug("Symlink detected "+symLink); |
557 | QFileInfo sym( symLink); | 559 | QFileInfo sym( symLink); |
558 | fileS.sprintf( "%10li", sym.size() ); | 560 | fileS.sprintf( "%10li", sym.size() ); |
559 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 561 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
560 | fileDate = sym.lastModified().toString(); | 562 | fileDate = sym.lastModified().toString(); |
561 | } else { | 563 | } else { |
562 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 564 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
563 | fileS.sprintf( "%10li", fi->size() ); | 565 | fileS.sprintf( "%10li", fi->size() ); |
564 | fileL.sprintf( "%s",fi->fileName().data() ); | 566 | fileL.sprintf( "%s",fi->fileName().data() ); |
565 | fileDate= fi->lastModified().toString(); | 567 | fileDate= fi->lastModified().toString(); |
566 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 568 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
567 | fileL+="/"; | 569 | fileL+="/"; |
568 | isDir=TRUE; | 570 | isDir=TRUE; |
569 | // qDebug( fileL); | 571 | // qDebug( fileL); |
570 | } | 572 | } |
571 | } | 573 | } |
572 | if(fileL !="./" && fi->exists()) { | 574 | if(fileL !="./" && fi->exists()) { |
573 | item= new QListViewItem( Local_View,fileL,fileS , fileDate); | 575 | item= new QListViewItem( Local_View,fileL,fileS , fileDate); |
574 | QPixmap pm; | 576 | QPixmap pm; |
575 | 577 | ||
576 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 578 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
577 | if( !QDir( fi->filePath() ).isReadable()) | 579 | if( !QDir( fi->filePath() ).isReadable()) |
578 | pm = Resource::loadPixmap( "lockedfolder" ); | 580 | pm = Resource::loadPixmap( "lockedfolder" ); |
579 | else | 581 | else |
580 | pm= Resource::loadPixmap( "folder" ); | 582 | pm= Resource::loadPixmap( "folder" ); |
581 | item->setPixmap( 0,pm ); | 583 | item->setPixmap( 0,pm ); |
582 | } else { | 584 | } else { |
583 | if( !fi->isReadable() ) | 585 | if( !fi->isReadable() ) |
584 | pm = Resource::loadPixmap( "locked" ); | 586 | pm = Resource::loadPixmap( "locked" ); |
585 | else { | 587 | else { |
586 | MimeType mt(fi->filePath()); | 588 | MimeType mt(fi->filePath()); |
587 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 589 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
588 | if(pm.isNull()) | 590 | if(pm.isNull()) |
589 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 591 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
590 | item->setPixmap( 0,pm); | 592 | item->setPixmap( 0,pm); |
591 | } | 593 | } |
592 | } | 594 | } |
593 | if( fileL.find("->",0,TRUE) != -1) { | 595 | if( fileL.find("->",0,TRUE) != -1) { |
594 | // overlay link image | 596 | // overlay link image |
595 | pm= Resource::loadPixmap( "folder" ); | 597 | pm= Resource::loadPixmap( "folder" ); |
596 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 598 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
597 | QPainter painter( &pm ); | 599 | QPainter painter( &pm ); |
598 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 600 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
599 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 601 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
600 | item->setPixmap( 0, pm); | 602 | item->setPixmap( 0, pm); |
601 | } | 603 | } |
602 | } | 604 | } |
603 | isDir=FALSE; | 605 | isDir=FALSE; |
604 | ++it; | 606 | ++it; |
605 | } | 607 | } |
606 | Local_View->setSorting( 3,FALSE); | 608 | Local_View->setSorting( 3,FALSE); |
607 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 609 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
608 | fillCombo( (const QString &)currentDir); | 610 | fillCombo( (const QString &)currentDir); |
609 | } | 611 | } |
610 | 612 | ||
611 | bool OpieFtp::populateRemoteView( ) | 613 | bool OpieFtp::populateRemoteView( ) |
612 | { | 614 | { |
613 | // qDebug("populate remoteview"); | 615 | // qDebug("populate remoteview"); |
614 | QString sfile=QDir::homeDirPath(); | 616 | QString sfile=QDir::homeDirPath(); |
615 | if(sfile.right(1) != "/") | 617 | if(sfile.right(1) != "/") |
616 | sfile+="/._temp"; | 618 | sfile+="/._temp"; |
617 | else | 619 | else |
618 | sfile+="._temp"; | 620 | sfile+="._temp"; |
619 | QFile file( sfile); | 621 | QFile file( sfile); |
620 | Remote_View->clear(); | 622 | Remote_View->clear(); |
621 | QString s, File_Name; | 623 | QString s, File_Name; |
622 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 624 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
623 | QString fileL, fileS, fileDate; | 625 | QString fileL, fileS, fileDate; |
624 | if ( file.open(IO_ReadOnly)) { | 626 | if ( file.open(IO_ReadOnly)) { |
625 | QTextStream t( &file ); // use a text stream | 627 | QTextStream t( &file ); // use a text stream |
626 | while ( !t.eof()) { | 628 | while ( !t.eof()) { |
627 | s = t.readLine(); | 629 | s = t.readLine(); |
628 | fileL = s.right(s.length()-55); | 630 | fileL = s.right(s.length()-55); |
629 | fileL = fileL.stripWhiteSpace(); | 631 | fileL = fileL.stripWhiteSpace(); |
630 | if(s.left(1) == "d") | 632 | if(s.left(1) == "d") |
631 | fileL = fileL+"/"; | 633 | fileL = fileL+"/"; |
632 | // fileL = "/"+fileL+"/"; | 634 | // fileL = "/"+fileL+"/"; |
633 | fileS = s.mid( 30, 42-30); | 635 | fileS = s.mid( 30, 42-30); |
634 | fileS = fileS.stripWhiteSpace(); | 636 | fileS = fileS.stripWhiteSpace(); |
635 | fileDate = s.mid( 42, 55-42); | 637 | fileDate = s.mid( 42, 55-42); |
636 | fileDate = fileDate.stripWhiteSpace(); | 638 | fileDate = fileDate.stripWhiteSpace(); |
637 | if(fileL.find("total",0,TRUE) == -1) { | 639 | if(fileL.find("total",0,TRUE) == -1) { |
638 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 640 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
639 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); | 641 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); |
640 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 642 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
641 | // if(itemDir) | 643 | // if(itemDir) |
642 | item->moveItem(itemDir); | 644 | item->moveItem(itemDir); |
643 | itemDir=item; | 645 | itemDir=item; |
644 | } else { | 646 | } else { |
645 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); | 647 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); |
646 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 648 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
647 | // if(itemFile) | 649 | // if(itemFile) |
648 | item->moveItem(itemDir); | 650 | item->moveItem(itemDir); |
649 | item->moveItem(itemFile); | 651 | item->moveItem(itemFile); |
650 | itemFile=item; | 652 | itemFile=item; |
651 | } | 653 | } |
652 | } | 654 | } |
653 | } | 655 | } |
654 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 656 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
655 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 657 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
656 | file.close(); | 658 | file.close(); |
657 | if( file.exists()) | 659 | if( file.exists()) |
658 | file. remove(); | 660 | file. remove(); |
659 | } else | 661 | } else |
660 | qDebug("temp file not opened successfullly "+sfile); | 662 | qDebug("temp file not opened successfullly "+sfile); |
661 | Remote_View->setSorting( 4,TRUE); | 663 | Remote_View->setSorting( 4,TRUE); |
662 | return true; | 664 | return true; |
663 | } | 665 | } |
664 | 666 | ||
665 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 667 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
666 | { | 668 | { |
667 | if(item) { | 669 | if(item) { |
668 | QCopEnvelope ( "QPE/System", "busy()" ); | 670 | QCopEnvelope ( "QPE/System", "busy()" ); |
669 | QString oldRemoteCurrentDir = currentRemoteDir; | 671 | QString oldRemoteCurrentDir = currentRemoteDir; |
670 | QString strItem=selectedItem->text(0); | 672 | QString strItem=selectedItem->text(0); |
671 | strItem=strItem.simplifyWhiteSpace(); | 673 | strItem=strItem.simplifyWhiteSpace(); |
672 | if(strItem == "../") { // the user wants to go ^ | 674 | if(strItem == "../") { // the user wants to go ^ |
673 | if( FtpCDUp( conn) == 0) { | 675 | if( FtpCDUp( conn) == 0) { |
674 | QString msg; | 676 | QString msg; |
675 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 677 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
676 | msg.replace(QRegExp(":"),"\n"); | 678 | msg.replace(QRegExp(":"),"\n"); |
677 | QMessageBox::message(tr("Note"),msg); | 679 | QMessageBox::message(tr("Note"),msg); |
678 | qDebug(msg); | 680 | qDebug(msg); |
679 | } | 681 | } |
680 | char path[256]; | 682 | char path[256]; |
681 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 683 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
682 | QString msg; | 684 | QString msg; |
683 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 685 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
684 | msg.replace(QRegExp(":"),"\n"); | 686 | msg.replace(QRegExp(":"),"\n"); |
685 | QMessageBox::message(tr("Note"),msg); | 687 | QMessageBox::message(tr("Note"),msg); |
686 | qDebug(msg); | 688 | qDebug(msg); |
687 | } | 689 | } |
688 | currentRemoteDir=path; | 690 | currentRemoteDir=path; |
689 | } else { | 691 | } else { |
690 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 692 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
691 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 693 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
692 | strItem = strItem.stripWhiteSpace(); | 694 | strItem = strItem.stripWhiteSpace(); |
693 | currentRemoteDir = strItem; | 695 | currentRemoteDir = strItem; |
694 | if( !remoteChDir( (const QString &)strItem)) { | 696 | if( !remoteChDir( (const QString &)strItem)) { |
695 | currentRemoteDir = oldRemoteCurrentDir; | 697 | currentRemoteDir = oldRemoteCurrentDir; |
696 | strItem=""; | 698 | strItem=""; |
697 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 699 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
698 | } | 700 | } |
699 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 701 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
700 | qDebug("trying directory"); | 702 | qDebug("trying directory"); |
701 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 703 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
702 | currentRemoteDir = oldRemoteCurrentDir; | 704 | currentRemoteDir = oldRemoteCurrentDir; |
703 | strItem=""; | 705 | strItem=""; |
704 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 706 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
705 | 707 | ||
706 | } else { | 708 | } else { |
707 | currentRemoteDir = currentRemoteDir+strItem; | 709 | currentRemoteDir = currentRemoteDir+strItem; |
708 | } | 710 | } |
709 | } else { | 711 | } else { |
710 | qDebug("download "+strItem); | 712 | qDebug("download "+strItem); |
711 | } | 713 | } |
712 | } | 714 | } |
713 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 715 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
714 | if(currentRemoteDir.right(1) !="/") | 716 | if(currentRemoteDir.right(1) !="/") |
715 | currentRemoteDir +="/"; | 717 | currentRemoteDir +="/"; |
716 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 718 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
717 | fillRemoteCombo( (const QString &)currentDir); | 719 | fillRemoteCombo( (const QString &)currentDir); |
718 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 720 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
719 | } | 721 | } |
720 | } | 722 | } |
721 | 723 | ||
722 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 724 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
723 | { | 725 | { |
724 | if(item) { | 726 | if(item) { |
725 | QString strItem=selectedItem->text(0); | 727 | QString strItem=selectedItem->text(0); |
726 | QString strSize=selectedItem->text(1); | 728 | QString strSize=selectedItem->text(1); |
727 | strSize=strSize.stripWhiteSpace(); | 729 | strSize=strSize.stripWhiteSpace(); |
728 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 730 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
729 | // is symlink | 731 | // is symlink |
730 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 732 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
731 | if(QDir(strItem2).exists() ) { | 733 | if(QDir(strItem2).exists() ) { |
732 | currentDir.cd(strItem2, TRUE); | 734 | currentDir.cd(strItem2, TRUE); |
733 | populateLocalView(); | 735 | populateLocalView(); |
734 | } | 736 | } |
735 | } else { // not a symlink | 737 | } else { // not a symlink |
736 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 738 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
737 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 739 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
738 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 740 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
739 | currentDir.cd(strItem,FALSE); | 741 | currentDir.cd(strItem,FALSE); |
740 | populateLocalView(); | 742 | populateLocalView(); |
741 | } else { | 743 | } else { |
742 | currentDir.cdUp(); | 744 | currentDir.cdUp(); |
743 | populateLocalView(); | 745 | populateLocalView(); |
744 | } | 746 | } |
745 | if(QDir(strItem).exists()){ | 747 | if(QDir(strItem).exists()){ |
746 | currentDir.cd(strItem, TRUE); | 748 | currentDir.cd(strItem, TRUE); |
747 | populateLocalView(); | 749 | populateLocalView(); |
748 | } | 750 | } |
749 | } else { | 751 | } else { |
750 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 752 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
751 | if( QFile::exists(strItem ) ) { | 753 | if( QFile::exists(strItem ) ) { |
752 | qDebug("upload "+strItem); | 754 | // qDebug("upload "+strItem); |
753 | } | 755 | } |
754 | } //end not symlink | 756 | } //end not symlink |
755 | chdir(strItem.latin1()); | 757 | chdir(strItem.latin1()); |
756 | } | 758 | } |
757 | } | 759 | } |
758 | } | 760 | } |
759 | 761 | ||
760 | void OpieFtp::doLocalCd() | 762 | void OpieFtp::doLocalCd() |
761 | { | 763 | { |
762 | localListClicked( Local_View->currentItem()); | 764 | localListClicked( Local_View->currentItem()); |
763 | } | 765 | } |
764 | 766 | ||
765 | void OpieFtp:: doRemoteCd() | 767 | void OpieFtp:: doRemoteCd() |
766 | { | 768 | { |
767 | remoteListClicked( Remote_View->currentItem()); | 769 | remoteListClicked( Remote_View->currentItem()); |
768 | 770 | ||
769 | } | 771 | } |
770 | 772 | ||
771 | void OpieFtp::showHidden() | 773 | void OpieFtp::showHidden() |
772 | { | 774 | { |
773 | if (!b) { | 775 | if (!b) { |
774 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 776 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
775 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 777 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
776 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 778 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
777 | b=TRUE; | 779 | b=TRUE; |
778 | 780 | ||
779 | } else { | 781 | } else { |
780 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 782 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
781 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 783 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
782 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 784 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
783 | b=FALSE; | 785 | b=FALSE; |
784 | } | 786 | } |
785 | populateLocalView(); | 787 | populateLocalView(); |
786 | } | 788 | } |
787 | 789 | ||
788 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 790 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
789 | { | 791 | { |
790 | switch (mouse) { | 792 | switch (mouse) { |
791 | case 1: | 793 | case 1: |
792 | break; | 794 | break; |
793 | case 2: | 795 | case 2: |
794 | showLocalMenu(item); | 796 | showLocalMenu(item); |
795 | break; | 797 | break; |
796 | }; | 798 | }; |
797 | } | 799 | } |
798 | 800 | ||
799 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 801 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
800 | { | 802 | { |
801 | switch (mouse) { | 803 | switch (mouse) { |
802 | case 1: | 804 | case 1: |
803 | break; | 805 | break; |
804 | case 2: | 806 | case 2: |
805 | showRemoteMenu(item); | 807 | showRemoteMenu(item); |
806 | break; | 808 | break; |
807 | }; | 809 | }; |
808 | } | 810 | } |
809 | 811 | ||
810 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 812 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
811 | { | 813 | { |
812 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 814 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
813 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) | 815 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) |
814 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 816 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
815 | else | 817 | else |
816 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 818 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
817 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 819 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
818 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 820 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
819 | m.insertSeparator(); | 821 | m.insertSeparator(); |
820 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 822 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
821 | m.exec( QCursor::pos() ); | 823 | m.exec( QCursor::pos() ); |
822 | } | 824 | } |
823 | 825 | ||
824 | void OpieFtp::showLocalMenu(QListViewItem * item) | 826 | void OpieFtp::showLocalMenu(QListViewItem * item) |
825 | { | 827 | { |
826 | QPopupMenu m; | 828 | QPopupMenu m; |
827 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 829 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
828 | m.insertSeparator(); | 830 | m.insertSeparator(); |
829 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 831 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
830 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 832 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
831 | else | 833 | else |
832 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 834 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
833 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 835 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
834 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 836 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
835 | m.insertSeparator(); | 837 | m.insertSeparator(); |
836 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 838 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
837 | m.setCheckable(TRUE); | 839 | m.setCheckable(TRUE); |
838 | if (b) | 840 | if (b) |
839 | m.setItemChecked(m.idAt(0),TRUE); | 841 | m.setItemChecked(m.idAt(0),TRUE); |
840 | else | 842 | else |
841 | m.setItemChecked(m.idAt(0),FALSE); | 843 | m.setItemChecked(m.idAt(0),FALSE); |
842 | 844 | ||
843 | m.exec( QCursor::pos() ); | 845 | m.exec( QCursor::pos() ); |
844 | } | 846 | } |
845 | 847 | ||
846 | void OpieFtp::localMakDir() | 848 | void OpieFtp::localMakDir() |
847 | { | 849 | { |
848 | InputDialog *fileDlg; | 850 | InputDialog *fileDlg; |
849 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 851 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
850 | fileDlg->exec(); | 852 | fileDlg->exec(); |
851 | if( fileDlg->result() == 1 ) { | 853 | if( fileDlg->result() == 1 ) { |
852 | QString filename = fileDlg->LineEdit1->text(); | 854 | QString filename = fileDlg->LineEdit1->text(); |
853 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 855 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
854 | } | 856 | } |
855 | populateLocalView(); | 857 | populateLocalView(); |
856 | } | 858 | } |
857 | 859 | ||
858 | void OpieFtp::localDelete() | 860 | void OpieFtp::localDelete() |
859 | { | 861 | { |
860 | QString f = Local_View->currentItem()->text(0); | 862 | QString f = Local_View->currentItem()->text(0); |
861 | if(QDir(f).exists() ) { | 863 | if(QDir(f).exists() ) { |
862 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 864 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
863 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 865 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { |
864 | case 0: { | 866 | case 0: { |
865 | f=currentDir.canonicalPath()+"/"+f; | 867 | f=currentDir.canonicalPath()+"/"+f; |
866 | QString cmd="rmdir "+f; | 868 | QString cmd="rmdir "+f; |
867 | system( cmd.latin1()); | 869 | system( cmd.latin1()); |
868 | populateLocalView(); | 870 | populateLocalView(); |
869 | } | 871 | } |
870 | break; | 872 | break; |
871 | case 1: | 873 | case 1: |
872 | // exit | 874 | // exit |
873 | break; | 875 | break; |
874 | }; | 876 | }; |
875 | 877 | ||
876 | } else { | 878 | } else { |
877 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 879 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
878 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 880 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
879 | case 0: { | 881 | case 0: { |
880 | f=currentDir.canonicalPath()+"/"+f; | 882 | f=currentDir.canonicalPath()+"/"+f; |