summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.cpp132
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.h18
-rw-r--r--noncore/unsupported/filebrowser/opie-filebrowser.control2
-rw-r--r--pics/symlink.pngbin0 -> 103 bytes
4 files changed, 117 insertions, 35 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp
index 6f82f95..34d5177 100644
--- a/noncore/unsupported/filebrowser/filebrowser.cpp
+++ b/noncore/unsupported/filebrowser/filebrowser.cpp
@@ -12,32 +12,33 @@
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#include <qpe/config.h>
28 29
29#include <qcopchannel_qws.h> 30#include <qcopchannel_qws.h>
30#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
31 32
32#include <qmessagebox.h> 33#include <qmessagebox.h>
33#include <qdir.h> 34#include <qdir.h>
34#include <qregexp.h> 35#include <qregexp.h>
35#include <qheader.h> 36#include <qheader.h>
36#include <qpe/qpetoolbar.h> 37#include <qpe/qpetoolbar.h>
37#include <qpopupmenu.h> 38#include <qpopupmenu.h>
38#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
39#include <qaction.h> 40#include <qaction.h>
40#include <qstringlist.h> 41#include <qstringlist.h>
41#include <qcursor.h> 42#include <qcursor.h>
42#include <qmultilineedit.h> 43#include <qmultilineedit.h>
43#include <qfont.h> 44#include <qfont.h>
@@ -48,54 +49,63 @@
48 49
49// 50//
50// FileItem 51// FileItem
51// 52//
52FileItem::FileItem( QListView * parent, const QFileInfo & fi ) 53FileItem::FileItem( QListView * parent, const QFileInfo & fi )
53 : QListViewItem( parent ), 54 : QListViewItem( parent ),
54 fileInfo( fi ) 55 fileInfo( fi )
55{ 56{
56 QDate d = fi.lastModified().date(); 57 QDate d = fi.lastModified().date();
57 58
58 setText( 0, fi.fileName() ); 59 setText( 0, fi.fileName() );
59 setText( 1, sizeString( fi.size() ) + " " ); 60 setText( 1, sizeString( fi.size() ) + " " );
60 setText( 2, QString().sprintf("%4d-%02d-%02d",d.year(), d.month(), d.day() ) ); 61 setText( 2, QString().sprintf("%4d-%02d-%02d",d.year(), d.month(), d.day() ) );
61 62
62 MimeType mt(fi.filePath()); 63 MimeType mt(fi.filePath());
63 64
64 if( fi.isDir() ) 65 if ( fi.isSymLink() )
65 setText( 3, "directory" ); 66 setText( 3, "symlink" );
67 else if( fi.isDir() )
68 setText( 3, "directory" );
66 else if( isLib() ) 69 else if( isLib() )
67 setText( 3, "library" ); 70 setText( 3, "library" );
68 else 71 else
69 setText( 3, mt.description() ); 72 setText( 3, mt.description() );
70 73
71 QPixmap pm; 74 QPixmap pm;
72 if( fi.isDir() ){ 75 if( fi.isDir() ){
73 if( !QDir( fi.filePath() ).isReadable() ) 76 if( !QDir( fi.filePath() ).isReadable() )
74 pm = Resource::loadPixmap( "lockedfolder" ); 77 pm = Resource::loadPixmap( "lockedfolder" );
75 else 78 else
76 pm = Resource::loadPixmap( "folder" ); 79 pm = Resource::loadPixmap( "folder" );
77 } 80 }
78 else if( !fi.isReadable() ) 81 else if( !fi.isReadable() )
79 pm = Resource::loadPixmap( "locked" ); 82 pm = Resource::loadPixmap( "locked" );
80 else if( isLib() ) 83 else if( isLib() )
81 pm = Resource::loadPixmap( "library" ); 84 pm = Resource::loadPixmap( "library" );
82 else 85 else
83 pm = mt.pixmap(); 86 pm = mt.pixmap();
84 if ( pm.isNull() ) 87 if ( pm.isNull() )
85 pm = Resource::loadPixmap("UnknownDocument-14"); 88 pm = Resource::loadPixmap("UnknownDocument-14");
89 if( fi.isSymLink() ){
90 // overlay link image
91 QPixmap lnk = Resource::loadPixmap( "symlink" );
92 QPainter painter( &pm );
93 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
94 pm.setMask( pm.createHeuristicMask( FALSE ) );
95 }
86 setPixmap(0,pm); 96 setPixmap(0,pm);
87} 97}
88 98
89QString FileItem::sizeString( unsigned int s ) 99QString FileItem::sizeString( unsigned int s )
90{ 100{
91 double size = s; 101 double size = s;
92 102
93 if ( size > 1024 * 1024 * 1024 ) 103 if ( size > 1024 * 1024 * 1024 )
94 return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G"; 104 return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G";
95 else if ( size > 1024 * 1024 ) 105 else if ( size > 1024 * 1024 )
96 return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M"; 106 return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M";
97 else if ( size > 1024 ) 107 else if ( size > 1024 )
98 return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K"; 108 return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K";
99 else 109 else
100 return QString::number( size ) + "B"; 110 return QString::number( size ) + "B";
101} 111}
@@ -152,116 +162,125 @@ bool FileItem::rename( const QString & name )
152 if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) 162 if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) )
153 return FALSE; 163 return FALSE;
154 164
155 oldpath = fileInfo.filePath(); 165 oldpath = fileInfo.filePath();
156 newpath = fileInfo.dirPath() + "/" + name; 166 newpath = fileInfo.dirPath() + "/" + name;
157 167
158 if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) 168 if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 )
159 return FALSE; 169 return FALSE;
160 else 170 else
161 return TRUE; 171 return TRUE;
162} 172}
163 173
164// 174//
165// FileView 175// FileView
166// 176//
167FileView::FileView( const QString & dir, QWidget * parent, 177FileView::FileView( const QString & dir, QWidget * parent,
168 const char * name ) 178 const char * name,
179 bool hidden, bool symlinks )
169 : QListView( parent, name ), 180 : QListView( parent, name ),
170 menuTimer( this ), 181 menuTimer( this ),
171 le( NULL ), 182 le( NULL ),
172 itemToRename( NULL ) 183 itemToRename( NULL ),
184 showHidden( hidden ),
185 showSymlinks( symlinks),
186 menuKeepsOpen( FALSE )
173{ 187{
174 addColumn( "Name" ); 188 addColumn( "Name" );
175 addColumn( "Date" ); 189 addColumn( "Date" );
176 addColumn( "Size" ); 190 addColumn( "Size" );
177 addColumn( "Type" ); 191 addColumn( "Type" );
178 192
179 showingHidden=FALSE;
180
181 setMultiSelection( TRUE ); 193 setMultiSelection( TRUE );
182 header()->hide(); 194 //header()->hide();
183 195
184 setColumnWidthMode( 0, Manual ); 196 setColumnWidthMode( 0, Manual );
185 setColumnWidthMode( 3, Manual ); 197 setColumnWidthMode( 3, Manual );
186 198
187 // right align yize column 199 // right align yize column
188 setColumnAlignment( 1, AlignRight ); 200 setColumnAlignment( 1, AlignRight );
189 201
190 generateDir( dir ); 202 generateDir( dir );
191 203
192 connect( this, SIGNAL( clicked( QListViewItem * )), 204 connect( this, SIGNAL( clicked( QListViewItem * )),
193 SLOT( itemClicked( QListViewItem * )) ); 205 SLOT( itemClicked( QListViewItem * )) );
194 connect( this, SIGNAL( doubleClicked( QListViewItem * )), 206 connect( this, SIGNAL( doubleClicked( QListViewItem * )),
195 SLOT( itemDblClicked( QListViewItem * )) ); 207 SLOT( itemDblClicked( QListViewItem * )) );
196 connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); 208 connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
197 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); 209 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
198} 210}
199 211
200void FileView::resizeEvent( QResizeEvent *e ) 212void FileView::resizeEvent( QResizeEvent *e )
201{ 213{
202 setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); 214 setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) );
203 215
204 // hide type column, we use it for "sort by type" only 216 // hide type column, we use it for "sort by type" only
205 setColumnWidth( 3, 0 ); 217 //setColumnWidth( 3, 0 );
206 QListView::resizeEvent( e ); 218 QListView::resizeEvent( e );
207} 219}
208 220
209void FileView::updateDir() 221void FileView::updateDir()
210{ 222{
211 generateDir( currentDir ); 223 generateDir( currentDir );
212} 224}
213 225
214void FileView::setDir( const QString & dir ) 226void FileView::setDir( const QString & dir )
215{ 227{
216 if ( dir.startsWith( "/dev" ) ) { 228 if ( dir.startsWith( "/dev" ) ) {
217 QMessageBox::warning( this, tr( "File Manager" ), 229 QMessageBox::warning( this, tr( "File Manager" ),
218 tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); 230 tr( "Can't show /dev/ directory." ), tr( "&Ok" ) );
219 return; 231 return;
220 } 232 }
221 dirHistory += currentDir; 233 dirHistory += currentDir;
222 generateDir( dir ); 234 generateDir( dir );
223} 235}
224 236
225void FileView::generateDir( const QString & dir ) 237void FileView::generateDir( const QString & dir )
226{ 238{
227 QDir d( dir ); 239 if(menuKeepsOpen){
240 cancelMenuTimer();
241 }
242 QDir d( dir );
228 243
229 if( d.exists() && !d.isReadable() ) return; 244 if( d.exists() && !d.isReadable() ) return;
230 245
231 currentDir = d.canonicalPath(); 246 currentDir = d.canonicalPath();
232 247
233 if( !showingHidden) 248 if( !showHidden)
234 d.setFilter( QDir::Dirs | QDir::Files ); 249 d.setFilter( QDir::Dirs | QDir::Files );
235 else 250 else
236 d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); 251 d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All);
237 252
238 d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); 253 d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed );
239 254
240 255
241 const QFileInfoList * list = d.entryInfoList(); 256 const QFileInfoList * list = d.entryInfoList();
242 QFileInfoListIterator it( *list ); 257 QFileInfoListIterator it( *list );
243 QFileInfo *fi; 258 QFileInfo *fi;
244 259
245 clear(); 260 clear();
246 while( (fi = it.current()) ){ 261 while( (fi = it.current()) ){
247 if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ 262 if( (fi->fileName() == ".") || (fi->fileName() == "..") ){
248 ++it; 263 ++it;
249 continue; 264 continue;
250 } 265 }
251 (void) new FileItem( (QListView *) this, *fi ); 266 if(!showSymlinks && fi->isSymLink()){
267 ++it;
268 continue;
269 }
270 (void) new FileItem( (QListView *) this, *fi );
252 ++it; 271 ++it;
253 } 272 }
254 emit dirChanged(); 273 emit dirChanged();
255} 274}
256 275
257void FileView::rename() 276void FileView::rename()
258{ 277{
259 itemToRename = (FileItem *) currentItem(); 278 itemToRename = (FileItem *) currentItem();
260 const QPixmap * pm; 279 const QPixmap * pm;
261 int pmw; 280 int pmw;
262 281
263 if( itemToRename == NULL ) return; 282 if( itemToRename == NULL ) return;
264 283
265 if( ( pm = itemToRename->pixmap( 0 ) ) == NULL ) 284 if( ( pm = itemToRename->pixmap( 0 ) ) == NULL )
266 pmw = 0; 285 pmw = 0;
267 else 286 else
@@ -557,65 +576,72 @@ void FileView::viewAsText()
557 e << i->getFilePath(); 576 e << i->getFilePath();
558// Global::execute( "textedit -f ", i->getFilePath() ); 577// Global::execute( "textedit -f ", i->getFilePath() );
559} 578}
560 579
561void FileView::itemClicked( QListViewItem * i) 580void FileView::itemClicked( QListViewItem * i)
562{ 581{
563 FileItem * t = (FileItem *) i; 582 FileItem * t = (FileItem *) i;
564 583
565 if( t == NULL ) return; 584 if( t == NULL ) return;
566 if( t->isDir() ){ 585 if( t->isDir() ){
567 setDir( t->getFilePath() ); 586 setDir( t->getFilePath() );
568 } 587 }
569} 588}
570 589
571void FileView::itemDblClicked( QListViewItem * i) 590void FileView::itemDblClicked( QListViewItem * i)
572{ 591{
573 FileItem * t = (FileItem *) i; 592 if(menuKeepsOpen){
593 cancelMenuTimer();
594 }
595
596 FileItem * t = (FileItem *) i;
574 597
575 if(t == NULL) return; 598 if(t == NULL) return;
576 if(t->launch() == -1){ 599 if(t->launch() == -1){
577 QMessageBox::warning( this, tr( "Launch Application" ), 600 QMessageBox::warning( this, tr( "Launch Application" ),
578 tr( "Launch failed!" ), tr( "Ok" ) ); 601 tr( "Launch failed!" ), tr( "Ok" ) );
579 } 602 }
580} 603}
581 604
582void FileView::parentDir() 605void FileView::parentDir()
583{ 606{
584 setDir( currentDir + "./.." ); 607 setDir( currentDir + "./.." );
585} 608}
586 609
587void FileView::lastDir() 610void FileView::lastDir()
588{ 611{
589 if( dirHistory.count() == 0 ) return; 612 if( dirHistory.count() == 0 ) return;
590 613
591 QString newDir = dirHistory.last(); 614 QString newDir = dirHistory.last();
592 dirHistory.remove( dirHistory.last() ); 615 dirHistory.remove( dirHistory.last() );
593 generateDir( newDir ); 616 generateDir( newDir );
594} 617}
595 618
596void FileView::contentsMousePressEvent( QMouseEvent * e ) 619void FileView::contentsMousePressEvent( QMouseEvent * e )
597{ 620{
598 QListView::contentsMousePressEvent( e ); 621 QListView::contentsMousePressEvent( e );
599 menuTimer.start( 750, TRUE ); 622 menuTimer.start( 750, TRUE );
600} 623}
601 624
602void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) 625void FileView::contentsMouseReleaseEvent( QMouseEvent * e )
603{ 626{
604 QListView::contentsMouseReleaseEvent( e ); 627 QListView::contentsMouseReleaseEvent( e );
605 menuTimer.stop(); 628 if(!menuKeepsOpen){
629 menuTimer.stop();
630 }
631
606} 632}
607 633
608void FileView::cancelMenuTimer() 634void FileView::cancelMenuTimer()
609{ 635{
610 if( menuTimer.isActive() ) 636 if( menuTimer.isActive() )
611 menuTimer.stop(); 637 menuTimer.stop();
612} 638}
613 639
614void FileView::addToDocuments() 640void FileView::addToDocuments()
615{ 641{
616 FileItem * i = (FileItem *) currentItem(); 642 FileItem * i = (FileItem *) currentItem();
617 DocLnk f; 643 DocLnk f;
618 QString n = i->text(0); 644 QString n = i->text(0);
619 n.replace(QRegExp("\\..*"),""); 645 n.replace(QRegExp("\\..*"),"");
620 f.setName( n ); 646 f.setName( n );
621 f.setFile( i->getFilePath() ); 647 f.setFile( i->getFilePath() );
@@ -663,81 +689,110 @@ void FileView::showFileMenu()
663 689
664 tr( "Copy" ), this, SLOT( copy() ) ); 690 tr( "Copy" ), this, SLOT( copy() ) );
665 m->insertItem( Resource::loadPixmap("paste"), 691 m->insertItem( Resource::loadPixmap("paste"),
666 tr( "Paste" ), this, SLOT( paste() ) ); 692 tr( "Paste" ), this, SLOT( paste() ) );
667 m->insertItem( tr( "Change Permissions" ), this, SLOT( chPerm() ) ); 693 m->insertItem( tr( "Change Permissions" ), this, SLOT( chPerm() ) );
668 m->insertItem(Resource::loadPixmap( "close" ), tr( "Delete" ), this, SLOT( del() ) ); 694 m->insertItem(Resource::loadPixmap( "close" ), tr( "Delete" ), this, SLOT( del() ) );
669 m->insertSeparator(); 695 m->insertSeparator();
670 m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) ); 696 m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) );
671 m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) ); 697 m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) );
672 m->popup( QCursor::pos() ); 698 m->popup( QCursor::pos() );
673} 699}
674 700
675// 701//
676// FileBrowser 702// FileBrowser
677// 703//
678 704
705void FileView::setShowHidden(bool hidden)
706{
707 showHidden=hidden;
708}
709
710void FileView::setShowSymlinks(bool symlinks)
711{
712 showSymlinks=symlinks;
713}
714
715void FileView::setMenuKeepsOpen(bool keepOpen)
716{
717 menuKeepsOpen=keepOpen;
718}
719
679FileBrowser::FileBrowser( QWidget * parent, 720FileBrowser::FileBrowser( QWidget * parent,
680 const char * name, WFlags f ) : 721 const char * name, WFlags f ) :
681 QMainWindow( parent, name, f ) 722 QMainWindow( parent, name, f )
682{ 723{
683 init( QDir::current().canonicalPath() ); 724 init( QDir::current().canonicalPath() );
684} 725}
685 726
686FileBrowser::FileBrowser( const QString & dir, QWidget * parent, 727FileBrowser::FileBrowser( const QString & dir, QWidget * parent,
687 const char * name, WFlags f ) : 728 const char * name, WFlags f ) :
688 QMainWindow( parent, name, f ) 729 QMainWindow( parent, name, f )
689{ 730{
690 init( dir ); 731 init( dir );
691} 732}
692 733
693void FileBrowser::init(const QString & dir) 734void FileBrowser::init(const QString & dir)
694{ 735{
695 setCaption( tr("File Manager") ); 736 setCaption( tr("File Manager") );
696 setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); 737 setIcon( Resource::loadPixmap( "filebrowser_icon" ) );
697 738
698 fileView = new FileView( dir, this ); 739 Config cfg("Filebrowser");
699 fileView->setAllColumnsShowFocus( TRUE ); 740 cfg.setGroup("View");
741 bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE");
742 bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE");
743
744 cfg.setGroup("Menu");
745 bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE");
746
700 747
748 fileView = new FileView( dir, this, 0, showHidden, showSymlinks );
749 fileView->setAllColumnsShowFocus( TRUE );
750 fileView->setMenuKeepsOpen(menuKeepsOpen);
751
701 setCentralWidget( fileView ); 752 setCentralWidget( fileView );
702 setToolBarsMovable( FALSE ); 753 setToolBarsMovable( FALSE );
703 754
704 QPEToolBar* toolBar = new QPEToolBar( this ); 755 QPEToolBar* toolBar = new QPEToolBar( this );
705 toolBar->setHorizontalStretchable( TRUE ); 756 toolBar->setHorizontalStretchable( TRUE );
706 757
707 QPEMenuBar* menuBar = new QPEMenuBar( toolBar ); 758 QPEMenuBar* menuBar = new QPEMenuBar( toolBar );
708 759
709 dirMenu = new QPopupMenu( this ); 760 dirMenu = new QPopupMenu( this );
710 menuBar->insertItem( tr( "Dir" ), dirMenu ); 761 menuBar->insertItem( tr( "Dir" ), dirMenu );
711 762
712 sortMenu = new QPopupMenu( this ); 763 sortMenu = new QPopupMenu( this );
713 menuBar->insertItem( tr( "Sort" ), sortMenu ); 764 menuBar->insertItem( tr( "Sort" ), sortMenu );
714 sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); 765 sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) );
715 sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); 766 sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) );
716 sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); 767 sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) );
717 sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); 768 sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) );
718 sortMenu->insertSeparator(); 769 sortMenu->insertSeparator();
719 sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); 770 sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) );
720 sortMenu->insertSeparator();
721 sortMenu->insertItem( tr( "Show Hidden "), this, SLOT( showHidden() ) );
722
723// fileView->showingHidden=FALSE;
724 771
725 sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); 772 sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE );
726 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); 773 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE );
727 774
775 viewMenu = new QPopupMenu( this);
776 viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) );
777 viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) );
778 viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden );
779 viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks );
780
781 menuBar->insertItem( tr("View"), viewMenu );
782
728 toolBar = new QPEToolBar( this ); 783 toolBar = new QPEToolBar( this );
729 784
730 lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), 785 lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ),
731 QString::null, 0, this, 0 ); 786 QString::null, 0, this, 0 );
732 connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); 787 connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) );
733 lastAction->addTo( toolBar ); 788 lastAction->addTo( toolBar );
734 lastAction->setEnabled( FALSE ); 789 lastAction->setEnabled( FALSE );
735 790
736 upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), 791 upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ),
737 QString::null, 0, this, 0 ); 792 QString::null, 0, this, 0 );
738 connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); 793 connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) );
739 upAction->addTo( toolBar ); 794 upAction->addTo( toolBar );
740 795
741 QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), 796 QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ),
742 QString::null, 0, this, 0 ); 797 QString::null, 0, this, 0 );
743 connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); 798 connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) );
@@ -857,55 +912,72 @@ void FileBrowser::sortType()
857} 912}
858 913
859void FileBrowser::updateSorting() 914void FileBrowser::updateSorting()
860{ 915{
861 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 916 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
862 917
863 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) 918 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) )
864 sortName(); 919 sortName();
865 else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) 920 else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) )
866 sortSize(); 921 sortSize();
867 else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) 922 else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) )
868 sortDate(); 923 sortDate();
869 else 924 else
870 sortType(); 925 sortType();
871} 926}
872 927
873void FileBrowser::showHidden() {
874 if(!fileView->showingHidden) {
875 fileView->showingHidden=TRUE;
876 sortMenu->setItemChecked( sortMenu->idAt( 7),TRUE);
877 } else {
878 fileView->showingHidden=FALSE;
879 sortMenu->setItemChecked( sortMenu->idAt( 7),FALSE);
880 }
881 fileView->updateDir();
882}
883
884void FileView::chPerm() { 928void FileView::chPerm() {
885 FileItem * i; 929 FileItem * i;
886 QStringList fl; 930 QStringList fl;
887 QString cmd; 931 QString cmd;
888 int err; 932 int err;
889 933
890 if((i = (FileItem *) firstChild()) == 0) return; 934 if((i = (FileItem *) firstChild()) == 0) return;
891 935
892 while( i ){ 936 while( i ){
893 if( i->isSelected() ){ 937 if( i->isSelected() ){
894 fl += i->getFilePath(); 938 fl += i->getFilePath();
895 } 939 }
896 i = (FileItem *) i->nextSibling(); 940 i = (FileItem *) i->nextSibling();
897 } 941 }
898 if( fl.count() < 1 ) return; 942 if( fl.count() < 1 ) return;
899 if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), 943 if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"),
900 tr("Yes"), tr("No") ) == 0) { 944 tr("Yes"), tr("No") ) == 0) {
901 for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { 945 for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) {
902 filePermissions *filePerm; 946 filePermissions *filePerm;
903 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); 947 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it));
904 filePerm->exec(); 948 filePerm->exec();
905 if( filePerm) 949 if( filePerm)
906 delete filePerm; 950 delete filePerm;
907 break; 951 break;
908 } 952 }
909 updateDir(); 953 updateDir();
910 } 954 }
911} 955}
956
957void FileBrowser::updateShowHidden()
958{
959 bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) );
960 valShowHidden=!valShowHidden;
961 viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden );
962 fileView->setShowHidden(valShowHidden);
963
964 Config cfg("Filebrowser");
965 cfg.setGroup("View");
966 cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE");
967
968 fileView->updateDir();
969}
970
971void FileBrowser::updateShowSymlinks()
972{
973 bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) );
974 valShowSymlinks=!valShowSymlinks;
975 viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks );
976 fileView->setShowSymlinks(valShowSymlinks);
977
978 Config cfg("Filebrowser");
979 cfg.setGroup("View");
980 cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE");
981
982 fileView->updateDir();
983}
diff --git a/noncore/unsupported/filebrowser/filebrowser.h b/noncore/unsupported/filebrowser/filebrowser.h
index 54856a0..983e58e 100644
--- a/noncore/unsupported/filebrowser/filebrowser.h
+++ b/noncore/unsupported/filebrowser/filebrowser.h
@@ -41,38 +41,45 @@ public:
41 bool isExecutable(){ return fileInfo.isExecutable(); } 41 bool isExecutable(){ return fileInfo.isExecutable(); }
42 bool isLib(); 42 bool isLib();
43 int launch(); 43 int launch();
44 bool rename( const QString & name ); 44 bool rename( const QString & name );
45private: 45private:
46 QString sizeString( unsigned int size ); 46 QString sizeString( unsigned int size );
47 QFileInfo fileInfo; 47 QFileInfo fileInfo;
48}; 48};
49 49
50 50
51class FileView : public QListView 51class FileView : public QListView
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54 54
55public: 55public:
56 FileView( const QString & dir, QWidget * parent = 0, 56 FileView( const QString & dir, QWidget * parent = 0,
57 const char * name = 0 ); 57 const char * name = 0,
58 bool hidden = FALSE,
59 bool symlinks = FALSE );
60
58 void setDir( const QString & dir ); 61 void setDir( const QString & dir );
59 QString cd(){ return currentDir; } 62 QString cd(){ return currentDir; }
60 QStringList history() const { return dirHistory; } 63 QStringList history() const { return dirHistory; }
61 bool showingHidden; 64 bool showingHidden;
62 65
66 void setShowHidden(bool hidden);
67 void setShowSymlinks(bool symlinks);
68 void setMenuKeepsOpen(bool keepOpen);
69
63public slots: 70public slots:
64 void updateDir(); 71 void updateDir();
65 void parentDir(); 72 void parentDir();
66 void lastDir(); 73 void lastDir();
67 74
68 void rename(); 75 void rename();
69 void copy(); 76 void copy();
70 void paste(); 77 void paste();
71 void del(); 78 void del();
72 void cut(); 79 void cut();
73 void newFolder(); 80 void newFolder();
74 void viewAsText(); 81 void viewAsText();
75 void chPerm(); 82 void chPerm();
76protected: 83protected:
77 void generateDir( const QString & dir ); 84 void generateDir( const QString & dir );
78 void resizeEvent( QResizeEvent* ); 85 void resizeEvent( QResizeEvent* );
@@ -84,62 +91,65 @@ protected slots:
84 void itemDblClicked( QListViewItem * i ); 91 void itemDblClicked( QListViewItem * i );
85 void showFileMenu(); 92 void showFileMenu();
86 void cancelMenuTimer(); 93 void cancelMenuTimer();
87 void selectAll(){ QListView::selectAll( TRUE ); } 94 void selectAll(){ QListView::selectAll( TRUE ); }
88 void deselectAll(){ QListView::selectAll( FALSE ); } 95 void deselectAll(){ QListView::selectAll( FALSE ); }
89 void addToDocuments(); 96 void addToDocuments();
90 void run(); 97 void run();
91 void endRenaming(); 98 void endRenaming();
92 99
93private: 100private:
94 QString currentDir; 101 QString currentDir;
95 QStringList dirHistory, flist; 102 QStringList dirHistory, flist;
96 QTimer menuTimer; 103 QTimer menuTimer;
97 InlineEdit * le; 104 InlineEdit * le;
98 FileItem * itemToRename; 105 FileItem * itemToRename;
99 bool selected; 106 bool selected;
107 bool showHidden;
108 bool showSymlinks;
109 bool menuKeepsOpen;
100 110
101 bool copyFile( const QString & dest, const QString & src ); 111 bool copyFile( const QString & dest, const QString & src );
102 112
103signals: 113signals:
104 void dirChanged(); 114 void dirChanged();
105 void textViewActivated( QWidget * w ); 115 void textViewActivated( QWidget * w );
106 void textViewDeactivated(); 116 void textViewDeactivated();
107}; 117};
108 118
109class FileBrowser : public QMainWindow 119class FileBrowser : public QMainWindow
110{ 120{
111 Q_OBJECT 121 Q_OBJECT
112 122
113public: 123public:
114 FileBrowser( QWidget * parent = 0, 124 FileBrowser( QWidget * parent = 0,
115 const char * name = 0, WFlags f = 0 ); 125 const char * name = 0, WFlags f = 0 );
116 FileBrowser( const QString & dir, QWidget * parent = 0, 126 FileBrowser( const QString & dir, QWidget * parent = 0,
117 const char * name = 0, WFlags f = 0 ); 127 const char * name = 0, WFlags f = 0 );
118public slots: 128public slots:
119 void changeCaption(const QString &); 129 void changeCaption(const QString &);
120private: 130private:
121 void init(const QString & dir); 131 void init(const QString & dir);
122 QString fileToCopy; 132 QString fileToCopy;
123 QPopupMenu * dirMenu, * sortMenu; 133 QPopupMenu * dirMenu, * sortMenu, *viewMenu;
124 FileView * fileView; 134 FileView * fileView;
125 QAction * pasteAction; 135 QAction * pasteAction;
126 QAction *lastAction; 136 QAction *lastAction;
127 QAction *upAction; 137 QAction *upAction;
128 138
129 bool copyFile( const QString & dest, const QString & src ); 139 bool copyFile( const QString & dest, const QString & src );
130 140
131private slots: 141private slots:
132 void pcmciaMessage( const QCString &msg, const QByteArray &); 142 void pcmciaMessage( const QCString &msg, const QByteArray &);
133 143
134 void sortName(); 144 void sortName();
135 void sortDate(); 145 void sortDate();
136 void sortSize(); 146 void sortSize();
137 void sortType(); 147 void sortType();
138 void updateSorting(); 148 void updateSorting();
139 149 void updateShowHidden();
150 void updateShowSymlinks();
140 void updateDirMenu(); 151 void updateDirMenu();
141 void dirSelected( int id ); 152 void dirSelected( int id );
142 void showHidden();
143}; 153};
144 154
145#endif 155#endif
diff --git a/noncore/unsupported/filebrowser/opie-filebrowser.control b/noncore/unsupported/filebrowser/opie-filebrowser.control
index c15ae17..0b8528a 100644
--- a/noncore/unsupported/filebrowser/opie-filebrowser.control
+++ b/noncore/unsupported/filebrowser/opie-filebrowser.control
@@ -1,9 +1,9 @@
1Files: bin/filebrowser apps/Applications/filebrowser.desktop 1Files: bin/filebrowser apps/Applications/filebrowser.desktop pics/symlink.png
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Warwick Allison <warwick@trolltech.com> 4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION)
8Description: Browse the file system 8Description: Browse the file system
9 The filebrowser for the Opie environment. 9 The filebrowser for the Opie environment.
diff --git a/pics/symlink.png b/pics/symlink.png
new file mode 100644
index 0000000..a0b267a
--- a/dev/null
+++ b/pics/symlink.png
Binary files differ