summaryrefslogtreecommitdiff
path: root/noncore/unsupported/filebrowser/filebrowser.cpp
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/unsupported/filebrowser/filebrowser.cpp
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/unsupported/filebrowser/filebrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp
index 8cf8a60..92a688a 100644
--- a/noncore/unsupported/filebrowser/filebrowser.cpp
+++ b/noncore/unsupported/filebrowser/filebrowser.cpp
@@ -167,196 +167,196 @@ bool FileItem::rename( const QString & name )
167 return FALSE; 167 return FALSE;
168 168
169 if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) 169 if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) )
170 return FALSE; 170 return FALSE;
171 171
172 oldpath = fileInfo.filePath(); 172 oldpath = fileInfo.filePath();
173 newpath = fileInfo.dirPath() + "/" + name; 173 newpath = fileInfo.dirPath() + "/" + name;
174 174
175 if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) 175 if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 )
176 return FALSE; 176 return FALSE;
177 else 177 else
178 return TRUE; 178 return TRUE;
179} 179}
180 180
181QPixmap FileItem::drawThumbnail(const QFileInfo &file) { 181QPixmap FileItem::drawThumbnail(const QFileInfo &file) {
182 182
183 /* 183 /*
184 * this thing is sloooooow, and it also doesn't load 184 * this thing is sloooooow, and it also doesn't load
185 * dynamicly (like a web browser). if anyone knows how to 185 * dynamicly (like a web browser). if anyone knows how to
186 * do that, please do! 186 * do that, please do!
187 */ 187 */
188 QString cacheDir = "/tmp/filebrowserThumbnailCache"; 188 QString cacheDir = "/tmp/filebrowserThumbnailCache";
189 QFileInfo cachedFile (cacheDir + file.filePath()); 189 QFileInfo cachedFile (cacheDir + file.filePath());
190 190
191 if (cachedFile.exists() && cachedFile.lastModified() == file.lastModified()) { 191 if (cachedFile.exists() && cachedFile.lastModified() == file.lastModified()) {
192 192
193 QPixmap cachedImage (cachedFile.filePath()); 193 QPixmap cachedImage (cachedFile.filePath());
194 return cachedImage; 194 return cachedImage;
195 } 195 }
196 else { 196 else {
197 197
198 QImage image (file.filePath()); 198 QImage image (file.filePath());
199 199
200 // if inside of cache dir, don't render thumbnails! recursive error! 200 // if inside of cache dir, don't render thumbnails! recursive error!
201 if (image.isNull() || file.filePath().contains(QRegExp("^" + cacheDir))) { 201 if (image.isNull() || file.filePath().contains(QRegExp("^" + cacheDir))) {
202 DocLnk doc (file.filePath()); 202 DocLnk doc (file.filePath());
203 return doc.pixmap(); 203 return doc.pixmap();
204 } 204 }
205 Config cfg("Filebrowser"); 205 Config cfg("Filebrowser");
206 cfg.setGroup("View"); 206 cfg.setGroup("View");
207 int size; 207 int size;
208 size =cfg.readNumEntry("ThumbSize", 72); 208 size =cfg.readNumEntry("ThumbSize", 72);
209 QPixmap thumb (size, size); 209 QPixmap thumb (size, size);
210 210
211 double scale = (double)image.height() / (double)image.width(); 211 double scale = (double)image.height() / (double)image.width();
212 int newHeight = int(size * scale); 212 int newHeight = int(size * scale);
213 thumb.convertFromImage (image.smoothScale(size, newHeight)); 213 thumb.convertFromImage (image.smoothScale(size, newHeight));
214 214
215 if (!cachedFile.dir().exists()) { 215 if (!cachedFile.dir().exists()) {
216 QString cmd = "/bin/mkdir -p \"" + cachedFile.dirPath() +"\""; 216 QString cmd = "/bin/mkdir -p \"" + cachedFile.dirPath() +"\"";
217 system( (const char *) cmd ); 217 system( (const char *) cmd );
218 } 218 }
219 219
220 if (thumb.save(cachedFile.filePath(), QPixmap::imageFormat(file.filePath()), 70)) { 220 if (thumb.save(cachedFile.filePath(), QPixmap::imageFormat(file.filePath()), 70)) {
221 // make thumbnail modify time the same as the image 221 // make thumbnail modify time the same as the image
222 QString cmd = "/bin/touch -r \"" + file.filePath() +"\" " + 222 QString cmd = "/bin/touch -r \"" + file.filePath() +"\" " +
223 "\"" + cachedFile.filePath() + "\""; 223 "\"" + cachedFile.filePath() + "\"";
224 system( (const char *) cmd ); 224 system( (const char *) cmd );
225 225
226 } 226 }
227 227
228 return thumb; 228 return thumb;
229 } 229 }
230} 230}
231 231
232// 232//
233// FileView 233// FileView
234// 234//
235FileView::FileView( const QString & dir, QWidget * parent, 235FileView::FileView( const QString & dir, QWidget * parent,
236 const char * name, 236 const char * name,
237 bool hidden, bool symlinks, bool thumbnails ) 237 bool hidden, bool symlinks, bool thumbnails )
238 : QListView( parent, name ), 238 : QListView( parent, name ),
239 menuTimer( this ), 239 menuTimer( this ),
240 le( NULL ), 240 le( NULL ),
241 itemToRename( NULL ), 241 itemToRename( NULL ),
242 showHidden( hidden ), 242 showHidden( hidden ),
243 showSymlinks( symlinks ), 243 showSymlinks( symlinks ),
244 showThumbnails( thumbnails ), 244 showThumbnails( thumbnails ),
245 menuKeepsOpen( FALSE ) 245 menuKeepsOpen( FALSE )
246{ 246{
247 addColumn( "Name" ); 247 addColumn( "Name" );
248 addColumn( "Size" ); 248 addColumn( "Size" );
249 addColumn( "Date" ); 249 addColumn( "Date" );
250 addColumn( "Type" ); 250 addColumn( "Type" );
251 251
252 setMultiSelection( TRUE ); 252 setMultiSelection( TRUE );
253 //header()->hide(); 253 //header()->hide();
254 254
255 setColumnWidthMode( 0, Manual ); 255 setColumnWidthMode( 0, Manual );
256 setColumnWidthMode( 3, Manual ); 256 setColumnWidthMode( 3, Manual );
257 257
258 // right align yize column 258 // right align yize column
259 setColumnAlignment( 1, AlignRight ); 259 setColumnAlignment( 1, AlignRight );
260 260
261 generateDir( dir ); 261 generateDir( dir );
262 262
263 connect( this, SIGNAL( clicked( QListViewItem * )), 263 connect( this, SIGNAL( clicked(QListViewItem*)),
264 SLOT( itemClicked( QListViewItem * )) ); 264 SLOT( itemClicked(QListViewItem*)) );
265 connect( this, SIGNAL( doubleClicked( QListViewItem * )), 265 connect( this, SIGNAL( doubleClicked(QListViewItem*)),
266 SLOT( itemDblClicked( QListViewItem * )) ); 266 SLOT( itemDblClicked(QListViewItem*)) );
267 connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); 267 connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
268 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); 268 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
269} 269}
270 270
271void FileView::resizeEvent( QResizeEvent *e ) 271void FileView::resizeEvent( QResizeEvent *e )
272{ 272{
273 setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); 273 setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) );
274 274
275 // hide type column, we use it for "sort by type" only 275 // hide type column, we use it for "sort by type" only
276 //setColumnWidth( 3, 0 ); 276 //setColumnWidth( 3, 0 );
277 QListView::resizeEvent( e ); 277 QListView::resizeEvent( e );
278} 278}
279 279
280void FileView::updateDir() 280void FileView::updateDir()
281{ 281{
282 generateDir( currentDir ); 282 generateDir( currentDir );
283} 283}
284 284
285void FileView::setDir( const QString & dir ) 285void FileView::setDir( const QString & dir )
286{ 286{
287 if ( dir.startsWith( "/dev" ) ) { 287 if ( dir.startsWith( "/dev" ) ) {
288 QMessageBox::warning( this, tr( "File Manager" ), 288 QMessageBox::warning( this, tr( "File Manager" ),
289 tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); 289 tr( "Can't show /dev/ directory." ), tr( "&Ok" ) );
290 return; 290 return;
291 } 291 }
292 dirHistory += currentDir; 292 dirHistory += currentDir;
293 generateDir( dir ); 293 generateDir( dir );
294} 294}
295 295
296void FileView::generateDir( const QString & dir ) 296void FileView::generateDir( const QString & dir )
297{ 297{
298 if(menuKeepsOpen){ 298 if(menuKeepsOpen){
299 cancelMenuTimer(); 299 cancelMenuTimer();
300 } 300 }
301 QDir d( dir ); 301 QDir d( dir );
302 302
303 if( d.exists() && !d.isReadable() ) return; 303 if( d.exists() && !d.isReadable() ) return;
304 304
305 currentDir = d.canonicalPath(); 305 currentDir = d.canonicalPath();
306 306
307 if( !showHidden) 307 if( !showHidden)
308 d.setFilter( QDir::Dirs | QDir::Files ); 308 d.setFilter( QDir::Dirs | QDir::Files );
309 else 309 else
310 d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); 310 d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All);
311 311
312 d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); 312 d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed );
313 313
314 const QFileInfoList * list = d.entryInfoList(); 314 const QFileInfoList * list = d.entryInfoList();
315 QFileInfoListIterator it( *list ); 315 QFileInfoListIterator it( *list );
316 QFileInfo *fi; 316 QFileInfo *fi;
317 317
318 QProgressBar *thumbProgress = 0; 318 QProgressBar *thumbProgress = 0;
319 if (showThumbnails) { 319 if (showThumbnails) {
320 320
321 thumbProgress = new QProgressBar(it.count(), this); 321 thumbProgress = new QProgressBar(it.count(), this);
322 thumbProgress->show(); 322 thumbProgress->show();
323 } 323 }
324 324
325 clear(); 325 clear();
326 326
327 int fileCount = 1; // used in the thumbnail progress meter 327 int fileCount = 1; // used in the thumbnail progress meter
328 while( (fi = it.current()) ){ 328 while( (fi = it.current()) ){
329 if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ 329 if( (fi->fileName() == ".") || (fi->fileName() == "..") ){
330 ++it; 330 ++it;
331 continue; 331 continue;
332 } 332 }
333 if(!showSymlinks && fi->isSymLink()){ 333 if(!showSymlinks && fi->isSymLink()){
334 ++it; 334 ++it;
335 continue; 335 continue;
336 } 336 }
337 // thumbnail progress 337 // thumbnail progress
338 if (showThumbnails) { 338 if (showThumbnails) {
339 339
340 thumbProgress->setProgress(fileCount); 340 thumbProgress->setProgress(fileCount);
341 } 341 }
342 (void) new FileItem( (QListView *) this, *fi ); 342 (void) new FileItem( (QListView *) this, *fi );
343 343
344 ++it; 344 ++it;
345 ++fileCount; 345 ++fileCount;
346 } 346 }
347 347
348 if (showThumbnails) { 348 if (showThumbnails) {
349 thumbProgress->close(); 349 thumbProgress->close();
350 } 350 }
351 emit dirChanged(); 351 emit dirChanged();
352 352
353} 353}
354 354
355void FileView::rename() 355void FileView::rename()
356{ 356{
357 itemToRename = (FileItem *) currentItem(); 357 itemToRename = (FileItem *) currentItem();
358 const QPixmap * pm; 358 const QPixmap * pm;
359 int pmw; 359 int pmw;
360 360
361 if( itemToRename == NULL ) return; 361 if( itemToRename == NULL ) return;
362 362
@@ -815,194 +815,194 @@ FileBrowser::FileBrowser( const QString & dir, QWidget * parent,
815 init( dir ); 815 init( dir );
816} 816}
817 817
818void FileBrowser::init(const QString & dir) 818void FileBrowser::init(const QString & dir)
819{ 819{
820 setCaption( tr("File Manager") ); 820 setCaption( tr("File Manager") );
821 setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); 821 setIcon( Resource::loadPixmap( "filebrowser_icon" ) );
822 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 822 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
823 823
824 824
825 Config cfg("Filebrowser"); 825 Config cfg("Filebrowser");
826 cfg.setGroup("View"); 826 cfg.setGroup("View");
827 bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); 827 bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE");
828 bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); 828 bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE");
829 bool showThumbnails=(cfg.readEntry("Thumbnails","FALSE") == "TRUE"); 829 bool showThumbnails=(cfg.readEntry("Thumbnails","FALSE") == "TRUE");
830 830
831 cfg.setGroup("Menu"); 831 cfg.setGroup("Menu");
832 bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); 832 bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE");
833 833
834 834
835 fileView = new FileView( dir, this, 0, showHidden, showSymlinks, showThumbnails ); 835 fileView = new FileView( dir, this, 0, showHidden, showSymlinks, showThumbnails );
836 fileView->setAllColumnsShowFocus( TRUE ); 836 fileView->setAllColumnsShowFocus( TRUE );
837 fileView->setMenuKeepsOpen(menuKeepsOpen); 837 fileView->setMenuKeepsOpen(menuKeepsOpen);
838 838
839 setCentralWidget( fileView ); 839 setCentralWidget( fileView );
840 setToolBarsMovable( FALSE ); 840 setToolBarsMovable( FALSE );
841 841
842 QToolBar* toolBar = new QToolBar( this ); 842 QToolBar* toolBar = new QToolBar( this );
843 toolBar->setHorizontalStretchable( TRUE ); 843 toolBar->setHorizontalStretchable( TRUE );
844 844
845 QMenuBar* menuBar = new QMenuBar( toolBar ); 845 QMenuBar* menuBar = new QMenuBar( toolBar );
846 846
847 dirMenu = new QPopupMenu( this ); 847 dirMenu = new QPopupMenu( this );
848 menuBar->insertItem( tr( "Dir" ), dirMenu ); 848 menuBar->insertItem( tr( "Dir" ), dirMenu );
849 849
850 sortMenu = new QPopupMenu( this ); 850 sortMenu = new QPopupMenu( this );
851 menuBar->insertItem( tr( "Sort" ), sortMenu ); 851 menuBar->insertItem( tr( "Sort" ), sortMenu );
852 sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); 852 sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) );
853 sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); 853 sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) );
854 sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); 854 sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) );
855 sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); 855 sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) );
856 sortMenu->insertSeparator(); 856 sortMenu->insertSeparator();
857 sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); 857 sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) );
858 858
859 sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); 859 sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE );
860 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); 860 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE );
861 861
862 viewMenu = new QPopupMenu( this); 862 viewMenu = new QPopupMenu( this);
863 viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); 863 viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) );
864 viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); 864 viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) );
865 viewMenu->insertItem( tr( "Thumbnails"), this, SLOT( updateShowThumbnails() ) ); 865 viewMenu->insertItem( tr( "Thumbnails"), this, SLOT( updateShowThumbnails() ) );
866 viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); 866 viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden );
867 viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); 867 viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks );
868 viewMenu->setItemChecked( viewMenu->idAt( 2 ), showThumbnails ); 868 viewMenu->setItemChecked( viewMenu->idAt( 2 ), showThumbnails );
869 869
870 menuBar->insertItem( tr("View"), viewMenu ); 870 menuBar->insertItem( tr("View"), viewMenu );
871 871
872 toolBar = new QToolBar( this ); 872 toolBar = new QToolBar( this );
873 873
874 lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), 874 lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ),
875 QString::null, 0, this, 0 ); 875 QString::null, 0, this, 0 );
876 connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); 876 connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) );
877 lastAction->addTo( toolBar ); 877 lastAction->addTo( toolBar );
878 lastAction->setEnabled( FALSE ); 878 lastAction->setEnabled( FALSE );
879 879
880 upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), 880 upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ),
881 QString::null, 0, this, 0 ); 881 QString::null, 0, this, 0 );
882 connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); 882 connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) );
883 upAction->addTo( toolBar ); 883 upAction->addTo( toolBar );
884 884
885 QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), 885 QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ),
886 QString::null, 0, this, 0 ); 886 QString::null, 0, this, 0 );
887 connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); 887 connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) );
888 a->addTo( toolBar ); 888 a->addTo( toolBar );
889 889
890 a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), 890 a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ),
891 QString::null, 0, this, 0 ); 891 QString::null, 0, this, 0 );
892 connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); 892 connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) );
893 a->addTo( toolBar ); 893 a->addTo( toolBar );
894 894
895 a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), 895 a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ),
896 QString::null, 0, this, 0 ); 896 QString::null, 0, this, 0 );
897 connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); 897 connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) );
898 a->addTo( toolBar ); 898 a->addTo( toolBar );
899 899
900 pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), 900 pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ),
901 QString::null, 0, this, 0 ); 901 QString::null, 0, this, 0 );
902 connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); 902 connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) );
903 pasteAction->addTo( toolBar ); 903 pasteAction->addTo( toolBar );
904 904
905// dirLabel = new QLabel(this, "DirLabel"); 905// dirLabel = new QLabel(this, "DirLabel");
906 906
907 connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); 907 connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) );
908 updateDirMenu(); 908 updateDirMenu();
909 909
910 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); 910 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this );
911 connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), 911 connect( pcmciaChannel, SIGNAL(received(const QCString&,const QByteArray&)),
912 this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); 912 this, SLOT(pcmciaMessage(const QCString&,const QByteArray&)) );
913} 913}
914 914
915void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) 915void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &)
916{ 916{
917 if ( msg == "mtabChanged()" ) { 917 if ( msg == "mtabChanged()" ) {
918 // ## Only really needed if current dir is on a card 918 // ## Only really needed if current dir is on a card
919 fileView->updateDir(); 919 fileView->updateDir();
920 } 920 }
921} 921}
922 922
923void FileBrowser::changeCaption(const QString & dir) { 923void FileBrowser::changeCaption(const QString & dir) {
924 setCaption( dir); 924 setCaption( dir);
925} 925}
926 926
927void FileBrowser::dirSelected( int id ) 927void FileBrowser::dirSelected( int id )
928{ 928{
929 int i = 0, j; 929 int i = 0, j;
930 QString dir; 930 QString dir;
931 931
932 // Bulid target dir from menu 932 // Bulid target dir from menu
933 while( (j = dirMenu->idAt( i )) != id ){ 933 while( (j = dirMenu->idAt( i )) != id ){
934 dir += dirMenu->text( j ).stripWhiteSpace(); 934 dir += dirMenu->text( j ).stripWhiteSpace();
935 if( dirMenu->text( j ) != "/" ) dir += "/"; 935 if( dirMenu->text( j ) != "/" ) dir += "/";
936 i++; 936 i++;
937 } 937 }
938 dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); 938 dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace();
939 939
940 fileView->setDir( dir ); 940 fileView->setDir( dir );
941} 941}
942 942
943void FileBrowser::updateDirMenu() 943void FileBrowser::updateDirMenu()
944{ 944{
945 QString spc, cd = fileView->cd(); 945 QString spc, cd = fileView->cd();
946 QStringList l = QStringList::split( "/", cd ); 946 QStringList l = QStringList::split( "/", cd );
947 int i = 0; 947 int i = 0;
948 948
949 dirMenu->clear(); 949 dirMenu->clear();
950 dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); 950 dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) );
951 951
952 for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { 952 for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
953 spc.fill( ' ', i++); 953 spc.fill( ' ', i++);
954 dirMenu->insertItem( spc + (*it), this, 954 dirMenu->insertItem( spc + (*it), this,
955 SLOT( dirSelected(int) ) ); 955 SLOT( dirSelected(int) ) );
956 } 956 }
957 dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); 957 dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE );
958 958
959 lastAction->setEnabled( fileView->history().count() != 0 ); 959 lastAction->setEnabled( fileView->history().count() != 0 );
960 upAction->setEnabled( cd != "/" ); 960 upAction->setEnabled( cd != "/" );
961} 961}
962 962
963void FileBrowser::sortName() 963void FileBrowser::sortName()
964{ 964{
965 fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 965 fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
966 fileView->sort(); 966 fileView->sort();
967 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); 967 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE );
968 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); 968 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE );
969 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); 969 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE );
970 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); 970 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE );
971} 971}
972 972
973void FileBrowser::sortSize() 973void FileBrowser::sortSize()
974{ 974{
975 fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 975 fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
976 fileView->sort(); 976 fileView->sort();
977 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); 977 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE );
978 sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); 978 sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE );
979 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); 979 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE );
980 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); 980 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE );
981} 981}
982 982
983void FileBrowser::sortDate() 983void FileBrowser::sortDate()
984{ 984{
985 fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 985 fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
986 fileView->sort(); 986 fileView->sort();
987 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); 987 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE );
988 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); 988 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE );
989 sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); 989 sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE );
990 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); 990 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE );
991} 991}
992 992
993void FileBrowser::sortType() 993void FileBrowser::sortType()
994{ 994{
995 fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 995 fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
996 fileView->sort(); 996 fileView->sort();
997 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); 997 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE );
998 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); 998 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE );
999 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); 999 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE );
1000 sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); 1000 sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE );
1001} 1001}
1002 1002
1003void FileBrowser::updateSorting() 1003void FileBrowser::updateSorting()
1004{ 1004{
1005 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 1005 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
1006 1006
1007 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) 1007 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) )
1008 sortName(); 1008 sortName();