summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-23 21:00:05 (UTC)
committer llornkcor <llornkcor>2002-09-23 21:00:05 (UTC)
commit47e87e10fada298a1027cf20d4d7f31a66dc1359 (patch) (unidiff)
tree169eec0098ad07644a401f928c2ff9e0a10aec67
parentf0b527f1c2a9ad78832893be6bfd1c6a24cdb569 (diff)
downloadopie-47e87e10fada298a1027cf20d4d7f31a66dc1359.zip
opie-47e87e10fada298a1027cf20d4d7f31a66dc1359.tar.gz
opie-47e87e10fada298a1027cf20d4d7f31a66dc1359.tar.bz2
more moving and some fixing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp942
-rw-r--r--noncore/apps/advancedfm/advancedfm.h2
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro2
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp5
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp940
5 files changed, 979 insertions, 912 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 8f49a53..3aa516c 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,50 +1,42 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
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#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
14 13
15#include "advancedfm.h" 14#include "advancedfm.h"
16#include "inputDialog.h"
17#include "filePermissions.h"
18#include "output.h"
19 15
20// #include <opie/ofileselector.h> 16// #include <opie/ofileselector.h>
21// #include <opie/ofiledialog.h> 17// #include <opie/ofiledialog.h>
22 18
23#include <qpe/lnkproperties.h>
24#include <qpe/filemanager.h> 19#include <qpe/filemanager.h>
25#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
26#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
27#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
28#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
29#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
30#include <qpe/config.h> 25#include <qpe/config.h>
31#include <qpe/mimetype.h> 26#include <qpe/mimetype.h>
32#include <qpe/applnk.h> 27#include <qpe/applnk.h>
33#include <qpe/ir.h> 28#include <qpe/ir.h>
34#include <qpe/resource.h> 29#include <qpe/resource.h>
35 30
36//#include <opie/ofileselector.h>
37#include <qmultilineedit.h>
38
39#include <qtabwidget.h> 31#include <qtabwidget.h>
40#include <qtextstream.h> 32#include <qtextstream.h>
41#include <qpushbutton.h> 33#include <qpushbutton.h>
42#include <qdatetime.h> 34#include <qdatetime.h>
43#include <qdir.h> 35#include <qdir.h>
44#include <qfile.h> 36#include <qfile.h>
45#include <qstring.h> 37#include <qstring.h>
46#include <qcombobox.h> 38#include <qcombobox.h>
47#include <qpopupmenu.h> 39#include <qpopupmenu.h>
48#include <qlistview.h> 40#include <qlistview.h>
49#include <qmainwindow.h> 41#include <qmainwindow.h>
50#include <qlabel.h> 42#include <qlabel.h>
@@ -64,84 +56,87 @@
64#include <dirent.h> 56#include <dirent.h>
65#include <stdio.h> 57#include <stdio.h>
66#include <time.h> 58#include <time.h>
67#include <fcntl.h> 59#include <fcntl.h>
68#include <mntent.h> 60#include <mntent.h>
69#include <string.h> 61#include <string.h>
70#include <errno.h> 62#include <errno.h>
71#include <sys/vfs.h> 63#include <sys/vfs.h>
72#include <mntent.h> 64#include <mntent.h>
73#include <sys/utsname.h> 65#include <sys/utsname.h>
74 66
75AdvancedFm::AdvancedFm( ) 67AdvancedFm::AdvancedFm( )
76 : QMainWindow( ) { 68 : QMainWindow( ) {
77 init(); 69 init();
78 70 initConnections();
79 populateLocalView(); 71 populateLocalView();
80 populateRemoteView(); 72 populateRemoteView();
81 currentPathCombo->setFocus(); 73 currentPathCombo->setFocus();
82} 74}
83 75
84AdvancedFm::~AdvancedFm() { 76AdvancedFm::~AdvancedFm() {
85} 77}
86 78
87void AdvancedFm::cleanUp() { 79void AdvancedFm::cleanUp() {
88 QString sfile=QDir::homeDirPath(); 80 QString sfile=QDir::homeDirPath();
89 if(sfile.right(1) != "/") 81 if(sfile.right(1) != "/")
90 sfile+="/._temp"; 82 sfile+="/._temp";
91 else 83 else
92 sfile+="._temp"; 84 sfile+="._temp";
93 QFile file( sfile); 85 QFile file( sfile);
94 if(file.exists()) 86 if(file.exists())
95 file.remove(); 87 file.remove();
96} 88}
97 89
98void AdvancedFm::tabChanged(QWidget *) { 90void AdvancedFm::tabChanged(QWidget *) {
99 if (TabWidget->currentPageIndex() == 0) { 91 if (TabWidget->currentPageIndex() == 0) {
100 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 92 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
101 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 93 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
102 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 94 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
103 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 95 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
104 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 96 setCaption("AdvancedFm :: "+fs+" :: "
97 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
105 98
106 } 99 }
107 if (TabWidget->currentPageIndex() == 1) { 100 if (TabWidget->currentPageIndex() == 1) {
108 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 101 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
109 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 102 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
110 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 103 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
111 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 104 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
112 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 105 setCaption("AdvancedFm :: "+fs+" :: "
106 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
113 } 107 }
114} 108}
115 109
116 110
117void AdvancedFm::populateLocalView() { 111void AdvancedFm::populateLocalView() {
118 QPixmap pm; 112 QPixmap pm;
119 Local_View->clear(); 113 Local_View->clear();
120 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 114 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
121 currentDir.setMatchAllDirs(TRUE); 115 currentDir.setMatchAllDirs(TRUE);
122 currentDir.setNameFilter(filterStr); 116 currentDir.setNameFilter(filterStr);
123 QString fileL, fileS, fileDate; 117 QString fileL, fileS, fileDate;
124 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 118 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
125 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 119 setCaption("AdvancedFm :: "+fs+" :: "
120 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
126 bool isDir=FALSE; 121 bool isDir=FALSE;
127 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 122 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
128 QFileInfoListIterator it(*list); 123 QFileInfoListIterator it(*list);
129 QFileInfo *fi; 124 QFileInfo *fi;
130 while ( (fi=it.current()) ) { 125 while ( (fi=it.current()) ) {
131 if (fi->isSymLink() ) { 126 if (fi->isSymLink() ) {
132 QString symLink=fi->readLink(); 127 QString symLink=fi->readLink();
133 QFileInfo sym( symLink); 128 QFileInfo sym( symLink);
134 fileS.sprintf( "%10i", sym.size() ); 129 fileS.sprintf( "%10i", sym.size() );
135 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 130 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
136 fileDate = sym.lastModified().toString(); 131 fileDate = sym.lastModified().toString();
137 } else { 132 } else {
138 fileS.sprintf( "%10i", fi->size() ); 133 fileS.sprintf( "%10i", fi->size() );
139 fileL.sprintf( "%s",fi->fileName().data() ); 134 fileL.sprintf( "%s",fi->fileName().data() );
140 fileDate= fi->lastModified().toString(); 135 fileDate= fi->lastModified().toString();
141 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 136 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
142 fileL+="/"; 137 fileL+="/";
143 isDir=TRUE; 138 isDir=TRUE;
144 } 139 }
145 } 140 }
146 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 141 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
147 if(fileL !="./" && fi->exists()) { 142 if(fileL !="./" && fi->exists()) {
@@ -210,36 +205,37 @@ void AdvancedFm::populateLocalView() {
210} 205}
211 206
212 207
213void AdvancedFm::populateRemoteView() { 208void AdvancedFm::populateRemoteView() {
214 QPixmap pm; 209 QPixmap pm;
215 Remote_View->clear(); 210 Remote_View->clear();
216 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 211 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
217 currentRemoteDir.setMatchAllDirs(TRUE); 212 currentRemoteDir.setMatchAllDirs(TRUE);
218 currentRemoteDir.setNameFilter(filterStr); 213 currentRemoteDir.setNameFilter(filterStr);
219 QString fileL, fileS, fileDate; 214 QString fileL, fileS, fileDate;
220 215
221 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 216 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
222 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 217 setCaption("AdvancedFm :: "+fs+" :: "
218 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
223 bool isDir=FALSE; 219 bool isDir=FALSE;
224 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 220 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
225 QFileInfoListIterator it(*list); 221 QFileInfoListIterator it(*list);
226 QFileInfo *fi; 222 QFileInfo *fi;
227 while ( (fi=it.current()) ) { 223 while ( (fi=it.current()) ) {
228 if (fi->isSymLink() ){ 224 if (fi->isSymLink() ){
229 QString symLink=fi->readLink(); 225 QString symLink=fi->readLink();
230 // qDebug("Symlink detected "+symLink); 226 // qDebug("Symlink detected "+symLink);
231 QFileInfo sym( symLink); 227 QFileInfo sym( symLink);
232 fileS.sprintf( "%10i", sym.size() ); 228 fileS.sprintf( "%10i", sym.size() );
233 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 229 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
234 fileDate = sym.lastModified().toString(); 230 fileDate = sym.lastModified().toString();
235 } else { 231 } else {
236 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 232 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
237 fileS.sprintf( "%10i", fi->size() ); 233 fileS.sprintf( "%10i", fi->size() );
238 fileL.sprintf( "%s",fi->fileName().data() ); 234 fileL.sprintf( "%s",fi->fileName().data() );
239 fileDate= fi->lastModified().toString(); 235 fileDate= fi->lastModified().toString();
240 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 236 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
241 fileL+="/"; 237 fileL+="/";
242 isDir=TRUE; 238 isDir=TRUE;
243 // qDebug( fileL); 239 // qDebug( fileL);
244 } 240 }
245 } 241 }
@@ -303,29 +299,29 @@ void AdvancedFm::populateRemoteView() {
303 } 299 }
304 300
305 Remote_View->setSorting( 3,FALSE); 301 Remote_View->setSorting( 3,FALSE);
306 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 302 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
307} 303}
308 304
309void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 305void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
310 if(selectedItem) { 306 if(selectedItem) {
311 QString strItem=selectedItem->text(0); 307 QString strItem=selectedItem->text(0);
312 QString strSize=selectedItem->text(1); 308 QString strSize=selectedItem->text(1);
313 strSize=strSize.stripWhiteSpace(); 309 strSize=strSize.stripWhiteSpace();
314 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 310 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
315 // is symlink
316 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 311 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
317 if(QDir(strItem2).exists() ) { 312 if(QDir(strItem2).exists() ) {
318 currentDir.cd(strItem2, TRUE); 313 currentDir.cd(strItem2, TRUE);
319 populateLocalView(); 314 populateLocalView();
315
320 } 316 }
321 } else { // not a symlink 317 } else { // not a symlink
322 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 318 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
323 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 319 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
324 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 320 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
325 currentDir.cd(strItem,FALSE); 321 currentDir.cd(strItem,FALSE);
326 populateLocalView(); 322 populateLocalView();
327 } else { 323 } else {
328 currentDir.cdUp(); 324 currentDir.cdUp();
329 populateLocalView(); 325 populateLocalView();
330 } 326 }
331 if(QDir(strItem).exists()){ 327 if(QDir(strItem).exists()){
@@ -334,40 +330,39 @@ void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
334 } 330 }
335 } else { 331 } else {
336 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 332 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
337 if( QFile::exists(strItem ) ) { 333 if( QFile::exists(strItem ) ) {
338 // qDebug("clicked item "+strItem); 334 // qDebug("clicked item "+strItem);
339 // DocLnk doc( strItem, FALSE ); 335 // DocLnk doc( strItem, FALSE );
340 // doc.execute(); 336 // doc.execute();
341 // Local_View->clearSelection(); 337 // Local_View->clearSelection();
342 } 338 }
343 } //end not symlink 339 } //end not symlink
344 chdir(strItem.latin1()); 340 chdir(strItem.latin1());
345 } 341 }
342 Local_View->ensureItemVisible(Local_View->firstChild());
343
346 } 344 }
347} 345}
348 346
349void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { 347void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
350 348
351 if(selectedItem) { 349 if(selectedItem) {
352 QString strItem=selectedItem->text(0); 350 QString strItem=selectedItem->text(0);
353 QString strSize=selectedItem->text(1); 351 QString strSize=selectedItem->text(1);
354 strSize=strSize.stripWhiteSpace(); 352 strSize=strSize.stripWhiteSpace();
355 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 353 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
356 // is symlink
357 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 354 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
358 if(QDir(strItem2).exists() ) {
359 currentRemoteDir.cd(strItem2, TRUE); 355 currentRemoteDir.cd(strItem2, TRUE);
360 populateRemoteView(); 356 populateRemoteView();
361 }
362 } else { // not a symlink 357 } else { // not a symlink
363 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 358 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
364 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 359 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
365 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 360 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
366 currentRemoteDir.cd(strItem,FALSE); 361 currentRemoteDir.cd(strItem,FALSE);
367 populateRemoteView(); 362 populateRemoteView();
368 } else { 363 } else {
369 currentRemoteDir.cdUp(); 364 currentRemoteDir.cdUp();
370 populateRemoteView(); 365 populateRemoteView();
371 } 366 }
372 if(QDir(strItem).exists()){ 367 if(QDir(strItem).exists()){
373 currentRemoteDir.cd(strItem, TRUE); 368 currentRemoteDir.cd(strItem, TRUE);
@@ -375,313 +370,53 @@ void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
375 } 370 }
376 } else { 371 } else {
377 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 372 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
378 if( QFile::exists(strItem ) ) { 373 if( QFile::exists(strItem ) ) {
379 // qDebug("clicked item "+strItem); 374 // qDebug("clicked item "+strItem);
380 // DocLnk doc( strItem, FALSE ); 375 // DocLnk doc( strItem, FALSE );
381 // doc.execute(); 376 // doc.execute();
382 // Remote_View->clearSelection(); 377 // Remote_View->clearSelection();
383 } 378 }
384 } //end not symlink 379 } //end not symlink
385 chdir(strItem.latin1()); 380 chdir(strItem.latin1());
386 } 381 }
382 Remote_View->ensureItemVisible(Remote_View->firstChild());
387 } 383 }
388} 384}
389 385
390void AdvancedFm::doLocalCd() {
391 localListClicked( Local_View->currentItem());
392}
393
394void AdvancedFm::doRemoteCd() {
395 localListClicked( Remote_View->currentItem());
396}
397
398void AdvancedFm::showHidden() {
399 if (b) {
400 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
401 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
402 b=FALSE;
403
404 } else {
405 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
406 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
407 b=TRUE;
408 }
409 populateLocalView();
410
411}
412
413void AdvancedFm::showRemoteHidden() {
414 if (b) {
415 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
416 b=TRUE;
417
418 } else {
419 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
420 b=FALSE;
421 }
422 populateRemoteView();
423}
424 386
425void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 387void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
426 qDebug("list pressed"); 388// qDebug("list pressed");
427 switch (mouse) { 389 switch (mouse) {
428 case 1: 390 case 1:
429 break; 391 break;
430 case 2: 392 case 2:
431 menuTimer.start( 750, TRUE ); 393 menuTimer.start( 750, TRUE );
432 qDebug("Start menu timer\n"); 394 qDebug("Start menu timer\n");
433 break; 395 break;
434 }; 396 };
435} 397}
436 398
437void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 399void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
438 400
439 switch (mouse) { 401 switch (mouse) {
440 case 1: 402 case 1:
441 break; 403 break;
442 case 2: 404 case 2:
443 menuTimer.start( 750, TRUE ); 405 menuTimer.start( 750, TRUE );
444 qDebug("Start menu timer"); 406 qDebug("Start menu timer");
445 break; 407 break;
446 }; 408 };
447} 409}
448 410
449void AdvancedFm::runThis() {
450 QString fs;
451 if (TabWidget->currentPageIndex() == 0) {
452 QString curFile = Local_View->currentItem()->text(0);
453 if(curFile != "../") {
454
455 fs= getFileSystemType((const QString &) currentDir.canonicalPath());
456 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
457 qDebug( fileInfo.owner());
458 if( (fileInfo.permission( QFileInfo::ExeUser)
459 | fileInfo.permission( QFileInfo::ExeGroup)
460 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
461 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
462 QCopEnvelope e("QPE/System", "execute(QString)" );
463 e << curFile;
464 } else {
465 curFile = currentDir.canonicalPath()+"/"+curFile;
466 DocLnk nf(curFile);
467 QString execStr = nf.exec();
468 qDebug( execStr);
469 if( execStr.isEmpty() ) {
470 } else {
471 nf.execute();
472 }
473 }
474 }
475 } else {
476 QString curFile = Remote_View->currentItem()->text(0);
477 if(curFile != "../") {
478
479 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
480 qDebug("Filesystemtype is "+fs);
481 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
482 if( (fileInfo.permission( QFileInfo::ExeUser)
483 | fileInfo.permission( QFileInfo::ExeGroup)
484 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
485 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
486 QCopEnvelope e("QPE/System", "execute(QString)" );
487 e << curFile;
488 } else {
489 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
490 DocLnk nf(curFile);
491 QString execStr = nf.exec();
492 qDebug(execStr);
493 if( execStr.isEmpty() ) {
494 } else {
495 nf.execute();
496 }
497 }
498 }
499 }
500}
501
502void AdvancedFm::runText() {
503 if (TabWidget->currentPageIndex() == 0) {
504 QString curFile = Local_View->currentItem()->text(0);
505 if(curFile != "../") {
506 curFile = currentDir.canonicalPath()+"/"+curFile;
507 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
508 e << curFile;
509 }
510 } else {
511 QString curFile = Remote_View->currentItem()->text(0);
512 if(curFile != "../") {
513 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
514 DocLnk nf(curFile);
515 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
516 e << curFile;
517 }
518 }
519}
520
521void AdvancedFm::localMakDir() {
522 InputDialog *fileDlg;
523 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
524 fileDlg->exec();
525 if( fileDlg->result() == 1 ) {
526 QString filename = fileDlg->LineEdit1->text();
527 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
528 }
529 populateLocalView();
530}
531
532void AdvancedFm::remoteMakDir() {
533 InputDialog *fileDlg;
534 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
535 fileDlg->exec();
536 if( fileDlg->result() == 1 ) {
537 QString filename = fileDlg->LineEdit1->text();
538 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
539 }
540 populateRemoteView();
541}
542
543void AdvancedFm::localDelete() {
544 QStringList curFileList = getPath();
545 if(curFileList.count() > 0) {
546 QString myFile;
547 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
548 myFile = (*it);
549 if( myFile.find(" -> ",0,TRUE) != -1)
550 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
551
552 QString f = currentDir.canonicalPath();
553 if(f.right(1).find("/",0,TRUE) == -1)
554 f+="/";
555 f+=myFile;
556 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
557 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
558 "\nand all it's contents ?"
559 ,tr("Yes"),tr("No"),0,0,1) ) {
560 case 0: {
561 f=f.left(f.length()-1);
562 QString cmd="rm -rf "+f;
563 system( cmd.latin1());
564 populateLocalView();
565 }
566 break;
567 case 1:
568 // exit
569 break;
570 };
571
572 } else {
573 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
574 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
575 case 0: {
576 QString cmd="rm "+f;
577 QFile file(f);
578 file.remove();
579 // system( cmd.latin1());
580 populateLocalView();
581 }
582 break;
583 case 1:
584 // exit
585 break;
586 };
587 }
588 }
589 }
590}
591
592void AdvancedFm::remoteDelete() {
593 QStringList curFileList = getPath();
594 if( curFileList.count() > 0) {
595 QString myFile;
596
597 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
598 myFile = (*it);
599 if(myFile.find(" -> ",0,TRUE) != -1)
600 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
601 QString f = currentRemoteDir.canonicalPath();
602 if(f.right(1).find("/",0,TRUE) == -1)
603 f+="/";
604 f+=myFile;
605 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
606 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
607 "\nand all it's contents ?",
608 tr("Yes"),tr("No"),0,0,1) ) {
609 case 0: {
610 f=f.left(f.length()-1);
611 QString cmd="rm -rf "+f;
612 system( cmd.latin1());
613 populateRemoteView();
614 }
615 break;
616 case 1:
617 // exit
618 break;
619 };
620
621 } else {
622 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
623 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
624 case 0: {
625 QString cmd="rm "+f;
626 QFile file(f);
627 file.remove();
628 // system( cmd.latin1());
629 populateRemoteView();
630 }
631 break;
632 case 1:
633 // exit
634 break;
635 };
636 }
637 }
638 }
639}
640
641void AdvancedFm::localRename() {
642 QString curFile = Local_View->currentItem()->text(0);
643 qDebug("currentItem "+curFile);
644 if( curFile !="../") {
645 InputDialog *fileDlg;
646 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
647 fileDlg->setInputText((const QString &)curFile);
648 fileDlg->exec();
649 if( fileDlg->result() == 1 ) {
650 QString oldname = currentDir.canonicalPath() + "/" + curFile;
651 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
652 if( rename(oldname.latin1(), newName.latin1())== -1)
653 QMessageBox::message(tr("Note"),tr("Could not rename"));
654 }
655 populateLocalView();
656 }
657}
658
659void AdvancedFm::remoteRename()
660{
661 QString curFile = Remote_View->currentItem()->text(0);
662 if( curFile !="../") {
663 InputDialog *fileDlg;
664 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
665 fileDlg->setInputText((const QString &)curFile);
666 fileDlg->exec();
667 if( fileDlg->result() == 1 ) {
668 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
669 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
670 if( rename(oldname.latin1(), newName.latin1())== -1)
671 QMessageBox::message(tr("Note"),tr("Could not rename"));
672 }
673 populateRemoteView();
674 }
675}
676 411
677void AdvancedFm::switchToLocalTab() { 412void AdvancedFm::switchToLocalTab() {
678 TabWidget->setCurrentPage(0); 413 TabWidget->setCurrentPage(0);
679 Local_View->setFocus(); 414 Local_View->setFocus();
680} 415}
681 416
682void AdvancedFm::switchToRemoteTab() { 417void AdvancedFm::switchToRemoteTab() {
683 TabWidget->setCurrentPage(1); 418 TabWidget->setCurrentPage(1);
684 Remote_View->setFocus(); 419 Remote_View->setFocus();
685} 420}
686 421
687void AdvancedFm::readConfig() { 422void AdvancedFm::readConfig() {
@@ -735,68 +470,24 @@ void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
735 chdir( currentPath.latin1() ); 470 chdir( currentPath.latin1() );
736 currentDir.cd( currentPath, TRUE); 471 currentDir.cd( currentPath, TRUE);
737 populateLocalView(); 472 populateLocalView();
738 update(); 473 update();
739 } else { 474 } else {
740 chdir( currentPath.latin1() ); 475 chdir( currentPath.latin1() );
741 currentRemoteDir.cd( currentPath, TRUE); 476 currentRemoteDir.cd( currentPath, TRUE);
742 populateRemoteView(); 477 populateRemoteView();
743 update(); 478 update();
744 } 479 }
745} 480}
746 481
747void AdvancedFm::filePerms() {
748
749 QStringList curFileList = getPath();
750 QString filePath;
751
752 if (TabWidget->currentPageIndex() == 0) {
753 filePath = currentDir.canonicalPath()+"/";
754 } else {
755 filePath= currentRemoteDir.canonicalPath()+"/";
756 }
757
758 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
759 filePermissions *filePerm;
760 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
761 filePerm->showMaximized();
762 filePerm->exec();
763 if( filePerm)
764 delete filePerm;
765 }
766 if (TabWidget->currentPageIndex() == 0) {
767 populateLocalView();
768 } else {
769 populateRemoteView();
770 }
771}
772
773void AdvancedFm::doProperties() {
774 QStringList curFileList = getPath();
775 QString filePath;
776 if (TabWidget->currentPageIndex() == 0) {
777 filePath = currentDir.canonicalPath()+"/";
778 } else {
779 filePath= currentRemoteDir.canonicalPath()+"/";
780 }
781 // qDebug("%d",curFileList.count());
782 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
783 qDebug((filePath+*it));
784 DocLnk lnk( (filePath+*it));
785 LnkProperties prop( &lnk );
786 prop.showMaximized();
787 prop.exec();
788 }
789}
790
791QStringList AdvancedFm::getPath() { 482QStringList AdvancedFm::getPath() {
792 QStringList strList; 483 QStringList strList;
793 if (TabWidget->currentPageIndex() == 0) { 484 if (TabWidget->currentPageIndex() == 0) {
794 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 485 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
795 QListViewItemIterator it( Local_View ); 486 QListViewItemIterator it( Local_View );
796 for ( ; it.current(); ++it ) { 487 for ( ; it.current(); ++it ) {
797 if ( it.current()->isSelected() ) { 488 if ( it.current()->isSelected() ) {
798 strList << it.current()->text(0); 489 strList << it.current()->text(0);
799 qDebug(it.current()->text(0)); 490 qDebug(it.current()->text(0));
800 } 491 }
801 } 492 }
802 return strList; 493 return strList;
@@ -832,554 +523,62 @@ void AdvancedFm::docButtonPushed() {
832 chdir( current.latin1() ); 523 chdir( current.latin1() );
833 if (TabWidget->currentPageIndex() == 0) { 524 if (TabWidget->currentPageIndex() == 0) {
834 currentDir.cd( current, TRUE); 525 currentDir.cd( current, TRUE);
835 populateLocalView(); 526 populateLocalView();
836 } else { 527 } else {
837 currentRemoteDir.cd( current, TRUE); 528 currentRemoteDir.cd( current, TRUE);
838 populateRemoteView(); 529 populateRemoteView();
839 } 530 }
840 update(); 531 update();
841} 532}
842 533
843void AdvancedFm::SDButtonPushed() { 534void AdvancedFm::SDButtonPushed() {
844 QString current = "/mnt/card"; 535 QString current = "/mnt/card";// this can change so fix
845 chdir( current.latin1() ); 536 chdir( current.latin1() );
846 if (TabWidget->currentPageIndex() == 0) { 537 if (TabWidget->currentPageIndex() == 0) {
847 currentDir.cd( current, TRUE); 538 currentDir.cd( current, TRUE);
848 populateLocalView(); 539 populateLocalView();
849 } else { 540 } else {
850 currentRemoteDir.cd( current, TRUE); 541 currentRemoteDir.cd( current, TRUE);
851 populateRemoteView(); 542 populateRemoteView();
852 } 543 }
853 update(); 544 update();
854 545
855} 546}
856 547
857void AdvancedFm::CFButtonPushed() { 548void AdvancedFm::CFButtonPushed() {
858 QString current; 549 QString current;
859 if(zaurusDevice) 550 if(zaurusDevice)
860 current= "/mnt/cf"; 551 current= "/mnt/cf"; //zaurus
861 else 552 else
862 current = "/mnt/hda"; 553 current = "/mnt/hda"; //ipaq
863 554
864 chdir( current.latin1() ); 555 chdir( current.latin1() );
865 if (TabWidget->currentPageIndex() == 0) { 556 if (TabWidget->currentPageIndex() == 0) {
866 currentDir.cd( current, TRUE); 557 currentDir.cd( current, TRUE);
867 populateLocalView(); 558 populateLocalView();
868 } else { 559 } else {
869 currentRemoteDir.cd( current, TRUE); 560 currentRemoteDir.cd( current, TRUE);
870 populateRemoteView(); 561 populateRemoteView();
871 } 562 }
872 update(); 563 update();
873
874}
875
876
877void AdvancedFm::upDir() {
878 if (TabWidget->currentPageIndex() == 0) {
879 QString current = currentDir.canonicalPath();
880 QDir dir(current);
881 dir.cdUp();
882 current = dir.canonicalPath();
883 chdir( current.latin1() );
884 currentDir.cd( current, TRUE);
885 populateLocalView();
886 update();
887 } else {
888 QString current = currentRemoteDir.canonicalPath();
889 QDir dir(current);
890 dir.cdUp();
891 current = dir.canonicalPath();
892 chdir( current.latin1() );
893 currentRemoteDir.cd( current, TRUE);
894 populateRemoteView();
895 update();
896 }
897}
898
899void AdvancedFm::copy() {
900 qApp->processEvents();
901 QStringList curFileList = getPath();
902 if( curFileList.count() > 0) {
903 QString curFile;
904 if (TabWidget->currentPageIndex() == 0) {
905 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
906
907 QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
908 qDebug("Destination file is "+destFile);
909
910 curFile = currentDir.canonicalPath()+"/"+(*it);
911 qDebug("CurrentFile file is " + curFile);
912
913 QFile f(destFile);
914 if( f.exists()) {
915 switch ( QMessageBox::warning(this,tr("Delete"),
916 destFile+tr(" already exists\nDo you really want to delete it?"),
917 tr("Yes"),tr("No"),0,0,1) ) {
918 case 0:
919 f.remove();
920 break;
921 case 1:
922 return;
923 break;
924 };
925 }
926 if(!copyFile(destFile, curFile) ) {
927 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
928 qWarning("nothin doing");
929 }
930 }
931 populateRemoteView();
932 TabWidget->setCurrentPage(1);
933
934 } else {
935 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
936
937 QString destFile = currentDir.canonicalPath()+"/"+(*it);
938 qDebug("Destination file is "+destFile);
939 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
940 qDebug("CurrentFile file is " + curFile);
941
942 QFile f(destFile);
943 if( f.exists()) {
944 switch ( QMessageBox::warning(this,tr("Delete"),
945 destFile+tr(" already exists\nDo you really want to delete it?"),
946 tr("Yes"),tr("No"),0,0,1) ) {
947 case 0:
948 f.remove();
949 break;
950 case 1:
951 return;
952 break;
953 };
954 }
955 if(!copyFile(destFile, curFile) ) {
956 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
957
958 qWarning("nothin doing");
959 }
960 }
961 populateLocalView();
962 TabWidget->setCurrentPage(0);
963 }
964
965 }
966}
967
968void AdvancedFm::copyAs() {
969 qApp->processEvents();
970
971 QStringList curFileList = getPath();
972 QString curFile;
973 InputDialog *fileDlg;
974 if (TabWidget->currentPageIndex() == 0) {
975 qDebug("tab 1");
976 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
977 QString destFile;
978 curFile = currentDir.canonicalPath()+"/"+(*it);
979 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
980
981 fileDlg->setInputText((const QString &) destFile );
982 fileDlg->exec();
983
984 if( fileDlg->result() == 1 ) {
985 QString filename = fileDlg->LineEdit1->text();
986 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
987
988 QFile f(destFile);
989 if( f.exists()) {
990 switch (QMessageBox::warning(this,tr("Delete"),
991 destFile+tr(" already exists\nDo you really want to delete it?"),
992 tr("Yes"),tr("No"),0,0,1) ) {
993 case 0:
994 f.remove();
995 break;
996 case 1:
997 return;
998 break;
999 };
1000 }
1001 if(!copyFile(destFile, curFile) ) {
1002 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1003 qWarning("nothin doing");
1004 }
1005 }
1006 delete fileDlg;
1007
1008 }
1009 populateRemoteView();
1010 TabWidget->setCurrentPage(1);
1011
1012 } else {
1013 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1014
1015 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1016 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
1017
1018 QString destFile;
1019 fileDlg->setInputText((const QString &) destFile);
1020 fileDlg->exec();
1021
1022 if( fileDlg->result() == 1 ) {
1023 QString filename = fileDlg->LineEdit1->text();
1024 destFile = currentDir.canonicalPath()+"/"+filename;
1025
1026 QFile f( destFile);
1027 if( f.exists()) {
1028 switch ( QMessageBox::warning(this,tr("Delete"),
1029 destFile+tr(" already exists\nDo you really want to delete it?"),
1030 tr("Yes"),tr("No"),0,0,1) ) {
1031 case 0:
1032 f.remove();
1033 break;
1034 case 1:
1035 return;
1036 break;
1037 };
1038 }
1039 if(!copyFile(destFile, curFile) ) {
1040 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1041 qWarning("nothin doing");
1042 }
1043
1044 }
1045 delete fileDlg;
1046
1047 }
1048 populateLocalView();
1049 TabWidget->setCurrentPage(0);
1050 }
1051}
1052
1053void AdvancedFm::copySameDir() {
1054 qApp->processEvents();
1055 QStringList curFileList = getPath();
1056 QString curFile;
1057 InputDialog *fileDlg;
1058
1059 if (TabWidget->currentPageIndex() == 0) {
1060
1061 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1062
1063 QString destFile;
1064 curFile = currentDir.canonicalPath()+"/"+(*it);
1065
1066 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1067 fileDlg->setInputText((const QString &) destFile );
1068 fileDlg->exec();
1069
1070 if( fileDlg->result() == 1 ) {
1071
1072 QString filename = fileDlg->LineEdit1->text();
1073 destFile = currentDir.canonicalPath()+"/"+filename;
1074
1075 QFile f(destFile);
1076 if( f.exists()) {
1077 switch (QMessageBox::warning(this,tr("Delete"),
1078 destFile+tr(" already exists\nDo you really want to delete it?"),
1079 tr("Yes"),tr("No"),0,0,1) ) {
1080 case 0:
1081
1082 f.remove();
1083 break;
1084 case 1:
1085 return;
1086 break;
1087 };
1088 }
1089 if(!copyFile(destFile, curFile) ) {
1090 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1091 qWarning("nothin doing");
1092 }
1093
1094 qDebug("copy "+curFile+" as "+destFile);
1095 }
1096 delete fileDlg;
1097 }
1098 populateLocalView();
1099
1100 } else {
1101 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1102
1103 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1104
1105 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1106 QString destFile;
1107 fileDlg->setInputText((const QString &) destFile);
1108 fileDlg->exec();
1109 if( fileDlg->result() == 1 ) {
1110 QString filename = fileDlg->LineEdit1->text();
1111
1112 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
1113
1114 QFile f(destFile);
1115 if( f.exists()) {
1116 switch ( QMessageBox::warning(this,tr("Delete"),
1117 destFile+tr(" already exists\nDo you really want to delete it?"),
1118 tr("Yes"),tr("No"),0,0,1) ) {
1119 case 0:
1120 f.remove();
1121 break;
1122 case 1:
1123 return;
1124 break;
1125 };
1126 }
1127 if(!copyFile(destFile, curFile) ) {
1128 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1129 qWarning("nothin doing");
1130 }
1131 qDebug("copy "+curFile+" as "+destFile);
1132 }
1133 delete fileDlg;
1134 }
1135 populateRemoteView();
1136 }
1137}
1138
1139void AdvancedFm::move() {
1140 qApp->processEvents();
1141
1142 QStringList curFileList = getPath();
1143 if( curFileList.count() > 0) {
1144 QString curFile;
1145 QString destFile;
1146
1147 if (TabWidget->currentPageIndex() == 0) {
1148
1149 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1150
1151 QString destFile = currentRemoteDir.canonicalPath();
1152
1153 if(destFile.right(1).find("/",0,TRUE) == -1)
1154 destFile+="/";
1155 destFile +=(*it);
1156 curFile = currentDir.canonicalPath();
1157
1158 qDebug("Destination file is "+destFile);
1159
1160 if(curFile.right(1).find("/",0,TRUE) == -1)
1161 curFile +="/";
1162
1163 curFile+=(*it);
1164 qDebug("CurrentFile file is " + curFile);
1165
1166 QFile f( curFile);
1167 if( f.exists()) {
1168 if(!copyFile( destFile, curFile) ) {
1169 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
1170 return;
1171 } else
1172 QFile::remove(curFile);
1173 }
1174 }
1175
1176 TabWidget->setCurrentPage(1);
1177
1178 } else { //view 2
1179
1180 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1181
1182 QString destFile = currentDir.canonicalPath();
1183
1184 if(destFile.right(1).find("/",0,TRUE) == -1)
1185 destFile+="/";
1186
1187 destFile +=(*it);
1188
1189 qDebug("Destination file is "+destFile);
1190
1191 curFile = currentRemoteDir.canonicalPath();
1192
1193 if(curFile.right(1).find("/",0,TRUE) == -1)
1194 curFile +="/";
1195 curFile+=(*it);
1196 qDebug("CurrentFile file is " + curFile);
1197
1198 QFile f( curFile);
1199 if( f.exists()) {
1200 if(!copyFile( destFile, curFile) ) {
1201 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
1202 return;
1203 } else
1204 QFile::remove( curFile);
1205 }
1206 TabWidget->setCurrentPage(0);
1207 }
1208 }
1209 populateRemoteView();
1210 populateLocalView();
1211 }
1212}
1213
1214bool AdvancedFm::copyFile( const QString & dest, const QString & src ) {
1215 char bf[ 50000 ];
1216 int bytesRead;
1217 bool success = TRUE;
1218 struct stat status;
1219
1220 QFile s( src );
1221 QFile d( dest );
1222
1223 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
1224 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
1225 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
1226 success = FALSE;
1227 break;
1228 }
1229 }
1230 if( success && (bytesRead > 0) ){
1231 d.writeBlock( bf, bytesRead );
1232 }
1233 } else {
1234 success = FALSE;
1235 }
1236
1237 // Set file permissions
1238 if( stat( (const char *) src, &status ) == 0 ){
1239 chmod( (const char *) dest, status.st_mode );
1240 }
1241
1242 return success;
1243}
1244
1245void AdvancedFm::runCommand() {
1246 QString curFile;
1247 if (TabWidget->currentPageIndex() == 0) {
1248 if( Local_View->currentItem())
1249 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
1250 } else {
1251 if(Remote_View->currentItem())
1252 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
1253 }
1254
1255 InputDialog *fileDlg;
1256 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1257 fileDlg->setInputText(curFile);
1258 fileDlg->exec();
1259 QString command;
1260 if( fileDlg->result() == 1 ) {
1261 command = fileDlg->LineEdit1->text();
1262
1263 Output *outDlg;
1264 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1265 outDlg->showMaximized();
1266 outDlg->show();
1267 qApp->processEvents();
1268 FILE *fp;
1269 char line[130];
1270 sleep(1);
1271 command +=" 2>&1";
1272 fp = popen( (const char *) command, "r");
1273 if ( !fp ) {
1274 qDebug("Could not execute '" + command + "'! err=%d", fp);
1275 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1276 pclose(fp);
1277 return;
1278 } else {
1279 while ( fgets( line, sizeof line, fp)) {
1280 QString lineStr = line;
1281 lineStr=lineStr.left(lineStr.length()-1);
1282 outDlg->OutputEdit->append(lineStr);
1283 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1284 }
1285 }
1286 pclose(fp);
1287
1288 }
1289}
1290
1291void AdvancedFm::runCommandStd() {
1292 QString curFile;
1293 if (TabWidget->currentPageIndex() == 0) {
1294 if( Local_View->currentItem())
1295 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
1296 } else {
1297 if(Remote_View->currentItem())
1298 curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0);
1299 }
1300
1301 InputDialog *fileDlg;
1302 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1303 fileDlg->setInputText(curFile);
1304 fileDlg->exec();
1305 QString command;
1306 if( fileDlg->result() == 1 ) {
1307 qApp->processEvents();
1308 command = fileDlg->LineEdit1->text() + " &";
1309 system(command.latin1());
1310 }
1311}
1312
1313void AdvancedFm::fileStatus() {
1314 QString curFile;
1315 if (TabWidget->currentPageIndex() == 0) {
1316 curFile = Local_View->currentItem()->text(0);
1317 } else {
1318 curFile = Remote_View->currentItem()->text(0);
1319 }
1320 QString command = " stat -l "+ curFile +" 2>&1";
1321 Output *outDlg;
1322 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1323 outDlg->showMaximized();
1324 outDlg->show();
1325 qApp->processEvents();
1326 FILE *fp;
1327 char line[130];
1328 sleep(1);
1329 fp = popen( (const char *) command, "r");
1330 if ( !fp ) {
1331 qDebug("Could not execute '" + command + "'! err=%d", fp);
1332 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1333 pclose(fp);
1334 return;
1335 } else {
1336 while ( fgets( line, sizeof line, fp)) {
1337 outDlg->OutputEdit->append(line);
1338 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1339
1340 }
1341
1342 }
1343 pclose(fp);
1344} 564}
1345 565
1346void AdvancedFm::mkDir() {
1347 if (TabWidget->currentPageIndex() == 0)
1348 localMakDir();
1349 else
1350 remoteMakDir();
1351
1352}
1353 566
1354void AdvancedFm::rn() {
1355 if (TabWidget->currentPageIndex() == 0)
1356 localRename();
1357 else
1358 remoteRename();
1359
1360}
1361
1362void AdvancedFm::del() {
1363 if (TabWidget->currentPageIndex() == 0)
1364 localDelete();
1365 else
1366 remoteDelete();
1367}
1368 567
1369void AdvancedFm::doAbout() { 568void AdvancedFm::doAbout() {
1370 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 569 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
1371 "is copyright 2002 by\n" 570 "is copyright 2002 by\n"
1372 "L.J.Potter<llornkcor@handhelds.org>\n" 571 "L.J.Potter<llornkcor@handhelds.org>\n"
1373 "and is licensed by the GPL")); 572 "and is licensed by the GPL"));
1374} 573}
1375 574
1376void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 575void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
1377 if( TabWidget->hasFocus()) 576 if( TabWidget->hasFocus())
1378 switch ( e->key() ) { 577 switch ( e->key() ) {
1379 case Key_Delete: 578 case Key_Delete:
1380 del(); 579 del();
1381 break; 580 break;
1382 case Key_H: 581 case Key_H:
1383 showHidden(); 582 showHidden();
1384 break; 583 break;
1385 case Key_E: 584 case Key_E:
@@ -1429,59 +628,24 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
1429 break; 628 break;
1430 case Key_7: 629 case Key_7:
1431 break; 630 break;
1432 case Key_8: 631 case Key_8:
1433 break; 632 break;
1434 case Key_9: 633 case Key_9:
1435 break; 634 break;
1436 case Key_0: 635 case Key_0:
1437 break; 636 break;
1438 } 637 }
1439} 638}
1440 639
1441void AdvancedFm::mkSym() {
1442 QString cmd;
1443 QStringList curFileList = getPath();
1444 if( curFileList.count() > 0) {
1445
1446 if (TabWidget->currentPageIndex() == 0) {
1447 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1448
1449 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
1450 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
1451 QString curFile = currentDir.canonicalPath()+"/"+(*it);
1452 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1453 cmd = "ln -s "+curFile+" "+destName;
1454 qDebug(cmd);
1455 system(cmd.latin1() );
1456 }
1457 populateRemoteView();
1458 TabWidget->setCurrentPage(1);
1459 } else {
1460 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1461
1462 QString destName = currentDir.canonicalPath()+"/"+(*it);
1463 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
1464 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1465 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1466
1467 cmd = "ln -s "+curFile+" "+destName;
1468 qDebug(cmd);
1469 system(cmd.latin1() );
1470 }
1471 populateLocalView();
1472 TabWidget->setCurrentPage(0);
1473 }
1474 }
1475}
1476 640
1477void AdvancedFm::QPEButtonPushed() { 641void AdvancedFm::QPEButtonPushed() {
1478 QString current = QPEApplication::qpeDir(); 642 QString current = QPEApplication::qpeDir();
1479 chdir( current.latin1() ); 643 chdir( current.latin1() );
1480 if (TabWidget->currentPageIndex() == 0) { 644 if (TabWidget->currentPageIndex() == 0) {
1481 currentDir.cd( current, TRUE); 645 currentDir.cd( current, TRUE);
1482 populateLocalView(); 646 populateLocalView();
1483 } else { 647 } else {
1484 currentRemoteDir.cd( current, TRUE); 648 currentRemoteDir.cd( current, TRUE);
1485 populateRemoteView(); 649 populateRemoteView();
1486 } 650 }
1487 update(); 651 update();
@@ -1535,90 +699,53 @@ QString AdvancedFm::getDiskSpace( const QString &path) {
1535 int availBlks = fss.f_bavail; 699 int availBlks = fss.f_bavail;
1536 700
1537 long mult = blkSize / 1024; 701 long mult = blkSize / 1024;
1538 long div = 1024 / blkSize; 702 long div = 1024 / blkSize;
1539 if ( !mult ) mult = 1; 703 if ( !mult ) mult = 1;
1540 if ( !div ) div = 1; 704 if ( !div ) div = 1;
1541 705
1542 return QString::number(availBlks * mult / div); 706 return QString::number(availBlks * mult / div);
1543 } 707 }
1544 return ""; 708 return "";
1545} 709}
1546 710
1547void AdvancedFm::doBeam() {
1548 Ir ir;
1549 if(!ir.supported()){
1550 } else {
1551
1552 QStringList curFileList = getPath();
1553 if( curFileList.count() > 0) {
1554
1555 if (TabWidget->currentPageIndex() == 0) {
1556 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1557
1558 QString curFile = currentDir.canonicalPath()+"/"+(*it);
1559 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1560 Ir *file = new Ir(this, "IR");
1561 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1562 file->send( curFile, curFile );
1563 }
1564
1565 } else {
1566 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1567
1568 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1569 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1570 Ir *file = new Ir(this, "IR");
1571 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1572 file->send( curFile, curFile );
1573
1574 }
1575 }
1576 }
1577 }
1578
1579}
1580
1581void AdvancedFm::fileBeamFinished( Ir *) {
1582 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
1583
1584}
1585 711
1586void AdvancedFm::showFileMenu() { 712void AdvancedFm::showFileMenu() {
1587 713
1588 QString curApp; 714 QString curApp;
1589 bool isLocalView = false; 715 bool isLocalView = false;
1590 if (TabWidget->currentPageIndex() == 0) { 716 if (TabWidget->currentPageIndex() == 0) {
1591 isLocalView = TRUE; 717 isLocalView = TRUE;
1592 curApp = Local_View->currentItem()->text(0); 718 curApp = Local_View->currentItem()->text(0);
1593 } else { 719 } else {
1594 curApp = Remote_View->currentItem()->text(0); 720 curApp = Remote_View->currentItem()->text(0);
1595 } 721 }
1596 722
1597 MimeType mt( curApp ); 723 MimeType mt( curApp );
1598 const AppLnk* app = mt.application(); 724 const AppLnk* app = mt.application();
1599 QFile fi(curApp); 725 QFile fi(curApp);
1600 726
1601 QPopupMenu *m = new QPopupMenu(0); 727 QPopupMenu *m = new QPopupMenu(0);
1602 728
1603 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 729 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
730 if ( !QFileInfo(fi).isDir() ) {
1604 m->insertSeparator(); 731 m->insertSeparator();
1605 if ( QFileInfo(fi).isDir() ) { 732// m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
1606 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 733// } else {
1607 } else {
1608 734
1609 if ( app ) 735 if ( app )
1610 m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); 736 m->insertItem( app->pixmap(), tr( "Open in "
737 + app->name() ), this, SLOT( runThis() ) );
1611 else if( QFileInfo(fi).isExecutable() ) 738 else if( QFileInfo(fi).isExecutable() )
1612 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 739 m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) );
1613 740
1614 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 741 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
1615 } 742 }
1616 m->insertSeparator(); 743 m->insertSeparator();
1617 744
1618 745
1619 if(isLocalView) 746 if(isLocalView)
1620 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 747 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
1621 else 748 else
1622 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 749 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
1623 750
1624 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 751 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
@@ -1644,44 +771,43 @@ void AdvancedFm::showFileMenu() {
1644 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 771 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
1645 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 772 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
1646 m->insertSeparator(); 773 m->insertSeparator();
1647 774
1648 if(isLocalView) 775 if(isLocalView)
1649 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 776 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
1650 else 777 else
1651 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 778 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1652 779
1653 m->insertSeparator(); 780 m->insertSeparator();
1654 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 781 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
1655 782
1656 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings 783 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1657 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1658 m->setCheckable(TRUE); 784 m->setCheckable(TRUE);
1659 if (!b) 785 if (!b)
1660 m->setItemChecked(m->idAt(0),TRUE); 786 m->setItemChecked(m->idAt(0),TRUE);
1661 else 787 else
1662 m->setItemChecked(m->idAt(0),FALSE); 788 m->setItemChecked(m->idAt(0),FALSE);
1663 789
1664 if(Ir::supported()) 790 if(Ir::supported())
1665 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 791 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
1666 m->setFocus(); 792 m->setFocus();
1667 m->exec( QCursor::pos() ); 793 m->exec( QCursor::pos() );
1668 sleep(1); 794 sleep(1);
1669 if(m) delete m; 795 if(m) delete m;
1670} 796}
1671 797
1672 798
1673void AdvancedFm::cancelMenuTimer() { 799void AdvancedFm::cancelMenuTimer() {
1674 800
1675 qDebug("selectionChanged: cancel menu timer"); 801// qDebug("selectionChanged: cancel menu timer");
1676 if( menuTimer.isActive() ) 802 if( menuTimer.isActive() )
1677 menuTimer.stop(); 803 menuTimer.stop();
1678} 804}
1679 805
1680QString AdvancedFm::checkDiskSpace(const QString &path) { 806QString AdvancedFm::checkDiskSpace(const QString &path) {
1681 struct statfs fss; 807 struct statfs fss;
1682 if ( !statfs( path.latin1(), &fss ) ) { 808 if ( !statfs( path.latin1(), &fss ) ) {
1683 int blkSize = fss.f_bsize; 809 int blkSize = fss.f_bsize;
1684// int totalBlks = fs.f_blocks; 810// int totalBlks = fs.f_blocks;
1685 int availBlks = fss.f_bavail; 811 int availBlks = fss.f_bavail;
1686 812
1687 long mult = blkSize / 1024; 813 long mult = blkSize / 1024;
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index b2705b8..12ad474 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -2,24 +2,25 @@
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 15
15#include <qpe/ir.h> 16#include <qpe/ir.h>
16 17
17#include <qvariant.h> 18#include <qvariant.h>
18#include <qdialog.h> 19#include <qdialog.h>
19#include <qmainwindow.h> 20#include <qmainwindow.h>
20#include <qstringlist.h> 21#include <qstringlist.h>
21#include <qdir.h> 22#include <qdir.h>
22#include <qstring.h> 23#include <qstring.h>
23#include <qpoint.h> 24#include <qpoint.h>
24#include <qtimer.h> 25#include <qtimer.h>
25 26
@@ -68,24 +69,25 @@ public:
68 int currentServerConfig; 69 int currentServerConfig;
69protected slots: 70protected slots:
70 void addToDocs(); 71 void addToDocs();
71 void doLocalCd(); 72 void doLocalCd();
72 void doRemoteCd(); 73 void doRemoteCd();
73// void copy(); 74// void copy();
74 void mkDir(); 75 void mkDir();
75 void del(); 76 void del();
76 void rn(); 77 void rn();
77 void populateLocalView(); 78 void populateLocalView();
78 void populateRemoteView(); 79 void populateRemoteView();
79 void showHidden(); 80 void showHidden();
81 void showMenuHidden();
80 void showRemoteHidden(); 82 void showRemoteHidden();
81 void writeConfig(); 83 void writeConfig();
82 void readConfig(); 84 void readConfig();
83 void localListClicked(QListViewItem *); 85 void localListClicked(QListViewItem *);
84 void remoteListClicked(QListViewItem *); 86 void remoteListClicked(QListViewItem *);
85 void localListPressed( int, QListViewItem *, const QPoint&, int); 87 void localListPressed( int, QListViewItem *, const QPoint&, int);
86 void remoteListPressed( int, QListViewItem *, const QPoint&, int); 88 void remoteListPressed( int, QListViewItem *, const QPoint&, int);
87 void localMakDir(); 89 void localMakDir();
88 void localDelete(); 90 void localDelete();
89 void remoteMakDir(); 91 void remoteMakDir();
90 void remoteDelete(); 92 void remoteDelete();
91/* bool remoteDirList(const QString &); */ 93/* bool remoteDirList(const QString &); */
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index 9629f0e..eb4f122 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,16 +1,16 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h 3HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h
4SOURCES = advancedfm.cpp advancedfmData.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp 4SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp
5TARGET = advancedfm 5TARGET = advancedfm
6REQUIRES=medium-config 6REQUIRES=medium-config
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9DESTDIR = $(OPIEDIR)/bin 9DESTDIR = $(OPIEDIR)/bin
10LIBS += -lqpe 10LIBS += -lqpe
11 11
12TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ 12TRANSLATIONS = ../../../i18n/de/advancedfm.ts \
13 ../../../i18n/en/advancedfm.ts \ 13 ../../../i18n/en/advancedfm.ts \
14 ../../../i18n/es/advancedfm.ts \ 14 ../../../i18n/es/advancedfm.ts \
15 ../../../i18n/fr/advancedfm.ts \ 15 ../../../i18n/fr/advancedfm.ts \
16 ../../../i18n/hu/advancedfm.ts \ 16 ../../../i18n/hu/advancedfm.ts \
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index a4f4d59..4c24e83 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -68,25 +68,25 @@ void AdvancedFm::init() {
68 layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); 68 layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5);
69 69
70 docButton = new QToolButton( this,"docsButton"); 70 docButton = new QToolButton( this,"docsButton");
71 docButton->setPixmap(Resource::loadPixmap("DocsIcon")); 71 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
72 docButton->setFixedSize( QSize( 20, 20 ) ); 72 docButton->setFixedSize( QSize( 20, 20 ) );
73 layout->addMultiCellWidget( docButton, 0, 0, 6, 6); 73 layout->addMultiCellWidget( docButton, 0, 0, 6, 6);
74 74
75 homeButton = new QToolButton( this,"homeButton"); 75 homeButton = new QToolButton( this,"homeButton");
76 homeButton->setPixmap(Resource::loadPixmap("home")); 76 homeButton->setPixmap(Resource::loadPixmap("home"));
77 homeButton->setFixedSize( QSize( 20, 20 ) ); 77 homeButton->setFixedSize( QSize( 20, 20 ) );
78 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); 78 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7);
79 79
80 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 80 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() ));
81 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 81 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
82 fileMenu->insertSeparator(); 82 fileMenu->insertSeparator();
83 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); 83 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
84 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); 84 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
85 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); 85 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
86 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); 86 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
87 fileMenu->insertSeparator(); 87 fileMenu->insertSeparator();
88 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 88 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
89 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); 89 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
90 fileMenu->setCheckable(TRUE); 90 fileMenu->setCheckable(TRUE);
91 91
92 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 92 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
@@ -189,26 +189,25 @@ void AdvancedFm::init() {
189 189
190 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 190 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
191 currentDir.setPath( QDir::currentDirPath()); 191 currentDir.setPath( QDir::currentDirPath());
192 192
193 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 193 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
194 currentRemoteDir.setPath( QDir::currentDirPath()); 194 currentRemoteDir.setPath( QDir::currentDirPath());
195 195
196 b = TRUE; 196 b = TRUE;
197 197
198 filterStr="*"; 198 filterStr="*";
199 b=FALSE; 199 b=FALSE;
200 200
201 201
202
203} 202}
204 203
205void AdvancedFm::initConnections() { 204void AdvancedFm::initConnections() {
206 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 205 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
207 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); 206 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) );
208 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); 207 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) );
209 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); 208 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) );
210 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 209 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
211 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 210 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
212 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 211 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
213 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 212 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
214 this, SLOT( currentPathComboActivated( const QString & ) ) ); 213 this, SLOT( currentPathComboActivated( const QString & ) ) );
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
new file mode 100644
index 0000000..7ee5065
--- a/dev/null
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -0,0 +1,940 @@
1/***************************************************************************
2 AdvancedFm.cpp
3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com
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 *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
12#include "advancedfm.h"
13#include "inputDialog.h"
14#include "output.h"
15#include "filePermissions.h"
16
17#include <qpe/lnkproperties.h>
18#include <qpe/qpeapplication.h>
19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/applnk.h>
24#include <qpe/ir.h>
25
26#include <qmessagebox.h>
27#include <qmultilineedit.h>
28
29#include <qstring.h>
30
31#include <qlayout.h>
32#include <qpixmap.h>
33#include <qcombobox.h>
34#include <qpopupmenu.h>
35#include <qtabwidget.h>
36#include <qtoolbutton.h>
37#include <qtabwidget.h>
38#include <qlineedit.h>
39#include <qlistview.h>
40
41#include <stdlib.h>
42#include <unistd.h>
43#include <sys/stat.h>
44#include <dirent.h>
45
46
47void AdvancedFm::doLocalCd() {
48 localListClicked( Local_View->currentItem());
49}
50
51void AdvancedFm::doRemoteCd() {
52 localListClicked( Remote_View->currentItem());
53}
54
55void AdvancedFm::showMenuHidden() {
56 showHidden();
57 if(b) b= false; else b=true;
58 showRemoteHidden();
59}
60
61void AdvancedFm::showHidden() {
62 if (b) {
63 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
64 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
65 b=FALSE;
66
67 } else {
68 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
70 b=TRUE;
71 }
72 populateLocalView();
73
74}
75
76void AdvancedFm::showRemoteHidden() {
77 if (b) {
78 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
79 b=TRUE;
80
81 } else {
82 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
83 b=FALSE;
84 }
85 populateRemoteView();
86}
87
88void AdvancedFm::runThis() {
89 QString fs;
90 if (TabWidget->currentPageIndex() == 0) {
91 QString curFile = Local_View->currentItem()->text(0);
92 if(curFile != "../") {
93
94 fs= getFileSystemType((const QString &) currentDir.canonicalPath());
95 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
96 qDebug( fileInfo.owner());
97 if( (fileInfo.permission( QFileInfo::ExeUser)
98 | fileInfo.permission( QFileInfo::ExeGroup)
99 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
100 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
101 QCopEnvelope e("QPE/System", "execute(QString)" );
102 e << curFile;
103 } else {
104 curFile = currentDir.canonicalPath()+"/"+curFile;
105 DocLnk nf(curFile);
106 QString execStr = nf.exec();
107 qDebug( execStr);
108 if( execStr.isEmpty() ) {
109 } else {
110 nf.execute();
111 }
112 }
113 }
114 } else {
115 QString curFile = Remote_View->currentItem()->text(0);
116 if(curFile != "../") {
117
118 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
119 qDebug("Filesystemtype is "+fs);
120 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
121 if( (fileInfo.permission( QFileInfo::ExeUser)
122 | fileInfo.permission( QFileInfo::ExeGroup)
123 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
124 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
125 QCopEnvelope e("QPE/System", "execute(QString)" );
126 e << curFile;
127 } else {
128 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
129 DocLnk nf(curFile);
130 QString execStr = nf.exec();
131 qDebug(execStr);
132 if( execStr.isEmpty() ) {
133 } else {
134 nf.execute();
135 }
136 }
137 }
138 }
139}
140
141void AdvancedFm::runText() {
142 if (TabWidget->currentPageIndex() == 0) {
143 QString curFile = Local_View->currentItem()->text(0);
144 if(curFile != "../") {
145 curFile = currentDir.canonicalPath()+"/"+curFile;
146 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
147 e << curFile;
148 }
149 } else {
150 QString curFile = Remote_View->currentItem()->text(0);
151 if(curFile != "../") {
152 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
153 DocLnk nf(curFile);
154 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
155 e << curFile;
156 }
157 }
158}
159
160void AdvancedFm::localMakDir() {
161 InputDialog *fileDlg;
162 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
163 fileDlg->exec();
164 if( fileDlg->result() == 1 ) {
165 QString filename = fileDlg->LineEdit1->text();
166 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
167 }
168 populateLocalView();
169}
170
171void AdvancedFm::remoteMakDir() {
172 InputDialog *fileDlg;
173 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
174 fileDlg->exec();
175 if( fileDlg->result() == 1 ) {
176 QString filename = fileDlg->LineEdit1->text();
177 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
178 }
179 populateRemoteView();
180}
181
182void AdvancedFm::localDelete() {
183 QStringList curFileList = getPath();
184 if(curFileList.count() > 0) {
185 QString myFile;
186 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
187 myFile = (*it);
188 if( myFile.find(" -> ",0,TRUE) != -1)
189 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
190
191 QString f = currentDir.canonicalPath();
192 if(f.right(1).find("/",0,TRUE) == -1)
193 f+="/";
194 f+=myFile;
195 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
196 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
197 "\nand all it's contents ?"
198 ,tr("Yes"),tr("No"),0,0,1) ) {
199 case 0: {
200 f=f.left(f.length()-1);
201 QString cmd="rm -rf "+f;
202 system( cmd.latin1());
203 populateLocalView();
204 }
205 break;
206 case 1:
207 // exit
208 break;
209 };
210
211 } else {
212 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
213 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
214 case 0: {
215 QString cmd="rm "+f;
216 QFile file(f);
217 file.remove();
218 // system( cmd.latin1());
219 populateLocalView();
220 }
221 break;
222 case 1:
223 // exit
224 break;
225 };
226 }
227 }
228 }
229}
230
231void AdvancedFm::remoteDelete() {
232 QStringList curFileList = getPath();
233 if( curFileList.count() > 0) {
234 QString myFile;
235
236 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
237 myFile = (*it);
238 if(myFile.find(" -> ",0,TRUE) != -1)
239 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
240 QString f = currentRemoteDir.canonicalPath();
241 if(f.right(1).find("/",0,TRUE) == -1)
242 f+="/";
243 f+=myFile;
244 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
245 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
246 "\nand all it's contents ?",
247 tr("Yes"),tr("No"),0,0,1) ) {
248 case 0: {
249 f=f.left(f.length()-1);
250 QString cmd="rm -rf "+f;
251 system( cmd.latin1());
252 populateRemoteView();
253 }
254 break;
255 case 1:
256 // exit
257 break;
258 };
259
260 } else {
261 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
262 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
263 case 0: {
264 QString cmd="rm "+f;
265 QFile file(f);
266 file.remove();
267 // system( cmd.latin1());
268 populateRemoteView();
269 }
270 break;
271 case 1:
272 // exit
273 break;
274 };
275 }
276 }
277 }
278}
279
280void AdvancedFm::localRename() {
281 QString curFile = Local_View->currentItem()->text(0);
282 qDebug("currentItem "+curFile);
283 if( curFile !="../") {
284 InputDialog *fileDlg;
285 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
286 fileDlg->setInputText((const QString &)curFile);
287 fileDlg->exec();
288 if( fileDlg->result() == 1 ) {
289 QString oldname = currentDir.canonicalPath() + "/" + curFile;
290 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
291//+".playlist";
292 if( rename(oldname.latin1(), newName.latin1())== -1)
293 QMessageBox::message(tr("Note"),tr("Could not rename"));
294 }
295 populateLocalView();
296 }
297}
298
299void AdvancedFm::remoteRename()
300{
301 QString curFile = Remote_View->currentItem()->text(0);
302 if( curFile !="../") {
303 InputDialog *fileDlg;
304 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
305 fileDlg->setInputText((const QString &)curFile);
306 fileDlg->exec();
307 if( fileDlg->result() == 1 ) {
308 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
309 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
310//+".playlist";
311 if( rename(oldname.latin1(), newName.latin1())== -1)
312 QMessageBox::message(tr("Note"),tr("Could not rename"));
313 }
314 populateRemoteView();
315 }
316}
317
318
319void AdvancedFm::filePerms() {
320
321 QStringList curFileList = getPath();
322 QString filePath;
323
324 if (TabWidget->currentPageIndex() == 0) {
325 filePath = currentDir.canonicalPath()+"/";
326 } else {
327 filePath= currentRemoteDir.canonicalPath()+"/";
328 }
329
330 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
331 filePermissions *filePerm;
332 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
333 filePerm->showMaximized();
334 filePerm->exec();
335 if( filePerm)
336 delete filePerm;
337 }
338 if (TabWidget->currentPageIndex() == 0) {
339 populateLocalView();
340 } else {
341 populateRemoteView();
342 }
343}
344
345void AdvancedFm::doProperties() {
346 QStringList curFileList = getPath();
347 QString filePath;
348 if (TabWidget->currentPageIndex() == 0) {
349 filePath = currentDir.canonicalPath()+"/";
350 } else {
351 filePath= currentRemoteDir.canonicalPath()+"/";
352 }
353 // qDebug("%d",curFileList.count());
354 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
355 qDebug((filePath+*it));
356 DocLnk lnk( (filePath+*it));
357 LnkProperties prop( &lnk );
358 prop.showMaximized();
359 prop.exec();
360 }
361}
362
363void AdvancedFm::upDir() {
364 if (TabWidget->currentPageIndex() == 0) {
365 QString current = currentDir.canonicalPath();
366 QDir dir(current);
367 dir.cdUp();
368 current = dir.canonicalPath();
369 chdir( current.latin1() );
370 currentDir.cd( current, TRUE);
371 populateLocalView();
372 update();
373 } else {
374 QString current = currentRemoteDir.canonicalPath();
375 QDir dir(current);
376 dir.cdUp();
377 current = dir.canonicalPath();
378 chdir( current.latin1() );
379 currentRemoteDir.cd( current, TRUE);
380 populateRemoteView();
381 update();
382 }
383}
384
385void AdvancedFm::copy() {
386 qApp->processEvents();
387 QStringList curFileList = getPath();
388 if( curFileList.count() > 0) {
389 QString curFile, item, destFile;
390 if (TabWidget->currentPageIndex() == 0) {
391 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
392 item=(*it);
393
394 if(item.find("->",0,TRUE)) //symlink
395 item = item.left(item.find("->",0,TRUE));
396
397 destFile = currentRemoteDir.canonicalPath()+"/"+ item;
398 qDebug("Destination file is "+destFile);
399
400 curFile = currentDir.canonicalPath()+"/"+ item;
401 qDebug("CurrentFile file is " + curFile);
402
403 QFile f(destFile);
404 if( f.exists()) {
405 switch ( QMessageBox::warning(this,tr("Delete"),
406 destFile+tr(" already exists\nDo you really want to delete it?"),
407 tr("Yes"),tr("No"),0,0,1) ) {
408 case 0:
409 f.remove();
410 break;
411 case 1:
412 return;
413 break;
414 };
415 }
416 if(!copyFile(destFile, curFile) ) {
417 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
418 return;
419 }
420 }
421 populateRemoteView();
422 TabWidget->setCurrentPage(1);
423
424 } else {
425 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
426 item= (*it);
427
428 if(item.find("->",0,TRUE)) //symlink
429 item = item.left(item.find("->",0,TRUE));
430
431 destFile = currentDir.canonicalPath()+"/"+ item;
432 qDebug("Destination file is "+destFile);
433
434 curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
435 qDebug("CurrentFile file is " + curFile);
436
437 QFile f(destFile);
438 if( f.exists()) {
439 switch ( QMessageBox::warning(this,tr("Delete"),
440 destFile+tr(" already exists\nDo you really want to delete it?"),
441 tr("Yes"),tr("No"),0,0,1) ) {
442 case 0:
443 f.remove();
444 break;
445 case 1:
446 return;
447 break;
448 };
449 }
450 if(!copyFile(destFile, curFile) ) {
451 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
452 +curFile +tr("to\n")+destFile);
453 return;
454
455 }
456 }
457 populateLocalView();
458 TabWidget->setCurrentPage(0);
459 }
460
461 }
462}
463
464void AdvancedFm::copyAs() {
465 qApp->processEvents();
466
467 QStringList curFileList = getPath();
468 QString curFile;
469 InputDialog *fileDlg;
470 if (TabWidget->currentPageIndex() == 0) {
471 qDebug("tab 1");
472 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
473 QString destFile;
474 curFile = currentDir.canonicalPath()+"/"+(*it);
475 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
476
477 fileDlg->setInputText((const QString &) destFile );
478 fileDlg->exec();
479
480 if( fileDlg->result() == 1 ) {
481 QString filename = fileDlg->LineEdit1->text();
482 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
483
484 QFile f(destFile);
485 if( f.exists()) {
486 switch (QMessageBox::warning(this,tr("Delete"),
487 destFile+tr(" already exists\nDo you really want to delete it?"),
488 tr("Yes"),tr("No"),0,0,1) ) {
489 case 0:
490 f.remove();
491 break;
492 case 1:
493 return;
494 break;
495 };
496 }
497 if(!copyFile(destFile, curFile) ) {
498 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
499 +curFile +tr("to\n")+destFile);
500 return;
501 }
502 }
503 delete fileDlg;
504
505 }
506 populateRemoteView();
507 TabWidget->setCurrentPage(1);
508
509 } else {
510 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
511
512 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
513 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
514
515 QString destFile;
516 fileDlg->setInputText((const QString &) destFile);
517 fileDlg->exec();
518
519 if( fileDlg->result() == 1 ) {
520 QString filename = fileDlg->LineEdit1->text();
521 destFile = currentDir.canonicalPath()+"/"+filename;
522
523 QFile f( destFile);
524 if( f.exists()) {
525 switch ( QMessageBox::warning(this,tr("Delete"),
526 destFile+tr(" already exists\nDo you really want to delete it?"),
527 tr("Yes"),tr("No"),0,0,1) ) {
528 case 0:
529 f.remove();
530 break;
531 case 1:
532 return;
533 break;
534 };
535 }
536 if(!copyFile(destFile, curFile) ) {
537 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
538 +curFile +tr("to\n")+destFile);
539 return;
540 }
541
542 }
543 delete fileDlg;
544
545 }
546 populateLocalView();
547 TabWidget->setCurrentPage(0);
548 }
549}
550
551void AdvancedFm::copySameDir() {
552 qApp->processEvents();
553 QStringList curFileList = getPath();
554 QString curFile, item, destFile;
555 InputDialog *fileDlg;
556
557 if (TabWidget->currentPageIndex() == 0) {
558
559 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
560 item=(*it);
561 curFile = currentDir.canonicalPath()+"/"+ item;
562
563 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
564 fileDlg->setInputText((const QString &) destFile );
565 fileDlg->exec();
566
567 if( fileDlg->result() == 1 ) {
568
569 QString filename = fileDlg->LineEdit1->text();
570 destFile = currentDir.canonicalPath()+"/"+filename;
571
572 QFile f(destFile);
573 if( f.exists()) {
574 switch (QMessageBox::warning(this,tr("Delete"),
575 destFile+tr(" already exists\nDo you really want to delete it?"),
576 tr("Yes"),tr("No"),0,0,1) ) {
577 case 0:
578
579 f.remove();
580 break;
581 case 1:
582 return;
583 break;
584 };
585 }
586 if(!copyFile(destFile, curFile) ) {
587 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
588 +curFile +tr("to\n")+destFile);
589 return;
590 }
591
592 qDebug("copy "+curFile+" as "+destFile);
593 }
594 delete fileDlg;
595 }
596 populateLocalView();
597
598 } else {
599 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
600 item=(*it);
601 curFile = currentRemoteDir.canonicalPath()+"/"+ item;
602
603 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
604 fileDlg->setInputText((const QString &) destFile);
605 fileDlg->exec();
606 if( fileDlg->result() == 1 ) {
607 QString filename = fileDlg->LineEdit1->text();
608
609 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
610
611 QFile f(destFile);
612 if( f.exists()) {
613 switch ( QMessageBox::warning(this,tr("Delete"),
614 destFile+tr(" already exists\nDo you really want to delete it?"),
615 tr("Yes"),tr("No"),0,0,1) ) {
616 case 0:
617 f.remove();
618 break;
619 case 1:
620 return;
621 break;
622 };
623 }
624 if(!copyFile(destFile, curFile) ) {
625 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
626 +curFile +tr("to\n")+destFile);
627 return;
628 }
629 qDebug("copy "+curFile+" as "+destFile);
630 }
631 delete fileDlg;
632 }
633 populateRemoteView();
634 }
635}
636
637void AdvancedFm::move() {
638 qApp->processEvents();
639
640 QStringList curFileList = getPath();
641 if( curFileList.count() > 0) {
642 QString curFile, destFile, item;
643
644 if (TabWidget->currentPageIndex() == 0) {
645
646 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
647 item=(*it);
648 QString destFile = currentRemoteDir.canonicalPath();
649
650 if(destFile.right(1).find("/",0,TRUE) == -1)
651 destFile+="/";
652 destFile += item;
653 curFile = currentDir.canonicalPath();
654
655 qDebug("Destination file is "+destFile);
656
657 if(curFile.right(1).find("/",0,TRUE) == -1)
658 curFile +="/";
659
660 curFile+= item;
661 qDebug("CurrentFile file is " + curFile);
662
663 QFile f( curFile);
664 if( f.exists()) {
665 if(!copyFile( destFile, curFile) ) {
666 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
667 return;
668 } else
669 QFile::remove(curFile);
670 }
671 }
672
673 TabWidget->setCurrentPage(1);
674
675 } else { //view 2
676
677 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
678 item = (*it);
679 QString destFile = currentDir.canonicalPath();
680
681 if(destFile.right(1).find("/",0,TRUE) == -1)
682 destFile+="/";
683
684 destFile += item;
685
686 qDebug("Destination file is "+destFile);
687
688 curFile = currentRemoteDir.canonicalPath();
689
690 if(curFile.right(1).find("/",0,TRUE) == -1)
691 curFile +="/";
692 curFile+= item;
693 qDebug("CurrentFile file is " + curFile);
694
695 QFile f( curFile);
696 if( f.exists()) {
697 if(!copyFile( destFile, curFile) ) {
698 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
699 return;
700 } else
701 QFile::remove( curFile);
702 }
703 TabWidget->setCurrentPage(0);
704 }
705 }
706 populateRemoteView();
707 populateLocalView();
708 }
709}
710
711bool AdvancedFm::copyFile( const QString & dest, const QString & src ) {
712 char bf[ 50000 ];
713 int bytesRead;
714 bool success = TRUE;
715 struct stat status;
716
717 QFile s( src );
718 QFile d( dest );
719
720 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
721 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
722 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
723 success = FALSE;
724 break;
725 }
726 }
727 if( success && (bytesRead > 0) ){
728 d.writeBlock( bf, bytesRead );
729 }
730 } else {
731 success = FALSE;
732 }
733
734 // Set file permissions
735 if( stat( (const char *) src, &status ) == 0 ){
736 chmod( (const char *) dest, status.st_mode );
737 }
738
739 return success;
740}
741
742void AdvancedFm::runCommand() {
743 QString curFile;
744 if (TabWidget->currentPageIndex() == 0) {
745 if( Local_View->currentItem())
746 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
747 } else {
748 if(Remote_View->currentItem())
749 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
750 }
751
752 InputDialog *fileDlg;
753 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
754 fileDlg->setInputText(curFile);
755 fileDlg->exec();
756 QString command;
757 if( fileDlg->result() == 1 ) {
758 command = fileDlg->LineEdit1->text();
759
760 Output *outDlg;
761 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
762 outDlg->showMaximized();
763 outDlg->show();
764 qApp->processEvents();
765 FILE *fp;
766 char line[130];
767 sleep(1);
768 command +=" 2>&1";
769 fp = popen( (const char *) command, "r");
770 if ( !fp ) {
771 qDebug("Could not execute '" + command + "'! err=%d", fp);
772 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
773 pclose(fp);
774 return;
775 } else {
776 while ( fgets( line, sizeof line, fp)) {
777 QString lineStr = line;
778 lineStr=lineStr.left(lineStr.length()-1);
779 outDlg->OutputEdit->append(lineStr);
780 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
781 }
782 }
783 pclose(fp);
784
785 }
786}
787
788void AdvancedFm::runCommandStd() {
789 QString curFile;
790 if (TabWidget->currentPageIndex() == 0) {
791 if( Local_View->currentItem())
792 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
793 } else {
794 if(Remote_View->currentItem())
795 curFile = currentRemoteDir.canonicalPath() +"/"
796 + Remote_View->currentItem()->text(0);
797 }
798
799 InputDialog *fileDlg;
800 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
801 fileDlg->setInputText(curFile);
802 fileDlg->exec();
803 QString command;
804 if( fileDlg->result() == 1 ) {
805 qApp->processEvents();
806 command = fileDlg->LineEdit1->text() + " &";
807 system(command.latin1());
808 }
809}
810
811void AdvancedFm::fileStatus() {
812 QString curFile;
813 if (TabWidget->currentPageIndex() == 0) {
814 curFile = Local_View->currentItem()->text(0);
815 } else {
816 curFile = Remote_View->currentItem()->text(0);
817 }
818 QString command = " stat -l "+ curFile +" 2>&1";
819 Output *outDlg;
820 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
821 outDlg->showMaximized();
822 outDlg->show();
823 qApp->processEvents();
824 FILE *fp;
825 char line[130];
826 sleep(1);
827 fp = popen( (const char *) command, "r");
828 if ( !fp ) {
829 qDebug("Could not execute '" + command + "'! err=%d", fp);
830 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
831 pclose(fp);
832 return;
833 } else {
834 while ( fgets( line, sizeof line, fp)) {
835 outDlg->OutputEdit->append(line);
836 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
837
838 }
839
840 }
841 pclose(fp);
842}
843
844void AdvancedFm::mkDir() {
845 if (TabWidget->currentPageIndex() == 0)
846 localMakDir();
847 else
848 remoteMakDir();
849
850}
851
852void AdvancedFm::rn() {
853 if (TabWidget->currentPageIndex() == 0)
854 localRename();
855 else
856 remoteRename();
857
858}
859
860void AdvancedFm::del() {
861 if (TabWidget->currentPageIndex() == 0)
862 localDelete();
863 else
864 remoteDelete();
865}
866
867void AdvancedFm::mkSym() {
868 QString cmd;
869 QStringList curFileList = getPath();
870 if( curFileList.count() > 0) {
871
872 if (TabWidget->currentPageIndex() == 0) {
873 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
874
875 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
876 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
877 QString curFile = currentDir.canonicalPath()+"/"+(*it);
878 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
879 cmd = "ln -s "+curFile+" "+destName;
880 qDebug(cmd);
881 system(cmd.latin1() );
882 }
883 populateRemoteView();
884 TabWidget->setCurrentPage(1);
885 } else {
886 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
887
888 QString destName = currentDir.canonicalPath()+"/"+(*it);
889 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
890 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
891 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
892
893 cmd = "ln -s "+curFile+" "+destName;
894 qDebug(cmd);
895 system(cmd.latin1() );
896 }
897 populateLocalView();
898 TabWidget->setCurrentPage(0);
899 }
900 }
901}
902
903void AdvancedFm::doBeam() {
904 Ir ir;
905 if(!ir.supported()){
906 } else {
907
908 QStringList curFileList = getPath();
909 if( curFileList.count() > 0) {
910
911 if (TabWidget->currentPageIndex() == 0) {
912 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
913
914 QString curFile = currentDir.canonicalPath()+"/"+(*it);
915 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
916 Ir *file = new Ir(this, "IR");
917 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
918 file->send( curFile, curFile );
919 }
920
921 } else {
922 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
923
924 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
925 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
926 Ir *file = new Ir(this, "IR");
927 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
928 file->send( curFile, curFile );
929
930 }
931 }
932 }
933 }
934
935}
936
937void AdvancedFm::fileBeamFinished( Ir *) {
938 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
939
940}