-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 | |||
@@ -25,6 +25,7 @@ | |||
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> |
@@ -61,8 +62,10 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
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 |
@@ -83,6 +86,13 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
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 | ||
@@ -165,21 +175,23 @@ bool FileItem::rename( const QString & name ) | |||
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 ); |
@@ -202,7 +214,7 @@ void FileView::resizeEvent( QResizeEvent *e ) | |||
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 | ||
@@ -224,13 +236,16 @@ void FileView::setDir( const QString & dir ) | |||
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); |
@@ -248,7 +263,11 @@ void FileView::generateDir( const QString & dir ) | |||
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(); |
@@ -570,7 +589,11 @@ void FileView::itemClicked( QListViewItem * i) | |||
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){ |
@@ -602,7 +625,10 @@ void FileView::contentsMousePressEvent( QMouseEvent * e ) | |||
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() |
@@ -676,6 +702,21 @@ void FileView::showFileMenu() | |||
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 ) |
@@ -695,9 +736,19 @@ void FileBrowser::init(const QString & dir) | |||
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 | ||
@@ -717,14 +768,18 @@ void FileBrowser::init(const QString & dir) | |||
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" ), |
@@ -870,17 +925,6 @@ void FileBrowser::updateSorting() | |||
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; |
@@ -909,3 +953,31 @@ void FileView::chPerm() { | |||
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 | |||
@@ -54,12 +54,19 @@ class FileView : public QListView | |||
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(); |
@@ -97,6 +104,9 @@ private: | |||
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 | ||
@@ -120,7 +130,7 @@ public slots: | |||
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; |
@@ -136,10 +146,10 @@ private slots: | |||
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,4 +1,4 @@ | |||
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> |
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 | |||