author | llornkcor <llornkcor> | 2002-03-24 21:58:35 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-24 21:58:35 (UTC) |
commit | 59e2a88589d8d3fce1a395d073516d99b4e46e78 (patch) (unidiff) | |
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 | 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 | |||
@@ -26,4 +26,5 @@ | |||
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> |
@@ -62,6 +63,8 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
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" ); |
@@ -84,4 +87,11 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
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 | } |
@@ -166,9 +176,13 @@ bool FileItem::rename( const QString & name ) | |||
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" ); |
@@ -177,8 +191,6 @@ FileView::FileView( const QString & dir, QWidget * parent, | |||
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 ); |
@@ -203,5 +215,5 @@ void FileView::resizeEvent( QResizeEvent *e ) | |||
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 | } |
@@ -225,5 +237,8 @@ void FileView::setDir( const QString & dir ) | |||
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; |
@@ -231,5 +246,5 @@ void FileView::generateDir( const QString & dir ) | |||
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 |
@@ -249,5 +264,9 @@ void FileView::generateDir( const QString & dir ) | |||
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 | } |
@@ -571,5 +590,9 @@ void FileView::itemClicked( QListViewItem * i) | |||
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; |
@@ -603,5 +626,8 @@ 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 | ||
@@ -677,4 +703,19 @@ void FileView::showFileMenu() | |||
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 ) : |
@@ -696,7 +737,17 @@ void FileBrowser::init(const QString & dir) | |||
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 ); |
@@ -718,12 +769,16 @@ void FileBrowser::init(const QString & dir) | |||
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 | ||
@@ -871,15 +926,4 @@ void FileBrowser::updateSorting() | |||
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; |
@@ -910,2 +954,30 @@ void FileView::chPerm() { | |||
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 | |||
@@ -55,5 +55,8 @@ class FileView : public QListView | |||
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; } |
@@ -61,4 +64,8 @@ public: | |||
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(); |
@@ -98,4 +105,7 @@ private: | |||
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 ); |
@@ -121,5 +131,5 @@ 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; |
@@ -137,8 +147,8 @@ private slots: | |||
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 | ||
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,3 +1,3 @@ | |||
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 |
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 | |||