-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 132 | ||||
-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, 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 | |||
@@ -24,8 +24,9 @@ | |||
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 | ||
@@ -60,10 +61,12 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
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() ); |
@@ -82,8 +85,15 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
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 | ||
89 | QString FileItem::sizeString( unsigned int s ) | 99 | QString FileItem::sizeString( unsigned int s ) |
@@ -164,23 +174,25 @@ bool FileItem::rename( const QString & name ) | |||
164 | // | 174 | // |
165 | // FileView | 175 | // FileView |
166 | // | 176 | // |
167 | FileView::FileView( const QString & dir, QWidget * parent, | 177 | FileView::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 | ||
@@ -201,9 +213,9 @@ void 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 | ||
209 | void FileView::updateDir() | 221 | void FileView::updateDir() |
@@ -223,15 +235,18 @@ void FileView::setDir( const QString & dir ) | |||
223 | } | 235 | } |
224 | 236 | ||
225 | void FileView::generateDir( const QString & dir ) | 237 | void 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 | ||
@@ -247,9 +262,13 @@ void FileView::generateDir( const QString & dir ) | |||
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 | } |
@@ -569,9 +588,13 @@ void FileView::itemClicked( QListViewItem * i) | |||
569 | } | 588 | } |
570 | 589 | ||
571 | void FileView::itemDblClicked( QListViewItem * i) | 590 | void 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" ), |
@@ -601,9 +624,12 @@ void FileView::contentsMousePressEvent( QMouseEvent * e ) | |||
601 | 624 | ||
602 | void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) | 625 | void 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 | ||
608 | void FileView::cancelMenuTimer() | 634 | void FileView::cancelMenuTimer() |
609 | { | 635 | { |
@@ -675,8 +701,23 @@ void FileView::showFileMenu() | |||
675 | // | 701 | // |
676 | // FileBrowser | 702 | // FileBrowser |
677 | // | 703 | // |
678 | 704 | ||
705 | void FileView::setShowHidden(bool hidden) | ||
706 | { | ||
707 | showHidden=hidden; | ||
708 | } | ||
709 | |||
710 | void FileView::setShowSymlinks(bool symlinks) | ||
711 | { | ||
712 | showSymlinks=symlinks; | ||
713 | } | ||
714 | |||
715 | void FileView::setMenuKeepsOpen(bool keepOpen) | ||
716 | { | ||
717 | menuKeepsOpen=keepOpen; | ||
718 | } | ||
719 | |||
679 | FileBrowser::FileBrowser( QWidget * parent, | 720 | FileBrowser::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 | { |
@@ -694,11 +735,21 @@ void 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 ); |
@@ -716,16 +767,20 @@ void FileBrowser::init(const QString & dir) | |||
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 ); |
@@ -869,19 +924,8 @@ void FileBrowser::updateSorting() | |||
869 | else | 924 | else |
870 | sortType(); | 925 | sortType(); |
871 | } | 926 | } |
872 | 927 | ||
873 | void 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 | |||
884 | void FileView::chPerm() { | 928 | void FileView::chPerm() { |
885 | FileItem * i; | 929 | FileItem * i; |
886 | QStringList fl; | 930 | QStringList fl; |
887 | QString cmd; | 931 | QString cmd; |
@@ -908,4 +952,32 @@ void FileView::chPerm() { | |||
908 | } | 952 | } |
909 | updateDir(); | 953 | updateDir(); |
910 | } | 954 | } |
911 | } | 955 | } |
956 | |||
957 | void 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 | |||
971 | void 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 | |||
@@ -53,14 +53,21 @@ class FileView : public QListView | |||
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | 54 | ||
55 | public: | 55 | public: |
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 | |||
63 | public slots: | 70 | public slots: |
64 | void updateDir(); | 71 | void updateDir(); |
65 | void parentDir(); | 72 | void parentDir(); |
66 | void lastDir(); | 73 | void lastDir(); |
@@ -96,8 +103,11 @@ private: | |||
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 | ||
103 | signals: | 113 | signals: |
@@ -119,9 +129,9 @@ public slots: | |||
119 | void changeCaption(const QString &); | 129 | void changeCaption(const QString &); |
120 | private: | 130 | private: |
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; |
@@ -135,11 +145,11 @@ private slots: | |||
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,5 +1,5 @@ | |||
1 | Files: bin/filebrowser apps/Applications/filebrowser.desktop | 1 | Files: bin/filebrowser apps/Applications/filebrowser.desktop pics/symlink.png |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Warwick Allison <warwick@trolltech.com> |
5 | Architecture: arm | 5 | Architecture: arm |
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 | |||