summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-02-21 22:44:28 (UTC)
committer llornkcor <llornkcor>2003-02-21 22:44:28 (UTC)
commita7448ec87d97a0128618e83ad7526bd884ef8853 (patch) (unidiff)
tree0dda2db8da959c26d0ec089bec161ae28486d2cc
parentd48baa03492fd4785ca273defb4e21bf8c0d1c08 (diff)
downloadopie-a7448ec87d97a0128618e83ad7526bd884ef8853.zip
opie-a7448ec87d97a0128618e83ad7526bd884ef8853.tar.gz
opie-a7448ec87d97a0128618e83ad7526bd884ef8853.tar.bz2
fix rename cancel.. hehehe
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp34
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp26
2 files changed, 45 insertions, 15 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index c653b90..9edf7c1 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -6,128 +6,130 @@
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#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#include "advancedfm.h" 13#include "advancedfm.h"
14 14
15#include <opie/otabwidget.h> 15#include <opie/otabwidget.h>
16// #include <opie/ofileselector.h> 16// #include <opie/ofileselector.h>
17// #include <opie/ofiledialog.h> 17// #include <opie/ofiledialog.h>
18 18
19#include <qpe/filemanager.h> 19#include <qpe/filemanager.h>
20#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/mimetype.h> 26#include <qpe/mimetype.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/ir.h> 28#include <qpe/ir.h>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30 30
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qdir.h> 35#include <qdir.h>
36#include <qfile.h> 36#include <qfile.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qlistview.h> 40#include <qlistview.h>
41#include <qmainwindow.h> 41#include <qmainwindow.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qprogressbar.h> 43#include <qprogressbar.h>
44#include <qspinbox.h> 44#include <qspinbox.h>
45#include <qwidget.h> 45#include <qwidget.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qimage.h> 47#include <qimage.h>
48#include <qpixmap.h> 48#include <qpixmap.h>
49#include <qmessagebox.h> 49#include <qmessagebox.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qregexp.h> 51#include <qregexp.h>
52 52
53#include <unistd.h> 53#include <unistd.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <sys/stat.h> 55#include <sys/stat.h>
56#include <dirent.h> 56#include <dirent.h>
57#include <stdio.h> 57#include <stdio.h>
58#include <time.h> 58#include <time.h>
59#include <fcntl.h> 59#include <fcntl.h>
60#include <mntent.h> 60#include <mntent.h>
61#include <string.h> 61#include <string.h>
62#include <errno.h> 62#include <errno.h>
63#include <sys/vfs.h> 63#include <sys/vfs.h>
64#include <mntent.h> 64#include <mntent.h>
65#include <sys/utsname.h> 65#include <sys/utsname.h>
66 66
67AdvancedFm::AdvancedFm( ) 67AdvancedFm::AdvancedFm( )
68 : QMainWindow( ) { 68 : QMainWindow( ) {
69 init(); 69 init();
70 renameBox = 0;
71
70 initConnections(); 72 initConnections();
71 populateLocalView(); 73 populateLocalView();
72 populateRemoteView(); 74 populateRemoteView();
73 currentPathCombo->setFocus(); 75 currentPathCombo->setFocus();
74} 76}
75 77
76AdvancedFm::~AdvancedFm() { 78AdvancedFm::~AdvancedFm() {
77} 79}
78 80
79void AdvancedFm::cleanUp() { 81void AdvancedFm::cleanUp() {
80 QString sfile=QDir::homeDirPath(); 82 QString sfile=QDir::homeDirPath();
81 if(sfile.right(1) != "/") 83 if(sfile.right(1) != "/")
82 sfile+="/._temp"; 84 sfile+="/._temp";
83 else 85 else
84 sfile+="._temp"; 86 sfile+="._temp";
85 QFile file( sfile); 87 QFile file( sfile);
86 if(file.exists()) 88 if(file.exists())
87 file.remove(); 89 file.remove();
88} 90}
89 91
90void AdvancedFm::tabChanged(QWidget *w) { 92void AdvancedFm::tabChanged(QWidget *w) {
91 qDebug("tab changed %d",TabWidget->getCurrentTab()); 93 qDebug("tab changed %d",TabWidget->getCurrentTab());
92 94
93 if ( w == tab) { 95 if ( w == tab) {
94// if (TabWidget->getCurrentTab() == 0) { 96// if (TabWidget->getCurrentTab() == 0) {
95// if (TabWidget->currentPageIndex() == 0) { 97// if (TabWidget->currentPageIndex() == 0) {
96 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 98 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
97 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 99 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
98 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 100 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
99 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 101 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
100 setCaption("AdvancedFm :: "+fs+" :: " 102 setCaption("AdvancedFm :: "+fs+" :: "
101 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 103 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
102 104
103 } 105 }
104 if ( w == tab_2) { 106 if ( w == tab_2) {
105// if (TabWidget->getCurrentTab() == 1) { 107// if (TabWidget->getCurrentTab() == 1) {
106 108
107// if (TabWidget->currentPageIndex() == 1) { 109// if (TabWidget->currentPageIndex() == 1) {
108 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 110 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
109 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 111 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
110 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 112 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
111 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 113 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
112 setCaption("AdvancedFm :: "+fs+" :: " 114 setCaption("AdvancedFm :: "+fs+" :: "
113 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 115 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
114 } 116 }
115} 117}
116 118
117 119
118void AdvancedFm::populateLocalView() { 120void AdvancedFm::populateLocalView() {
119 QPixmap pm; 121 QPixmap pm;
120 Local_View->clear(); 122 Local_View->clear();
121 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 123 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
122 currentDir.setMatchAllDirs(TRUE); 124 currentDir.setMatchAllDirs(TRUE);
123 currentDir.setNameFilter(filterStr); 125 currentDir.setNameFilter(filterStr);
124 QString fileL, fileS, fileDate; 126 QString fileL, fileS, fileDate;
125 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 127 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
126 setCaption("AdvancedFm :: "+fs+" :: " 128 setCaption("AdvancedFm :: "+fs+" :: "
127 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 129 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
128 bool isDir=FALSE; 130 bool isDir=FALSE;
129 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 131 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
130 QFileInfoListIterator it(*list); 132 QFileInfoListIterator it(*list);
131 QFileInfo *fi; 133 QFileInfo *fi;
132 while ( (fi=it.current()) ) { 134 while ( (fi=it.current()) ) {
133 if (fi->isSymLink() ) { 135 if (fi->isSymLink() ) {
@@ -341,146 +343,161 @@ void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
341 populateLocalView(); 343 populateLocalView();
342 } 344 }
343 } else { 345 } else {
344 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 346 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
345 if( QFile::exists(strItem ) ) { 347 if( QFile::exists(strItem ) ) {
346 // qDebug("clicked item "+strItem); 348 // qDebug("clicked item "+strItem);
347 // DocLnk doc( strItem, FALSE ); 349 // DocLnk doc( strItem, FALSE );
348 // doc.execute(); 350 // doc.execute();
349 // Local_View->clearSelection(); 351 // Local_View->clearSelection();
350 } 352 }
351 } //end not symlink 353 } //end not symlink
352 chdir(strItem.latin1()); 354 chdir(strItem.latin1());
353 } 355 }
354 356
355 } 357 }
356} 358}
357 359
358void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { 360void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
359 361
360 if(selectedItem) { 362 if(selectedItem) {
361 QString strItem=selectedItem->text(0); 363 QString strItem=selectedItem->text(0);
362 QString strSize=selectedItem->text(1); 364 QString strSize=selectedItem->text(1);
363 strSize=strSize.stripWhiteSpace(); 365 strSize=strSize.stripWhiteSpace();
364 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 366 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
365 QString strItem2 = dealWithSymName((const QString&)strItem); 367 QString strItem2 = dealWithSymName((const QString&)strItem);
366// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 368// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
367 currentRemoteDir.cd(strItem2, TRUE); 369 currentRemoteDir.cd(strItem2, TRUE);
368 populateRemoteView(); 370 populateRemoteView();
369 } else { // not a symlink 371 } else { // not a symlink
370 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 372 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
371 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 373 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
372 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 374 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
373 currentRemoteDir.cd(strItem,FALSE); 375 currentRemoteDir.cd(strItem,FALSE);
374 populateRemoteView(); 376 populateRemoteView();
375 Remote_View->ensureItemVisible(Remote_View->firstChild()); 377 Remote_View->ensureItemVisible(Remote_View->firstChild());
376 } else { 378 } else {
377 currentRemoteDir.cdUp(); 379 currentRemoteDir.cdUp();
378 populateRemoteView(); 380 populateRemoteView();
379 Remote_View->ensureItemVisible(Remote_View->firstChild()); 381 Remote_View->ensureItemVisible(Remote_View->firstChild());
380 } 382 }
381 if(QDir(strItem).exists()){ 383 if(QDir(strItem).exists()){
382 currentRemoteDir.cd(strItem, TRUE); 384 currentRemoteDir.cd(strItem, TRUE);
383 populateRemoteView(); 385 populateRemoteView();
384 Remote_View->ensureItemVisible(Remote_View->firstChild()); 386 Remote_View->ensureItemVisible(Remote_View->firstChild());
385 } 387 }
386 } else { 388 } else {
387 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 389 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
388 if( QFile::exists(strItem ) ) { 390 if( QFile::exists(strItem ) ) {
389 // qDebug("clicked item "+strItem); 391 // qDebug("clicked item "+strItem);
390 // DocLnk doc( strItem, FALSE ); 392 // DocLnk doc( strItem, FALSE );
391 // doc.execute(); 393 // doc.execute();
392 // Remote_View->clearSelection(); 394 // Remote_View->clearSelection();
393 } 395 }
394 } //end not symlink 396 } //end not symlink
395 chdir(strItem.latin1()); 397 chdir(strItem.latin1());
396 } 398 }
397 } 399 }
398} 400}
399 401
400 402
401void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 403void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
402// qDebug("list pressed"); 404// qDebug("list pressed");
403 switch (mouse) { 405 switch (mouse) {
404 case 1: 406 case 1:
407 {
408 if(renameBox != 0 )
409 {
410 qDebug("cancel rename");
411 cancelRename();
412 }
413
414 }
405 break; 415 break;
406 case 2: 416 case 2:
407 menuTimer.start( 500, TRUE ); 417 menuTimer.start( 500, TRUE );
408 qDebug("Start menu timer\n"); 418 qDebug("Start menu timer\n");
409 break; 419 break;
410 }; 420 };
411} 421}
412 422
413void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 423void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
414 424
415 switch (mouse) { 425 switch (mouse) {
416 case 1: 426 case 1:
417 break; 427 {
418 case 2: 428 if(renameBox != 0 )
419 menuTimer.start( 500, TRUE ); 429 {
420 qDebug("Start menu timer"); 430 qDebug("cancel rename");
421 break; 431 cancelRename();
422 }; 432 }
433 }
434 break;
435 case 2:
436 menuTimer.start( 500, TRUE );
437 qDebug("Start menu timer");
438 break;
439 };
423} 440}
424 441
425 442
426void AdvancedFm::switchToLocalTab() { 443void AdvancedFm::switchToLocalTab() {
427 TabWidget->setCurrentTab(0); 444 TabWidget->setCurrentTab(0);
428 Local_View->setFocus(); 445 Local_View->setFocus();
429} 446}
430 447
431void AdvancedFm::switchToRemoteTab() { 448void AdvancedFm::switchToRemoteTab() {
432 TabWidget->setCurrentTab(1); 449 TabWidget->setCurrentTab(1);
433 Remote_View->setFocus(); 450 Remote_View->setFocus();
434} 451}
435 452
436void AdvancedFm::readConfig() { 453void AdvancedFm::readConfig() {
437 Config cfg("AdvancedFm"); 454 Config cfg("AdvancedFm");
438} 455}
439 456
440void AdvancedFm::writeConfig() { 457void AdvancedFm::writeConfig() {
441 Config cfg("AdvancedFm"); 458 Config cfg("AdvancedFm");
442} 459}
443 460
444void AdvancedFm::currentPathComboChanged() { 461void AdvancedFm::currentPathComboChanged() {
445 if (TabWidget->getCurrentTab() == 0) { 462 if (TabWidget->getCurrentTab() == 0) {
446// if (TabWidget->currentPageIndex() == 0) { 463// if (TabWidget->currentPageIndex() == 0) {
447 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 464 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
448 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 465 currentDir.setPath( currentPathCombo->lineEdit()->text() );
449 populateLocalView(); 466 populateLocalView();
450 } else { 467 } else {
451 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 468 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
452 } 469 }
453 } 470 }
454 if (TabWidget->getCurrentTab() == 0) { 471 if (TabWidget->getCurrentTab() == 0) {
455// if (TabWidget->currentPageIndex() == 0) { 472// if (TabWidget->currentPageIndex() == 0) {
456 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 473 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
457 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 474 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
458 populateRemoteView(); 475 populateRemoteView();
459 } else { 476 } else {
460 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 477 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
461 } 478 }
462 } 479 }
463} 480}
464 481
465void AdvancedFm::fillCombo(const QString &currentPath) { 482void AdvancedFm::fillCombo(const QString &currentPath) {
466 qDebug("%d",TabWidget->getCurrentTab()); 483 qDebug("%d",TabWidget->getCurrentTab());
467 if (TabWidget->getCurrentTab() == 0) { 484 if (TabWidget->getCurrentTab() == 0) {
468// if (TabWidget->currentPageIndex() == 0) { 485// if (TabWidget->currentPageIndex() == 0) {
469 currentPathCombo->lineEdit()->setText( currentPath); 486 currentPathCombo->lineEdit()->setText( currentPath);
470 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 487 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
471 currentPathCombo->clear(); 488 currentPathCombo->clear();
472 localDirPathStringList.prepend( currentPath ); 489 localDirPathStringList.prepend( currentPath );
473 currentPathCombo->insertStringList( localDirPathStringList,-1); 490 currentPathCombo->insertStringList( localDirPathStringList,-1);
474 } 491 }
475 } else { 492 } else {
476 currentPathCombo->lineEdit()->setText( currentPath); 493 currentPathCombo->lineEdit()->setText( currentPath);
477 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 494 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
478 currentPathCombo->clear(); 495 currentPathCombo->clear();
479 remoteDirPathStringList.prepend( currentPath ); 496 remoteDirPathStringList.prepend( currentPath );
480 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 497 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
481 } 498 }
482 } 499 }
483} 500}
484 501
485void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 502void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
486 if (TabWidget->getCurrentTab() == 0) { 503 if (TabWidget->getCurrentTab() == 0) {
@@ -818,64 +835,65 @@ void AdvancedFm::showFileMenu() {
818 835
819 if(Ir::supported()) 836 if(Ir::supported())
820 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 837 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
821 m->setFocus(); 838 m->setFocus();
822 m->exec( QPoint( 4,QCursor::pos().y()) ); 839 m->exec( QPoint( 4,QCursor::pos().y()) );
823 840
824 if(m) delete m; 841 if(m) delete m;
825} 842}
826 843
827 844
828void AdvancedFm::cancelMenuTimer() { 845void AdvancedFm::cancelMenuTimer() {
829 846
830// qDebug("selectionChanged: cancel menu timer"); 847// qDebug("selectionChanged: cancel menu timer");
831 if( menuTimer.isActive() ) 848 if( menuTimer.isActive() )
832 menuTimer.stop(); 849 menuTimer.stop();
833} 850}
834 851
835QString AdvancedFm::checkDiskSpace(const QString &path) { 852QString AdvancedFm::checkDiskSpace(const QString &path) {
836 struct statfs fss; 853 struct statfs fss;
837 if ( !statfs( path.latin1(), &fss ) ) { 854 if ( !statfs( path.latin1(), &fss ) ) {
838 int blkSize = fss.f_bsize; 855 int blkSize = fss.f_bsize;
839// int totalBlks = fs.f_blocks; 856// int totalBlks = fs.f_blocks;
840 int availBlks = fss.f_bavail; 857 int availBlks = fss.f_bavail;
841 858
842 long mult = blkSize / 1024; 859 long mult = blkSize / 1024;
843 long div = 1024 / blkSize; 860 long div = 1024 / blkSize;
844 if ( !mult ) mult = 1; 861 if ( !mult ) mult = 1;
845 if ( !div ) div = 1; 862 if ( !div ) div = 1;
846 863
847 864
848 return QString::number(availBlks * mult / div); 865 return QString::number(availBlks * mult / div);
849 } 866 }
850 return ""; 867 return "";
851} 868}
852 869
853void AdvancedFm::addToDocs() { 870void AdvancedFm::addToDocs() {
854 QStringList strListPaths = getPath(); 871 QStringList strListPaths = getPath();
855 if( strListPaths.count() > 0) { 872 if( strListPaths.count() > 0) {
856 QString curFile; 873 QString curFile;
857 if (TabWidget->getCurrentTab() == 0) { 874 if (TabWidget->getCurrentTab() == 0) {
858// if (TabWidget->currentPageIndex() == 0) { 875// if (TabWidget->currentPageIndex() == 0) {
859 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 876 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
860 curFile = currentDir.canonicalPath()+"/"+(*it); 877 curFile = currentDir.canonicalPath()+"/"+(*it);
861 qDebug(curFile); 878 qDebug(curFile);
862 DocLnk f; 879 DocLnk f;
863// curFile.replace(QRegExp("\\..*"),""); 880// curFile.replace(QRegExp("\\..*"),"");
864 f.setName((*it)); 881 f.setName((*it));
865 f.setFile( curFile); 882 f.setFile( curFile);
866 f.writeLink(); 883 f.writeLink();
867 } 884 }
868 } else { 885 } else {
869 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 886 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
870 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 887 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
871 qDebug(curFile); 888 qDebug(curFile);
872 889
873 DocLnk f; 890 DocLnk f;
874// curFile.replace(QRegExp("\\..*"),""); 891// curFile.replace(QRegExp("\\..*"),"");
875 f.setName((*it)); 892 f.setName((*it));
876 f.setFile( curFile); 893 f.setFile( curFile);
877 f.writeLink(); 894 f.writeLink();
878 } 895 }
879 } 896 }
880 } 897 }
881} 898}
899
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index f067013..2ddcabc 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -966,160 +966,172 @@ void AdvancedFm::doBeam() {
966 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 966 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
967 Ir *file = new Ir(this, "IR"); 967 Ir *file = new Ir(this, "IR");
968 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 968 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
969 file->send( curFile, curFile ); 969 file->send( curFile, curFile );
970 970
971 } 971 }
972 } 972 }
973 } 973 }
974 } 974 }
975 975
976} 976}
977 977
978void AdvancedFm::fileBeamFinished( Ir *) { 978void AdvancedFm::fileBeamFinished( Ir *) {
979 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 979 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
980 980
981} 981}
982 982
983void AdvancedFm::selectAll() { 983void AdvancedFm::selectAll() {
984 if (TabWidget->getCurrentTab() == 0) { 984 if (TabWidget->getCurrentTab() == 0) {
985 Local_View->selectAll(true); 985 Local_View->selectAll(true);
986 Local_View->setSelected( Local_View->firstChild(),false); 986 Local_View->setSelected( Local_View->firstChild(),false);
987 } else { 987 } else {
988 Remote_View->selectAll(true); 988 Remote_View->selectAll(true);
989 Remote_View->setSelected( Remote_View->firstChild(),false); 989 Remote_View->setSelected( Remote_View->firstChild(),false);
990 } 990 }
991} 991}
992 992
993void AdvancedFm::startProcess(const QString & cmd) { 993void AdvancedFm::startProcess(const QString & cmd) {
994 QStringList command; 994 QStringList command;
995 OProcess *process; 995 OProcess *process;
996 process = new OProcess(); 996 process = new OProcess();
997 connect(process, SIGNAL(processExited(OProcess *)), 997 connect(process, SIGNAL(processExited(OProcess *)),
998 this, SLOT( processEnded())); 998 this, SLOT( processEnded()));
999 999
1000 command << "/bin/sh"; 1000 command << "/bin/sh";
1001 command << "-c"; 1001 command << "-c";
1002 command << cmd.latin1(); 1002 command << cmd.latin1();
1003 *process << command; 1003 *process << command;
1004 if(!process->start(OProcess::NotifyOnExit) ) 1004 if(!process->start(OProcess::NotifyOnExit) )
1005 qDebug("could not start process"); 1005 qDebug("could not start process");
1006} 1006}
1007 1007
1008void AdvancedFm::processEnded() { 1008void AdvancedFm::processEnded() {
1009 populateLocalView(); 1009 populateLocalView();
1010 populateRemoteView(); 1010 populateRemoteView();
1011} 1011}
1012 1012
1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
1014 if ( o->inherits( "QLineEdit" ) ) { 1014 if ( o->inherits( "QLineEdit" ) ) {
1015 if ( e->type() == QEvent::KeyPress ) { 1015 if ( e->type() == QEvent::KeyPress ) {
1016 QKeyEvent *ke = (QKeyEvent*)e; 1016 QKeyEvent *ke = (QKeyEvent*)e;
1017 if ( ke->key() == Key_Return || 1017 if ( ke->key() == Key_Return ||
1018 ke->key() == Key_Enter ) { 1018 ke->key() == Key_Enter ) {
1019 okRename(); 1019 okRename();
1020 return true; 1020 return true;
1021 } else if ( ke->key() == Key_Escape ) { 1021 } else if ( ke->key() == Key_Escape ) {
1022 cancelRename(); 1022 cancelRename();
1023 return true; 1023 return true;
1024 } 1024 }
1025 } else if ( e->type() == QEvent::FocusOut ) { 1025 } else if ( e->type() == QEvent::FocusOut ) {
1026 cancelRename(); 1026 cancelRename();
1027 return true; 1027 return true;
1028 } 1028 }
1029 } 1029 }
1030 if ( o->inherits( "QListView" ) ) {
1031 if ( e->type() == QEvent::FocusOut ) {
1032 printf("focusIn\n");
1033
1034 }
1035 }
1036
1030 return QWidget::eventFilter( o, e ); 1037 return QWidget::eventFilter( o, e );
1031} 1038}
1032 1039
1033 1040
1034void AdvancedFm::cancelRename() { 1041void AdvancedFm::cancelRename()
1042{
1035 qDebug("cancel rename"); 1043 qDebug("cancel rename");
1036 QListView * view; 1044 QListView * view;
1037 if (TabWidget->getCurrentTab() == 0) { 1045 if (TabWidget->getCurrentTab() == 0)
1038 view = Local_View; 1046 {
1039 } 1047 view = Local_View;
1048 }
1040 else 1049 else
1041 { 1050 {
1042 view = Remote_View; 1051 view = Remote_View;
1043 } 1052 }
1044 1053
1045 bool resetFocus = view->viewport()->focusProxy() == renameBox; 1054 bool resetFocus = view->viewport()->focusProxy() == renameBox;
1046 delete renameBox; 1055 delete renameBox;
1047 renameBox = 0; 1056 renameBox = 0;
1048 if ( resetFocus ) { 1057 if ( resetFocus ) {
1049 view->viewport()->setFocusProxy( view); 1058 view->viewport()->setFocusProxy( view);
1050 view->setFocus(); 1059 view->setFocus();
1051 } 1060 }
1052} 1061}
1053 1062
1054void AdvancedFm::doRename(QListView * view) { 1063void AdvancedFm::doRename(QListView * view)
1064{
1055 1065
1056 QRect r = view->itemRect( view->currentItem( )); 1066 QRect r = view->itemRect( view->currentItem( ));
1057 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 1067 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
1058 r.setX( view->contentsX() ); 1068 r.setX( view->contentsX() );
1059 if ( r.width() > view->visibleWidth() ) 1069 if ( r.width() > view->visibleWidth() )
1060 r.setWidth( view->visibleWidth() ); 1070 r.setWidth( view->visibleWidth() );
1061 1071
1062 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 1072 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
1063 renameBox->setFrame(true); 1073 renameBox->setFrame(true);
1064 1074
1065 renameBox->setText( view->currentItem()->text(0) ); 1075 renameBox->setText( view->currentItem()->text(0) );
1066 1076
1067 renameBox->selectAll(); 1077 renameBox->selectAll();
1068 renameBox->installEventFilter( this ); 1078 renameBox->installEventFilter( this );
1069 view->addChild( renameBox, r.x(), r.y() ); 1079 view->addChild( renameBox, r.x(), r.y() );
1070 renameBox->resize( r.size() ); 1080 renameBox->resize( r.size() );
1071 view->viewport()->setFocusProxy( renameBox ); 1081 view->viewport()->setFocusProxy( renameBox );
1072 renameBox->setFocus(); 1082 renameBox->setFocus();
1073 renameBox->show(); 1083 renameBox->show();
1074 1084
1075} 1085}
1076 1086
1077 1087
1078void AdvancedFm::localRename() { 1088void AdvancedFm::localRename()
1089{
1079 oldName = Local_View->currentItem()->text(0); 1090 oldName = Local_View->currentItem()->text(0);
1080 doRename(Local_View ); 1091 doRename(Local_View );
1081 populateLocalView(); 1092 populateLocalView();
1082} 1093}
1083 1094
1084void AdvancedFm::remoteRename() 1095void AdvancedFm::remoteRename()
1085{ 1096{
1086 oldName = Remote_View->currentItem()->text(0); 1097 oldName = Remote_View->currentItem()->text(0);
1087 doRename(Local_View ); 1098 doRename(Local_View );
1088 populateRemoteView(); 1099 populateRemoteView();
1089} 1100}
1090 1101
1091void AdvancedFm::okRename() { 1102void AdvancedFm::okRename()
1103{
1092 QString newName = renameBox->text(); 1104 QString newName = renameBox->text();
1093 cancelRename(); 1105 cancelRename();
1094 int tabs=0; 1106 int tabs=0;
1095 QListView * view; 1107 QListView * view;
1096 tabs = TabWidget->getCurrentTab(); 1108 tabs = TabWidget->getCurrentTab();
1097 if ( tabs == 0) 1109 if ( tabs == 0)
1098 { 1110 {
1099 view = Local_View; 1111 view = Local_View;
1100 QString path = currentDir.canonicalPath() + "/"; 1112 QString path = currentDir.canonicalPath() + "/";
1101 oldName = path + oldName; 1113 oldName = path + oldName;
1102 newName = path + newName; 1114 newName = path + newName;
1103 } 1115 }
1104 else 1116 else
1105 { 1117 {
1106 view = Remote_View; 1118 view = Remote_View;
1107 QString path = currentRemoteDir.canonicalPath() + "/"; 1119 QString path = currentRemoteDir.canonicalPath() + "/";
1108 oldName = path + oldName; 1120 oldName = path + oldName;
1109 newName = path + newName; 1121 newName = path + newName;
1110 } 1122 }
1111 1123
1112 if( view->currentItem() == NULL) 1124 if( view->currentItem() == NULL)
1113 return; 1125 return;
1114 if( rename(oldName.latin1(), newName.latin1())== -1) 1126 if( rename(oldName.latin1(), newName.latin1())== -1)
1115 QMessageBox::message(tr("Note"),tr("Could not rename")); 1127 QMessageBox::message(tr("Note"),tr("Could not rename"));
1116 else 1128 else
1117 oldName = ""; 1129 oldName = "";
1118 1130
1119 view->takeItem( view->currentItem() ); 1131 view->takeItem( view->currentItem() );
1120 delete view->currentItem(); 1132 delete view->currentItem();
1121 if ( tabs == 0) 1133 if ( tabs == 0)
1122 populateLocalView(); 1134 populateLocalView();
1123 else 1135 else
1124 populateRemoteView(); 1136 populateRemoteView();
1125} 1137}