-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 171 | ||||
-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.h | 33 |
2 files changed, 178 insertions, 26 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index 8c01655..10e50f0 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -13,16 +13,17 @@ | |||
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 | |||
21 | #include "inlineedit.h" | 22 | #include "inlineedit.h" |
22 | #include "filebrowser.h" | 23 | #include "filebrowser.h" |
23 | #include "filePermissions.h" | 24 | #include "filePermissions.h" |
24 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
25 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
26 | #include <qpe/mimetype.h> | 27 | #include <qpe/mimetype.h> |
27 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
@@ -38,20 +39,22 @@ | |||
38 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
39 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.h> |
40 | #include <qaction.h> | 41 | #include <qaction.h> |
41 | #include <qstringlist.h> | 42 | #include <qstringlist.h> |
42 | #include <qcursor.h> | 43 | #include <qcursor.h> |
43 | #include <qmultilineedit.h> | 44 | #include <qmultilineedit.h> |
44 | #include <qfont.h> | 45 | #include <qfont.h> |
45 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qprogressbar.h> | ||
46 | 48 | ||
47 | #include <unistd.h> | 49 | #include <unistd.h> |
48 | #include <stdlib.h> | 50 | #include <stdlib.h> |
49 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <qpe/qpeapplication.h> | ||
50 | 53 | ||
51 | // | 54 | // |
52 | // FileItem | 55 | // FileItem |
53 | // | 56 | // |
54 | FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | 57 | FileItem::FileItem( QListView * parent, const QFileInfo & fi ) |
55 | : QListViewItem( parent ), | 58 | : QListViewItem( parent ), |
56 | fileInfo( fi ) | 59 | fileInfo( fi ) |
57 | { | 60 | { |
@@ -78,20 +81,23 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
78 | pm = Resource::loadPixmap( "lockedfolder" ); | 81 | pm = Resource::loadPixmap( "lockedfolder" ); |
79 | else | 82 | else |
80 | pm = Resource::loadPixmap( "folder" ); | 83 | pm = Resource::loadPixmap( "folder" ); |
81 | } | 84 | } |
82 | else if( !fi.isReadable() ) | 85 | else if( !fi.isReadable() ) |
83 | pm = Resource::loadPixmap( "locked" ); | 86 | pm = Resource::loadPixmap( "locked" ); |
84 | else if( isLib() ) | 87 | else if( isLib() ) |
85 | pm = Resource::loadPixmap( "library" ); | 88 | pm = Resource::loadPixmap( "library" ); |
86 | else | 89 | else if( ((FileView* )parent)->getShowThumbnails() && mt.id().contains(QRegExp("^image/", FALSE, FALSE)) ) |
90 | pm = drawThumbnail(fi); | ||
91 | else | ||
87 | pm = mt.pixmap(); | 92 | pm = mt.pixmap(); |
88 | if ( pm.isNull() ) | 93 | if ( pm.isNull() ) |
89 | pm = Resource::loadPixmap("UnknownDocument-14"); | 94 | pm = Resource::loadPixmap("UnknownDocument-14"); |
95 | |||
90 | if( fi.isSymLink() ){ | 96 | if( fi.isSymLink() ){ |
91 | // overlay link image | 97 | // overlay link image |
92 | QPixmap lnk = Resource::loadPixmap( "filebrowser/symlink" ); | 98 | QPixmap lnk = Resource::loadPixmap( "filebrowser/symlink" ); |
93 | QPainter painter( &pm ); | 99 | QPainter painter( &pm ); |
94 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 100 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
95 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 101 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
96 | } | 102 | } |
97 | setPixmap(0,pm); | 103 | setPixmap(0,pm); |
@@ -167,28 +173,80 @@ bool FileItem::rename( const QString & name ) | |||
167 | newpath = fileInfo.dirPath() + "/" + name; | 173 | newpath = fileInfo.dirPath() + "/" + name; |
168 | 174 | ||
169 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) | 175 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) |
170 | return FALSE; | 176 | return FALSE; |
171 | else | 177 | else |
172 | return TRUE; | 178 | return TRUE; |
173 | } | 179 | } |
174 | 180 | ||
181 | QPixmap FileItem::drawThumbnail(const QFileInfo &file) { | ||
182 | |||
183 | /* | ||
184 | * this thing is sloooooow, and it also doesn't load | ||
185 | * dynamicly (like a web browser). if anyone knows how to | ||
186 | * do that, please do! | ||
187 | */ | ||
188 | QString cacheDir = "/tmp/filebrowserThumbnailCache"; | ||
189 | QFileInfo cachedFile (cacheDir + file.filePath()); | ||
190 | |||
191 | if (cachedFile.exists() && cachedFile.lastModified() == file.lastModified()) { | ||
192 | |||
193 | QPixmap cachedImage (cachedFile.filePath()); | ||
194 | return cachedImage; | ||
195 | } | ||
196 | else { | ||
197 | |||
198 | QImage image (file.filePath()); | ||
199 | |||
200 | // if inside of cache dir, don't render thumbnails! recursive error! | ||
201 | if (image.isNull() || file.filePath().contains(QRegExp("^" + cacheDir))) { | ||
202 | DocLnk doc (file.filePath()); | ||
203 | return doc.pixmap(); | ||
204 | } | ||
205 | Config cfg("Filebrowser"); | ||
206 | cfg.setGroup("View"); | ||
207 | int size; | ||
208 | size =cfg.readNumEntry("ThumbSize", 72); | ||
209 | QPixmap thumb (size, size); | ||
210 | |||
211 | double scale = (double)image.height() / (double)image.width(); | ||
212 | int newHeight = int(size * scale); | ||
213 | thumb.convertFromImage (image.smoothScale(size, newHeight)); | ||
214 | |||
215 | if (!cachedFile.dir().exists()) { | ||
216 | QString cmd = "/bin/mkdir -p \"" + cachedFile.dirPath() +"\""; | ||
217 | system( (const char *) cmd ); | ||
218 | } | ||
219 | |||
220 | if (thumb.save(cachedFile.filePath(), QPixmap::imageFormat(file.filePath()), 70)) { | ||
221 | // make thumbnail modify time the same as the image | ||
222 | QString cmd = "/bin/touch -r \"" + file.filePath() +"\" " + | ||
223 | "\"" + cachedFile.filePath() + "\""; | ||
224 | system( (const char *) cmd ); | ||
225 | |||
226 | } | ||
227 | |||
228 | return thumb; | ||
229 | } | ||
230 | } | ||
231 | |||
175 | // | 232 | // |
176 | // FileView | 233 | // FileView |
177 | // | 234 | // |
178 | FileView::FileView( const QString & dir, QWidget * parent, | 235 | FileView::FileView( const QString & dir, QWidget * parent, |
179 | const char * name, | 236 | const char * name, |
180 | bool hidden, bool symlinks ) | 237 | bool hidden, bool symlinks, bool thumbnails ) |
181 | : QListView( parent, name ), | 238 | : QListView( parent, name ), |
182 | menuTimer( this ), | 239 | menuTimer( this ), |
183 | le( NULL ), | 240 | le( NULL ), |
184 | itemToRename( NULL ), | 241 | itemToRename( NULL ), |
185 | showHidden( hidden ), | 242 | showHidden( hidden ), |
186 | showSymlinks( symlinks), | 243 | showSymlinks( symlinks ), |
244 | showThumbnails( thumbnails ), | ||
187 | menuKeepsOpen( FALSE ) | 245 | menuKeepsOpen( FALSE ) |
188 | { | 246 | { |
189 | addColumn( "Name" ); | 247 | addColumn( "Name" ); |
190 | addColumn( "Size" ); | 248 | addColumn( "Size" ); |
191 | addColumn( "Date" ); | 249 | addColumn( "Date" ); |
192 | addColumn( "Type" ); | 250 | addColumn( "Type" ); |
193 | 251 | ||
194 | setMultiSelection( TRUE ); | 252 | setMultiSelection( TRUE ); |
@@ -248,35 +306,55 @@ void FileView::generateDir( const QString & dir ) | |||
248 | 306 | ||
249 | if( !showHidden) | 307 | if( !showHidden) |
250 | d.setFilter( QDir::Dirs | QDir::Files ); | 308 | d.setFilter( QDir::Dirs | QDir::Files ); |
251 | else | 309 | else |
252 | d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); | 310 | d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); |
253 | 311 | ||
254 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); | 312 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); |
255 | 313 | ||
256 | |||
257 | const QFileInfoList * list = d.entryInfoList(); | 314 | const QFileInfoList * list = d.entryInfoList(); |
258 | QFileInfoListIterator it( *list ); | 315 | QFileInfoListIterator it( *list ); |
259 | QFileInfo *fi; | 316 | QFileInfo *fi; |
260 | 317 | ||
318 | QProgressBar *thumbProgress = 0; | ||
319 | if (showThumbnails) { | ||
320 | |||
321 | thumbProgress = new QProgressBar(it.count(), this); | ||
322 | thumbProgress->show(); | ||
323 | } | ||
324 | |||
261 | clear(); | 325 | clear(); |
262 | while( (fi = it.current()) ){ | 326 | |
263 | if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ | 327 | int fileCount = 1; // used in the thumbnail progress meter |
328 | while( (fi = it.current()) ){ | ||
329 | if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ | ||
330 | ++it; | ||
331 | continue; | ||
332 | } | ||
333 | if(!showSymlinks && fi->isSymLink()){ | ||
264 | ++it; | 334 | ++it; |
265 | continue; | 335 | continue; |
266 | } | 336 | } |
267 | if(!showSymlinks && fi->isSymLink()){ | 337 | // thumbnail progress |
338 | if (showThumbnails) { | ||
339 | |||
340 | thumbProgress->setProgress(fileCount); | ||
341 | } | ||
342 | (void) new FileItem( (QListView *) this, *fi ); | ||
343 | |||
268 | ++it; | 344 | ++it; |
269 | continue; | 345 | ++fileCount; |
346 | } | ||
347 | |||
348 | if (showThumbnails) { | ||
349 | thumbProgress->close(); | ||
270 | } | 350 | } |
271 | (void) new FileItem( (QListView *) this, *fi ); | ||
272 | ++it; | ||
273 | } | ||
274 | emit dirChanged(); | 351 | emit dirChanged(); |
352 | |||
275 | } | 353 | } |
276 | 354 | ||
277 | void FileView::rename() | 355 | void FileView::rename() |
278 | { | 356 | { |
279 | itemToRename = (FileItem *) currentItem(); | 357 | itemToRename = (FileItem *) currentItem(); |
280 | const QPixmap * pm; | 358 | const QPixmap * pm; |
281 | int pmw; | 359 | int pmw; |
282 | 360 | ||
@@ -458,16 +536,35 @@ void FileView::cut() | |||
458 | 536 | ||
459 | // get the names of the files to cut | 537 | // get the names of the files to cut |
460 | FileItem * item; | 538 | FileItem * item; |
461 | 539 | ||
462 | if((item = (FileItem *) firstChild()) == 0) return; | 540 | if((item = (FileItem *) firstChild()) == 0) return; |
463 | 541 | ||
464 | flist.clear(); | 542 | flist.clear(); |
465 | while( item ){ | 543 | while( item ){ |
544 | if( ite | ||
545 | // ##### a better inmplementation might be to rename the CUT file | ||
546 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. | ||
547 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; | ||
548 | QStringList newflist; | ||
549 | newflist.clear(); | ||
550 | |||
551 | cmd = "rm -rf " + cd; | ||
552 | system ( (const char *) cmd ); | ||
553 | cmd = "mkdir " + cd; | ||
554 | system( (const char *) cmd ); | ||
555 | |||
556 | // get the names of the files to cut | ||
557 | FileItem * item; | ||
558 | |||
559 | if((item = (FileItem *) firstChild()) == 0) return; | ||
560 | |||
561 | flist.clear(); | ||
562 | while( item ){ | ||
466 | if( item->isSelected() /*&& !item->isDir()*/ ){ | 563 | if( item->isSelected() /*&& !item->isDir()*/ ){ |
467 | flist += item->getFilePath(); | 564 | flist += item->getFilePath(); |
468 | } | 565 | } |
469 | item = (FileItem *) item->nextSibling(); | 566 | item = (FileItem *) item->nextSibling(); |
470 | } | 567 | } |
471 | 568 | ||
472 | // move these files into a tmp dir | 569 | // move these files into a tmp dir |
473 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { | 570 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { |
@@ -708,16 +805,21 @@ void FileView::setShowHidden(bool hidden) | |||
708 | showHidden=hidden; | 805 | showHidden=hidden; |
709 | } | 806 | } |
710 | 807 | ||
711 | void FileView::setShowSymlinks(bool symlinks) | 808 | void FileView::setShowSymlinks(bool symlinks) |
712 | { | 809 | { |
713 | showSymlinks=symlinks; | 810 | showSymlinks=symlinks; |
714 | } | 811 | } |
715 | 812 | ||
813 | void FileView::setShowThumbnails(bool thumbnails) | ||
814 | { | ||
815 | showThumbnails=thumbnails; | ||
816 | } | ||
817 | |||
716 | void FileView::setMenuKeepsOpen(bool keepOpen) | 818 | void FileView::setMenuKeepsOpen(bool keepOpen) |
717 | { | 819 | { |
718 | menuKeepsOpen=keepOpen; | 820 | menuKeepsOpen=keepOpen; |
719 | } | 821 | } |
720 | 822 | ||
721 | FileBrowser::FileBrowser( QWidget * parent, | 823 | FileBrowser::FileBrowser( QWidget * parent, |
722 | const char * name, WFlags f ) : | 824 | const char * name, WFlags f ) : |
723 | QMainWindow( parent, name, f ) | 825 | QMainWindow( parent, name, f ) |
@@ -731,27 +833,30 @@ FileBrowser::FileBrowser( const QString & dir, QWidget * parent, | |||
731 | { | 833 | { |
732 | init( dir ); | 834 | init( dir ); |
733 | } | 835 | } |
734 | 836 | ||
735 | void FileBrowser::init(const QString & dir) | 837 | void FileBrowser::init(const QString & dir) |
736 | { | 838 | { |
737 | setCaption( tr("File Manager") ); | 839 | setCaption( tr("File Manager") ); |
738 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); | 840 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); |
841 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | ||
842 | |||
739 | 843 | ||
740 | Config cfg("Filebrowser"); | 844 | Config cfg("Filebrowser"); |
741 | cfg.setGroup("View"); | 845 | cfg.setGroup("View"); |
742 | bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); | 846 | bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); |
743 | bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); | 847 | bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); |
848 | bool showThumbnails=(cfg.readEntry("Thumbnails","FALSE") == "TRUE"); | ||
744 | 849 | ||
745 | cfg.setGroup("Menu"); | 850 | cfg.setGroup("Menu"); |
746 | bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); | 851 | bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); |
747 | 852 | ||
748 | 853 | ||
749 | fileView = new FileView( dir, this, 0, showHidden, showSymlinks ); | 854 | fileView = new FileView( dir, this, 0, showHidden, showSymlinks, showThumbnails ); |
750 | fileView->setAllColumnsShowFocus( TRUE ); | 855 | fileView->setAllColumnsShowFocus( TRUE ); |
751 | fileView->setMenuKeepsOpen(menuKeepsOpen); | 856 | fileView->setMenuKeepsOpen(menuKeepsOpen); |
752 | 857 | ||
753 | setCentralWidget( fileView ); | 858 | setCentralWidget( fileView ); |
754 | setToolBarsMovable( FALSE ); | 859 | setToolBarsMovable( FALSE ); |
755 | 860 | ||
756 | QPEToolBar* toolBar = new QPEToolBar( this ); | 861 | QPEToolBar* toolBar = new QPEToolBar( this ); |
757 | toolBar->setHorizontalStretchable( TRUE ); | 862 | toolBar->setHorizontalStretchable( TRUE ); |
@@ -771,18 +876,20 @@ void FileBrowser::init(const QString & dir) | |||
771 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); | 876 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); |
772 | 877 | ||
773 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); | 878 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); |
774 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 879 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
775 | 880 | ||
776 | viewMenu = new QPopupMenu( this); | 881 | viewMenu = new QPopupMenu( this); |
777 | viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); | 882 | viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); |
778 | viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); | 883 | viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); |
884 | viewMenu->insertItem( tr( "Thumbnails"), this, SLOT( updateShowThumbnails() ) ); | ||
779 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); | 885 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); |
780 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); | 886 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); |
887 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), showThumbnails ); | ||
781 | 888 | ||
782 | menuBar->insertItem( tr("View"), viewMenu ); | 889 | menuBar->insertItem( tr("View"), viewMenu ); |
783 | 890 | ||
784 | toolBar = new QPEToolBar( this ); | 891 | toolBar = new QPEToolBar( this ); |
785 | 892 | ||
786 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), | 893 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), |
787 | QString::null, 0, this, 0 ); | 894 | QString::null, 0, this, 0 ); |
788 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); | 895 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); |
@@ -925,17 +1032,16 @@ void FileBrowser::updateSorting() | |||
925 | else | 1032 | else |
926 | sortType(); | 1033 | sortType(); |
927 | } | 1034 | } |
928 | 1035 | ||
929 | void FileView::chPerm() { | 1036 | void FileView::chPerm() { |
930 | FileItem * i; | 1037 | FileItem * i; |
931 | QStringList fl; | 1038 | QStringList fl; |
932 | QString cmd; | 1039 | QString cmd; |
933 | int err; | ||
934 | 1040 | ||
935 | if((i = (FileItem *) firstChild()) == 0) return; | 1041 | if((i = (FileItem *) firstChild()) == 0) return; |
936 | 1042 | ||
937 | while( i ){ | 1043 | while( i ){ |
938 | if( i->isSelected() ){ | 1044 | if( i->isSelected() ){ |
939 | fl += i->getFilePath(); | 1045 | fl += i->getFilePath(); |
940 | } | 1046 | } |
941 | i = (FileItem *) i->nextSibling(); | 1047 | i = (FileItem *) i->nextSibling(); |
@@ -977,8 +1083,47 @@ void FileBrowser::updateShowSymlinks() | |||
977 | fileView->setShowSymlinks(valShowSymlinks); | 1083 | fileView->setShowSymlinks(valShowSymlinks); |
978 | 1084 | ||
979 | Config cfg("Filebrowser"); | 1085 | Config cfg("Filebrowser"); |
980 | cfg.setGroup("View"); | 1086 | cfg.setGroup("View"); |
981 | cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); | 1087 | cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); |
982 | 1088 | ||
983 | fileView->updateDir(); | 1089 | fileView->updateDir(); |
984 | } | 1090 | } |
1091 | |||
1092 | void FileBrowser::updateShowThumbnails() | ||
1093 | { | ||
1094 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); | ||
1095 | valShowThumbnails=!valShowThumbnails; | ||
1096 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); | ||
1097 | fileView->setShowThumbnails(valShowThumbnails); | ||
1098 | |||
1099 | Config cfg("Filebrowser"); | ||
1100 | cfg.setGroup("View"); | ||
1101 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); | ||
1102 | |||
1103 | fileView->updateDir(); | ||
1104 | } | ||
1105 | |||
1106 | void FileBrowser::cleanUp() { | ||
1107 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; | ||
1108 | // qDebug("exit"); | ||
1109 | system(cmdr.latin1()); | ||
1110 | } | ||
1111 | |||
1112 | { | ||
1113 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); | ||
1114 | valShowThumbnails=!valShowThumbnails; | ||
1115 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); | ||
1116 | fileView->setShowThumbnails(valShowThumbnails); | ||
1117 | |||
1118 | Config cfg("Filebrowser"); | ||
1119 | cfg.setGroup("View"); | ||
1120 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); | ||
1121 | |||
1122 | fileView->updateDir(); | ||
1123 | } | ||
1124 | |||
1125 | void FileBrowser::cleanUp() { | ||
1126 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; | ||
1127 | // qDebug("exit"); | ||
1128 | system(cmdr.latin1()); | ||
1129 | } | ||
diff --git a/noncore/unsupported/filebrowser/filebrowser.h b/noncore/unsupported/filebrowser/filebrowser.h index 983e58e..549d463 100644 --- a/noncore/unsupported/filebrowser/filebrowser.h +++ b/noncore/unsupported/filebrowser/filebrowser.h | |||
@@ -40,38 +40,42 @@ public: | |||
40 | bool isDir(){ return fileInfo.isDir(); } | 40 | bool isDir(){ return fileInfo.isDir(); } |
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 ); |
45 | private: | 45 | private: |
46 | QString sizeString( unsigned int size ); | 46 | QString sizeString( unsigned int size ); |
47 | QFileInfo fileInfo; | 47 | QFileInfo fileInfo; |
48 | QPixmap FileItem::drawThumbnail(const QFileInfo &file); | ||
48 | }; | 49 | }; |
49 | 50 | ||
50 | 51 | ||
51 | class FileView : public QListView | 52 | class FileView : public QListView |
52 | { | 53 | { |
53 | Q_OBJECT | 54 | Q_OBJECT |
54 | 55 | ||
55 | public: | 56 | public: |
56 | FileView( const QString & dir, QWidget * parent = 0, | 57 | FileView( const QString & dir, QWidget * parent = 0, |
57 | const char * name = 0, | 58 | const char * name = 0, |
58 | bool hidden = FALSE, | 59 | bool hidden = FALSE, |
59 | bool symlinks = FALSE ); | 60 | bool symlinks = FALSE, |
61 | bool thumbnails = FALSE ); | ||
60 | 62 | ||
61 | void setDir( const QString & dir ); | 63 | void setDir( const QString & dir ); |
62 | QString cd(){ return currentDir; } | 64 | QString cd(){ return currentDir; } |
63 | QStringList history() const { return dirHistory; } | 65 | QStringList history() const { return dirHistory; } |
64 | bool showingHidden; | 66 | bool showingHidden; |
65 | 67 | ||
66 | void setShowHidden(bool hidden); | 68 | void setShowHidden(bool hidden); |
67 | void setShowSymlinks(bool symlinks); | 69 | void setShowSymlinks(bool symlinks); |
68 | void setMenuKeepsOpen(bool keepOpen); | 70 | void setShowThumbnails(bool thumbnails); |
69 | 71 | bool getShowThumbnails () const { return showThumbnails; } | |
72 | void setMenuKeepsOpen(bool keepOpen); | ||
73 | |||
70 | public slots: | 74 | public slots: |
71 | void updateDir(); | 75 | void updateDir(); |
72 | void parentDir(); | 76 | void parentDir(); |
73 | void lastDir(); | 77 | void lastDir(); |
74 | 78 | ||
75 | void rename(); | 79 | void rename(); |
76 | void copy(); | 80 | void copy(); |
77 | void paste(); | 81 | void paste(); |
@@ -91,27 +95,27 @@ protected slots: | |||
91 | void itemDblClicked( QListViewItem * i ); | 95 | void itemDblClicked( QListViewItem * i ); |
92 | void showFileMenu(); | 96 | void showFileMenu(); |
93 | void cancelMenuTimer(); | 97 | void cancelMenuTimer(); |
94 | void selectAll(){ QListView::selectAll( TRUE ); } | 98 | void selectAll(){ QListView::selectAll( TRUE ); } |
95 | void deselectAll(){ QListView::selectAll( FALSE ); } | 99 | void deselectAll(){ QListView::selectAll( FALSE ); } |
96 | void addToDocuments(); | 100 | void addToDocuments(); |
97 | void run(); | 101 | void run(); |
98 | void endRenaming(); | 102 | void endRenaming(); |
99 | |||
100 | private: | 103 | private: |
101 | QString currentDir; | 104 | QString currentDir; |
102 | QStringList dirHistory, flist; | 105 | QStringList dirHistory, flist; |
103 | QTimer menuTimer; | 106 | QTimer menuTimer; |
104 | InlineEdit * le; | 107 | InlineEdit * le; |
105 | FileItem * itemToRename; | 108 | FileItem * itemToRename; |
106 | bool selected; | 109 | bool selected; |
107 | bool showHidden; | 110 | bool showHidden; |
108 | bool showSymlinks; | 111 | bool showSymlinks; |
109 | bool menuKeepsOpen; | 112 | bool showThumbnails; |
113 | bool menuKeepsOpen; | ||
110 | 114 | ||
111 | bool copyFile( const QString & dest, const QString & src ); | 115 | bool copyFile( const QString & dest, const QString & src ); |
112 | 116 | ||
113 | signals: | 117 | signals: |
114 | void dirChanged(); | 118 | void dirChanged(); |
115 | void textViewActivated( QWidget * w ); | 119 | void textViewActivated( QWidget * w ); |
116 | void textViewDeactivated(); | 120 | void textViewDeactivated(); |
117 | }; | 121 | }; |
@@ -141,15 +145,18 @@ private: | |||
141 | private slots: | 145 | private slots: |
142 | void pcmciaMessage( const QCString &msg, const QByteArray &); | 146 | void pcmciaMessage( const QCString &msg, const QByteArray &); |
143 | 147 | ||
144 | void sortName(); | 148 | void sortName(); |
145 | void sortDate(); | 149 | void sortDate(); |
146 | void sortSize(); | 150 | void sortSize(); |
147 | void sortType(); | 151 | void sortType(); |
148 | void updateSorting(); | 152 | void updateSorting(); |
149 | void updateShowHidden(); | 153 | void updateShowHidden(); |
150 | void updateShowSymlinks(); | 154 | void updateShowSymlinks(); |
155 | void updateShowThumbnails(); | ||
151 | void updateDirMenu(); | 156 | void updateDirMenu(); |
152 | void dirSelected( int id ); | 157 | void dirSelected( int id ); |
158 | void cleanUp(); | ||
159 | |||
153 | }; | 160 | }; |
154 | 161 | ||
155 | #endif | 162 | #endif |