summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-02-21 22:05:19 (UTC)
committer llornkcor <llornkcor>2003-02-21 22:05:19 (UTC)
commitd48baa03492fd4785ca273defb4e21bf8c0d1c08 (patch) (unidiff)
tree3235810cc1113a6f6d25b4f1c60d3d2aa430b7e7
parente09381c4b3d482c6b553a61c5fb0502a089dcc5f (diff)
downloadopie-d48baa03492fd4785ca273defb4e21bf8c0d1c08.zip
opie-d48baa03492fd4785ca273defb4e21bf8c0d1c08.tar.gz
opie-d48baa03492fd4785ca273defb4e21bf8c0d1c08.tar.bz2
inline rename - no popup now, after selecting rename from menu, enter to commit the rename, cancel to cancel
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.h13
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp152
2 files changed, 124 insertions, 41 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 7ced056..42775ee 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -35,24 +35,25 @@ class QListView;
35class QListviewItem; 35class QListviewItem;
36class QLabel; 36class QLabel;
37class QProgressBar; 37class QProgressBar;
38class QSpinBox; 38class QSpinBox;
39class QTabWidget; 39class QTabWidget;
40class QWidget; 40class QWidget;
41class QPEToolBar; 41class QPEToolBar;
42class QPEMenuBar; 42class QPEMenuBar;
43class QPopupMenu; 43class QPopupMenu;
44class QFile; 44class QFile;
45class QListViewItem; 45class QListViewItem;
46class QLineEdit; 46class QLineEdit;
47
47//class QPushButton; 48//class QPushButton;
48class QToolButton; 49class QToolButton;
49class Ir; 50class Ir;
50 51
51class AdvancedFm : public QMainWindow 52class AdvancedFm : public QMainWindow
52{ 53{
53 Q_OBJECT 54 Q_OBJECT
54public: 55public:
55 AdvancedFm(); 56 AdvancedFm();
56 ~AdvancedFm(); 57 ~AdvancedFm();
57 58
58 OTabWidget *TabWidget; 59 OTabWidget *TabWidget;
@@ -107,25 +108,26 @@ protected slots:
107 void doProperties(); 108 void doProperties();
108 void runCommand(); 109 void runCommand();
109 void runCommandStd(); 110 void runCommandStd();
110 QStringList getPath(); 111 QStringList getPath();
111 void mkSym(); 112 void mkSym();
112 void switchToLocalTab(); 113 void switchToLocalTab();
113 void switchToRemoteTab(); 114 void switchToRemoteTab();
114 115
115protected: 116protected:
116 bool zaurusDevice; 117 bool zaurusDevice;
117 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 118 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
118 QStringList remoteDirPathStringList, localDirPathStringList; 119 QStringList remoteDirPathStringList, localDirPathStringList;
119 120 QLineEdit *renameBox;
121
120 void init(); 122 void init();
121 void initConnections(); 123 void initConnections();
122 void keyReleaseEvent( QKeyEvent *); 124 void keyReleaseEvent( QKeyEvent *);
123 QString getFileSystemType(const QString &); 125 QString getFileSystemType(const QString &);
124 QString getDiskSpace(const QString &); 126 QString getDiskSpace(const QString &);
125 void parsetab(const QString &fileName); 127 void parsetab(const QString &fileName);
126 QString checkDiskSpace(const QString &); 128 QString checkDiskSpace(const QString &);
127 QString dealWithSymName(const QString &); 129 QString dealWithSymName(const QString &);
128 130
129protected slots: 131protected slots:
130 void showFileMenu(); 132 void showFileMenu();
131 void cancelMenuTimer(); 133 void cancelMenuTimer();
@@ -140,19 +142,24 @@ protected slots:
140 void copyAs(); 142 void copyAs();
141 void copySameDir(); 143 void copySameDir();
142 void currentPathComboActivated(const QString &); 144 void currentPathComboActivated(const QString &);
143 void fillCombo(const QString &); 145 void fillCombo(const QString &);
144 bool copyFile( const QString & , const QString & ); 146 bool copyFile( const QString & , const QString & );
145 void move(); 147 void move();
146 void fileStatus(); 148 void fileStatus();
147 void doAbout(); 149 void doAbout();
148 void doBeam(); 150 void doBeam();
149 void fileBeamFinished( Ir *); 151 void fileBeamFinished( Ir *);
150 152
151private: 153private:
152 QTimer menuTimer; 154 QString oldName;
153 void startProcess(const QString &); 155 QTimer menuTimer;
156 void startProcess(const QString &);
157 bool eventFilter( QObject * , QEvent * );
158 void cancelRename();
159 void doRename(QListView *);
160 void okRename();
154private slots: 161private slots:
155 void processEnded(); 162 void processEnded();
156}; 163};
157 164
158#endif // ADVANCEDFM_H 165#endif // ADVANCEDFM_H
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 98d024d..f067013 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -330,62 +330,24 @@ void AdvancedFm::remoteDelete() {
330 }; 330 };
331 } 331 }
332 QString cmd="rm "+f; 332 QString cmd="rm "+f;
333 QFile file(f); 333 QFile file(f);
334 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 334 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
335 file.remove(); 335 file.remove();
336 } 336 }
337 } 337 }
338 } 338 }
339 populateRemoteView(); 339 populateRemoteView();
340} 340}
341 341
342void AdvancedFm::localRename() {
343 QString curFile = Local_View->currentItem()->text(0);
344 qDebug("currentItem "+curFile);
345 if( curFile !="../") {
346 InputDialog *fileDlg;
347 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
348 fileDlg->setInputText((const QString &)curFile);
349 fileDlg->exec();
350 if( fileDlg->result() == 1 ) {
351 QString oldname = currentDir.canonicalPath() + "/" + curFile;
352 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
353//+".playlist";
354 if( rename(oldname.latin1(), newName.latin1())== -1)
355 QMessageBox::message(tr("Note"),tr("Could not rename"));
356 }
357 populateLocalView();
358 }
359}
360
361void AdvancedFm::remoteRename()
362{
363 QString curFile = Remote_View->currentItem()->text(0);
364 if( curFile !="../") {
365 InputDialog *fileDlg;
366 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
367 fileDlg->setInputText((const QString &)curFile);
368 fileDlg->exec();
369 if( fileDlg->result() == 1 ) {
370 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
371 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
372//+".playlist";
373 if( rename(oldname.latin1(), newName.latin1())== -1)
374 QMessageBox::message(tr("Note"),tr("Could not rename"));
375 }
376 populateRemoteView();
377 }
378}
379
380 342
381void AdvancedFm::filePerms() { 343void AdvancedFm::filePerms() {
382 344
383 QStringList curFileList = getPath(); 345 QStringList curFileList = getPath();
384 QString filePath; 346 QString filePath;
385 347
386 if (TabWidget->getCurrentTab() == 0) { 348 if (TabWidget->getCurrentTab() == 0) {
387 filePath = currentDir.canonicalPath()+"/"; 349 filePath = currentDir.canonicalPath()+"/";
388 } else { 350 } else {
389 filePath= currentRemoteDir.canonicalPath()+"/"; 351 filePath= currentRemoteDir.canonicalPath()+"/";
390 } 352 }
391 353
@@ -1038,12 +1000,126 @@ void AdvancedFm::startProcess(const QString & cmd) {
1038 command << "/bin/sh"; 1000 command << "/bin/sh";
1039 command << "-c"; 1001 command << "-c";
1040 command << cmd.latin1(); 1002 command << cmd.latin1();
1041 *process << command; 1003 *process << command;
1042 if(!process->start(OProcess::NotifyOnExit) ) 1004 if(!process->start(OProcess::NotifyOnExit) )
1043 qDebug("could not start process"); 1005 qDebug("could not start process");
1044} 1006}
1045 1007
1046void AdvancedFm::processEnded() { 1008void AdvancedFm::processEnded() {
1047 populateLocalView(); 1009 populateLocalView();
1048 populateRemoteView(); 1010 populateRemoteView();
1049} 1011}
1012
1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
1014 if ( o->inherits( "QLineEdit" ) ) {
1015 if ( e->type() == QEvent::KeyPress ) {
1016 QKeyEvent *ke = (QKeyEvent*)e;
1017 if ( ke->key() == Key_Return ||
1018 ke->key() == Key_Enter ) {
1019 okRename();
1020 return true;
1021 } else if ( ke->key() == Key_Escape ) {
1022 cancelRename();
1023 return true;
1024 }
1025 } else if ( e->type() == QEvent::FocusOut ) {
1026 cancelRename();
1027 return true;
1028 }
1029 }
1030 return QWidget::eventFilter( o, e );
1031}
1032
1033
1034void AdvancedFm::cancelRename() {
1035 qDebug("cancel rename");
1036 QListView * view;
1037 if (TabWidget->getCurrentTab() == 0) {
1038 view = Local_View;
1039 }
1040 else
1041 {
1042 view = Remote_View;
1043 }
1044
1045 bool resetFocus = view->viewport()->focusProxy() == renameBox;
1046 delete renameBox;
1047 renameBox = 0;
1048 if ( resetFocus ) {
1049 view->viewport()->setFocusProxy( view);
1050 view->setFocus();
1051 }
1052}
1053
1054void AdvancedFm::doRename(QListView * view) {
1055
1056 QRect r = view->itemRect( view->currentItem( ));
1057 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
1058 r.setX( view->contentsX() );
1059 if ( r.width() > view->visibleWidth() )
1060 r.setWidth( view->visibleWidth() );
1061
1062 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
1063 renameBox->setFrame(true);
1064
1065 renameBox->setText( view->currentItem()->text(0) );
1066
1067 renameBox->selectAll();
1068 renameBox->installEventFilter( this );
1069 view->addChild( renameBox, r.x(), r.y() );
1070 renameBox->resize( r.size() );
1071 view->viewport()->setFocusProxy( renameBox );
1072 renameBox->setFocus();
1073 renameBox->show();
1074
1075}
1076
1077
1078void AdvancedFm::localRename() {
1079 oldName = Local_View->currentItem()->text(0);
1080 doRename(Local_View );
1081 populateLocalView();
1082}
1083
1084void AdvancedFm::remoteRename()
1085{
1086 oldName = Remote_View->currentItem()->text(0);
1087 doRename(Local_View );
1088 populateRemoteView();
1089}
1090
1091void AdvancedFm::okRename() {
1092 QString newName = renameBox->text();
1093 cancelRename();
1094 int tabs=0;
1095 QListView * view;
1096 tabs = TabWidget->getCurrentTab();
1097 if ( tabs == 0)
1098 {
1099 view = Local_View;
1100 QString path = currentDir.canonicalPath() + "/";
1101 oldName = path + oldName;
1102 newName = path + newName;
1103 }
1104 else
1105 {
1106 view = Remote_View;
1107 QString path = currentRemoteDir.canonicalPath() + "/";
1108 oldName = path + oldName;
1109 newName = path + newName;
1110 }
1111
1112 if( view->currentItem() == NULL)
1113 return;
1114 if( rename(oldName.latin1(), newName.latin1())== -1)
1115 QMessageBox::message(tr("Note"),tr("Could not rename"));
1116 else
1117 oldName = "";
1118
1119 view->takeItem( view->currentItem() );
1120 delete view->currentItem();
1121 if ( tabs == 0)
1122 populateLocalView();
1123 else
1124 populateRemoteView();
1125}