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