summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-17 13:19:26 (UTC)
committer simon <simon>2002-12-17 13:19:26 (UTC)
commit72b81e8f489c2d349ad0d481fdc7a870fd627ec8 (patch) (unidiff)
tree2a8e98e1edeefec6df03330571d49dcd2667df93
parent1dee9c33c12ba45134b1ccb17bc84bc7fa94eb3b (diff)
downloadopie-72b81e8f489c2d349ad0d481fdc7a870fd627ec8.zip
opie-72b81e8f489c2d349ad0d481fdc7a870fd627ec8.tar.gz
opie-72b81e8f489c2d349ad0d481fdc7a870fd627ec8.tar.bz2
- i18n fixlet by Carsten
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index f77554a..a6b59c7 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,1051 +1,1051 @@
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!"),
490 item+tr("\nexists. Ok to overwrite?"), 490 item+tr("\nexists. Ok to overwrite?"),
491 tr("Yes"),tr("No"),0,0,1) ) { 491 tr("Yes"),tr("No"),0,0,1) ) {
492 case 1: 492 case 1:
493 return; 493 return;
494 break; 494 break;
495 }; 495 };
496 } 496 }
497 f.remove(); 497 f.remove();
498 } 498 }
499 if(!copyFile( curFile, destFile) ) { 499 if(!copyFile( curFile, destFile) ) {
500 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 500 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
501 return; 501 return;
502 } 502 }
503 } 503 }
504 populateRemoteView(); 504 populateRemoteView();
505 TabWidget->setCurrentTab(1); 505 TabWidget->setCurrentTab(1);
506 506
507 } else { 507 } else {
508 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 508 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
509 item= (*it); 509 item= (*it);
510 if(item.find("->",0,TRUE)) //symlink 510 if(item.find("->",0,TRUE)) //symlink
511 item = item.left(item.find("->",0,TRUE)); 511 item = item.left(item.find("->",0,TRUE));
512 512
513 destFile = currentDir.canonicalPath()+"/"+ item; 513 destFile = currentDir.canonicalPath()+"/"+ item;
514 qDebug("Destination file is "+destFile); 514 qDebug("Destination file is "+destFile);
515 515
516 curFile = currentRemoteDir.canonicalPath()+"/"+ item;; 516 curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
517 qDebug("CurrentFile file is " + curFile); 517 qDebug("CurrentFile file is " + curFile);
518 518
519 QFile f(destFile); 519 QFile f(destFile);
520 if( f.exists()) { 520 if( f.exists()) {
521 switch ( QMessageBox::warning(this,tr("File Exists!"), 521 switch ( QMessageBox::warning(this,tr("File Exists!"),
522 item+tr("\nexists. Ok to overwrite?"), 522 item+tr("\nexists. Ok to overwrite?"),
523 tr("Yes"),tr("No"),0,0,1) ) { 523 tr("Yes"),tr("No"),0,0,1) ) {
524 case 1: 524 case 1:
525 return; 525 return;
526 break; 526 break;
527 }; 527 };
528 f.remove(); 528 f.remove();
529 } 529 }
530 if(!copyFile( curFile, destFile) ) { 530 if(!copyFile( curFile, destFile) ) {
531 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 531 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
532 +curFile +tr("to\n")+destFile); 532 +curFile +tr("to\n")+destFile);
533 return; 533 return;
534 534
535 } 535 }
536 } 536 }
537 populateLocalView(); 537 populateLocalView();
538 TabWidget->setCurrentTab(0); 538 TabWidget->setCurrentTab(0);
539 } 539 }
540 540
541 } 541 }
542} 542}
543 543
544void AdvancedFm::copyAs() { 544void AdvancedFm::copyAs() {
545 qApp->processEvents(); 545 qApp->processEvents();
546 546
547 QStringList curFileList = getPath(); 547 QStringList curFileList = getPath();
548 QString curFile, item; 548 QString curFile, item;
549 InputDialog *fileDlg; 549 InputDialog *fileDlg;
550 if (TabWidget->getCurrentTab() == 0) { 550 if (TabWidget->getCurrentTab() == 0) {
551 qDebug("tab 1"); 551 qDebug("tab 1");
552 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 552 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
553 QString destFile; 553 QString destFile;
554 item=(*it); 554 item=(*it);
555 curFile = currentDir.canonicalPath()+"/"+(*it); 555 curFile = currentDir.canonicalPath()+"/"+(*it);
556 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 556 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
557 557
558 fileDlg->setInputText((const QString &) destFile ); 558 fileDlg->setInputText((const QString &) destFile );
559 fileDlg->exec(); 559 fileDlg->exec();
560 560
561 if( fileDlg->result() == 1 ) { 561 if( fileDlg->result() == 1 ) {
562 QString filename = fileDlg->LineEdit1->text(); 562 QString filename = fileDlg->LineEdit1->text();
563 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 563 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
564 564
565 QFile f(destFile); 565 QFile f(destFile);
566 if( f.exists()) { 566 if( f.exists()) {
567 switch (QMessageBox::warning(this,tr("File Exists!"), 567 switch (QMessageBox::warning(this,tr("File Exists!"),
568 item+tr("\nexists. Ok to overwrite?"), 568 item+tr("\nexists. Ok to overwrite?"),
569 tr("Yes"),tr("No"),0,0,1) ) { 569 tr("Yes"),tr("No"),0,0,1) ) {
570 case 0: 570 case 0:
571 f.remove(); 571 f.remove();
572 break; 572 break;
573 case 1: 573 case 1:
574 return; 574 return;
575 break; 575 break;
576 }; 576 };
577 } 577 }
578 if(!copyFile( curFile,destFile) ) { 578 if(!copyFile( curFile,destFile) ) {
579 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 579 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
580 +curFile +tr("to\n")+destFile); 580 +curFile +tr("to\n")+destFile);
581 return; 581 return;
582 } 582 }
583 } 583 }
584 delete fileDlg; 584 delete fileDlg;
585 585
586 } 586 }
587 populateRemoteView(); 587 populateRemoteView();
588 TabWidget->setCurrentTab(1); 588 TabWidget->setCurrentTab(1);
589 589
590 } else { 590 } else {
591 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 591 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
592 592
593 item=(*it); 593 item=(*it);
594 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 594 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
595 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 595 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
596 596
597 QString destFile; 597 QString destFile;
598 fileDlg->setInputText((const QString &) destFile); 598 fileDlg->setInputText((const QString &) destFile);
599 fileDlg->exec(); 599 fileDlg->exec();
600 600
601 if( fileDlg->result() == 1 ) { 601 if( fileDlg->result() == 1 ) {
602 QString filename = fileDlg->LineEdit1->text(); 602 QString filename = fileDlg->LineEdit1->text();
603 destFile = currentDir.canonicalPath()+"/"+filename; 603 destFile = currentDir.canonicalPath()+"/"+filename;
604 604
605 QFile f( destFile); 605 QFile f( destFile);
606 if( f.exists()) { 606 if( f.exists()) {
607 switch ( QMessageBox::warning(this,tr("File Exists!"), 607 switch ( QMessageBox::warning(this,tr("File Exists!"),
608 item+tr("\nexists. Ok to overwrite?"), 608 item+tr("\nexists. Ok to overwrite?"),
609 tr("Yes"),tr("No"),0,0,1) ) { 609 tr("Yes"),tr("No"),0,0,1) ) {
610 case 0: 610 case 0:
611 f.remove(); 611 f.remove();
612 break; 612 break;
613 case 1: 613 case 1:
614 return; 614 return;
615 break; 615 break;
616 }; 616 };
617 } 617 }
618 if(!copyFile( curFile,destFile) ) { 618 if(!copyFile( curFile,destFile) ) {
619 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 619 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
620 +curFile +tr("to\n")+destFile); 620 +curFile +tr("to\n")+destFile);
621 return; 621 return;
622 } 622 }
623 623
624 } 624 }
625 delete fileDlg; 625 delete fileDlg;
626 626
627 } 627 }
628 populateLocalView(); 628 populateLocalView();
629 TabWidget->setCurrentTab(0); 629 TabWidget->setCurrentTab(0);
630 } 630 }
631} 631}
632 632
633void AdvancedFm::copySameDir() { 633void AdvancedFm::copySameDir() {
634 qApp->processEvents(); 634 qApp->processEvents();
635 QStringList curFileList = getPath(); 635 QStringList curFileList = getPath();
636 QString curFile, item, destFile; 636 QString curFile, item, destFile;
637 InputDialog *fileDlg; 637 InputDialog *fileDlg;
638 638
639 if (TabWidget->getCurrentTab() == 0) { 639 if (TabWidget->getCurrentTab() == 0) {
640 640
641 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 641 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
642 item=(*it); 642 item=(*it);
643 curFile = currentDir.canonicalPath()+"/"+ item; 643 curFile = currentDir.canonicalPath()+"/"+ item;
644 644
645 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 645 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
646 fileDlg->setInputText((const QString &) destFile ); 646 fileDlg->setInputText((const QString &) destFile );
647 fileDlg->exec(); 647 fileDlg->exec();
648 648
649 if( fileDlg->result() == 1 ) { 649 if( fileDlg->result() == 1 ) {
650 650
651 QString filename = fileDlg->LineEdit1->text(); 651 QString filename = fileDlg->LineEdit1->text();
652 destFile = currentDir.canonicalPath()+"/"+filename; 652 destFile = currentDir.canonicalPath()+"/"+filename;
653 653
654 QFile f(destFile); 654 QFile f(destFile);
655 if( f.exists()) { 655 if( f.exists()) {
656 switch (QMessageBox::warning(this,tr("Delete"), 656 switch (QMessageBox::warning(this,tr("Delete"),
657 destFile+tr(" already exists\nDo you really want to delete it?"), 657 destFile+tr(" already exists.\nDo you really want to delete it?"),
658 tr("Yes"),tr("No"),0,0,1) ) { 658 tr("Yes"),tr("No"),0,0,1) ) {
659 case 0: 659 case 0:
660 660
661 f.remove(); 661 f.remove();
662 break; 662 break;
663 case 1: 663 case 1:
664 return; 664 return;
665 break; 665 break;
666 }; 666 };
667 } 667 }
668 if(!copyFile( curFile,destFile) ) { 668 if(!copyFile( curFile,destFile) ) {
669 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 669 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
670 +curFile +tr("to\n")+destFile); 670 +curFile +tr("to\n")+destFile);
671 return; 671 return;
672 } 672 }
673 673
674 qDebug("copy "+curFile+" as "+destFile); 674 qDebug("copy "+curFile+" as "+destFile);
675 } 675 }
676 delete fileDlg; 676 delete fileDlg;
677 } 677 }
678 populateLocalView(); 678 populateLocalView();
679 679
680 } else { 680 } else {
681 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 681 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
682 item=(*it); 682 item=(*it);
683 curFile = currentRemoteDir.canonicalPath()+"/"+ item; 683 curFile = currentRemoteDir.canonicalPath()+"/"+ item;
684 684
685 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 685 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
686 fileDlg->setInputText((const QString &) destFile); 686 fileDlg->setInputText((const QString &) destFile);
687 fileDlg->exec(); 687 fileDlg->exec();
688 if( fileDlg->result() == 1 ) { 688 if( fileDlg->result() == 1 ) {
689 QString filename = fileDlg->LineEdit1->text(); 689 QString filename = fileDlg->LineEdit1->text();
690 690
691 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 691 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
692 692
693 QFile f(destFile); 693 QFile f(destFile);
694 if( f.exists()) { 694 if( f.exists()) {
695 switch ( QMessageBox::warning(this,tr("Delete"), 695 switch ( QMessageBox::warning(this,tr("Delete"),
696 destFile+tr(" already exists\nDo you really want to delete it?"), 696 destFile+tr(" already exists.\nDo you really want to delete it?"),
697 tr("Yes"),tr("No"),0,0,1) ) { 697 tr("Yes"),tr("No"),0,0,1) ) {
698 case 0: 698 case 0:
699 f.remove(); 699 f.remove();
700 break; 700 break;
701 case 1: 701 case 1:
702 return; 702 return;
703 break; 703 break;
704 }; 704 };
705 } 705 }
706 if(!copyFile( curFile,destFile) ) { 706 if(!copyFile( curFile,destFile) ) {
707 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 707 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
708 +curFile +tr("to\n")+destFile); 708 +curFile +tr("to\n")+destFile);
709 return; 709 return;
710 } 710 }
711 qDebug("copy "+curFile+" as "+destFile); 711 qDebug("copy "+curFile+" as "+destFile);
712 } 712 }
713 delete fileDlg; 713 delete fileDlg;
714 } 714 }
715 populateRemoteView(); 715 populateRemoteView();
716 } 716 }
717} 717}
718 718
719void AdvancedFm::move() { 719void AdvancedFm::move() {
720 qApp->processEvents(); 720 qApp->processEvents();
721 721
722 QStringList curFileList = getPath(); 722 QStringList curFileList = getPath();
723 if( curFileList.count() > 0) { 723 if( curFileList.count() > 0) {
724 QString curFile, destFile, item; 724 QString curFile, destFile, item;
725 725
726 if (TabWidget->getCurrentTab() == 0) { 726 if (TabWidget->getCurrentTab() == 0) {
727 727
728 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 728 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
729 item=(*it); 729 item=(*it);
730 QString destFile = currentRemoteDir.canonicalPath(); 730 QString destFile = currentRemoteDir.canonicalPath();
731 731
732 if(destFile.right(1).find("/",0,TRUE) == -1) 732 if(destFile.right(1).find("/",0,TRUE) == -1)
733 destFile+="/"; 733 destFile+="/";
734 destFile += item; 734 destFile += item;
735 curFile = currentDir.canonicalPath(); 735 curFile = currentDir.canonicalPath();
736 736
737 qDebug("Destination file is "+destFile); 737 qDebug("Destination file is "+destFile);
738 738
739 if(curFile.right(1).find("/",0,TRUE) == -1) 739 if(curFile.right(1).find("/",0,TRUE) == -1)
740 curFile +="/"; 740 curFile +="/";
741 741
742 curFile+= item; 742 curFile+= item;
743 qDebug("CurrentFile file is " + curFile); 743 qDebug("CurrentFile file is " + curFile);
744 744
745 QFile f( curFile); 745 QFile f( curFile);
746 if( f.exists()) { 746 if( f.exists()) {
747 if(!copyFile( curFile,destFile) ) { 747 if(!copyFile( curFile,destFile) ) {
748 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 748 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
749 return; 749 return;
750 } else 750 } else
751 QFile::remove(curFile); 751 QFile::remove(curFile);
752 } 752 }
753 } 753 }
754 754
755 TabWidget->setCurrentTab(1); 755 TabWidget->setCurrentTab(1);
756 756
757 } else { //view 2 757 } else { //view 2
758 758
759 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 759 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
760 item = (*it); 760 item = (*it);
761 QString destFile = currentDir.canonicalPath(); 761 QString destFile = currentDir.canonicalPath();
762 762
763 if(destFile.right(1).find("/",0,TRUE) == -1) 763 if(destFile.right(1).find("/",0,TRUE) == -1)
764 destFile+="/"; 764 destFile+="/";
765 765
766 destFile += item; 766 destFile += item;
767 767
768 qDebug("Destination file is "+destFile); 768 qDebug("Destination file is "+destFile);
769 769
770 curFile = currentRemoteDir.canonicalPath(); 770 curFile = currentRemoteDir.canonicalPath();
771 771
772 if(curFile.right(1).find("/",0,TRUE) == -1) 772 if(curFile.right(1).find("/",0,TRUE) == -1)
773 curFile +="/"; 773 curFile +="/";
774 curFile+= item; 774 curFile+= item;
775 qDebug("CurrentFile file is " + curFile); 775 qDebug("CurrentFile file is " + curFile);
776 776
777 QFile f( curFile); 777 QFile f( curFile);
778 if( f.exists()) { 778 if( f.exists()) {
779 if(!copyFile( curFile, destFile) ) { 779 if(!copyFile( curFile, destFile) ) {
780 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); 780 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
781 return; 781 return;
782 } else 782 } else
783 QFile::remove( curFile); 783 QFile::remove( curFile);
784 } 784 }
785 TabWidget->setCurrentTab(0); 785 TabWidget->setCurrentTab(0);
786 } 786 }
787 } 787 }
788 populateRemoteView(); 788 populateRemoteView();
789 populateLocalView(); 789 populateLocalView();
790 } 790 }
791} 791}
792 792
793bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 793bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
794 char bf[ 50000 ]; 794 char bf[ 50000 ];
795 int bytesRead; 795 int bytesRead;
796 bool success = TRUE; 796 bool success = TRUE;
797 struct stat status; 797 struct stat status;
798 798
799 QFile s( src ); 799 QFile s( src );
800 QFile d( dest ); 800 QFile d( dest );
801 801
802 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 802 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
803 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 803 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
804 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 804 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
805 success = FALSE; 805 success = FALSE;
806 break; 806 break;
807 } 807 }
808 } 808 }
809 if( success && (bytesRead > 0) ){ 809 if( success && (bytesRead > 0) ){
810 d.writeBlock( bf, bytesRead ); 810 d.writeBlock( bf, bytesRead );
811 } 811 }
812 } else { 812 } else {
813 success = FALSE; 813 success = FALSE;
814 } 814 }
815 815
816 // Set file permissions 816 // Set file permissions
817 if( stat( (const char *) src, &status ) == 0 ){ 817 if( stat( (const char *) src, &status ) == 0 ){
818 chmod( (const char *) dest, status.st_mode ); 818 chmod( (const char *) dest, status.st_mode );
819 } 819 }
820 820
821 return success; 821 return success;
822} 822}
823 823
824void AdvancedFm::runCommand() { 824void AdvancedFm::runCommand() {
825 QString curFile; 825 QString curFile;
826 if (TabWidget->getCurrentTab() == 0) { 826 if (TabWidget->getCurrentTab() == 0) {
827 if( Local_View->currentItem()) 827 if( Local_View->currentItem())
828 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 828 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
829 } else { 829 } else {
830 if(Remote_View->currentItem()) 830 if(Remote_View->currentItem())
831 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 831 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
832 } 832 }
833 833
834 InputDialog *fileDlg; 834 InputDialog *fileDlg;
835 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 835 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
836 fileDlg->setInputText(curFile); 836 fileDlg->setInputText(curFile);
837 fileDlg->exec(); 837 fileDlg->exec();
838 //QString command; 838 //QString command;
839 839
840 if( fileDlg->result() == 1 ) { 840 if( fileDlg->result() == 1 ) {
841 qDebug(fileDlg->LineEdit1->text()); 841 qDebug(fileDlg->LineEdit1->text());
842 QStringList command; 842 QStringList command;
843 843
844 command << "/bin/sh"; 844 command << "/bin/sh";
845 command << "-c"; 845 command << "-c";
846 command << fileDlg->LineEdit1->text(); 846 command << fileDlg->LineEdit1->text();
847 Output *outDlg; 847 Output *outDlg;
848 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 848 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
849 outDlg->showMaximized(); 849 outDlg->showMaximized();
850 outDlg->exec(); 850 outDlg->exec();
851 qApp->processEvents(); 851 qApp->processEvents();
852 852
853 } 853 }
854} 854}
855 855
856void AdvancedFm::runCommandStd() { 856void AdvancedFm::runCommandStd() {
857 QString curFile; 857 QString curFile;
858 if (TabWidget->getCurrentTab() == 0) { 858 if (TabWidget->getCurrentTab() == 0) {
859 if( Local_View->currentItem()) 859 if( Local_View->currentItem())
860 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 860 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
861 } else { 861 } else {
862 if(Remote_View->currentItem()) 862 if(Remote_View->currentItem())
863 curFile = currentRemoteDir.canonicalPath() +"/" 863 curFile = currentRemoteDir.canonicalPath() +"/"
864 + Remote_View->currentItem()->text(0); 864 + Remote_View->currentItem()->text(0);
865 } 865 }
866 866
867 InputDialog *fileDlg; 867 InputDialog *fileDlg;
868 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 868 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
869 fileDlg->setInputText(curFile); 869 fileDlg->setInputText(curFile);
870 fileDlg->exec(); 870 fileDlg->exec();
871 871
872 if( fileDlg->result() == 1 ) { 872 if( fileDlg->result() == 1 ) {
873 qApp->processEvents(); 873 qApp->processEvents();
874 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 874 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
875 } 875 }
876} 876}
877 877
878void AdvancedFm::fileStatus() { 878void AdvancedFm::fileStatus() {
879 QString curFile; 879 QString curFile;
880 if (TabWidget->getCurrentTab() == 0) { 880 if (TabWidget->getCurrentTab() == 0) {
881 curFile = Local_View->currentItem()->text(0); 881 curFile = Local_View->currentItem()->text(0);
882 } else { 882 } else {
883 curFile = Remote_View->currentItem()->text(0); 883 curFile = Remote_View->currentItem()->text(0);
884 } 884 }
885 885
886 QStringList command; 886 QStringList command;
887 command << "/bin/sh"; 887 command << "/bin/sh";
888 command << "-c"; 888 command << "-c";
889 command << "stat -l "+ curFile; 889 command << "stat -l "+ curFile;
890 890
891 Output *outDlg; 891 Output *outDlg;
892 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 892 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
893 outDlg->showMaximized(); 893 outDlg->showMaximized();
894 outDlg->exec(); 894 outDlg->exec();
895 qApp->processEvents(); 895 qApp->processEvents();
896 896
897 897
898// Output *outDlg; 898// Output *outDlg;
899// outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 899// outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
900// outDlg->showMaximized(); 900// outDlg->showMaximized();
901// outDlg->show(); 901// outDlg->show();
902// qApp->processEvents(); 902// qApp->processEvents();
903 903
904// FILE *fp; 904// FILE *fp;
905// char line[130]; 905// char line[130];
906// sleep(1); 906// sleep(1);
907// fp = popen( (const char *) command, "r"); 907// fp = popen( (const char *) command, "r");
908// if ( !fp ) { 908// if ( !fp ) {
909// qDebug("Could not execute '" + command + "'! err=%d", fp); 909// qDebug("Could not execute '" + command + "'! err=%d", fp);
910// QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 910// QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
911// pclose(fp); 911// pclose(fp);
912// return; 912// return;
913// } else { 913// } else {
914// while ( fgets( line, sizeof line, fp)) { 914// while ( fgets( line, sizeof line, fp)) {
915// outDlg->OutputEdit->append(line); 915// outDlg->OutputEdit->append(line);
916// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 916// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
917 917
918// } 918// }
919 919
920// } 920// }
921// pclose(fp); 921// pclose(fp);
922} 922}
923 923
924 924
925void AdvancedFm::mkDir() { 925void AdvancedFm::mkDir() {
926 if (TabWidget->getCurrentTab() == 0) 926 if (TabWidget->getCurrentTab() == 0)
927 localMakDir(); 927 localMakDir();
928 else 928 else
929 remoteMakDir(); 929 remoteMakDir();
930 930
931} 931}
932 932
933void AdvancedFm::rn() { 933void AdvancedFm::rn() {
934 if (TabWidget->getCurrentTab() == 0) 934 if (TabWidget->getCurrentTab() == 0)
935 localRename(); 935 localRename();
936 else 936 else
937 remoteRename(); 937 remoteRename();
938 938
939} 939}
940 940
941void AdvancedFm::del() { 941void AdvancedFm::del() {
942 if (TabWidget->getCurrentTab() == 0) 942 if (TabWidget->getCurrentTab() == 0)
943 localDelete(); 943 localDelete();
944 else 944 else
945 remoteDelete(); 945 remoteDelete();
946} 946}
947 947
948void AdvancedFm::mkSym() { 948void AdvancedFm::mkSym() {
949 QString cmd; 949 QString cmd;
950 QStringList curFileList = getPath(); 950 QStringList curFileList = getPath();
951 if( curFileList.count() > 0) { 951 if( curFileList.count() > 0) {
952 952
953 if (TabWidget->getCurrentTab() == 0) { 953 if (TabWidget->getCurrentTab() == 0) {
954 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 954 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
955 955
956 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 956 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
957 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 957 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
958 QString curFile = currentDir.canonicalPath()+"/"+(*it); 958 QString curFile = currentDir.canonicalPath()+"/"+(*it);
959 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 959 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
960 cmd = "ln -s "+curFile+" "+destName; 960 cmd = "ln -s "+curFile+" "+destName;
961 qDebug(cmd); 961 qDebug(cmd);
962 startProcess( (const QString)cmd ); 962 startProcess( (const QString)cmd );
963 } 963 }
964 populateRemoteView(); 964 populateRemoteView();
965 TabWidget->setCurrentTab(1); 965 TabWidget->setCurrentTab(1);
966 } else { 966 } else {
967 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 967 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
968 968
969 QString destName = currentDir.canonicalPath()+"/"+(*it); 969 QString destName = currentDir.canonicalPath()+"/"+(*it);
970 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 970 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
971 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 971 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
972 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 972 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
973 973
974 cmd = "ln -s "+curFile+" "+destName; 974 cmd = "ln -s "+curFile+" "+destName;
975 qDebug(cmd); 975 qDebug(cmd);
976 startProcess( (const QString)cmd ); 976 startProcess( (const QString)cmd );
977 } 977 }
978 populateLocalView(); 978 populateLocalView();
979 TabWidget->setCurrentTab(0); 979 TabWidget->setCurrentTab(0);
980 } 980 }
981 } 981 }
982} 982}
983 983
984void AdvancedFm::doBeam() { 984void AdvancedFm::doBeam() {
985 Ir ir; 985 Ir ir;
986 if(!ir.supported()){ 986 if(!ir.supported()){
987 } else { 987 } else {
988 988
989 QStringList curFileList = getPath(); 989 QStringList curFileList = getPath();
990 if( curFileList.count() > 0) { 990 if( curFileList.count() > 0) {
991 991
992 if (TabWidget->getCurrentTab() == 0) { 992 if (TabWidget->getCurrentTab() == 0) {
993 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 993 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
994 994
995 QString curFile = currentDir.canonicalPath()+"/"+(*it); 995 QString curFile = currentDir.canonicalPath()+"/"+(*it);
996 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 996 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
997 Ir *file = new Ir(this, "IR"); 997 Ir *file = new Ir(this, "IR");
998 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 998 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
999 file->send( curFile, curFile ); 999 file->send( curFile, curFile );
1000 } 1000 }
1001 1001
1002 } else { 1002 } else {
1003 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1003 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1004 1004
1005 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1005 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1006 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 1006 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1007 Ir *file = new Ir(this, "IR"); 1007 Ir *file = new Ir(this, "IR");
1008 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1008 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1009 file->send( curFile, curFile ); 1009 file->send( curFile, curFile );
1010 1010
1011 } 1011 }
1012 } 1012 }
1013 } 1013 }
1014 } 1014 }
1015 1015
1016} 1016}
1017 1017
1018void AdvancedFm::fileBeamFinished( Ir *) { 1018void AdvancedFm::fileBeamFinished( Ir *) {
1019 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 1019 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
1020 1020
1021} 1021}
1022 1022
1023void AdvancedFm::selectAll() { 1023void AdvancedFm::selectAll() {
1024 if (TabWidget->getCurrentTab() == 0) { 1024 if (TabWidget->getCurrentTab() == 0) {
1025 Local_View->selectAll(true); 1025 Local_View->selectAll(true);
1026 Local_View->setSelected( Local_View->firstChild(),false); 1026 Local_View->setSelected( Local_View->firstChild(),false);
1027 } else { 1027 } else {
1028 Remote_View->selectAll(true); 1028 Remote_View->selectAll(true);
1029 Remote_View->setSelected( Remote_View->firstChild(),false); 1029 Remote_View->setSelected( Remote_View->firstChild(),false);
1030 } 1030 }
1031} 1031}
1032 1032
1033void AdvancedFm::startProcess(const QString & cmd) { 1033void AdvancedFm::startProcess(const QString & cmd) {
1034 QStringList command; 1034 QStringList command;
1035 OProcess *process; 1035 OProcess *process;
1036 process = new OProcess(); 1036 process = new OProcess();
1037 connect(process, SIGNAL(processExited(OProcess *)), 1037 connect(process, SIGNAL(processExited(OProcess *)),
1038 this, SLOT( processEnded())); 1038 this, SLOT( processEnded()));
1039 1039
1040 command << "/bin/sh"; 1040 command << "/bin/sh";
1041 command << "-c"; 1041 command << "-c";
1042 command << cmd.latin1(); 1042 command << cmd.latin1();
1043 *process << command; 1043 *process << command;
1044 if(!process->start(OProcess::NotifyOnExit) ) 1044 if(!process->start(OProcess::NotifyOnExit) )
1045 qDebug("could not start process"); 1045 qDebug("could not start process");
1046} 1046}
1047 1047
1048void AdvancedFm::processEnded() { 1048void AdvancedFm::processEnded() {
1049 populateLocalView(); 1049 populateLocalView();
1050 populateRemoteView(); 1050 populateRemoteView();
1051} 1051}