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