summaryrefslogtreecommitdiff
path: root/noncore/unsupported/filebrowser/filebrowser.cpp
Unidiff
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
@@ -215,100 +215,100 @@ QPixmap FileItem::drawThumbnail(const QFileInfo &file) {
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();
@@ -863,98 +863,98 @@ void FileBrowser::init(const QString & dir)
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 != "/" );