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
@@ -54,32 +54,34 @@
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);
@@ -389,50 +391,65 @@ void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
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}
@@ -866,16 +883,17 @@ void AdvancedFm::addToDocs() {
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
@@ -1014,94 +1014,106 @@ bool 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() + "/";