summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-09-25 05:50:48 (UTC)
committer llornkcor <llornkcor>2004-09-25 05:50:48 (UTC)
commitdba0864dd99dfc86a33bde72809634be7f0da9c4 (patch) (unidiff)
tree074ccc67cc4e7474d697117357bca2c1b19cef16
parent244945237bc55945ba41f86d5f175204e00592ea (diff)
downloadopie-dba0864dd99dfc86a33bde72809634be7f0da9c4.zip
opie-dba0864dd99dfc86a33bde72809634be7f0da9c4.tar.gz
opie-dba0864dd99dfc86a33bde72809634be7f0da9c4.tar.bz2
fix move overwrite
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp114
1 files changed, 60 insertions, 54 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index b5a05d3..f14f588 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,844 +1,850 @@
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 12
13#include "advancedfm.h" 13#include "advancedfm.h"
14#include "output.h" 14#include "output.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16 16
17/* OPIE */ 17/* OPIE */
18#include <opie2/odebug.h> 18#include <opie2/odebug.h>
19#include <qpe/lnkproperties.h> 19#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/applnk.h> 21#include <qpe/applnk.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT*/ 24/* QT*/
25 25
26#include <qmessagebox.h> 26#include <qmessagebox.h>
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qlistview.h> 28#include <qlistview.h>
29 29
30/* STD */ 30/* STD */
31 31
32#include <errno.h> 32#include <errno.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <sys/stat.h> 35#include <sys/stat.h>
36#include <dirent.h> 36#include <dirent.h>
37#include <sys/sendfile.h> 37#include <sys/sendfile.h>
38#include <fcntl.h> 38#include <fcntl.h>
39 39
40void AdvancedFm::doDirChange() { 40void AdvancedFm::doDirChange() {
41 QString pathItem = CurrentView()->currentItem()->text(0); 41 QString pathItem = CurrentView()->currentItem()->text(0);
42 if( pathItem == "../") { 42 if( pathItem == "../") {
43 ListClicked( CurrentView()->currentItem()); 43 ListClicked( CurrentView()->currentItem());
44 } else { 44 } else {
45 if( pathItem.find(" -> ",0,TRUE) != -1) 45 if( pathItem.find(" -> ",0,TRUE) != -1)
46 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 46 pathItem = dealWithSymName((const QString&)pathItem)+"/";
47// owarn << pathItem << oendl; 47// owarn << pathItem << oendl;
48 changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 48 changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
49 } 49 }
50} 50}
51 51
52void AdvancedFm::showMenuHidden() { 52void AdvancedFm::showMenuHidden() {
53 if (b) { 53 if (b) {
54 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 54 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
55 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 55 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
56 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 56 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
57 } else { 57 } else {
58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
59 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 59 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
60 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 60 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
61 } 61 }
62 b = !b; 62 b = !b;
63 populateView(); 63 populateView();
64} 64}
65 65
66void AdvancedFm::showHidden() { 66void AdvancedFm::showHidden() {
67 if (b) { 67 if (b) {
68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
69 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 69 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
70 } else { 70 } else {
71 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 71 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
72 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 72 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
73 } 73 }
74 populateView(); 74 populateView();
75} 75}
76 76
77QString AdvancedFm::dealWithSymName(const QString &fileName) { 77QString AdvancedFm::dealWithSymName(const QString &fileName) {
78 QString strItem = fileName; 78 QString strItem = fileName;
79 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 79 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
80} 80}
81 81
82void AdvancedFm::runThis() { 82void AdvancedFm::runThis() {
83 if( !CurrentView()->currentItem()) return; 83 if( !CurrentView()->currentItem()) return;
84 QString fs; 84 QString fs;
85 QDir *thisDir = CurrentDir(); 85 QDir *thisDir = CurrentDir();
86 86
87 QString curFile = CurrentView()->currentItem()->text(0); 87 QString curFile = CurrentView()->currentItem()->text(0);
88 QString path = thisDir->canonicalPath(); 88 QString path = thisDir->canonicalPath();
89 89
90 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 90 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
91 91
92 curFile = dealWithSymName((const QString&)curFile); 92 curFile = dealWithSymName((const QString&)curFile);
93 93
94 if(curFile != "../") { 94 if(curFile != "../") {
95 95
96 fs = getFileSystemType((const QString &) path); 96 fs = getFileSystemType((const QString &) path);
97 QFileInfo fileInfo( path + "/" + curFile); 97 QFileInfo fileInfo( path + "/" + curFile);
98// odebug << fileInfo.owner() << oendl; 98// odebug << fileInfo.owner() << oendl;
99 99
100 if( (fileInfo.permission( QFileInfo::ExeUser) 100 if( (fileInfo.permission( QFileInfo::ExeUser)
101 | fileInfo.permission( QFileInfo::ExeGroup) 101 | fileInfo.permission( QFileInfo::ExeGroup)
102 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 102 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
103 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 103 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
104 QCopEnvelope e("QPE/System", "execute(QString)" ); 104 QCopEnvelope e("QPE/System", "execute(QString)" );
105 e << curFile; 105 e << curFile;
106 } else { 106 } else {
107 curFile = path + "/" + curFile; 107 curFile = path + "/" + curFile;
108 DocLnk nf(curFile); 108 DocLnk nf(curFile);
109 QString execStr = nf.exec(); 109 QString execStr = nf.exec();
110// odebug << execStr << oendl; 110// odebug << execStr << oendl;
111 if( execStr.isEmpty() ) { 111 if( execStr.isEmpty() ) {
112 } else { 112 } else {
113 nf.execute(); 113 nf.execute();
114 } 114 }
115 } 115 }
116 } 116 }
117} 117}
118 118
119void AdvancedFm::runText() { 119void AdvancedFm::runText() {
120 if( !CurrentView()->currentItem()) return; 120 if( !CurrentView()->currentItem()) return;
121 QString curFile = CurrentView()->currentItem()->text(0); 121 QString curFile = CurrentView()->currentItem()->text(0);
122 if(curFile != "../") { 122 if(curFile != "../") {
123 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 123 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
124 curFile = dealWithSymName((const QString&)curFile); 124 curFile = dealWithSymName((const QString&)curFile);
125 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 125 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
126 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 126 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
127 e << curFile; 127 e << curFile;
128 } 128 }
129} 129}
130 130
131void AdvancedFm::makeDir() { 131void AdvancedFm::makeDir() {
132 InputDialog *fileDlg; 132 InputDialog *fileDlg;
133 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 133 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
134 fileDlg->exec(); 134 fileDlg->exec();
135 if( fileDlg->result() == 1 ) { 135 if( fileDlg->result() == 1 ) {
136 QDir *thisDir = CurrentDir(); 136 QDir *thisDir = CurrentDir();
137 QString filename = fileDlg->LineEdit1->text(); 137 QString filename = fileDlg->LineEdit1->text();
138 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 138 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
139 } 139 }
140 populateView(); 140 populateView();
141} 141}
142 142
143void AdvancedFm::doDelete() { 143void AdvancedFm::doDelete() {
144 QStringList curFileList = getPath(); 144 QStringList curFileList = getPath();
145 bool doMsg=true; 145 bool doMsg=true;
146 int count = curFileList.count(); 146 int count = curFileList.count();
147 if( count > 0) { 147 if( count > 0) {
148 if(count > 1 ) { 148 if(count > 1 ) {
149 QString msg; 149 QString msg;
150 msg=tr("Really delete\n%1 files?").arg(count); 150 msg=tr("Really delete\n%1 files?").arg(count);
151 switch ( QMessageBox::warning(this,tr("Delete"),msg 151 switch ( QMessageBox::warning(this,tr("Delete"),msg
152 ,tr("Yes"),tr("No"),0,0,1) ) 152 ,tr("Yes"),tr("No"),0,0,1) )
153 { 153 {
154 case 0: 154 case 0:
155 doMsg=false; 155 doMsg=false;
156 break; 156 break;
157 case 1: 157 case 1:
158 return; 158 return;
159 break; 159 break;
160 }; 160 };
161 } 161 }
162 162
163 QString myFile; 163 QString myFile;
164 164
165 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 165 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
166 myFile = (*it); 166 myFile = (*it);
167 if( myFile.find(" -> ",0,TRUE) != -1) 167 if( myFile.find(" -> ",0,TRUE) != -1)
168 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 168 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
169 169
170 QString f = CurrentDir()->canonicalPath(); 170 QString f = CurrentDir()->canonicalPath();
171 if(f.right(1).find("/",0,TRUE) == -1) 171 if(f.right(1).find("/",0,TRUE) == -1)
172 f += "/"; 172 f += "/";
173 f += myFile; 173 f += myFile;
174 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 174 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
175 //if file is a directory 175 //if file is a directory
176 176
177 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 177 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
178 tr("Really delete %1\nand all it's contents ?" ).arg( f ) , 178 tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
179 tr("Yes"), tr("No"), 0, 0, 1) ) { 179 tr("Yes"), tr("No"), 0, 0, 1) ) {
180 case 0: 180 case 0:
181 { 181 {
182 f=f.left(f.length()-1); 182 f=f.left(f.length()-1);
183 QString cmd="rm -rf "+f; 183 QString cmd="rm -rf "+f;
184 startProcess( (const QString)cmd.latin1() ); 184 startProcess( (const QString)cmd.latin1() );
185 populateView(); 185 populateView();
186 } 186 }
187 break; 187 break;
188 case 1: 188 case 1:
189 // exit 189 // exit
190 break; 190 break;
191 }; 191 };
192 192
193 } else { 193 } else {
194 if(doMsg) { 194 if(doMsg) {
195 switch ( QMessageBox::warning(this,tr("Delete"), 195 switch ( QMessageBox::warning(this,tr("Delete"),
196 tr("Really delete\n%1?").arg( myFile ), 196 tr("Really delete\n%1?").arg( myFile ),
197 tr("Yes"), tr("No"), 0, 0, 1) ) { 197 tr("Yes"), tr("No"), 0, 0, 1) ) {
198 case 1: 198 case 1:
199 return; 199 return;
200 break; 200 break;
201 }; 201 };
202 } 202 }
203 203
204 QString cmd="rm "+f; 204 QString cmd="rm "+f;
205 QFile file(f); 205 QFile file(f);
206 QFileInfo fi(myFile); 206 QFileInfo fi(myFile);
207 if( fi.fileName().find("../",0,TRUE)==-1) { 207 if( fi.fileName().find("../",0,TRUE)==-1) {
208// odebug << "remove link files "+myFile << oendl; 208// odebug << "remove link files "+myFile << oendl;
209 209
210// DocLnk lnk(f); 210// DocLnk lnk(f);
211 DocLnk *lnk; 211 DocLnk *lnk;
212 lnk = new DocLnk(f); 212 lnk = new DocLnk(f);
213// odebug << "Deleting doclnk " + lnk->linkFile() << oendl; 213// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
214 if(lnk->isValid()) 214 if(lnk->isValid())
215 lnk->removeLinkFile(); 215 lnk->removeLinkFile();
216 // delete lnk; 216 // delete lnk;
217 file.remove(); 217 file.remove();
218 } 218 }
219 } 219 }
220 } 220 }
221 } 221 }
222 populateView(); 222 populateView();
223} 223}
224 224
225void AdvancedFm::filePerms() { 225void AdvancedFm::filePerms() {
226 QStringList curFileList = getPath(); 226 QStringList curFileList = getPath();
227 QString filePath; 227 QString filePath;
228 228
229 filePath = CurrentDir()->canonicalPath()+"/"; 229 filePath = CurrentDir()->canonicalPath()+"/";
230 230
231 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 231 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
232 filePermissions *filePerm; 232 filePermissions *filePerm;
233 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 233 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
234 QPEApplication::execDialog( filePerm ); 234 QPEApplication::execDialog( filePerm );
235 if( filePerm ) 235 if( filePerm )
236 delete filePerm; 236 delete filePerm;
237 } 237 }
238 populateView(); 238 populateView();
239} 239}
240 240
241void AdvancedFm::doProperties() { 241void AdvancedFm::doProperties() {
242#if defined(QT_QWS_OPIE) 242#if defined(QT_QWS_OPIE)
243 243
244 QStringList curFileList = getPath(); 244 QStringList curFileList = getPath();
245 245
246 QString filePath; 246 QString filePath;
247 filePath = CurrentDir()->canonicalPath()+"/"; 247 filePath = CurrentDir()->canonicalPath()+"/";
248 248
249// odebug << "" << curFileList.count() << "" << oendl; 249// odebug << "" << curFileList.count() << "" << oendl;
250 250
251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
252// odebug << (filePath+*it) << oendl; 252// odebug << (filePath+*it) << oendl;
253 DocLnk lnk( (filePath+*it)); 253 DocLnk lnk( (filePath+*it));
254 LnkProperties prop( &lnk ); 254 LnkProperties prop( &lnk );
255 QPEApplication::execDialog( &prop ); 255 QPEApplication::execDialog( &prop );
256 } 256 }
257#endif 257#endif
258 258
259} 259}
260 260
261void AdvancedFm::upDir() { 261void AdvancedFm::upDir() {
262 QDir *thisDir = CurrentDir(); 262 QDir *thisDir = CurrentDir();
263 QString current = thisDir->canonicalPath(); 263 QString current = thisDir->canonicalPath();
264 QDir dir(current); 264 QDir dir(current);
265 dir.cdUp(); 265 dir.cdUp();
266 current = dir.canonicalPath(); 266 current = dir.canonicalPath();
267 chdir( current.latin1() ); 267 chdir( current.latin1() );
268 thisDir->cd( current, TRUE); 268 thisDir->cd( current, TRUE);
269 269
270 populateView(); 270 populateView();
271 update(); 271 update();
272} 272}
273 273
274void AdvancedFm::copyTimer() { 274void AdvancedFm::copyTimer() {
275 QTimer::singleShot(125,this,SLOT(copy())); 275 QTimer::singleShot(125,this,SLOT(copy()));
276} 276}
277 277
278void AdvancedFm::copy() { 278void AdvancedFm::copy() {
279 QStringList curFileList = getPath(); 279 QStringList curFileList = getPath();
280 280
281 QDir *thisDir = CurrentDir(); 281 QDir *thisDir = CurrentDir();
282 QDir *thatDir = OtherDir(); 282 QDir *thatDir = OtherDir();
283 283
284 bool doMsg=true; 284 bool doMsg=true;
285 int count=curFileList.count(); 285 int count=curFileList.count();
286 if( count > 0) { 286 if( count > 0) {
287 if(count > 1 ){ 287 if(count > 1 ){
288 QString msg; 288 QString msg;
289 msg=tr("Really copy\n%1 files?").arg(count); 289 msg=tr("Really copy\n%1 files?").arg(count);
290 switch ( QMessageBox::warning(this,tr("Copy"),msg 290 switch ( QMessageBox::warning(this,tr("Copy"),msg
291 ,tr("Yes"),tr("No"),0,0,1) ) 291 ,tr("Yes"),tr("No"),0,0,1) )
292 { 292 {
293 case 0: 293 case 0:
294 doMsg=false; 294 doMsg=false;
295 break; 295 break;
296 case 1: 296 case 1:
297 return; 297 return;
298 break; 298 break;
299 }; 299 };
300 } 300 }
301 301
302 QString curFile, item, destFile; 302 QString curFile, item, destFile;
303 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 303 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
304 item=(*it); 304 item=(*it);
305 if(item.find("->",0,TRUE)) //symlink 305 if(item.find("->",0,TRUE)) //symlink
306 item = item.left(item.find("->",0,TRUE)); 306 item = item.left(item.find("->",0,TRUE));
307 307
308 curFile = thisDir->canonicalPath()+"/"+ item; 308 curFile = thisDir->canonicalPath()+"/"+ item;
309 destFile = thatDir->canonicalPath()+"/"+ item; 309 destFile = thatDir->canonicalPath()+"/"+ item;
310 310
311// odebug << "Destination file is "+destFile << oendl; 311// odebug << "Destination file is "+destFile << oendl;
312// odebug << "CurrentFile file is " + curFile << oendl; 312// odebug << "CurrentFile file is " + curFile << oendl;
313 313
314 QFile f(destFile); 314 QFile f(destFile);
315 if( f.exists()) { 315 if( f.exists()) {
316 if(doMsg) { 316 if(doMsg) {
317 switch ( QMessageBox::warning(this,tr("File Exists!"), 317 switch ( QMessageBox::warning(this,tr("File Exists!"),
318 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), 318 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item),
319 tr("Yes"),tr("No"),0,0,1)) { 319 tr("Yes"),tr("No"),0,0,1)) {
320 case 1: 320 case 1:
321 return; 321 return;
322 break; 322 break;
323 }; 323 };
324 } 324 }
325 f.remove(); 325 f.remove();
326 } 326 }
327 327
328 if( !copyFile( curFile, destFile) ) { 328 if( !copyFile( curFile, destFile) ) {
329 QMessageBox::message("AdvancedFm", 329 QMessageBox::message("AdvancedFm",
330 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 330 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
331 return; 331 return;
332 } 332 }
333 } 333 }
334 rePopulate(); 334 rePopulate();
335 } 335 }
336} 336}
337 337
338void AdvancedFm::copyAsTimer() { 338void AdvancedFm::copyAsTimer() {
339 QTimer::singleShot(125,this,SLOT(copyAs())); 339 QTimer::singleShot(125,this,SLOT(copyAs()));
340} 340}
341 341
342void AdvancedFm::copyAs() { 342void AdvancedFm::copyAs() {
343 343
344 QStringList curFileList = getPath(); 344 QStringList curFileList = getPath();
345 QString curFile, item; 345 QString curFile, item;
346 InputDialog *fileDlg; 346 InputDialog *fileDlg;
347 347
348 QDir *thisDir = CurrentDir(); 348 QDir *thisDir = CurrentDir();
349 QDir *thatDir = OtherDir(); 349 QDir *thatDir = OtherDir();
350 350
351 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 351 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
352 QString destFile; 352 QString destFile;
353 item=(*it); 353 item=(*it);
354 curFile = thisDir->canonicalPath()+"/"+(*it); 354 curFile = thisDir->canonicalPath()+"/"+(*it);
355 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); 355 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0);
356 356
357 fileDlg->setInputText((const QString &) destFile ); 357 fileDlg->setInputText((const QString &) destFile );
358 fileDlg->exec(); 358 fileDlg->exec();
359 359
360 if( fileDlg->result() == 1 ) { 360 if( fileDlg->result() == 1 ) {
361 QString filename = fileDlg->LineEdit1->text(); 361 QString filename = fileDlg->LineEdit1->text();
362 destFile = thatDir->canonicalPath()+"/"+filename; 362 destFile = thatDir->canonicalPath()+"/"+filename;
363 363
364 QFile f( destFile); 364 QFile f( destFile);
365 if( f.exists()) { 365 if( f.exists()) {
366 switch (QMessageBox::warning(this,tr("File Exists!"), 366 switch (QMessageBox::warning(this,tr("File Exists!"),
367 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), 367 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item),
368 tr("Yes"),tr("No"),0,0,1) ) { 368 tr("Yes"),tr("No"),0,0,1) ) {
369 case 0: 369 case 0:
370 f.remove(); 370 f.remove();
371 break; 371 break;
372 case 1: 372 case 1:
373 return; 373 return;
374 break; 374 break;
375 }; 375 };
376 } 376 }
377 if( !copyFile( curFile, destFile) ) { 377 if( !copyFile( curFile, destFile) ) {
378 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 378 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
379 return; 379 return;
380 } 380 }
381 } 381 }
382 delete fileDlg; 382 delete fileDlg;
383 383
384 } 384 }
385 rePopulate(); 385 rePopulate();
386 // setOtherTabCurrent(); 386 // setOtherTabCurrent();
387 qApp->processEvents(); 387 qApp->processEvents();
388 388
389} 389}
390 390
391void AdvancedFm::copySameDirTimer() { 391void AdvancedFm::copySameDirTimer() {
392 QTimer::singleShot(125,this,SLOT(copySameDir())); 392 QTimer::singleShot(125,this,SLOT(copySameDir()));
393} 393}
394 394
395void AdvancedFm::copySameDir() { 395void AdvancedFm::copySameDir() {
396 qApp->processEvents(); 396 qApp->processEvents();
397 QStringList curFileList = getPath(); 397 QStringList curFileList = getPath();
398 QString curFile, item, destFile; 398 QString curFile, item, destFile;
399 InputDialog *fileDlg; 399 InputDialog *fileDlg;
400 400
401 QDir *thisDir = CurrentDir(); 401 QDir *thisDir = CurrentDir();
402 402
403 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 403 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
404 item=(*it); 404 item=(*it);
405 curFile = thisDir->canonicalPath()+"/"+ item; 405 curFile = thisDir->canonicalPath()+"/"+ item;
406 406
407 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 407 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
408 fileDlg->setInputText((const QString &) destFile ); 408 fileDlg->setInputText((const QString &) destFile );
409 fileDlg->exec(); 409 fileDlg->exec();
410 410
411 if( fileDlg->result() == 1 ) { 411 if( fileDlg->result() == 1 ) {
412 412
413 QString filename = fileDlg->LineEdit1->text(); 413 QString filename = fileDlg->LineEdit1->text();
414 destFile = thisDir->canonicalPath()+"/"+filename; 414 destFile = thisDir->canonicalPath()+"/"+filename;
415 415
416 QFile f(destFile); 416 QFile f(destFile);
417 if( f.exists()) { 417 if( f.exists()) {
418 switch (QMessageBox::warning(this,tr("Delete"), 418 switch (QMessageBox::warning(this,tr("Delete"),
419 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), 419 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile),
420 tr("Yes"),tr("No"),0,0,1) ) { 420 tr("Yes"),tr("No"),0,0,1) ) {
421 case 0: 421 case 0:
422 422
423 f.remove(); 423 f.remove();
424 break; 424 break;
425 case 1: 425 case 1:
426 return; 426 return;
427 break; 427 break;
428 }; 428 };
429 } 429 }
430 if(!copyFile( curFile,destFile) ) { 430 if(!copyFile( curFile,destFile) ) {
431 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 431 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
432 return; 432 return;
433 } 433 }
434 434
435// odebug << "copy "+curFile+" as "+destFile << oendl; 435// odebug << "copy "+curFile+" as "+destFile << oendl;
436 } 436 }
437 delete fileDlg; 437 delete fileDlg;
438 } 438 }
439 rePopulate(); 439 rePopulate();
440} 440}
441 441
442void AdvancedFm::moveTimer() { 442void AdvancedFm::moveTimer() {
443 QTimer::singleShot(125,this,SLOT(move())); 443 QTimer::singleShot(125,this,SLOT(move()));
444} 444}
445 445
446void AdvancedFm::move() { 446void AdvancedFm::move() {
447 447
448 QStringList curFileList = getPath(); 448 QStringList curFileList = getPath();
449 if( curFileList.count() > 0) { 449 if( curFileList.count() > 0) {
450 QString curFile, destFile, item; 450 QString curFile, destFile, item;
451 451
452 QDir *thisDir = CurrentDir(); 452 QDir *thisDir = CurrentDir();
453 QDir *thatDir = OtherDir(); 453 QDir *thatDir = OtherDir();
454 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 454 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
455 item=(*it); 455 item=(*it);
456 QString destFile = thatDir->canonicalPath(); 456 QString destFile = thatDir->canonicalPath();
457 457
458 if(destFile.right(1).find("/",0,TRUE) == -1) 458 if(destFile.right(1).find("/",0,TRUE) == -1)
459 destFile+="/"; 459 destFile+="/";
460 destFile += item; 460 destFile += item;
461// odebug << "Destination file is "+destFile << oendl; 461// odebug << "Destination file is "+destFile << oendl;
462 462
463 curFile = thisDir->canonicalPath(); 463 curFile = thisDir->canonicalPath();
464 if(curFile.right(1).find("/",0,TRUE) == -1) 464 if(curFile.right(1).find("/",0,TRUE) == -1)
465 curFile +="/"; 465 curFile +="/";
466 curFile+= item; 466 curFile+= item;
467// odebug << "CurrentFile file is " + curFile << oendl; 467// odebug << "CurrentFile file is " + curFile << oendl;
468 468
469 if(QFileInfo(curFile).isDir()) { 469 if(QFileInfo(curFile).isDir()) {
470 moveDirectory( curFile, destFile ); 470 moveDirectory( curFile, destFile );
471 rePopulate(); 471 rePopulate();
472 return; 472 return;
473 } 473 }
474 QFile f( curFile); 474 QFile f( destFile);
475 if( f.exists()) { 475 if( f.exists()) {
476 if( !copyFile( curFile, destFile) ) { 476 switch ( QMessageBox::warning(this,tr("File Exists!"),
477 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 477 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile),
478 return; 478 tr("Yes"),tr("No"),0,0,1)) {
479 } else 479 case 1:
480 QFile::remove(curFile); 480 return;
481 } 481 break;
482 } 482 };
483 483 if( !copyFile( curFile, destFile) ) {
484 } 484 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile));
485 rePopulate(); 485 return;
486 } else
487 QFile::remove(curFile);
488 }
489 }
490 }
491 rePopulate();
486 //setOtherTabCurrent(); 492 //setOtherTabCurrent();
487} 493}
488 494
489bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 495bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
490 int err = 0; 496 int err = 0;
491 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; 497 if( copyDirectory( src, dest ) ) {
492 err = system((const char*)cmd); 498 QString cmd = "rm -rf " + src;
493 } else 499 err = system((const char*)cmd);
494 err = -1; 500 } else
495 501 err = -1;
496 if(err!=0) { 502
497 QMessageBox::message(tr("Note"),tr("Could not move\n") + src); 503 if(err!=0) {
498 return false; 504 QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
499 } 505 return false;
500 return true; 506 }
507 return true;
501} 508}
502 509
503bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 510bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
504 511
505 QString cmd = "/bin/cp -fpR " + src + " " + dest; 512 QString cmd = "/bin/cp -fpR " + src + " " + dest;
506 owarn << cmd << oendl; 513 owarn << cmd << oendl;
507 int err = system( (const char *) cmd ); 514 int err = system( (const char *) cmd );
508 if ( err != 0 ) { 515 if ( err != 0 ) {
509 QMessageBox::message("AdvancedFm", 516 QMessageBox::message("AdvancedFm", tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
510 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); 517 return false;
511 return false; 518 }
512 }
513 519
514 return true; 520 return true;
515} 521}
516 522
517 523
518bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 524bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
519 if(QFileInfo(src).isDir()) { 525 if(QFileInfo(src).isDir()) {
520 if( copyDirectory( src, dest )) { 526 if( copyDirectory( src, dest )) {
521 // setOtherTabCurrent(); 527 // setOtherTabCurrent();
522 rePopulate(); 528 rePopulate();
523 return true; 529 return true;
524 } 530 }
525 else 531 else
526 return false; 532 return false;
527 } 533 }
528 534
529 535
530 bool success = true; 536 bool success = true;
531 struct stat status; 537 struct stat status;
532 QFile srcFile(src); 538 QFile srcFile(src);
533 QFile destFile(dest); 539 QFile destFile(dest);
534 int err=0; 540 int err=0;
535 int read_fd=0; 541 int read_fd=0;
536 int write_fd=0; 542 int write_fd=0;
537 struct stat stat_buf; 543 struct stat stat_buf;
538 off_t offset = 0; 544 off_t offset = 0;
539 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 545 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
540// owarn << "open failed" << oendl; 546// owarn << "open failed" << oendl;
541 return success = false; 547 return success = false;
542 } 548 }
543 read_fd = srcFile.handle(); 549 read_fd = srcFile.handle();
544 if(read_fd != -1) { 550 if(read_fd != -1) {
545 fstat (read_fd, &stat_buf); 551 fstat (read_fd, &stat_buf);
546 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 552 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
547// owarn << "destfile open failed" << oendl; 553// owarn << "destfile open failed" << oendl;
548 return success = false; 554 return success = false;
549 } 555 }
550 write_fd = destFile.handle(); 556 write_fd = destFile.handle();
551 if(write_fd != -1) { 557 if(write_fd != -1) {
552 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 558 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
553 if( err == -1) { 559 if( err == -1) {
554 QString msg; 560 QString msg;
555 switch(err) { 561 switch(err) {
556 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 562 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
557 case EINVAL: msg = "Descriptor is not valid or locked. "; 563 case EINVAL: msg = "Descriptor is not valid or locked. ";
558 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 564 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
559 case EIO: msg = "Unspecified error while reading from in_fd."; 565 case EIO: msg = "Unspecified error while reading from in_fd.";
560 }; 566 };
561 success = false; 567 success = false;
562// owarn << msg << oendl; 568// owarn << msg << oendl;
563 } 569 }
564 } else { 570 } else {
565 success = false; 571 success = false;
566 } 572 }
567 } else { 573 } else {
568 success = false; 574 success = false;
569 } 575 }
570 srcFile.close(); 576 srcFile.close();
571 destFile.close(); 577 destFile.close();
572 // Set file permissions 578 // Set file permissions
573 if( stat( QFile::encodeName(src), &status ) == 0 ) { 579 if( stat( QFile::encodeName(src), &status ) == 0 ) {
574 chmod( QFile::encodeName(dest), status.st_mode ); 580 chmod( QFile::encodeName(dest), status.st_mode );
575 } 581 }
576 582
577 return success; 583 return success;
578} 584}
579 585
580void AdvancedFm::runCommand() { 586void AdvancedFm::runCommand() {
581 if( !CurrentView()->currentItem()) return; 587 if( !CurrentView()->currentItem()) return;
582 QDir *thisDir = CurrentDir(); 588 QDir *thisDir = CurrentDir();
583 589
584 QString curFile; 590 QString curFile;
585 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 591 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
586 592
587 InputDialog *fileDlg; 593 InputDialog *fileDlg;
588 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 594 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
589 fileDlg->setInputText(curFile); 595 fileDlg->setInputText(curFile);
590 fileDlg->exec(); 596 fileDlg->exec();
591 //QString command; 597 //QString command;
592 598
593 if( fileDlg->result() == 1 ) { 599 if( fileDlg->result() == 1 ) {
594// odebug << fileDlg->LineEdit1->text() << oendl; 600// odebug << fileDlg->LineEdit1->text() << oendl;
595 QStringList command; 601 QStringList command;
596 602
597 command << "/bin/sh"; 603 command << "/bin/sh";
598 command << "-c"; 604 command << "-c";
599 command << fileDlg->LineEdit1->text(); 605 command << fileDlg->LineEdit1->text();
600 Output *outDlg; 606 Output *outDlg;
601 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 607 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
602 QPEApplication::execDialog( outDlg ); 608 QPEApplication::execDialog( outDlg );
603 qApp->processEvents(); 609 qApp->processEvents();
604 610
605 } 611 }
606} 612}
607 613
608void AdvancedFm::runCommandStd() { 614void AdvancedFm::runCommandStd() {
609 if( !CurrentView()->currentItem()) return; 615 if( !CurrentView()->currentItem()) return;
610 QString curFile; 616 QString curFile;
611 QDir *thisDir = CurrentDir(); 617 QDir *thisDir = CurrentDir();
612 QListView *thisView = CurrentView(); 618 QListView *thisView = CurrentView();
613 if( thisView->currentItem()) 619 if( thisView->currentItem())
614 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 620 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
615 621
616 InputDialog *fileDlg; 622 InputDialog *fileDlg;
617 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 623 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
618 fileDlg->setInputText(curFile); 624 fileDlg->setInputText(curFile);
619 fileDlg->exec(); 625 fileDlg->exec();
620 626
621 if( fileDlg->result() == 1 ) { 627 if( fileDlg->result() == 1 ) {
622 qApp->processEvents(); 628 qApp->processEvents();
623 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 629 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
624 } 630 }
625} 631}
626 632
627void AdvancedFm::fileStatus() { 633void AdvancedFm::fileStatus() {
628 if( !CurrentView()->currentItem()) return; 634 if( !CurrentView()->currentItem()) return;
629 QString curFile; 635 QString curFile;
630 curFile = CurrentView()->currentItem()->text(0); 636 curFile = CurrentView()->currentItem()->text(0);
631 637
632 QStringList command; 638 QStringList command;
633 command << "/bin/sh"; 639 command << "/bin/sh";
634 command << "-c"; 640 command << "-c";
635 command << "stat -l "+ curFile; 641 command << "stat -l "+ curFile;
636 642
637 Output *outDlg; 643 Output *outDlg;
638 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 644 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
639 QPEApplication::execDialog( outDlg ); 645 QPEApplication::execDialog( outDlg );
640 qApp->processEvents(); 646 qApp->processEvents();
641} 647}
642 648
643 649
644void AdvancedFm::mkDir() { 650void AdvancedFm::mkDir() {
645 makeDir(); 651 makeDir();
646} 652}
647 653
648void AdvancedFm::rn() { 654void AdvancedFm::rn() {
649 renameIt(); 655 renameIt();
650} 656}
651 657
652void AdvancedFm::del() { 658void AdvancedFm::del() {
653 doDelete(); 659 doDelete();
654} 660}
655 661
656void AdvancedFm::mkSym() { 662void AdvancedFm::mkSym() {
657 QString cmd; 663 QString cmd;
658 QStringList curFileList = getPath(); 664 QStringList curFileList = getPath();
659 if( curFileList.count() > 0) { 665 if( curFileList.count() > 0) {
660 QDir *thisDir = CurrentDir(); 666 QDir *thisDir = CurrentDir();
661 QDir * thatDir = OtherDir(); 667 QDir * thatDir = OtherDir();
662 668
663 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 669 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
664 670
665 QString destName = thatDir->canonicalPath()+"/"+(*it); 671 QString destName = thatDir->canonicalPath()+"/"+(*it);
666 if(destName.right(1) == "/") { 672 if(destName.right(1) == "/") {
667 destName = destName.left( destName.length() -1); 673 destName = destName.left( destName.length() -1);
668 } 674 }
669 675
670 QString curFile = thisDir->canonicalPath()+"/"+(*it); 676 QString curFile = thisDir->canonicalPath()+"/"+(*it);
671 677
672 if( curFile.right(1) == "/") { 678 if( curFile.right(1) == "/") {
673 curFile = curFile.left( curFile.length() -1); 679 curFile = curFile.left( curFile.length() -1);
674 } 680 }
675 681
676 cmd = "ln -s "+curFile+" "+destName; 682 cmd = "ln -s "+curFile+" "+destName;
677// odebug << cmd << oendl; 683// odebug << cmd << oendl;
678 startProcess( (const QString)cmd ); 684 startProcess( (const QString)cmd );
679 } 685 }
680 rePopulate(); 686 rePopulate();
681 setOtherTabCurrent(); 687 setOtherTabCurrent();
682 } 688 }
683} 689}
684 690
685void AdvancedFm::doBeam() { 691void AdvancedFm::doBeam() {
686 Ir ir; 692 Ir ir;
687 if(!ir.supported()) { 693 if(!ir.supported()) {
688 } else { 694 } else {
689 QStringList curFileList = getPath(); 695 QStringList curFileList = getPath();
690 if( curFileList.count() > 0) { 696 if( curFileList.count() > 0) {
691 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 697 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
692 QString curFile = (*it); 698 QString curFile = (*it);
693 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 699 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
694 if( curFilePath.right(1) == "/") { 700 if( curFilePath.right(1) == "/") {
695 curFilePath = curFilePath.left( curFilePath.length() -1); 701 curFilePath = curFilePath.left( curFilePath.length() -1);
696 } 702 }
697 Ir *file = new Ir(this, "IR"); 703 Ir *file = new Ir(this, "IR");
698 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); 704 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
699 file->send( curFilePath, curFile ); 705 file->send( curFilePath, curFile );
700 } 706 }
701 } 707 }
702 } 708 }
703} 709}
704 710
705void AdvancedFm::fileBeamFinished( Ir *) { 711void AdvancedFm::fileBeamFinished( Ir *) {
706 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 712 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
707} 713}
708 714
709void AdvancedFm::selectAll() { 715void AdvancedFm::selectAll() {
710 QListView *thisView = CurrentView(); 716 QListView *thisView = CurrentView();
711 thisView->selectAll(true); 717 thisView->selectAll(true);
712 thisView->setSelected( thisView->firstChild(),false); 718 thisView->setSelected( thisView->firstChild(),false);
713} 719}
714 720
715void AdvancedFm::startProcess(const QString & cmd) { 721void AdvancedFm::startProcess(const QString & cmd) {
716 QStringList command; 722 QStringList command;
717 OProcess *process; 723 OProcess *process;
718 process = new OProcess(); 724 process = new OProcess();
719 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); 725 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*)));
720 726
721 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); 727 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
722 728
723 command << "/bin/sh"; 729 command << "/bin/sh";
724 command << "-c"; 730 command << "-c";
725 command << cmd.latin1(); 731 command << cmd.latin1();
726 *process << command; 732 *process << command;
727 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 733 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
728 odebug << "could not start process" << oendl; 734 odebug << "could not start process" << oendl;
729} 735}
730 736
731void AdvancedFm::processEnded(OProcess *) { 737void AdvancedFm::processEnded(OProcess *) {
732 rePopulate(); 738 rePopulate();
733} 739}
734 740
735void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 741void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
736// owarn << "received stderrt " << buflen << " bytes" << oendl; 742// owarn << "received stderrt " << buflen << " bytes" << oendl;
737 743
738 QString lineStr = buffer; 744 QString lineStr = buffer;
739 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 745 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
740} 746}
741 747
742bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 748bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
743 if ( o->inherits( "QLineEdit" ) ) { 749 if ( o->inherits( "QLineEdit" ) ) {
744 if ( e->type() == QEvent::KeyPress ) { 750 if ( e->type() == QEvent::KeyPress ) {
745 QKeyEvent *ke = (QKeyEvent*)e; 751 QKeyEvent *ke = (QKeyEvent*)e;
746 if ( ke->key() == Key_Return || 752 if ( ke->key() == Key_Return ||
747 ke->key() == Key_Enter ) { 753 ke->key() == Key_Enter ) {
748 okRename(); 754 okRename();
749 return true; 755 return true;
750 } 756 }
751 else if ( ke->key() == Key_Escape ) { 757 else if ( ke->key() == Key_Escape ) {
752 cancelRename(); 758 cancelRename();
753 return true; 759 return true;
754 } 760 }
755 } 761 }
756 else if ( e->type() == QEvent::FocusOut ) { 762 else if ( e->type() == QEvent::FocusOut ) {
757 cancelRename(); 763 cancelRename();
758 return true; 764 return true;
759 } 765 }
760 } 766 }
761/* if ( o->inherits( "QListView" ) ) { 767/* if ( o->inherits( "QListView" ) ) {
762 if ( e->type() == QEvent::FocusIn ) { 768 if ( e->type() == QEvent::FocusIn ) {
763// if( o == Local_View) { //keep track of which view 769// if( o == Local_View) { //keep track of which view
764 // qDebug("local view"); 770 // qDebug("local view");
765// whichTab = 1; 771// whichTab = 1;
766// } else { 772// } else {
767// whichTab = 2; 773// whichTab = 2;
768 // qDebug("remote view"); 774 // qDebug("remote view");
769// } 775// }
770 } 776 }
771 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 777 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
772 } 778 }
773*/ 779*/
774 return QWidget::eventFilter( o, e ); 780 return QWidget::eventFilter( o, e );
775} 781}
776 782
777 783
778void AdvancedFm::cancelRename() { 784void AdvancedFm::cancelRename() {
779// odebug << "cancel rename" << oendl; 785// odebug << "cancel rename" << oendl;
780 QListView * view; 786 QListView * view;
781 view = CurrentView(); 787 view = CurrentView();
782 788
783 bool resetFocus = view->viewport()->focusProxy() == renameBox; 789 bool resetFocus = view->viewport()->focusProxy() == renameBox;
784 delete renameBox; 790 delete renameBox;
785 renameBox = 0; 791 renameBox = 0;
786 if ( resetFocus ) { 792 if ( resetFocus ) {
787 view->viewport()->setFocusProxy( view); 793 view->viewport()->setFocusProxy( view);
788 view->setFocus(); 794 view->setFocus();
789 } 795 }
790} 796}
791 797
792void AdvancedFm::doRename(QListView * view) { 798void AdvancedFm::doRename(QListView * view) {
793 if( !CurrentView()->currentItem()) return; 799 if( !CurrentView()->currentItem()) return;
794 800
795 QRect r = view->itemRect( view->currentItem( )); 801 QRect r = view->itemRect( view->currentItem( ));
796 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 802 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
797 r.setX( view->contentsX() ); 803 r.setX( view->contentsX() );
798 if ( r.width() > view->visibleWidth() ) 804 if ( r.width() > view->visibleWidth() )
799 r.setWidth( view->visibleWidth() ); 805 r.setWidth( view->visibleWidth() );
800 806
801 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 807 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
802 renameBox->setFrame(true); 808 renameBox->setFrame(true);
803 renameBox->setText( view->currentItem()->text(0) ); 809 renameBox->setText( view->currentItem()->text(0) );
804 renameBox->selectAll(); 810 renameBox->selectAll();
805 renameBox->installEventFilter( this ); 811 renameBox->installEventFilter( this );
806 view->addChild( renameBox, r.x(), r.y() ); 812 view->addChild( renameBox, r.x(), r.y() );
807 renameBox->resize( r.size() ); 813 renameBox->resize( r.size() );
808 view->viewport()->setFocusProxy( renameBox ); 814 view->viewport()->setFocusProxy( renameBox );
809 renameBox->setFocus(); 815 renameBox->setFocus();
810 renameBox->show(); 816 renameBox->show();
811} 817}
812 818
813 819
814void AdvancedFm::renameIt() { 820void AdvancedFm::renameIt() {
815 if( !CurrentView()->currentItem()) return; 821 if( !CurrentView()->currentItem()) return;
816 822
817 QListView *thisView = CurrentView(); 823 QListView *thisView = CurrentView();
818 oldName = thisView->currentItem()->text(0); 824 oldName = thisView->currentItem()->text(0);
819 doRename( thisView ); 825 doRename( thisView );
820} 826}
821 827
822void AdvancedFm::okRename() { 828void AdvancedFm::okRename() {
823 qDebug("okrename"); 829 qDebug("okrename");
824 if( !renameBox) return; 830 if( !renameBox) return;
825 831
826 QString newName = renameBox->text(); 832 QString newName = renameBox->text();
827 cancelRename(); 833 cancelRename();
828 QListView * view = CurrentView(); 834 QListView * view = CurrentView();
829 QString path = CurrentDir()->canonicalPath() + "/"; 835 QString path = CurrentDir()->canonicalPath() + "/";
830 oldName = path + oldName; 836 oldName = path + oldName;
831 newName = path + newName; 837 newName = path + newName;
832 if( rename( oldName.latin1(), newName.latin1())== -1) 838 if( rename( oldName.latin1(), newName.latin1())== -1)
833 QMessageBox::message(tr("Note"),tr("Could not rename")); 839 QMessageBox::message(tr("Note"),tr("Could not rename"));
834 else 840 else
835 oldName = ""; 841 oldName = "";
836 QListViewItem *item = view->currentItem(); 842 QListViewItem *item = view->currentItem();
837 view->takeItem( item ); 843 view->takeItem( item );
838 delete item; 844 delete item;
839 rePopulate(); 845 rePopulate();
840} 846}
841 847
842void AdvancedFm::openSearch() { 848void AdvancedFm::openSearch() {
843 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 849 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
844} 850}