author | llornkcor <llornkcor> | 2003-02-21 22:05:19 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-21 22:05:19 (UTC) |
commit | d48baa03492fd4785ca273defb4e21bf8c0d1c08 (patch) (unidiff) | |
tree | 3235810cc1113a6f6d25b4f1c60d3d2aa430b7e7 | |
parent | e09381c4b3d482c6b553a61c5fb0502a089dcc5f (diff) | |
download | opie-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
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 13 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 152 |
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 | |||
@@ -1,158 +1,165 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfm.h | 2 | advancedfm.h |
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 | #ifndef ADVANCEDFM_H | 12 | #ifndef ADVANCEDFM_H |
13 | #define ADVANCEDFM_H | 13 | #define ADVANCEDFM_H |
14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | 14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties |
15 | #define QT_QWS_OPIE | 15 | #define QT_QWS_OPIE |
16 | 16 | ||
17 | //#include <opie/otabwidget.h> | 17 | //#include <opie/otabwidget.h> |
18 | #include <qpe/ir.h> | 18 | #include <qpe/ir.h> |
19 | 19 | ||
20 | #include <qvariant.h> | 20 | #include <qvariant.h> |
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qpoint.h> | 26 | #include <qpoint.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | 28 | ||
29 | class OTabWidget; | 29 | class OTabWidget; |
30 | class QVBoxLayout; | 30 | class QVBoxLayout; |
31 | class QHBoxLayout; | 31 | class QHBoxLayout; |
32 | class QGridLayout; | 32 | class QGridLayout; |
33 | class QComboBox; | 33 | class QComboBox; |
34 | class QListView; | 34 | class QListView; |
35 | class QListviewItem; | 35 | class QListviewItem; |
36 | class QLabel; | 36 | class QLabel; |
37 | class QProgressBar; | 37 | class QProgressBar; |
38 | class QSpinBox; | 38 | class QSpinBox; |
39 | class QTabWidget; | 39 | class QTabWidget; |
40 | class QWidget; | 40 | class QWidget; |
41 | class QPEToolBar; | 41 | class QPEToolBar; |
42 | class QPEMenuBar; | 42 | class QPEMenuBar; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QFile; | 44 | class QFile; |
45 | class QListViewItem; | 45 | class QListViewItem; |
46 | class QLineEdit; | 46 | class QLineEdit; |
47 | |||
47 | //class QPushButton; | 48 | //class QPushButton; |
48 | class QToolButton; | 49 | class QToolButton; |
49 | class Ir; | 50 | class Ir; |
50 | 51 | ||
51 | class AdvancedFm : public QMainWindow | 52 | class AdvancedFm : public QMainWindow |
52 | { | 53 | { |
53 | Q_OBJECT | 54 | Q_OBJECT |
54 | public: | 55 | public: |
55 | AdvancedFm(); | 56 | AdvancedFm(); |
56 | ~AdvancedFm(); | 57 | ~AdvancedFm(); |
57 | 58 | ||
58 | OTabWidget *TabWidget; | 59 | OTabWidget *TabWidget; |
59 | // QTabWidget *TabWidget; | 60 | // QTabWidget *TabWidget; |
60 | QWidget *tab, *tab_2, *tab_3; | 61 | QWidget *tab, *tab_2, *tab_3; |
61 | QListView *Local_View, *Remote_View; | 62 | QListView *Local_View, *Remote_View; |
62 | 63 | ||
63 | QLineEdit *currentPathEdit; | 64 | QLineEdit *currentPathEdit; |
64 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; | 65 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; |
65 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 66 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
66 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 67 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
67 | QDir currentDir, currentRemoteDir; | 68 | QDir currentDir, currentRemoteDir; |
68 | QComboBox *currentPathCombo; | 69 | QComboBox *currentPathCombo; |
69 | QString filterStr; | 70 | QString filterStr; |
70 | QListViewItem * item; | 71 | QListViewItem * item; |
71 | bool b; | 72 | bool b; |
72 | QStringList fileSystemTypeList, fsList; | 73 | QStringList fileSystemTypeList, fsList; |
73 | int currentServerConfig; | 74 | int currentServerConfig; |
74 | protected slots: | 75 | protected slots: |
75 | void selectAll(); | 76 | void selectAll(); |
76 | void addToDocs(); | 77 | void addToDocs(); |
77 | void doLocalCd(); | 78 | void doLocalCd(); |
78 | void doRemoteCd(); | 79 | void doRemoteCd(); |
79 | // void copy(); | 80 | // void copy(); |
80 | void mkDir(); | 81 | void mkDir(); |
81 | void del(); | 82 | void del(); |
82 | void rn(); | 83 | void rn(); |
83 | void populateLocalView(); | 84 | void populateLocalView(); |
84 | void populateRemoteView(); | 85 | void populateRemoteView(); |
85 | void showHidden(); | 86 | void showHidden(); |
86 | void showMenuHidden(); | 87 | void showMenuHidden(); |
87 | void showRemoteHidden(); | 88 | void showRemoteHidden(); |
88 | void writeConfig(); | 89 | void writeConfig(); |
89 | void readConfig(); | 90 | void readConfig(); |
90 | void localListClicked(QListViewItem *); | 91 | void localListClicked(QListViewItem *); |
91 | void remoteListClicked(QListViewItem *); | 92 | void remoteListClicked(QListViewItem *); |
92 | void localListPressed( int, QListViewItem *, const QPoint&, int); | 93 | void localListPressed( int, QListViewItem *, const QPoint&, int); |
93 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); | 94 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); |
94 | void localMakDir(); | 95 | void localMakDir(); |
95 | void localDelete(); | 96 | void localDelete(); |
96 | void remoteMakDir(); | 97 | void remoteMakDir(); |
97 | void remoteDelete(); | 98 | void remoteDelete(); |
98 | /* bool remoteDirList(const QString &); */ | 99 | /* bool remoteDirList(const QString &); */ |
99 | /* bool remoteChDir(const QString &); */ | 100 | /* bool remoteChDir(const QString &); */ |
100 | void tabChanged(QWidget*); | 101 | void tabChanged(QWidget*); |
101 | void cleanUp(); | 102 | void cleanUp(); |
102 | void remoteRename(); | 103 | void remoteRename(); |
103 | void localRename(); | 104 | void localRename(); |
104 | void runThis(); | 105 | void runThis(); |
105 | void runText(); | 106 | void runText(); |
106 | void filePerms(); | 107 | void filePerms(); |
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 | ||
115 | protected: | 116 | protected: |
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 | ||
129 | protected slots: | 131 | protected slots: |
130 | void showFileMenu(); | 132 | void showFileMenu(); |
131 | void cancelMenuTimer(); | 133 | void cancelMenuTimer(); |
132 | void homeButtonPushed(); | 134 | void homeButtonPushed(); |
133 | void docButtonPushed(); | 135 | void docButtonPushed(); |
134 | void SDButtonPushed(); | 136 | void SDButtonPushed(); |
135 | void CFButtonPushed(); | 137 | void CFButtonPushed(); |
136 | void QPEButtonPushed(); | 138 | void QPEButtonPushed(); |
137 | void upDir(); | 139 | void upDir(); |
138 | void currentPathComboChanged(); | 140 | void currentPathComboChanged(); |
139 | void copy(); | 141 | void copy(); |
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 | ||
151 | private: | 153 | private: |
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(); | ||
154 | private slots: | 161 | private 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 | |||
@@ -278,166 +278,128 @@ void AdvancedFm::localDelete() { | |||
278 | void AdvancedFm::remoteDelete() { | 278 | void AdvancedFm::remoteDelete() { |
279 | QStringList curFileList = getPath(); | 279 | QStringList curFileList = getPath(); |
280 | bool doMsg=true; | 280 | bool doMsg=true; |
281 | int count=curFileList.count(); | 281 | int count=curFileList.count(); |
282 | if( count > 0) { | 282 | if( count > 0) { |
283 | if(count > 1 ){ | 283 | if(count > 1 ){ |
284 | QString msg; | 284 | QString msg; |
285 | msg=tr("Really delete\n%1 files?").arg(count); | 285 | msg=tr("Really delete\n%1 files?").arg(count); |
286 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 286 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
287 | ,tr("Yes"),tr("No"),0,0,1) ) { | 287 | ,tr("Yes"),tr("No"),0,0,1) ) { |
288 | case 0: | 288 | case 0: |
289 | doMsg=false; | 289 | doMsg=false; |
290 | break; | 290 | break; |
291 | case 1: | 291 | case 1: |
292 | return; | 292 | return; |
293 | break; | 293 | break; |
294 | }; | 294 | }; |
295 | } | 295 | } |
296 | 296 | ||
297 | QString myFile; | 297 | QString myFile; |
298 | 298 | ||
299 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 299 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
300 | myFile = (*it); | 300 | myFile = (*it); |
301 | if(myFile.find(" -> ",0,TRUE) != -1) | 301 | if(myFile.find(" -> ",0,TRUE) != -1) |
302 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 302 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
303 | QString f = currentRemoteDir.canonicalPath(); | 303 | QString f = currentRemoteDir.canonicalPath(); |
304 | if(f.right(1).find("/",0,TRUE) == -1) | 304 | if(f.right(1).find("/",0,TRUE) == -1) |
305 | f+="/"; | 305 | f+="/"; |
306 | f+=myFile; | 306 | f+=myFile; |
307 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 307 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
308 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ | 308 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ |
309 | "\nand all it's contents ?", | 309 | "\nand all it's contents ?", |
310 | tr("Yes"),tr("No"),0,0,1) ) { | 310 | tr("Yes"),tr("No"),0,0,1) ) { |
311 | case 0: { | 311 | case 0: { |
312 | f=f.left(f.length()-1); | 312 | f=f.left(f.length()-1); |
313 | QString cmd="rm -rf "+f; | 313 | QString cmd="rm -rf "+f; |
314 | startProcess( (const QString)cmd ); | 314 | startProcess( (const QString)cmd ); |
315 | populateRemoteView(); | 315 | populateRemoteView(); |
316 | } | 316 | } |
317 | break; | 317 | break; |
318 | case 1: | 318 | case 1: |
319 | // exit | 319 | // exit |
320 | break; | 320 | break; |
321 | }; | 321 | }; |
322 | 322 | ||
323 | } else { | 323 | } else { |
324 | if(doMsg) { | 324 | if(doMsg) { |
325 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 325 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
326 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 326 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
327 | case 1: | 327 | case 1: |
328 | return; | 328 | return; |
329 | break; | 329 | break; |
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 | ||
342 | void 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 | |||
361 | void 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 | ||
381 | void AdvancedFm::filePerms() { | 343 | void 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 | ||
392 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
393 | filePermissions *filePerm; | 355 | filePermissions *filePerm; |
394 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
395 | filePerm->showMaximized(); | 357 | filePerm->showMaximized(); |
396 | filePerm->exec(); | 358 | filePerm->exec(); |
397 | if( filePerm) | 359 | if( filePerm) |
398 | delete filePerm; | 360 | delete filePerm; |
399 | } | 361 | } |
400 | if (TabWidget->getCurrentTab() == 0) { | 362 | if (TabWidget->getCurrentTab() == 0) { |
401 | populateLocalView(); | 363 | populateLocalView(); |
402 | } else { | 364 | } else { |
403 | populateRemoteView(); | 365 | populateRemoteView(); |
404 | } | 366 | } |
405 | } | 367 | } |
406 | 368 | ||
407 | void AdvancedFm::doProperties() { | 369 | void AdvancedFm::doProperties() { |
408 | #if defined(QT_QWS_OPIE) | 370 | #if defined(QT_QWS_OPIE) |
409 | 371 | ||
410 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
411 | 373 | ||
412 | QString filePath; | 374 | QString filePath; |
413 | if (TabWidget->getCurrentTab() == 0) { | 375 | if (TabWidget->getCurrentTab() == 0) { |
414 | filePath = currentDir.canonicalPath()+"/"; | 376 | filePath = currentDir.canonicalPath()+"/"; |
415 | } else { | 377 | } else { |
416 | filePath= currentRemoteDir.canonicalPath()+"/"; | 378 | filePath= currentRemoteDir.canonicalPath()+"/"; |
417 | } | 379 | } |
418 | qDebug("%d",curFileList.count()); | 380 | qDebug("%d",curFileList.count()); |
419 | 381 | ||
420 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
421 | qDebug((filePath+*it)); | 383 | qDebug((filePath+*it)); |
422 | DocLnk lnk( (filePath+*it)); | 384 | DocLnk lnk( (filePath+*it)); |
423 | LnkProperties prop( &lnk ); | 385 | LnkProperties prop( &lnk ); |
424 | prop.showMaximized(); | 386 | prop.showMaximized(); |
425 | prop.exec(); | 387 | prop.exec(); |
426 | } | 388 | } |
427 | #endif | 389 | #endif |
428 | 390 | ||
429 | } | 391 | } |
430 | 392 | ||
431 | void AdvancedFm::upDir() { | 393 | void AdvancedFm::upDir() { |
432 | if (TabWidget->getCurrentTab() == 0) { | 394 | if (TabWidget->getCurrentTab() == 0) { |
433 | QString current = currentDir.canonicalPath(); | 395 | QString current = currentDir.canonicalPath(); |
434 | QDir dir(current); | 396 | QDir dir(current); |
435 | dir.cdUp(); | 397 | dir.cdUp(); |
436 | current = dir.canonicalPath(); | 398 | current = dir.canonicalPath(); |
437 | chdir( current.latin1() ); | 399 | chdir( current.latin1() ); |
438 | currentDir.cd( current, TRUE); | 400 | currentDir.cd( current, TRUE); |
439 | populateLocalView(); | 401 | populateLocalView(); |
440 | update(); | 402 | update(); |
441 | } else { | 403 | } else { |
442 | QString current = currentRemoteDir.canonicalPath(); | 404 | QString current = currentRemoteDir.canonicalPath(); |
443 | QDir dir(current); | 405 | QDir dir(current); |
@@ -986,64 +948,178 @@ void AdvancedFm::doBeam() { | |||
986 | 948 | ||
987 | QStringList curFileList = getPath(); | 949 | QStringList curFileList = getPath(); |
988 | if( curFileList.count() > 0) { | 950 | if( curFileList.count() > 0) { |
989 | 951 | ||
990 | if (TabWidget->getCurrentTab() == 0) { | 952 | if (TabWidget->getCurrentTab() == 0) { |
991 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
992 | 954 | ||
993 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
994 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
995 | Ir *file = new Ir(this, "IR"); | 957 | Ir *file = new Ir(this, "IR"); |
996 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
997 | file->send( curFile, curFile ); | 959 | file->send( curFile, curFile ); |
998 | } | 960 | } |
999 | 961 | ||
1000 | } else { | 962 | } else { |
1001 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1002 | 964 | ||
1003 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1004 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1005 | Ir *file = new Ir(this, "IR"); | 967 | Ir *file = new Ir(this, "IR"); |
1006 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
1007 | file->send( curFile, curFile ); | 969 | file->send( curFile, curFile ); |
1008 | 970 | ||
1009 | } | 971 | } |
1010 | } | 972 | } |
1011 | } | 973 | } |
1012 | } | 974 | } |
1013 | 975 | ||
1014 | } | 976 | } |
1015 | 977 | ||
1016 | void AdvancedFm::fileBeamFinished( Ir *) { | 978 | void AdvancedFm::fileBeamFinished( Ir *) { |
1017 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1018 | 980 | ||
1019 | } | 981 | } |
1020 | 982 | ||
1021 | void AdvancedFm::selectAll() { | 983 | void AdvancedFm::selectAll() { |
1022 | if (TabWidget->getCurrentTab() == 0) { | 984 | if (TabWidget->getCurrentTab() == 0) { |
1023 | Local_View->selectAll(true); | 985 | Local_View->selectAll(true); |
1024 | Local_View->setSelected( Local_View->firstChild(),false); | 986 | Local_View->setSelected( Local_View->firstChild(),false); |
1025 | } else { | 987 | } else { |
1026 | Remote_View->selectAll(true); | 988 | Remote_View->selectAll(true); |
1027 | Remote_View->setSelected( Remote_View->firstChild(),false); | 989 | Remote_View->setSelected( Remote_View->firstChild(),false); |
1028 | } | 990 | } |
1029 | } | 991 | } |
1030 | 992 | ||
1031 | void AdvancedFm::startProcess(const QString & cmd) { | 993 | void AdvancedFm::startProcess(const QString & cmd) { |
1032 | QStringList command; | 994 | QStringList command; |
1033 | OProcess *process; | 995 | OProcess *process; |
1034 | process = new OProcess(); | 996 | process = new OProcess(); |
1035 | connect(process, SIGNAL(processExited(OProcess *)), | 997 | connect(process, SIGNAL(processExited(OProcess *)), |
1036 | this, SLOT( processEnded())); | 998 | this, SLOT( processEnded())); |
1037 | 999 | ||
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 | ||
1046 | void AdvancedFm::processEnded() { | 1008 | void AdvancedFm::processEnded() { |
1047 | populateLocalView(); | 1009 | populateLocalView(); |
1048 | populateRemoteView(); | 1010 | populateRemoteView(); |
1049 | } | 1011 | } |
1012 | |||
1013 | bool 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 | |||
1034 | void 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 | |||
1054 | void 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 | |||
1078 | void AdvancedFm::localRename() { | ||
1079 | oldName = Local_View->currentItem()->text(0); | ||
1080 | doRename(Local_View ); | ||
1081 | populateLocalView(); | ||
1082 | } | ||
1083 | |||
1084 | void AdvancedFm::remoteRename() | ||
1085 | { | ||
1086 | oldName = Remote_View->currentItem()->text(0); | ||
1087 | doRename(Local_View ); | ||
1088 | populateRemoteView(); | ||
1089 | } | ||
1090 | |||
1091 | void 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 | } | ||