summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index bef701a..f89ad30 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,1018 +1,1020 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.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#include "advancedfm.h" 12#include "advancedfm.h"
13#include "inputDialog.h" 13#include "inputDialog.h"
14#include "output.h" 14#include "output.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16 16
17#include <opie/otabwidget.h> 17#include <opie/otabwidget.h>
18 18
19#include <qpe/lnkproperties.h> 19#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qpe/ir.h> 26#include <qpe/ir.h>
27 27
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qmultilineedit.h> 29#include <qmultilineedit.h>
30 30
31#include <qstring.h> 31#include <qstring.h>
32 32
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37#include <qtabwidget.h> 37#include <qtabwidget.h>
38#include <qtoolbutton.h> 38#include <qtoolbutton.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qlineedit.h> 40#include <qlineedit.h>
41#include <qlistview.h> 41#include <qlistview.h>
42 42
43#include <stdlib.h> 43#include <stdlib.h>
44#include <unistd.h> 44#include <unistd.h>
45#include <sys/stat.h> 45#include <sys/stat.h>
46#include <dirent.h> 46#include <dirent.h>
47 47
48 48
49void AdvancedFm::doLocalCd() { 49void AdvancedFm::doLocalCd() {
50 localListClicked( Local_View->currentItem()); 50 localListClicked( Local_View->currentItem());
51} 51}
52 52
53void AdvancedFm::doRemoteCd() { 53void AdvancedFm::doRemoteCd() {
54 localListClicked( Remote_View->currentItem()); 54 localListClicked( Remote_View->currentItem());
55} 55}
56 56
57void AdvancedFm::showMenuHidden() { 57void AdvancedFm::showMenuHidden() {
58 if (b) { 58 if (b) {
59 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 59 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
60 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 60 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
61 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 61 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
62// b=FALSE; 62// b=FALSE;
63 63
64 } else { 64 } else {
65 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 65 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
66 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 66 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
67 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 67 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
68// b=TRUE; 68// b=TRUE;
69 } 69 }
70 populateLocalView(); 70 populateLocalView();
71 populateRemoteView(); 71 populateRemoteView();
72// if(TabWidget->getCurrentTab() == 0) 72// if(TabWidget->getCurrentTab() == 0)
73// showHidden(); 73// showHidden();
74// else 74// else
75// showRemoteHidden(); 75// showRemoteHidden();
76// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); 76// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
77 if(b) b = false; else b = true; 77 if(b) b = false; else b = true;
78} 78}
79 79
80void AdvancedFm::showHidden() { 80void AdvancedFm::showHidden() {
81 if (b) { 81 if (b) {
82 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 82 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
84// b=FALSE; 84// b=FALSE;
85 85
86 } else { 86 } else {
87 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 87 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
88// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 88// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
89// b=TRUE; 89// b=TRUE;
90 } 90 }
91 populateLocalView(); 91 populateLocalView();
92} 92}
93 93
94void AdvancedFm::showRemoteHidden() { 94void AdvancedFm::showRemoteHidden() {
95 if (b) { 95 if (b) {
96 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 96 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
97// b=TRUE; 97// b=TRUE;
98 98
99 } else { 99 } else {
100 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 100 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
101// b=FALSE; 101// b=FALSE;
102 } 102 }
103 populateRemoteView(); 103 populateRemoteView();
104} 104}
105 105
106void AdvancedFm::runThis() { 106void AdvancedFm::runThis() {
107 QString fs; 107 QString fs;
108 if (TabWidget->getCurrentTab() == 0) { 108 if (TabWidget->getCurrentTab() == 0) {
109 QString curFile = Local_View->currentItem()->text(0); 109 QString curFile = Local_View->currentItem()->text(0);
110 if(curFile != "../") { 110 if(curFile != "../") {
111 111
112 fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 112 fs= getFileSystemType((const QString &) currentDir.canonicalPath());
113 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 113 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
114 qDebug( fileInfo.owner()); 114 qDebug( fileInfo.owner());
115 if( (fileInfo.permission( QFileInfo::ExeUser) 115 if( (fileInfo.permission( QFileInfo::ExeUser)
116 | fileInfo.permission( QFileInfo::ExeGroup) 116 | fileInfo.permission( QFileInfo::ExeGroup)
117 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 117 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
118 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 118 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
119 QCopEnvelope e("QPE/System", "execute(QString)" ); 119 QCopEnvelope e("QPE/System", "execute(QString)" );
120 e << curFile; 120 e << curFile;
121 } else { 121 } else {
122 curFile = currentDir.canonicalPath()+"/"+curFile; 122 curFile = currentDir.canonicalPath()+"/"+curFile;
123 DocLnk nf(curFile); 123 DocLnk nf(curFile);
124 QString execStr = nf.exec(); 124 QString execStr = nf.exec();
125 qDebug( execStr); 125 qDebug( execStr);
126 if( execStr.isEmpty() ) { 126 if( execStr.isEmpty() ) {
127 } else { 127 } else {
128 nf.execute(); 128 nf.execute();
129 } 129 }
130 } 130 }
131 } 131 }
132 } else { 132 } else {
133 QString curFile = Remote_View->currentItem()->text(0); 133 QString curFile = Remote_View->currentItem()->text(0);
134 if(curFile != "../") { 134 if(curFile != "../") {
135 135
136 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 136 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
137 qDebug("Filesystemtype is "+fs); 137 qDebug("Filesystemtype is "+fs);
138 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 138 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
139 if( (fileInfo.permission( QFileInfo::ExeUser) 139 if( (fileInfo.permission( QFileInfo::ExeUser)
140 | fileInfo.permission( QFileInfo::ExeGroup) 140 | fileInfo.permission( QFileInfo::ExeGroup)
141 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 141 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
142 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 142 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
143 QCopEnvelope e("QPE/System", "execute(QString)" ); 143 QCopEnvelope e("QPE/System", "execute(QString)" );
144 e << curFile; 144 e << curFile;
145 } else { 145 } else {
146 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 146 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
147 DocLnk nf(curFile); 147 DocLnk nf(curFile);
148 QString execStr = nf.exec(); 148 QString execStr = nf.exec();
149 qDebug(execStr); 149 qDebug(execStr);
150 if( execStr.isEmpty() ) { 150 if( execStr.isEmpty() ) {
151 } else { 151 } else {
152 nf.execute(); 152 nf.execute();
153 } 153 }
154 } 154 }
155 } 155 }
156 } 156 }
157} 157}
158 158
159void AdvancedFm::runText() { 159void AdvancedFm::runText() {
160 if (TabWidget->getCurrentTab() == 0) { 160 if (TabWidget->getCurrentTab() == 0) {
161 QString curFile = Local_View->currentItem()->text(0); 161 QString curFile = Local_View->currentItem()->text(0);
162 if(curFile != "../") { 162 if(curFile != "../") {
163 curFile = currentDir.canonicalPath()+"/"+curFile; 163 curFile = currentDir.canonicalPath()+"/"+curFile;
164 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 164 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
165 e << curFile; 165 e << curFile;
166 } 166 }
167 } else { 167 } else {
168 QString curFile = Remote_View->currentItem()->text(0); 168 QString curFile = Remote_View->currentItem()->text(0);
169 if(curFile != "../") { 169 if(curFile != "../") {
170 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 170 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
171 DocLnk nf(curFile); 171 DocLnk nf(curFile);
172 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 172 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
173 e << curFile; 173 e << curFile;
174 } 174 }
175 } 175 }
176} 176}
177 177
178void AdvancedFm::localMakDir() { 178void AdvancedFm::localMakDir() {
179 InputDialog *fileDlg; 179 InputDialog *fileDlg;
180 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 180 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
181 fileDlg->exec(); 181 fileDlg->exec();
182 if( fileDlg->result() == 1 ) { 182 if( fileDlg->result() == 1 ) {
183 QString filename = fileDlg->LineEdit1->text(); 183 QString filename = fileDlg->LineEdit1->text();
184 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 184 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
185 } 185 }
186 populateLocalView(); 186 populateLocalView();
187} 187}
188 188
189void AdvancedFm::remoteMakDir() { 189void AdvancedFm::remoteMakDir() {
190 InputDialog *fileDlg; 190 InputDialog *fileDlg;
191 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 191 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
192 fileDlg->exec(); 192 fileDlg->exec();
193 if( fileDlg->result() == 1 ) { 193 if( fileDlg->result() == 1 ) {
194 QString filename = fileDlg->LineEdit1->text(); 194 QString filename = fileDlg->LineEdit1->text();
195 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); 195 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
196 } 196 }
197 populateRemoteView(); 197 populateRemoteView();
198} 198}
199 199
200void AdvancedFm::localDelete() { 200void AdvancedFm::localDelete() {
201 QStringList curFileList = getPath(); 201 QStringList curFileList = getPath();
202 bool doMsg=true; 202 bool doMsg=true;
203 int count=curFileList.count(); 203 int count=curFileList.count();
204 if( count > 0) { 204 if( count > 0) {
205 if(count > 1 ){ 205 if(count > 1 ){
206 QString msg; 206 QString msg;
207 msg=tr("Really delete\n%1 files?").arg(count); 207 msg=tr("Really delete\n%1 files?").arg(count);
208 switch ( QMessageBox::warning(this,tr("Delete"),msg 208 switch ( QMessageBox::warning(this,tr("Delete"),msg
209 ,tr("Yes"),tr("No"),0,0,1) ) { 209 ,tr("Yes"),tr("No"),0,0,1) ) {
210 case 0: 210 case 0:
211 doMsg=false; 211 doMsg=false;
212 break; 212 break;
213 case 1: 213 case 1:
214 return; 214 return;
215 break; 215 break;
216 }; 216 };
217 } 217 }
218 218
219 QString myFile; 219 QString myFile;
220 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 220 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
221 myFile = (*it); 221 myFile = (*it);
222 if( myFile.find(" -> ",0,TRUE) != -1) 222 if( myFile.find(" -> ",0,TRUE) != -1)
223 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 223 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
224 224
225 QString f = currentDir.canonicalPath(); 225 QString f = currentDir.canonicalPath();
226 if(f.right(1).find("/",0,TRUE) == -1) 226 if(f.right(1).find("/",0,TRUE) == -1)
227 f+="/"; 227 f+="/";
228 f+=myFile; 228 f+=myFile;
229 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 229 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
230 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ 230 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+
231 "\nand all it's contents ?" 231 "\nand all it's contents ?"
232 ,tr("Yes"),tr("No"),0,0,1) ) { 232 ,tr("Yes"),tr("No"),0,0,1) ) {
233 case 0: { 233 case 0: {
234 f=f.left(f.length()-1); 234 f=f.left(f.length()-1);
235 QString cmd="rm -rf "+f; 235 QString cmd="rm -rf "+f;
236 system( cmd.latin1()); 236 system( cmd.latin1());
237 populateLocalView(); 237 populateLocalView();
238 } 238 }
239 break; 239 break;
240 case 1: 240 case 1:
241 // exit 241 // exit
242 break; 242 break;
243 }; 243 };
244 244
245 } else { 245 } else {
246 if(doMsg) { 246 if(doMsg) {
247 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 247 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
248 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 248 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
249 case 1: 249 case 1:
250 return; 250 return;
251 break; 251 break;
252 }; 252 };
253 } 253 }
254 QString cmd="rm "+f; 254 QString cmd="rm "+f;
255 QFile file(f); 255 QFile file(f);
256 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 256 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
257 file.remove(); 257 file.remove();
258 // system( cmd.latin1()); 258 // system( cmd.latin1());
259 } 259 }
260 } 260 }
261 } 261 }
262 populateLocalView(); 262 populateLocalView();
263} 263}
264 264
265void AdvancedFm::remoteDelete() { 265void AdvancedFm::remoteDelete() {
266 QStringList curFileList = getPath(); 266 QStringList curFileList = getPath();
267 bool doMsg=true; 267 bool doMsg=true;
268 int count=curFileList.count(); 268 int count=curFileList.count();
269 if( count > 0) { 269 if( count > 0) {
270 if(count > 1 ){ 270 if(count > 1 ){
271 QString msg; 271 QString msg;
272 msg=tr("Really delete\n%1 files?").arg(count); 272 msg=tr("Really delete\n%1 files?").arg(count);
273 switch ( QMessageBox::warning(this,tr("Delete"),msg 273 switch ( QMessageBox::warning(this,tr("Delete"),msg
274 ,tr("Yes"),tr("No"),0,0,1) ) { 274 ,tr("Yes"),tr("No"),0,0,1) ) {
275 case 0: 275 case 0:
276 doMsg=false; 276 doMsg=false;
277 break; 277 break;
278 case 1: 278 case 1:
279 return; 279 return;
280 break; 280 break;
281 }; 281 };
282 } 282 }
283 283
284 QString myFile; 284 QString myFile;
285 285
286 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 286 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
287 myFile = (*it); 287 myFile = (*it);
288 if(myFile.find(" -> ",0,TRUE) != -1) 288 if(myFile.find(" -> ",0,TRUE) != -1)
289 myFile = myFile.left(myFile.find(" -> ",0,TRUE)); 289 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
290 QString f = currentRemoteDir.canonicalPath(); 290 QString f = currentRemoteDir.canonicalPath();
291 if(f.right(1).find("/",0,TRUE) == -1) 291 if(f.right(1).find("/",0,TRUE) == -1)
292 f+="/"; 292 f+="/";
293 f+=myFile; 293 f+=myFile;
294 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 294 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
295 switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ 295 switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+
296 "\nand all it's contents ?", 296 "\nand all it's contents ?",
297 tr("Yes"),tr("No"),0,0,1) ) { 297 tr("Yes"),tr("No"),0,0,1) ) {
298 case 0: { 298 case 0: {
299 f=f.left(f.length()-1); 299 f=f.left(f.length()-1);
300 QString cmd="rm -rf "+f; 300 QString cmd="rm -rf "+f;
301 system( cmd.latin1()); 301 system( cmd.latin1());
302 populateRemoteView(); 302 populateRemoteView();
303 } 303 }
304 break; 304 break;
305 case 1: 305 case 1:
306 // exit 306 // exit
307 break; 307 break;
308 }; 308 };
309 309
310 } else { 310 } else {
311 if(doMsg) { 311 if(doMsg) {
312 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 312 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
313 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 313 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
314 case 1: 314 case 1:
315 return; 315 return;
316 break; 316 break;
317 }; 317 };
318 } 318 }
319 QString cmd="rm "+f; 319 QString cmd="rm "+f;
320 QFile file(f); 320 QFile file(f);
321 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 321 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
322 file.remove(); 322 file.remove();
323 // system( cmd.latin1()); 323 // system( cmd.latin1());
324 } 324 }
325 } 325 }
326 } 326 }
327 populateRemoteView(); 327 populateRemoteView();
328} 328}
329 329
330void AdvancedFm::localRename() { 330void AdvancedFm::localRename() {
331 QString curFile = Local_View->currentItem()->text(0); 331 QString curFile = Local_View->currentItem()->text(0);
332 qDebug("currentItem "+curFile); 332 qDebug("currentItem "+curFile);
333 if( curFile !="../") { 333 if( curFile !="../") {
334 InputDialog *fileDlg; 334 InputDialog *fileDlg;
335 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 335 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
336 fileDlg->setInputText((const QString &)curFile); 336 fileDlg->setInputText((const QString &)curFile);
337 fileDlg->exec(); 337 fileDlg->exec();
338 if( fileDlg->result() == 1 ) { 338 if( fileDlg->result() == 1 ) {
339 QString oldname = currentDir.canonicalPath() + "/" + curFile; 339 QString oldname = currentDir.canonicalPath() + "/" + curFile;
340 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 340 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
341//+".playlist"; 341//+".playlist";
342 if( rename(oldname.latin1(), newName.latin1())== -1) 342 if( rename(oldname.latin1(), newName.latin1())== -1)
343 QMessageBox::message(tr("Note"),tr("Could not rename")); 343 QMessageBox::message(tr("Note"),tr("Could not rename"));
344 } 344 }
345 populateLocalView(); 345 populateLocalView();
346 } 346 }
347} 347}
348 348
349void AdvancedFm::remoteRename() 349void AdvancedFm::remoteRename()
350{ 350{
351 QString curFile = Remote_View->currentItem()->text(0); 351 QString curFile = Remote_View->currentItem()->text(0);
352 if( curFile !="../") { 352 if( curFile !="../") {
353 InputDialog *fileDlg; 353 InputDialog *fileDlg;
354 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 354 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
355 fileDlg->setInputText((const QString &)curFile); 355 fileDlg->setInputText((const QString &)curFile);
356 fileDlg->exec(); 356 fileDlg->exec();
357 if( fileDlg->result() == 1 ) { 357 if( fileDlg->result() == 1 ) {
358 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; 358 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
359 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 359 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
360//+".playlist"; 360//+".playlist";
361 if( rename(oldname.latin1(), newName.latin1())== -1) 361 if( rename(oldname.latin1(), newName.latin1())== -1)
362 QMessageBox::message(tr("Note"),tr("Could not rename")); 362 QMessageBox::message(tr("Note"),tr("Could not rename"));
363 } 363 }
364 populateRemoteView(); 364 populateRemoteView();
365 } 365 }
366} 366}
367 367
368 368
369void AdvancedFm::filePerms() { 369void AdvancedFm::filePerms() {
370 370
371 QStringList curFileList = getPath(); 371 QStringList curFileList = getPath();
372 QString filePath; 372 QString filePath;
373 373
374 if (TabWidget->getCurrentTab() == 0) { 374 if (TabWidget->getCurrentTab() == 0) {
375 filePath = currentDir.canonicalPath()+"/"; 375 filePath = currentDir.canonicalPath()+"/";
376 } else { 376 } else {
377 filePath= currentRemoteDir.canonicalPath()+"/"; 377 filePath= currentRemoteDir.canonicalPath()+"/";
378 } 378 }
379 379
380 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 380 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
381 filePermissions *filePerm; 381 filePermissions *filePerm;
382 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 382 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
383 filePerm->showMaximized(); 383 filePerm->showMaximized();
384 filePerm->exec(); 384 filePerm->exec();
385 if( filePerm) 385 if( filePerm)
386 delete filePerm; 386 delete filePerm;
387 } 387 }
388 if (TabWidget->getCurrentTab() == 0) { 388 if (TabWidget->getCurrentTab() == 0) {
389 populateLocalView(); 389 populateLocalView();
390 } else { 390 } else {
391 populateRemoteView(); 391 populateRemoteView();
392 } 392 }
393} 393}
394 394
395void AdvancedFm::doProperties() { 395void AdvancedFm::doProperties() {
396#if defined(QT_QWS_OPIE) 396#if defined(QT_QWS_OPIE)
397 397
398 QStringList curFileList = getPath(); 398 QStringList curFileList = getPath();
399 399
400 QString filePath; 400 QString filePath;
401 if (TabWidget->getCurrentTab() == 0) { 401 if (TabWidget->getCurrentTab() == 0) {
402 filePath = currentDir.canonicalPath()+"/"; 402 filePath = currentDir.canonicalPath()+"/";
403 } else { 403 } else {
404 filePath= currentRemoteDir.canonicalPath()+"/"; 404 filePath= currentRemoteDir.canonicalPath()+"/";
405 } 405 }
406 qDebug("%d",curFileList.count()); 406 qDebug("%d",curFileList.count());
407 407
408 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 408 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
409 qDebug((filePath+*it)); 409 qDebug((filePath+*it));
410 DocLnk lnk( (filePath+*it)); 410 DocLnk lnk( (filePath+*it));
411 LnkProperties prop( &lnk ); 411 LnkProperties prop( &lnk );
412 prop.showMaximized(); 412 prop.showMaximized();
413 prop.exec(); 413 prop.exec();
414 } 414 }
415#endif 415#endif
416 416
417} 417}
418 418
419void AdvancedFm::upDir() { 419void AdvancedFm::upDir() {
420 if (TabWidget->getCurrentTab() == 0) { 420 if (TabWidget->getCurrentTab() == 0) {
421 QString current = currentDir.canonicalPath(); 421 QString current = currentDir.canonicalPath();
422 QDir dir(current); 422 QDir dir(current);
423 dir.cdUp(); 423 dir.cdUp();
424 current = dir.canonicalPath(); 424 current = dir.canonicalPath();
425 chdir( current.latin1() ); 425 chdir( current.latin1() );
426 currentDir.cd( current, TRUE); 426 currentDir.cd( current, TRUE);
427 populateLocalView(); 427 populateLocalView();
428 update(); 428 update();
429 } else { 429 } else {
430 QString current = currentRemoteDir.canonicalPath(); 430 QString current = currentRemoteDir.canonicalPath();
431 QDir dir(current); 431 QDir dir(current);
432 dir.cdUp(); 432 dir.cdUp();
433 current = dir.canonicalPath(); 433 current = dir.canonicalPath();
434 chdir( current.latin1() ); 434 chdir( current.latin1() );
435 currentRemoteDir.cd( current, TRUE); 435 currentRemoteDir.cd( current, TRUE);
436 populateRemoteView(); 436 populateRemoteView();
437 update(); 437 update();
438 } 438 }
439} 439}
440 440
441void AdvancedFm::copy() { 441void AdvancedFm::copy() {
442 qApp->processEvents(); 442 qApp->processEvents();
443 QStringList curFileList = getPath(); 443 QStringList curFileList = getPath();
444 bool doMsg=true; 444 bool doMsg=true;
445 int count=curFileList.count(); 445 int count=curFileList.count();
446 if( count > 0) { 446 if( count > 0) {
447 if(count > 1 ){ 447 if(count > 1 ){
448 QString msg; 448 QString msg;
449 msg=tr("Really copy\n%1 files?").arg(count); 449 msg=tr("Really copy\n%1 files?").arg(count);
450 switch ( QMessageBox::warning(this,tr("Delete"),msg 450 switch ( QMessageBox::warning(this,tr("Delete"),msg
451 ,tr("Yes"),tr("No"),0,0,1) ) { 451 ,tr("Yes"),tr("No"),0,0,1) ) {
452 case 0: 452 case 0:
453 doMsg=false; 453 doMsg=false;
454 break; 454 break;
455 case 1: 455 case 1:
456 return; 456 return;
457 break; 457 break;
458 }; 458 };
459 } 459 }
460 460
461 QString curFile, item, destFile; 461 QString curFile, item, destFile;
462 if (TabWidget->getCurrentTab() == 0) { 462 if (TabWidget->getCurrentTab() == 0) {
463 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 463 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
464 item=(*it); 464 item=(*it);
465 if(item.find("->",0,TRUE)) //symlink 465 if(item.find("->",0,TRUE)) //symlink
466 item = item.left(item.find("->",0,TRUE)); 466 item = item.left(item.find("->",0,TRUE));
467 467
468 destFile = currentRemoteDir.canonicalPath()+"/"+ item; 468 destFile = currentRemoteDir.canonicalPath()+"/"+ item;
469 qDebug("Destination file is "+destFile); 469 qDebug("Destination file is "+destFile);
470 470
471 curFile = currentDir.canonicalPath()+"/"+ item; 471 curFile = currentDir.canonicalPath()+"/"+ item;
472 qDebug("CurrentFile file is " + curFile); 472 qDebug("CurrentFile file is " + curFile);
473 473
474 QFile f(destFile); 474 QFile f(destFile);
475 if( f.exists()) { 475 if( f.exists()) {
476 if(doMsg) { 476 if(doMsg) {
477 switch ( QMessageBox::warning(this,tr("File Exists!"), 477 switch ( QMessageBox::warning(this,tr("File Exists!"),
478 item+tr("\nexists. Ok to overwrite?"), 478 item+tr("\nexists. Ok to overwrite?"),
479 tr("Yes"),tr("No"),0,0,1) ) { 479 tr("Yes"),tr("No"),0,0,1) ) {
480 case 1: 480 case 1:
481 return; 481 return;
482 break; 482 break;
483 }; 483 };
484 } 484 }
485 f.remove(); 485 f.remove();
486 } 486 }
487 if(!copyFile(destFile, curFile) ) { 487 if(!copyFile(destFile, curFile) ) {
488 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 488 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
489 return; 489 return;
490 } 490 }
491 } 491 }
492 populateRemoteView(); 492 populateRemoteView();
493 TabWidget->setCurrentTab(1); 493 TabWidget->setCurrentTab(1);
494 494
495 } else { 495 } else {
496 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 496 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
497 item= (*it); 497 item= (*it);
498 if(item.find("->",0,TRUE)) //symlink 498 if(item.find("->",0,TRUE)) //symlink
499 item = item.left(item.find("->",0,TRUE)); 499 item = item.left(item.find("->",0,TRUE));
500 500
501 destFile = currentDir.canonicalPath()+"/"+ item; 501 destFile = currentDir.canonicalPath()+"/"+ item;
502 qDebug("Destination file is "+destFile); 502 qDebug("Destination file is "+destFile);
503 503
504 curFile = currentRemoteDir.canonicalPath()+"/"+ item;; 504 curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
505 qDebug("CurrentFile file is " + curFile); 505 qDebug("CurrentFile file is " + curFile);
506 506
507 QFile f(destFile); 507 QFile f(destFile);
508 if( f.exists()) { 508 if( f.exists()) {
509 switch ( QMessageBox::warning(this,tr("File Exists!"), 509 switch ( QMessageBox::warning(this,tr("File Exists!"),
510 item+tr("\nexists. Ok to overwrite?"), 510 item+tr("\nexists. Ok to overwrite?"),
511 tr("Yes"),tr("No"),0,0,1) ) { 511 tr("Yes"),tr("No"),0,0,1) ) {
512 case 1: 512 case 1:
513 return; 513 return;
514 break; 514 break;
515 }; 515 };
516 f.remove(); 516 f.remove();
517 } 517 }
518 if(!copyFile(destFile, curFile) ) { 518 if(!copyFile(destFile, curFile) ) {
519 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 519 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
520 +curFile +tr("to\n")+destFile); 520 +curFile +tr("to\n")+destFile);
521 return; 521 return;
522 522
523 } 523 }
524 } 524 }
525 populateLocalView(); 525 populateLocalView();
526 TabWidget->setCurrentTab(0); 526 TabWidget->setCurrentTab(0);
527 } 527 }
528 528
529 } 529 }
530} 530}
531 531
532void AdvancedFm::copyAs() { 532void AdvancedFm::copyAs() {
533 qApp->processEvents(); 533 qApp->processEvents();
534 534
535 QStringList curFileList = getPath(); 535 QStringList curFileList = getPath();
536 QString curFile; 536 QString curFile, item;
537 InputDialog *fileDlg; 537 InputDialog *fileDlg;
538 if (TabWidget->getCurrentTab() == 0) { 538 if (TabWidget->getCurrentTab() == 0) {
539 qDebug("tab 1"); 539 qDebug("tab 1");
540 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 540 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
541 QString destFile; 541 QString destFile;
542 item=(*it);
542 curFile = currentDir.canonicalPath()+"/"+(*it); 543 curFile = currentDir.canonicalPath()+"/"+(*it);
543 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 544 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
544 545
545 fileDlg->setInputText((const QString &) destFile ); 546 fileDlg->setInputText((const QString &) destFile );
546 fileDlg->exec(); 547 fileDlg->exec();
547 548
548 if( fileDlg->result() == 1 ) { 549 if( fileDlg->result() == 1 ) {
549 QString filename = fileDlg->LineEdit1->text(); 550 QString filename = fileDlg->LineEdit1->text();
550 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 551 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
551 552
552 QFile f(destFile); 553 QFile f(destFile);
553 if( f.exists()) { 554 if( f.exists()) {
554 switch (QMessageBox::warning(this,tr("File Exists!"), 555 switch (QMessageBox::warning(this,tr("File Exists!"),
555 item+tr("\nexists. Ok to overwrite?"), 556 item+tr("\nexists. Ok to overwrite?"),
556 tr("Yes"),tr("No"),0,0,1) ) { 557 tr("Yes"),tr("No"),0,0,1) ) {
557 case 0: 558 case 0:
558 f.remove(); 559 f.remove();
559 break; 560 break;
560 case 1: 561 case 1:
561 return; 562 return;
562 break; 563 break;
563 }; 564 };
564 } 565 }
565 if(!copyFile(destFile, curFile) ) { 566 if(!copyFile(destFile, curFile) ) {
566 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 567 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
567 +curFile +tr("to\n")+destFile); 568 +curFile +tr("to\n")+destFile);
568 return; 569 return;
569 } 570 }
570 } 571 }
571 delete fileDlg; 572 delete fileDlg;
572 573
573 } 574 }
574 populateRemoteView(); 575 populateRemoteView();
575 TabWidget->setCurrentTab(1); 576 TabWidget->setCurrentTab(1);
576 577
577 } else { 578 } else {
578 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 579 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
579 580
581 item=(*it);
580 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 582 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
581 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 583 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
582 584
583 QString destFile; 585 QString destFile;
584 fileDlg->setInputText((const QString &) destFile); 586 fileDlg->setInputText((const QString &) destFile);
585 fileDlg->exec(); 587 fileDlg->exec();
586 588
587 if( fileDlg->result() == 1 ) { 589 if( fileDlg->result() == 1 ) {
588 QString filename = fileDlg->LineEdit1->text(); 590 QString filename = fileDlg->LineEdit1->text();
589 destFile = currentDir.canonicalPath()+"/"+filename; 591 destFile = currentDir.canonicalPath()+"/"+filename;
590 592
591 QFile f( destFile); 593 QFile f( destFile);
592 if( f.exists()) { 594 if( f.exists()) {
593 switch ( QMessageBox::warning(this,tr("File Exists!"), 595 switch ( QMessageBox::warning(this,tr("File Exists!"),
594 item+tr("\nexists. Ok to overwrite?"), 596 item+tr("\nexists. Ok to overwrite?"),
595 tr("Yes"),tr("No"),0,0,1) ) { 597 tr("Yes"),tr("No"),0,0,1) ) {
596 case 0: 598 case 0:
597 f.remove(); 599 f.remove();
598 break; 600 break;
599 case 1: 601 case 1:
600 return; 602 return;
601 break; 603 break;
602 }; 604 };
603 } 605 }
604 if(!copyFile(destFile, curFile) ) { 606 if(!copyFile(destFile, curFile) ) {
605 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 607 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
606 +curFile +tr("to\n")+destFile); 608 +curFile +tr("to\n")+destFile);
607 return; 609 return;
608 } 610 }
609 611
610 } 612 }
611 delete fileDlg; 613 delete fileDlg;
612 614
613 } 615 }
614 populateLocalView(); 616 populateLocalView();
615 TabWidget->setCurrentTab(0); 617 TabWidget->setCurrentTab(0);
616 } 618 }
617} 619}
618 620
619void AdvancedFm::copySameDir() { 621void AdvancedFm::copySameDir() {
620 qApp->processEvents(); 622 qApp->processEvents();
621 QStringList curFileList = getPath(); 623 QStringList curFileList = getPath();
622 QString curFile, item, destFile; 624 QString curFile, item, destFile;
623 InputDialog *fileDlg; 625 InputDialog *fileDlg;
624 626
625 if (TabWidget->getCurrentTab() == 0) { 627 if (TabWidget->getCurrentTab() == 0) {
626 628
627 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 629 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
628 item=(*it); 630 item=(*it);
629 curFile = currentDir.canonicalPath()+"/"+ item; 631 curFile = currentDir.canonicalPath()+"/"+ item;
630 632
631 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 633 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
632 fileDlg->setInputText((const QString &) destFile ); 634 fileDlg->setInputText((const QString &) destFile );
633 fileDlg->exec(); 635 fileDlg->exec();
634 636
635 if( fileDlg->result() == 1 ) { 637 if( fileDlg->result() == 1 ) {
636 638
637 QString filename = fileDlg->LineEdit1->text(); 639 QString filename = fileDlg->LineEdit1->text();
638 destFile = currentDir.canonicalPath()+"/"+filename; 640 destFile = currentDir.canonicalPath()+"/"+filename;
639 641
640 QFile f(destFile); 642 QFile f(destFile);
641 if( f.exists()) { 643 if( f.exists()) {
642 switch (QMessageBox::warning(this,tr("Delete"), 644 switch (QMessageBox::warning(this,tr("Delete"),
643 destFile+tr(" already exists\nDo you really want to delete it?"), 645 destFile+tr(" already exists\nDo you really want to delete it?"),
644 tr("Yes"),tr("No"),0,0,1) ) { 646 tr("Yes"),tr("No"),0,0,1) ) {
645 case 0: 647 case 0:
646 648
647 f.remove(); 649 f.remove();
648 break; 650 break;
649 case 1: 651 case 1:
650 return; 652 return;
651 break; 653 break;
652 }; 654 };
653 } 655 }
654 if(!copyFile(destFile, curFile) ) { 656 if(!copyFile(destFile, curFile) ) {
655 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 657 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
656 +curFile +tr("to\n")+destFile); 658 +curFile +tr("to\n")+destFile);
657 return; 659 return;
658 } 660 }
659 661
660 qDebug("copy "+curFile+" as "+destFile); 662 qDebug("copy "+curFile+" as "+destFile);
661 } 663 }
662 delete fileDlg; 664 delete fileDlg;
663 } 665 }
664 populateLocalView(); 666 populateLocalView();
665 667
666 } else { 668 } else {
667 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 669 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
668 item=(*it); 670 item=(*it);
669 curFile = currentRemoteDir.canonicalPath()+"/"+ item; 671 curFile = currentRemoteDir.canonicalPath()+"/"+ item;
670 672
671 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 673 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
672 fileDlg->setInputText((const QString &) destFile); 674 fileDlg->setInputText((const QString &) destFile);
673 fileDlg->exec(); 675 fileDlg->exec();
674 if( fileDlg->result() == 1 ) { 676 if( fileDlg->result() == 1 ) {
675 QString filename = fileDlg->LineEdit1->text(); 677 QString filename = fileDlg->LineEdit1->text();
676 678
677 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 679 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
678 680
679 QFile f(destFile); 681 QFile f(destFile);
680 if( f.exists()) { 682 if( f.exists()) {
681 switch ( QMessageBox::warning(this,tr("Delete"), 683 switch ( QMessageBox::warning(this,tr("Delete"),
682 destFile+tr(" already exists\nDo you really want to delete it?"), 684 destFile+tr(" already exists\nDo you really want to delete it?"),
683 tr("Yes"),tr("No"),0,0,1) ) { 685 tr("Yes"),tr("No"),0,0,1) ) {
684 case 0: 686 case 0:
685 f.remove(); 687 f.remove();
686 break; 688 break;
687 case 1: 689 case 1:
688 return; 690 return;
689 break; 691 break;
690 }; 692 };
691 } 693 }
692 if(!copyFile(destFile, curFile) ) { 694 if(!copyFile(destFile, curFile) ) {
693 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 695 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
694 +curFile +tr("to\n")+destFile); 696 +curFile +tr("to\n")+destFile);
695 return; 697 return;
696 } 698 }
697 qDebug("copy "+curFile+" as "+destFile); 699 qDebug("copy "+curFile+" as "+destFile);
698 } 700 }
699 delete fileDlg; 701 delete fileDlg;
700 } 702 }
701 populateRemoteView(); 703 populateRemoteView();
702 } 704 }
703} 705}
704 706
705void AdvancedFm::move() { 707void AdvancedFm::move() {
706 qApp->processEvents(); 708 qApp->processEvents();
707 709
708 QStringList curFileList = getPath(); 710 QStringList curFileList = getPath();
709 if( curFileList.count() > 0) { 711 if( curFileList.count() > 0) {
710 QString curFile, destFile, item; 712 QString curFile, destFile, item;
711 713
712 if (TabWidget->getCurrentTab() == 0) { 714 if (TabWidget->getCurrentTab() == 0) {
713 715
714 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 716 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
715 item=(*it); 717 item=(*it);
716 QString destFile = currentRemoteDir.canonicalPath(); 718 QString destFile = currentRemoteDir.canonicalPath();
717 719
718 if(destFile.right(1).find("/",0,TRUE) == -1) 720 if(destFile.right(1).find("/",0,TRUE) == -1)
719 destFile+="/"; 721 destFile+="/";
720 destFile += item; 722 destFile += item;
721 curFile = currentDir.canonicalPath(); 723 curFile = currentDir.canonicalPath();
722 724
723 qDebug("Destination file is "+destFile); 725 qDebug("Destination file is "+destFile);
724 726
725 if(curFile.right(1).find("/",0,TRUE) == -1) 727 if(curFile.right(1).find("/",0,TRUE) == -1)
726 curFile +="/"; 728 curFile +="/";
727 729
728 curFile+= item; 730 curFile+= item;
729 qDebug("CurrentFile file is " + curFile); 731 qDebug("CurrentFile file is " + curFile);
730 732
731 QFile f( curFile); 733 QFile f( curFile);
732 if( f.exists()) { 734 if( f.exists()) {
733 if(!copyFile( destFile, curFile) ) { 735 if(!copyFile( destFile, curFile) ) {
734 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 736 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
735 return; 737 return;
736 } else 738 } else
737 QFile::remove(curFile); 739 QFile::remove(curFile);
738 } 740 }
739 } 741 }
740 742
741 TabWidget->setCurrentTab(1); 743 TabWidget->setCurrentTab(1);
742 744
743 } else { //view 2 745 } else { //view 2
744 746
745 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 747 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
746 item = (*it); 748 item = (*it);
747 QString destFile = currentDir.canonicalPath(); 749 QString destFile = currentDir.canonicalPath();
748 750
749 if(destFile.right(1).find("/",0,TRUE) == -1) 751 if(destFile.right(1).find("/",0,TRUE) == -1)
750 destFile+="/"; 752 destFile+="/";
751 753
752 destFile += item; 754 destFile += item;
753 755
754 qDebug("Destination file is "+destFile); 756 qDebug("Destination file is "+destFile);
755 757
756 curFile = currentRemoteDir.canonicalPath(); 758 curFile = currentRemoteDir.canonicalPath();
757 759
758 if(curFile.right(1).find("/",0,TRUE) == -1) 760 if(curFile.right(1).find("/",0,TRUE) == -1)
759 curFile +="/"; 761 curFile +="/";
760 curFile+= item; 762 curFile+= item;
761 qDebug("CurrentFile file is " + curFile); 763 qDebug("CurrentFile file is " + curFile);
762 764
763 QFile f( curFile); 765 QFile f( curFile);
764 if( f.exists()) { 766 if( f.exists()) {
765 if(!copyFile( destFile, curFile) ) { 767 if(!copyFile( destFile, curFile) ) {
766 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); 768 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
767 return; 769 return;
768 } else 770 } else
769 QFile::remove( curFile); 771 QFile::remove( curFile);
770 } 772 }
771 TabWidget->setCurrentTab(0); 773 TabWidget->setCurrentTab(0);
772 } 774 }
773 } 775 }
774 populateRemoteView(); 776 populateRemoteView();
775 populateLocalView(); 777 populateLocalView();
776 } 778 }
777} 779}
778 780
779bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { 781bool AdvancedFm::copyFile( const QString & dest, const QString & src ) {
780 char bf[ 50000 ]; 782 char bf[ 50000 ];
781 int bytesRead; 783 int bytesRead;
782 bool success = TRUE; 784 bool success = TRUE;
783 struct stat status; 785 struct stat status;
784 786
785 QFile s( src ); 787 QFile s( src );
786 QFile d( dest ); 788 QFile d( dest );
787 789
788 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 790 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
789 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 791 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
790 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 792 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
791 success = FALSE; 793 success = FALSE;
792 break; 794 break;
793 } 795 }
794 } 796 }
795 if( success && (bytesRead > 0) ){ 797 if( success && (bytesRead > 0) ){
796 d.writeBlock( bf, bytesRead ); 798 d.writeBlock( bf, bytesRead );
797 } 799 }
798 } else { 800 } else {
799 success = FALSE; 801 success = FALSE;
800 } 802 }
801 803
802 // Set file permissions 804 // Set file permissions
803 if( stat( (const char *) src, &status ) == 0 ){ 805 if( stat( (const char *) src, &status ) == 0 ){
804 chmod( (const char *) dest, status.st_mode ); 806 chmod( (const char *) dest, status.st_mode );
805 } 807 }
806 808
807 return success; 809 return success;
808} 810}
809 811
810void AdvancedFm::runCommand() { 812void AdvancedFm::runCommand() {
811 QString curFile; 813 QString curFile;
812 if (TabWidget->getCurrentTab() == 0) { 814 if (TabWidget->getCurrentTab() == 0) {
813 if( Local_View->currentItem()) 815 if( Local_View->currentItem())
814 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 816 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
815 } else { 817 } else {
816 if(Remote_View->currentItem()) 818 if(Remote_View->currentItem())
817 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 819 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
818 } 820 }
819 821
820 InputDialog *fileDlg; 822 InputDialog *fileDlg;
821 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 823 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
822 fileDlg->setInputText(curFile); 824 fileDlg->setInputText(curFile);
823 fileDlg->exec(); 825 fileDlg->exec();
824 QString command; 826 QString command;
825 if( fileDlg->result() == 1 ) { 827 if( fileDlg->result() == 1 ) {
826 command = fileDlg->LineEdit1->text(); 828 command = fileDlg->LineEdit1->text();
827 829
828 Output *outDlg; 830 Output *outDlg;
829 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 831 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
830 outDlg->showMaximized(); 832 outDlg->showMaximized();
831 outDlg->show(); 833 outDlg->show();
832 qApp->processEvents(); 834 qApp->processEvents();
833 FILE *fp; 835 FILE *fp;
834 char line[130]; 836 char line[130];
835 sleep(1); 837 sleep(1);
836 command +=" 2>&1"; 838 command +=" 2>&1";
837 fp = popen( (const char *) command, "r"); 839 fp = popen( (const char *) command, "r");
838 if ( !fp ) { 840 if ( !fp ) {
839 qDebug("Could not execute '" + command + "'! err=%d", fp); 841 qDebug("Could not execute '" + command + "'! err=%d", fp);
840 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 842 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
841 pclose(fp); 843 pclose(fp);
842 return; 844 return;
843 } else { 845 } else {
844 while ( fgets( line, sizeof line, fp)) { 846 while ( fgets( line, sizeof line, fp)) {
845 QString lineStr = line; 847 QString lineStr = line;
846 lineStr=lineStr.left(lineStr.length()-1); 848 lineStr=lineStr.left(lineStr.length()-1);
847 outDlg->OutputEdit->append(lineStr); 849 outDlg->OutputEdit->append(lineStr);
848 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 850 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
849 } 851 }
850 } 852 }
851 pclose(fp); 853 pclose(fp);
852 854
853 } 855 }
854} 856}
855 857
856void AdvancedFm::runCommandStd() { 858void AdvancedFm::runCommandStd() {
857 QString curFile; 859 QString curFile;
858 if (TabWidget->getCurrentTab() == 0) { 860 if (TabWidget->getCurrentTab() == 0) {
859 if( Local_View->currentItem()) 861 if( Local_View->currentItem())
860 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 862 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
861 } else { 863 } else {
862 if(Remote_View->currentItem()) 864 if(Remote_View->currentItem())
863 curFile = currentRemoteDir.canonicalPath() +"/" 865 curFile = currentRemoteDir.canonicalPath() +"/"
864 + Remote_View->currentItem()->text(0); 866 + Remote_View->currentItem()->text(0);
865 } 867 }
866 868
867 InputDialog *fileDlg; 869 InputDialog *fileDlg;
868 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 870 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
869 fileDlg->setInputText(curFile); 871 fileDlg->setInputText(curFile);
870 fileDlg->exec(); 872 fileDlg->exec();
871 QString command; 873 QString command;
872 if( fileDlg->result() == 1 ) { 874 if( fileDlg->result() == 1 ) {
873 qApp->processEvents(); 875 qApp->processEvents();
874 command = fileDlg->LineEdit1->text() + " &"; 876 command = fileDlg->LineEdit1->text() + " &";
875 system(command.latin1()); 877 system(command.latin1());
876 } 878 }
877} 879}
878 880
879void AdvancedFm::fileStatus() { 881void AdvancedFm::fileStatus() {
880 QString curFile; 882 QString curFile;
881 if (TabWidget->getCurrentTab() == 0) { 883 if (TabWidget->getCurrentTab() == 0) {
882 curFile = Local_View->currentItem()->text(0); 884 curFile = Local_View->currentItem()->text(0);
883 } else { 885 } else {
884 curFile = Remote_View->currentItem()->text(0); 886 curFile = Remote_View->currentItem()->text(0);
885 } 887 }
886 QString command = " stat -l "+ curFile +" 2>&1"; 888 QString command = " stat -l "+ curFile +" 2>&1";
887 Output *outDlg; 889 Output *outDlg;
888 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 890 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
889 outDlg->showMaximized(); 891 outDlg->showMaximized();
890 outDlg->show(); 892 outDlg->show();
891 qApp->processEvents(); 893 qApp->processEvents();
892 FILE *fp; 894 FILE *fp;
893 char line[130]; 895 char line[130];
894 sleep(1); 896 sleep(1);
895 fp = popen( (const char *) command, "r"); 897 fp = popen( (const char *) command, "r");
896 if ( !fp ) { 898 if ( !fp ) {
897 qDebug("Could not execute '" + command + "'! err=%d", fp); 899 qDebug("Could not execute '" + command + "'! err=%d", fp);
898 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 900 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
899 pclose(fp); 901 pclose(fp);
900 return; 902 return;
901 } else { 903 } else {
902 while ( fgets( line, sizeof line, fp)) { 904 while ( fgets( line, sizeof line, fp)) {
903 outDlg->OutputEdit->append(line); 905 outDlg->OutputEdit->append(line);
904 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 906 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
905 907
906 } 908 }
907 909
908 } 910 }
909 pclose(fp); 911 pclose(fp);
910} 912}
911 913
912void AdvancedFm::mkDir() { 914void AdvancedFm::mkDir() {
913 if (TabWidget->getCurrentTab() == 0) 915 if (TabWidget->getCurrentTab() == 0)
914 localMakDir(); 916 localMakDir();
915 else 917 else
916 remoteMakDir(); 918 remoteMakDir();
917 919
918} 920}
919 921
920void AdvancedFm::rn() { 922void AdvancedFm::rn() {
921 if (TabWidget->getCurrentTab() == 0) 923 if (TabWidget->getCurrentTab() == 0)
922 localRename(); 924 localRename();
923 else 925 else
924 remoteRename(); 926 remoteRename();
925 927
926} 928}
927 929
928void AdvancedFm::del() { 930void AdvancedFm::del() {
929 if (TabWidget->getCurrentTab() == 0) 931 if (TabWidget->getCurrentTab() == 0)
930 localDelete(); 932 localDelete();
931 else 933 else
932 remoteDelete(); 934 remoteDelete();
933} 935}
934 936
935void AdvancedFm::mkSym() { 937void AdvancedFm::mkSym() {
936 QString cmd; 938 QString cmd;
937 QStringList curFileList = getPath(); 939 QStringList curFileList = getPath();
938 if( curFileList.count() > 0) { 940 if( curFileList.count() > 0) {
939 941
940 if (TabWidget->getCurrentTab() == 0) { 942 if (TabWidget->getCurrentTab() == 0) {
941 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 943 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
942 944
943 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 945 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
944 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 946 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
945 QString curFile = currentDir.canonicalPath()+"/"+(*it); 947 QString curFile = currentDir.canonicalPath()+"/"+(*it);
946 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 948 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
947 cmd = "ln -s "+curFile+" "+destName; 949 cmd = "ln -s "+curFile+" "+destName;
948 qDebug(cmd); 950 qDebug(cmd);
949 system(cmd.latin1() ); 951 system(cmd.latin1() );
950 } 952 }
951 populateRemoteView(); 953 populateRemoteView();
952 TabWidget->setCurrentTab(1); 954 TabWidget->setCurrentTab(1);
953 } else { 955 } else {
954 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 956 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
955 957
956 QString destName = currentDir.canonicalPath()+"/"+(*it); 958 QString destName = currentDir.canonicalPath()+"/"+(*it);
957 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 959 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
958 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 960 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
959 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 961 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
960 962
961 cmd = "ln -s "+curFile+" "+destName; 963 cmd = "ln -s "+curFile+" "+destName;
962 qDebug(cmd); 964 qDebug(cmd);
963 system(cmd.latin1() ); 965 system(cmd.latin1() );
964 } 966 }
965 populateLocalView(); 967 populateLocalView();
966 TabWidget->setCurrentTab(0); 968 TabWidget->setCurrentTab(0);
967 } 969 }
968 } 970 }
969} 971}
970 972
971void AdvancedFm::doBeam() { 973void AdvancedFm::doBeam() {
972 Ir ir; 974 Ir ir;
973 if(!ir.supported()){ 975 if(!ir.supported()){
974 } else { 976 } else {
975 977
976 QStringList curFileList = getPath(); 978 QStringList curFileList = getPath();
977 if( curFileList.count() > 0) { 979 if( curFileList.count() > 0) {
978 980
979 if (TabWidget->getCurrentTab() == 0) { 981 if (TabWidget->getCurrentTab() == 0) {
980 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 982 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
981 983
982 QString curFile = currentDir.canonicalPath()+"/"+(*it); 984 QString curFile = currentDir.canonicalPath()+"/"+(*it);
983 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 985 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
984 Ir *file = new Ir(this, "IR"); 986 Ir *file = new Ir(this, "IR");
985 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 987 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
986 file->send( curFile, curFile ); 988 file->send( curFile, curFile );
987 } 989 }
988 990
989 } else { 991 } else {
990 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 992 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
991 993
992 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 994 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
993 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 995 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
994 Ir *file = new Ir(this, "IR"); 996 Ir *file = new Ir(this, "IR");
995 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 997 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
996 file->send( curFile, curFile ); 998 file->send( curFile, curFile );
997 999
998 } 1000 }
999 } 1001 }
1000 } 1002 }
1001 } 1003 }
1002 1004
1003} 1005}
1004 1006
1005void AdvancedFm::fileBeamFinished( Ir *) { 1007void AdvancedFm::fileBeamFinished( Ir *) {
1006 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 1008 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
1007 1009
1008} 1010}
1009 1011
1010void AdvancedFm::selectAll() { 1012void AdvancedFm::selectAll() {
1011 if (TabWidget->getCurrentTab() == 0) { 1013 if (TabWidget->getCurrentTab() == 0) {
1012 Local_View->selectAll(true); 1014 Local_View->selectAll(true);
1013 Local_View->setSelected( Local_View->firstChild(),false); 1015 Local_View->setSelected( Local_View->firstChild(),false);
1014 } else { 1016 } else {
1015 Remote_View->selectAll(true); 1017 Remote_View->selectAll(true);
1016 Remote_View->setSelected( Remote_View->firstChild(),false); 1018 Remote_View->setSelected( Remote_View->firstChild(),false);
1017 } 1019 }
1018} 1020}