author | llornkcor <llornkcor> | 2002-02-24 17:05:29 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-24 17:05:29 (UTC) |
commit | f39b6cfe0cccca9dac39b4b15cfe076426d5a4c5 (patch) (unidiff) | |
tree | e0cd32c7d9d5673ca0ef317a52f1ce9cae1957c4 | |
parent | 3008905fb88af28835417f722642d93bd1417f69 (diff) | |
download | opie-f39b6cfe0cccca9dac39b4b15cfe076426d5a4c5.zip opie-f39b6cfe0cccca9dac39b4b15cfe076426d5a4c5.tar.gz opie-f39b6cfe0cccca9dac39b4b15cfe076426d5a4c5.tar.bz2 |
changed how view as text was being executed
-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index eaf5eeb..10dff07 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -1,77 +1,79 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "inlineedit.h" | 21 | #include "inlineedit.h" |
22 | #include "filebrowser.h" | 22 | #include "filebrowser.h" |
23 | #include "filePermissions.h" | 23 | #include "filePermissions.h" |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/global.h> | 25 | #include <qpe/global.h> |
26 | #include <qpe/mimetype.h> | 26 | #include <qpe/mimetype.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | 28 | ||
29 | #include <qcopchannel_qws.h> | 29 | #include <qcopchannel_qws.h> |
30 | #include <qcopenvelope_qws.h> | ||
31 | |||
30 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
31 | #include <qdir.h> | 33 | #include <qdir.h> |
32 | #include <qregexp.h> | 34 | #include <qregexp.h> |
33 | #include <qheader.h> | 35 | #include <qheader.h> |
34 | #include <qpe/qpetoolbar.h> | 36 | #include <qpe/qpetoolbar.h> |
35 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
36 | #include <qpe/qpemenubar.h> | 38 | #include <qpe/qpemenubar.h> |
37 | #include <qaction.h> | 39 | #include <qaction.h> |
38 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
39 | #include <qcursor.h> | 41 | #include <qcursor.h> |
40 | #include <qmultilineedit.h> | 42 | #include <qmultilineedit.h> |
41 | #include <qfont.h> | 43 | #include <qfont.h> |
42 | 44 | ||
43 | #include <unistd.h> | 45 | #include <unistd.h> |
44 | #include <stdlib.h> | 46 | #include <stdlib.h> |
45 | #include <sys/stat.h> | 47 | #include <sys/stat.h> |
46 | 48 | ||
47 | // | 49 | // |
48 | // FileItem | 50 | // FileItem |
49 | // | 51 | // |
50 | FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | 52 | FileItem::FileItem( QListView * parent, const QFileInfo & fi ) |
51 | : QListViewItem( parent ), | 53 | : QListViewItem( parent ), |
52 | fileInfo( fi ) | 54 | fileInfo( fi ) |
53 | { | 55 | { |
54 | QDate d = fi.lastModified().date(); | 56 | QDate d = fi.lastModified().date(); |
55 | 57 | ||
56 | setText( 0, fi.fileName() ); | 58 | setText( 0, fi.fileName() ); |
57 | setText( 1, sizeString( fi.size() ) + " " ); | 59 | setText( 1, sizeString( fi.size() ) + " " ); |
58 | setText( 2, QString().sprintf("%4d-%02d-%02d",d.year(), d.month(), d.day() ) ); | 60 | setText( 2, QString().sprintf("%4d-%02d-%02d",d.year(), d.month(), d.day() ) ); |
59 | 61 | ||
60 | MimeType mt(fi.filePath()); | 62 | MimeType mt(fi.filePath()); |
61 | 63 | ||
62 | if( fi.isDir() ) | 64 | if( fi.isDir() ) |
63 | setText( 3, "directory" ); | 65 | setText( 3, "directory" ); |
64 | else if( isLib() ) | 66 | else if( isLib() ) |
65 | setText( 3, "library" ); | 67 | setText( 3, "library" ); |
66 | else | 68 | else |
67 | setText( 3, mt.description() ); | 69 | setText( 3, mt.description() ); |
68 | 70 | ||
69 | QPixmap pm; | 71 | QPixmap pm; |
70 | if( fi.isDir() ){ | 72 | if( fi.isDir() ){ |
71 | if( !QDir( fi.filePath() ).isReadable() ) | 73 | if( !QDir( fi.filePath() ).isReadable() ) |
72 | pm = Resource::loadPixmap( "lockedfolder" ); | 74 | pm = Resource::loadPixmap( "lockedfolder" ); |
73 | else | 75 | else |
74 | pm = Resource::loadPixmap( "folder" ); | 76 | pm = Resource::loadPixmap( "folder" ); |
75 | } | 77 | } |
76 | else if( !fi.isReadable() ) | 78 | else if( !fi.isReadable() ) |
77 | pm = Resource::loadPixmap( "locked" ); | 79 | pm = Resource::loadPixmap( "locked" ); |
@@ -501,97 +503,99 @@ void FileView::del() | |||
501 | // Dependant upon the "rm" command - will probably have to be replaced | 503 | // Dependant upon the "rm" command - will probably have to be replaced |
502 | // | 504 | // |
503 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | 505 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { |
504 | cmd = "/bin/rm -rf \"" + (*it) + "\""; | 506 | cmd = "/bin/rm -rf \"" + (*it) + "\""; |
505 | err = system( (const char *) cmd ); | 507 | err = system( (const char *) cmd ); |
506 | if ( err != 0 ) { | 508 | if ( err != 0 ) { |
507 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), | 509 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), |
508 | tr("Ok") ); | 510 | tr("Ok") ); |
509 | break; | 511 | break; |
510 | } | 512 | } |
511 | } | 513 | } |
512 | updateDir(); | 514 | updateDir(); |
513 | } | 515 | } |
514 | } | 516 | } |
515 | 517 | ||
516 | void FileView::newFolder() | 518 | void FileView::newFolder() |
517 | { | 519 | { |
518 | int t = 1; | 520 | int t = 1; |
519 | FileItem * i; | 521 | FileItem * i; |
520 | QString nd = currentDir + "/NewFolder"; | 522 | QString nd = currentDir + "/NewFolder"; |
521 | 523 | ||
522 | while( QFile( nd ).exists() ){ | 524 | while( QFile( nd ).exists() ){ |
523 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); | 525 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); |
524 | } | 526 | } |
525 | 527 | ||
526 | if( mkdir( (const char *) nd, 0777 ) != 0){ | 528 | if( mkdir( (const char *) nd, 0777 ) != 0){ |
527 | QMessageBox::warning( this, tr( "New folder" ), | 529 | QMessageBox::warning( this, tr( "New folder" ), |
528 | tr( "Folder creation failed!" ), | 530 | tr( "Folder creation failed!" ), |
529 | tr( "Ok" ) ); | 531 | tr( "Ok" ) ); |
530 | return; | 532 | return; |
531 | } | 533 | } |
532 | updateDir(); | 534 | updateDir(); |
533 | 535 | ||
534 | if((i = (FileItem *) firstChild()) == 0) return; | 536 | if((i = (FileItem *) firstChild()) == 0) return; |
535 | 537 | ||
536 | while( i ){ | 538 | while( i ){ |
537 | if( i->isDir() && ( i->getFilePath() == nd ) ){ | 539 | if( i->isDir() && ( i->getFilePath() == nd ) ){ |
538 | setCurrentItem( i ); | 540 | setCurrentItem( i ); |
539 | rename(); | 541 | rename(); |
540 | break; | 542 | break; |
541 | } | 543 | } |
542 | i = (FileItem *) i->nextSibling(); | 544 | i = (FileItem *) i->nextSibling(); |
543 | } | 545 | } |
544 | } | 546 | } |
545 | 547 | ||
546 | void FileView::viewAsText() | 548 | void FileView::viewAsText() |
547 | { | 549 | { |
548 | FileItem * i = (FileItem *) currentItem(); | 550 | FileItem * i = (FileItem *) currentItem(); |
549 | Global::execute( "textedit -f ", i->getFilePath() ); | 551 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); |
552 | e << i->getFilePath(); | ||
553 | // Global::execute( "textedit -f ", i->getFilePath() ); | ||
550 | } | 554 | } |
551 | 555 | ||
552 | void FileView::itemClicked( QListViewItem * i) | 556 | void FileView::itemClicked( QListViewItem * i) |
553 | { | 557 | { |
554 | FileItem * t = (FileItem *) i; | 558 | FileItem * t = (FileItem *) i; |
555 | 559 | ||
556 | if( t == NULL ) return; | 560 | if( t == NULL ) return; |
557 | if( t->isDir() ){ | 561 | if( t->isDir() ){ |
558 | setDir( t->getFilePath() ); | 562 | setDir( t->getFilePath() ); |
559 | } | 563 | } |
560 | } | 564 | } |
561 | 565 | ||
562 | void FileView::itemDblClicked( QListViewItem * i) | 566 | void FileView::itemDblClicked( QListViewItem * i) |
563 | { | 567 | { |
564 | FileItem * t = (FileItem *) i; | 568 | FileItem * t = (FileItem *) i; |
565 | 569 | ||
566 | if(t == NULL) return; | 570 | if(t == NULL) return; |
567 | if(t->launch() == -1){ | 571 | if(t->launch() == -1){ |
568 | QMessageBox::warning( this, tr( "Launch Application" ), | 572 | QMessageBox::warning( this, tr( "Launch Application" ), |
569 | tr( "Launch failed!" ), tr( "Ok" ) ); | 573 | tr( "Launch failed!" ), tr( "Ok" ) ); |
570 | } | 574 | } |
571 | } | 575 | } |
572 | 576 | ||
573 | void FileView::parentDir() | 577 | void FileView::parentDir() |
574 | { | 578 | { |
575 | setDir( currentDir + "./.." ); | 579 | setDir( currentDir + "./.." ); |
576 | } | 580 | } |
577 | 581 | ||
578 | void FileView::lastDir() | 582 | void FileView::lastDir() |
579 | { | 583 | { |
580 | if( dirHistory.count() == 0 ) return; | 584 | if( dirHistory.count() == 0 ) return; |
581 | 585 | ||
582 | QString newDir = dirHistory.last(); | 586 | QString newDir = dirHistory.last(); |
583 | dirHistory.remove( dirHistory.last() ); | 587 | dirHistory.remove( dirHistory.last() ); |
584 | generateDir( newDir ); | 588 | generateDir( newDir ); |
585 | } | 589 | } |
586 | 590 | ||
587 | void FileView::contentsMousePressEvent( QMouseEvent * e ) | 591 | void FileView::contentsMousePressEvent( QMouseEvent * e ) |
588 | { | 592 | { |
589 | QListView::contentsMousePressEvent( e ); | 593 | QListView::contentsMousePressEvent( e ); |
590 | menuTimer.start( 750, TRUE ); | 594 | menuTimer.start( 750, TRUE ); |
591 | } | 595 | } |
592 | 596 | ||
593 | void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) | 597 | void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) |
594 | { | 598 | { |
595 | QListView::contentsMouseReleaseEvent( e ); | 599 | QListView::contentsMouseReleaseEvent( e ); |
596 | menuTimer.stop(); | 600 | menuTimer.stop(); |
597 | } | 601 | } |