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