author | llornkcor <llornkcor> | 2002-03-24 21:58:35 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-24 21:58:35 (UTC) |
commit | 59e2a88589d8d3fce1a395d073516d99b4e46e78 (patch) (side-by-side diff) | |
tree | 6bcad0ead84cdacca7a264d0bf0347c675103403 | |
parent | e37311c84c3f14f947a4e28df809898d23cb2495 (diff) | |
download | opie-59e2a88589d8d3fce1a395d073516d99b4e46e78.zip opie-59e2a88589d8d3fce1a395d073516d99b4e46e78.tar.gz opie-59e2a88589d8d3fce1a395d073516d99b4e46e78.tar.bz2 |
changes sent in by Max Weninger
-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 120 | ||||
-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.h | 18 | ||||
-rw-r--r-- | noncore/unsupported/filebrowser/opie-filebrowser.control | 2 | ||||
-rw-r--r-- | pics/symlink.png | bin | 0 -> 103 bytes |
4 files changed, 111 insertions, 29 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 @@ -25,6 +25,7 @@ #include <qpe/global.h> #include <qpe/mimetype.h> #include <qpe/applnk.h> +#include <qpe/config.h> #include <qcopchannel_qws.h> #include <qpe/qcopenvelope_qws.h> @@ -61,7 +62,9 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) MimeType mt(fi.filePath()); - if( fi.isDir() ) + if ( fi.isSymLink() ) + setText( 3, "symlink" ); + else if( fi.isDir() ) setText( 3, "directory" ); else if( isLib() ) setText( 3, "library" ); @@ -83,6 +86,13 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) pm = mt.pixmap(); if ( pm.isNull() ) pm = Resource::loadPixmap("UnknownDocument-14"); + if( fi.isSymLink() ){ + // overlay link image + QPixmap lnk = Resource::loadPixmap( "symlink" ); + QPainter painter( &pm ); + painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); + pm.setMask( pm.createHeuristicMask( FALSE ) ); + } setPixmap(0,pm); } @@ -165,21 +175,23 @@ bool FileItem::rename( const QString & name ) // FileView // FileView::FileView( const QString & dir, QWidget * parent, - const char * name ) + const char * name, + bool hidden, bool symlinks ) : QListView( parent, name ), menuTimer( this ), le( NULL ), - itemToRename( NULL ) + itemToRename( NULL ), + showHidden( hidden ), + showSymlinks( symlinks), + menuKeepsOpen( FALSE ) { addColumn( "Name" ); addColumn( "Date" ); addColumn( "Size" ); addColumn( "Type" ); - showingHidden=FALSE; - setMultiSelection( TRUE ); - header()->hide(); + //header()->hide(); setColumnWidthMode( 0, Manual ); setColumnWidthMode( 3, Manual ); @@ -202,7 +214,7 @@ void FileView::resizeEvent( QResizeEvent *e ) setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); // hide type column, we use it for "sort by type" only - setColumnWidth( 3, 0 ); + //setColumnWidth( 3, 0 ); QListView::resizeEvent( e ); } @@ -224,13 +236,16 @@ void FileView::setDir( const QString & dir ) void FileView::generateDir( const QString & dir ) { + if(menuKeepsOpen){ + cancelMenuTimer(); + } QDir d( dir ); if( d.exists() && !d.isReadable() ) return; currentDir = d.canonicalPath(); - if( !showingHidden) + if( !showHidden) d.setFilter( QDir::Dirs | QDir::Files ); else d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); @@ -248,6 +263,10 @@ void FileView::generateDir( const QString & dir ) ++it; continue; } + if(!showSymlinks && fi->isSymLink()){ + ++it; + continue; + } (void) new FileItem( (QListView *) this, *fi ); ++it; } @@ -570,6 +589,10 @@ void FileView::itemClicked( QListViewItem * i) void FileView::itemDblClicked( QListViewItem * i) { + if(menuKeepsOpen){ + cancelMenuTimer(); + } + FileItem * t = (FileItem *) i; if(t == NULL) return; @@ -602,9 +625,12 @@ void FileView::contentsMousePressEvent( QMouseEvent * e ) void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) { QListView::contentsMouseReleaseEvent( e ); + if(!menuKeepsOpen){ menuTimer.stop(); } +} + void FileView::cancelMenuTimer() { if( menuTimer.isActive() ) @@ -676,6 +702,21 @@ void FileView::showFileMenu() // FileBrowser // +void FileView::setShowHidden(bool hidden) +{ + showHidden=hidden; +} + +void FileView::setShowSymlinks(bool symlinks) +{ + showSymlinks=symlinks; +} + +void FileView::setMenuKeepsOpen(bool keepOpen) +{ + menuKeepsOpen=keepOpen; +} + FileBrowser::FileBrowser( QWidget * parent, const char * name, WFlags f ) : QMainWindow( parent, name, f ) @@ -695,8 +736,18 @@ void FileBrowser::init(const QString & dir) setCaption( tr("File Manager") ); setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); - fileView = new FileView( dir, this ); + Config cfg("Filebrowser"); + cfg.setGroup("View"); + bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); + bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); + + cfg.setGroup("Menu"); + bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); + + + fileView = new FileView( dir, this, 0, showHidden, showSymlinks ); fileView->setAllColumnsShowFocus( TRUE ); + fileView->setMenuKeepsOpen(menuKeepsOpen); setCentralWidget( fileView ); setToolBarsMovable( FALSE ); @@ -717,14 +768,18 @@ void FileBrowser::init(const QString & dir) sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); sortMenu->insertSeparator(); sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); - sortMenu->insertSeparator(); - sortMenu->insertItem( tr( "Show Hidden "), this, SLOT( showHidden() ) ); - -// fileView->showingHidden=FALSE; sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); + viewMenu = new QPopupMenu( this); + viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); + viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); + viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); + viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); + + menuBar->insertItem( tr("View"), viewMenu ); + toolBar = new QPEToolBar( this ); lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), @@ -870,17 +925,6 @@ void FileBrowser::updateSorting() sortType(); } -void FileBrowser::showHidden() { - if(!fileView->showingHidden) { - fileView->showingHidden=TRUE; - sortMenu->setItemChecked( sortMenu->idAt( 7),TRUE); - } else { - fileView->showingHidden=FALSE; - sortMenu->setItemChecked( sortMenu->idAt( 7),FALSE); - } - fileView->updateDir(); -} - void FileView::chPerm() { FileItem * i; QStringList fl; @@ -909,3 +953,31 @@ void FileView::chPerm() { updateDir(); } } + +void FileBrowser::updateShowHidden() +{ + bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) ); + valShowHidden=!valShowHidden; + viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden ); + fileView->setShowHidden(valShowHidden); + + Config cfg("Filebrowser"); + cfg.setGroup("View"); + cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE"); + + fileView->updateDir(); +} + +void FileBrowser::updateShowSymlinks() +{ + bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) ); + valShowSymlinks=!valShowSymlinks; + viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks ); + fileView->setShowSymlinks(valShowSymlinks); + + Config cfg("Filebrowser"); + cfg.setGroup("View"); + cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); + + fileView->updateDir(); +} 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 @@ -54,12 +54,19 @@ class FileView : public QListView public: FileView( const QString & dir, QWidget * parent = 0, - const char * name = 0 ); + const char * name = 0, + bool hidden = FALSE, + bool symlinks = FALSE ); + void setDir( const QString & dir ); QString cd(){ return currentDir; } QStringList history() const { return dirHistory; } bool showingHidden; + void setShowHidden(bool hidden); + void setShowSymlinks(bool symlinks); + void setMenuKeepsOpen(bool keepOpen); + public slots: void updateDir(); void parentDir(); @@ -97,6 +104,9 @@ private: InlineEdit * le; FileItem * itemToRename; bool selected; + bool showHidden; + bool showSymlinks; + bool menuKeepsOpen; bool copyFile( const QString & dest, const QString & src ); @@ -120,7 +130,7 @@ public slots: private: void init(const QString & dir); QString fileToCopy; - QPopupMenu * dirMenu, * sortMenu; + QPopupMenu * dirMenu, * sortMenu, *viewMenu; FileView * fileView; QAction * pasteAction; QAction *lastAction; @@ -136,10 +146,10 @@ private slots: void sortSize(); void sortType(); void updateSorting(); - + void updateShowHidden(); + void updateShowSymlinks(); void updateDirMenu(); void dirSelected( int id ); - void showHidden(); }; #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,4 +1,4 @@ -Files: bin/filebrowser apps/Applications/filebrowser.desktop +Files: bin/filebrowser apps/Applications/filebrowser.desktop pics/symlink.png Priority: optional Section: opie/applications Maintainer: Warwick Allison <warwick@trolltech.com> diff --git a/pics/symlink.png b/pics/symlink.png Binary files differnew file mode 100644 index 0000000..a0b267a --- a/dev/null +++ b/pics/symlink.png |