author | llornkcor <llornkcor> | 2002-02-24 15:27:06 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-24 15:27:06 (UTC) |
commit | a43106c752dae2404f33a07dc80851c4a745d2bc (patch) (unidiff) | |
tree | 1bddeba58034bc08c6a24d656098d9104df99ee6 /noncore/unsupported/filebrowser/filebrowser.cpp | |
parent | 7dd14b051a5c1bad0fd0c76c00d06b0d51e1f17f (diff) | |
download | opie-a43106c752dae2404f33a07dc80851c4a745d2bc.zip opie-a43106c752dae2404f33a07dc80851c4a745d2bc.tar.gz opie-a43106c752dae2404f33a07dc80851c4a745d2bc.tar.bz2 |
added permissions dialog
Diffstat (limited to 'noncore/unsupported/filebrowser/filebrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 422 |
1 files changed, 226 insertions, 196 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index 9439bb8..384d7da 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -21,5 +21,5 @@ | |||
21 | #include "inlineedit.h" | 21 | #include "inlineedit.h" |
22 | #include "filebrowser.h" | 22 | #include "filebrowser.h" |
23 | 23 | #include "filePermissions.h" | |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/global.h> | 25 | #include <qpe/global.h> |
@@ -61,25 +61,25 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | |||
61 | 61 | ||
62 | if( fi.isDir() ) | 62 | if( fi.isDir() ) |
63 | setText( 3, "directory" ); | 63 | setText( 3, "directory" ); |
64 | else if( isLib() ) | 64 | else if( isLib() ) |
65 | setText( 3, "library" ); | 65 | setText( 3, "library" ); |
66 | else | 66 | else |
67 | setText( 3, mt.description() ); | 67 | setText( 3, mt.description() ); |
68 | 68 | ||
69 | QPixmap pm; | 69 | QPixmap pm; |
70 | if( fi.isDir() ){ | 70 | if( fi.isDir() ){ |
71 | if( !QDir( fi.filePath() ).isReadable() ) | 71 | if( !QDir( fi.filePath() ).isReadable() ) |
72 | pm = Resource::loadPixmap( "lockedfolder" ); | 72 | pm = Resource::loadPixmap( "lockedfolder" ); |
73 | else | 73 | else |
74 | pm = Resource::loadPixmap( "folder" ); | 74 | pm = Resource::loadPixmap( "folder" ); |
75 | } | 75 | } |
76 | else if( !fi.isReadable() ) | 76 | else if( !fi.isReadable() ) |
77 | pm = Resource::loadPixmap( "locked" ); | 77 | pm = Resource::loadPixmap( "locked" ); |
78 | else if( isLib() ) | 78 | else if( isLib() ) |
79 | pm = Resource::loadPixmap( "library" ); | 79 | pm = Resource::loadPixmap( "library" ); |
80 | else | 80 | else |
81 | pm = mt.pixmap(); | 81 | pm = mt.pixmap(); |
82 | if ( pm.isNull() ) | 82 | if ( pm.isNull() ) |
83 | pm = Resource::loadPixmap("UnknownDocument-14"); | 83 | pm = Resource::loadPixmap("UnknownDocument-14"); |
84 | setPixmap(0,pm); | 84 | setPixmap(0,pm); |
85 | } | 85 | } |
@@ -90,11 +90,11 @@ QString FileItem::sizeString( unsigned int s ) | |||
90 | 90 | ||
91 | if ( size > 1024 * 1024 * 1024 ) | 91 | if ( size > 1024 * 1024 * 1024 ) |
92 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G"; | 92 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G"; |
93 | else if ( size > 1024 * 1024 ) | 93 | else if ( size > 1024 * 1024 ) |
94 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M"; | 94 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M"; |
95 | else if ( size > 1024 ) | 95 | else if ( size > 1024 ) |
96 | return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K"; | 96 | return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K"; |
97 | else | 97 | else |
98 | return QString::number( size ) + "B"; | 98 | return QString::number( size ) + "B"; |
99 | } | 99 | } |
100 | 100 | ||
@@ -106,15 +106,15 @@ QString FileItem::key( int column, bool ascending ) const | |||
106 | 106 | ||
107 | if( (column == 0) && fileInfo.isDir() ){ // Sort by name | 107 | if( (column == 0) && fileInfo.isDir() ){ // Sort by name |
108 | // We want the directories to appear at the top of the list | 108 | // We want the directories to appear at the top of the list |
109 | tmp = (char) 0; | 109 | tmp = (char) 0; |
110 | return (tmp + text( column ).lower()); | 110 | return (tmp + text( column ).lower()); |
111 | } | 111 | } |
112 | else if( column == 2 ) { // Sort by date | 112 | else if( column == 2 ) { // Sort by date |
113 | QDateTime epoch( QDate( 1980, 1, 1 ) ); | 113 | QDateTime epoch( QDate( 1980, 1, 1 ) ); |
114 | tmp.sprintf( "%08d", epoch.secsTo( fileInfo.lastModified() ) ); | 114 | tmp.sprintf( "%08d", epoch.secsTo( fileInfo.lastModified() ) ); |
115 | return tmp; | 115 | return tmp; |
116 | } | 116 | } |
117 | else if( column == 1 ) { // Sort by size | 117 | else if( column == 1 ) { // Sort by size |
118 | return tmp.sprintf( "%08d", fileInfo.size() ); | 118 | return tmp.sprintf( "%08d", fileInfo.size() ); |
119 | } | 119 | } |
120 | 120 | ||
@@ -126,9 +126,9 @@ bool FileItem::isLib() | |||
126 | // This is of course not foolproof | 126 | // This is of course not foolproof |
127 | if( !qstrncmp("lib", fileInfo.baseName(), 3) && | 127 | if( !qstrncmp("lib", fileInfo.baseName(), 3) && |
128 | ( fileInfo.extension().contains( "so" ) || | 128 | ( fileInfo.extension().contains( "so" ) || |
129 | fileInfo.extension().contains( "a" ) ) ) | 129 | fileInfo.extension().contains( "a" ) ) ) |
130 | return TRUE; | 130 | return TRUE; |
131 | else | 131 | else |
132 | return FALSE; | 132 | return FALSE; |
133 | } | 133 | } |
134 | 134 | ||
@@ -146,8 +146,8 @@ bool FileItem::rename( const QString & name ) | |||
146 | 146 | ||
147 | if ( name.isEmpty() ) | 147 | if ( name.isEmpty() ) |
148 | return FALSE; | 148 | return FALSE; |
149 | 149 | ||
150 | if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) | 150 | if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) |
151 | return FALSE; | 151 | return FALSE; |
152 | 152 | ||
153 | oldpath = fileInfo.filePath(); | 153 | oldpath = fileInfo.filePath(); |
@@ -155,7 +155,7 @@ bool FileItem::rename( const QString & name ) | |||
155 | 155 | ||
156 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) | 156 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) |
157 | return FALSE; | 157 | return FALSE; |
158 | else | 158 | else |
159 | return TRUE; | 159 | return TRUE; |
160 | } | 160 | } |
161 | 161 | ||
@@ -164,5 +164,5 @@ bool FileItem::rename( const QString & name ) | |||
164 | // | 164 | // |
165 | FileView::FileView( const QString & dir, QWidget * parent, | 165 | FileView::FileView( const QString & dir, QWidget * parent, |
166 | const char * name ) | 166 | const char * name ) |
167 | : QListView( parent, name ), | 167 | : QListView( parent, name ), |
168 | menuTimer( this ), | 168 | menuTimer( this ), |
@@ -187,7 +187,7 @@ FileView::FileView( const QString & dir, QWidget * parent, | |||
187 | 187 | ||
188 | connect( this, SIGNAL( clicked( QListViewItem * )), | 188 | connect( this, SIGNAL( clicked( QListViewItem * )), |
189 | SLOT( itemClicked( QListViewItem * )) ); | 189 | SLOT( itemClicked( QListViewItem * )) ); |
190 | connect( this, SIGNAL( doubleClicked( QListViewItem * )), | 190 | connect( this, SIGNAL( doubleClicked( QListViewItem * )), |
191 | SLOT( itemDblClicked( QListViewItem * )) ); | 191 | SLOT( itemDblClicked( QListViewItem * )) ); |
192 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 192 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
193 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 193 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
@@ -211,7 +211,7 @@ void FileView::setDir( const QString & dir ) | |||
211 | { | 211 | { |
212 | if ( dir.startsWith( "/dev" ) ) { | 212 | if ( dir.startsWith( "/dev" ) ) { |
213 | QMessageBox::warning( this, tr( "File Manager" ), | 213 | QMessageBox::warning( this, tr( "File Manager" ), |
214 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); | 214 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | dirHistory += currentDir; | 217 | dirHistory += currentDir; |
@@ -229,5 +229,5 @@ void FileView::generateDir( const QString & dir ) | |||
229 | d.setFilter( QDir::Dirs | QDir::Files ); | 229 | d.setFilter( QDir::Dirs | QDir::Files ); |
230 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | | 230 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | |
231 | QDir::Reversed ); | 231 | QDir::Reversed ); |
232 | 232 | ||
233 | const QFileInfoList * list = d.entryInfoList(); | 233 | const QFileInfoList * list = d.entryInfoList(); |
@@ -237,10 +237,10 @@ void FileView::generateDir( const QString & dir ) | |||
237 | clear(); | 237 | clear(); |
238 | while( (fi = it.current()) ){ | 238 | while( (fi = it.current()) ){ |
239 | if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ | 239 | if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ |
240 | ++it; | 240 | ++it; |
241 | continue; | 241 | continue; |
242 | } | 242 | } |
243 | (void) new FileItem( (QListView *) this, *fi ); | 243 | (void) new FileItem( (QListView *) this, *fi ); |
244 | ++it; | 244 | ++it; |
245 | } | 245 | } |
246 | 246 | ||
@@ -257,7 +257,7 @@ void FileView::rename() | |||
257 | 257 | ||
258 | if( ( pm = itemToRename->pixmap( 0 ) ) == NULL ) | 258 | if( ( pm = itemToRename->pixmap( 0 ) ) == NULL ) |
259 | pmw = 0; | 259 | pmw = 0; |
260 | else | 260 | else |
261 | pmw = pm->width(); | 261 | pmw = pm->width(); |
262 | 262 | ||
263 | ensureItemVisible( itemToRename ); | 263 | ensureItemVisible( itemToRename ); |
@@ -270,7 +270,7 @@ void FileView::rename() | |||
270 | 270 | ||
271 | if( le == NULL ){ | 271 | if( le == NULL ){ |
272 | le = new InlineEdit( this ); | 272 | le = new InlineEdit( this ); |
273 | le->setFrame( FALSE ); | 273 | le->setFrame( FALSE ); |
274 | connect( le, SIGNAL( lostFocus() ), SLOT( endRenaming() ) ); | 274 | connect( le, SIGNAL( lostFocus() ), SLOT( endRenaming() ) ); |
275 | } | 275 | } |
276 | 276 | ||
@@ -291,16 +291,16 @@ void FileView::endRenaming() | |||
291 | { | 291 | { |
292 | if( le && itemToRename ){ | 292 | if( le && itemToRename ){ |
293 | le->hide(); | 293 | le->hide(); |
294 | setSelected( itemToRename, selected ); | 294 | setSelected( itemToRename, selected ); |
295 | 295 | ||
296 | if( !itemToRename->rename( le->text() ) ){ | 296 | if( !itemToRename->rename( le->text() ) ){ |
297 | QMessageBox::warning( this, tr( "Rename file" ), | 297 | QMessageBox::warning( this, tr( "Rename file" ), |
298 | tr( "Rename failed!" ), tr( "&Ok" ) ); | 298 | tr( "Rename failed!" ), tr( "&Ok" ) ); |
299 | } else { | 299 | } else { |
300 | updateDir(); | 300 | updateDir(); |
301 | } | 301 | } |
302 | itemToRename = NULL; | 302 | itemToRename = NULL; |
303 | horizontalScrollBar()->setEnabled( TRUE ); | 303 | horizontalScrollBar()->setEnabled( TRUE ); |
304 | verticalScrollBar()->setEnabled( TRUE ); | 304 | verticalScrollBar()->setEnabled( TRUE ); |
305 | } | 305 | } |
306 | } | 306 | } |
@@ -319,8 +319,8 @@ void FileView::copy() | |||
319 | flist.clear(); | 319 | flist.clear(); |
320 | while( i ){ | 320 | while( i ){ |
321 | if( i->isSelected() /*&& !i->isDir()*/ ){ | 321 | if( i->isSelected() /*&& !i->isDir()*/ ){ |
322 | flist += i->getFilePath(); | 322 | flist += i->getFilePath(); |
323 | } | 323 | } |
324 | i = (FileItem *) i->nextSibling(); | 324 | i = (FileItem *) i->nextSibling(); |
325 | } | 325 | } |
326 | } | 326 | } |
@@ -334,47 +334,47 @@ void FileView::paste() | |||
334 | 334 | ||
335 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { | 335 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { |
336 | basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); | 336 | basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); |
337 | 337 | ||
338 | dest = cd + "/" + basename; | 338 | dest = cd + "/" + basename; |
339 | if( QFile( dest ).exists() ){ | 339 | if( QFile( dest ).exists() ){ |
340 | i = 1; | 340 | i = 1; |
341 | dest = cd + "/Copy of " + basename; | 341 | dest = cd + "/Copy of " + basename; |
342 | while( QFile( dest ).exists() ){ | 342 | while( QFile( dest ).exists() ){ |
343 | dest.sprintf( "%s/Copy (%d) of %s", (const char *) cd, i++, | 343 | dest.sprintf( "%s/Copy (%d) of %s", (const char *) cd, i++, |
344 | (const char *) basename ); | 344 | (const char *) basename ); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | // | 348 | // |
349 | // Copy a directory recursively using the "cp" command - | 349 | // Copy a directory recursively using the "cp" command - |
350 | // may have to be changed | 350 | // may have to be changed |
351 | // | 351 | // |
352 | if( QFileInfo( (*it) ).isDir() ){ | 352 | if( QFileInfo( (*it) ).isDir() ){ |
353 | cmd = "/bin/cp -fpR \"" + (*it) +"\" " + "\"" + dest + "\""; | 353 | cmd = "/bin/cp -fpR \"" + (*it) +"\" " + "\"" + dest + "\""; |
354 | err = system( (const char *) cmd ); | 354 | err = system( (const char *) cmd ); |
355 | } else if( !copyFile( dest, (*it) ) ){ | 355 | } else if( !copyFile( dest, (*it) ) ){ |
356 | err = -1; | 356 | err = -1; |
357 | } else { | 357 | } else { |
358 | err = 0; | 358 | err = 0; |
359 | } | 359 | } |
360 | 360 | ||
361 | if ( err != 0 ) { | 361 | if ( err != 0 ) { |
362 | QMessageBox::warning( this, tr("Paste file"), tr("Paste failed!"), | 362 | QMessageBox::warning( this, tr("Paste file"), tr("Paste failed!"), |
363 | tr("Ok") ); | 363 | tr("Ok") ); |
364 | break; | 364 | break; |
365 | } else { | 365 | } else { |
366 | updateDir(); | 366 | updateDir(); |
367 | QListViewItem * i = firstChild(); | 367 | QListViewItem * i = firstChild(); |
368 | basename = dest.mid( dest.findRev("/") + 1, dest.length() ); | 368 | basename = dest.mid( dest.findRev("/") + 1, dest.length() ); |
369 | 369 | ||
370 | while( i ){ | 370 | while( i ){ |
371 | if( i->text(0) == basename ){ | 371 | if( i->text(0) == basename ){ |
372 | setCurrentItem( i ); | 372 | setCurrentItem( i ); |
373 | ensureItemVisible( i ); | 373 | ensureItemVisible( i ); |
374 | break; | 374 | break; |
375 | } | 375 | } |
376 | i = i->nextSibling(); | 376 | i = i->nextSibling(); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | } | 380 | } |
@@ -391,24 +391,24 @@ bool FileView::copyFile( const QString & dest, const QString & src ) | |||
391 | 391 | ||
392 | if( s.open( IO_ReadOnly | IO_Raw ) && | 392 | if( s.open( IO_ReadOnly | IO_Raw ) && |
393 | d.open( IO_WriteOnly | IO_Raw ) ) | 393 | d.open( IO_WriteOnly | IO_Raw ) ) |
394 | { | 394 | { |
395 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == | 395 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == |
396 | sizeof( bf ) ) | 396 | sizeof( bf ) ) |
397 | { | 397 | { |
398 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 398 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
399 | success = FALSE; | 399 | success = FALSE; |
400 | break; | 400 | break; |
401 | } | 401 | } |
402 | } | 402 | } |
403 | if( success && (bytesRead > 0) ){ | 403 | if( success && (bytesRead > 0) ){ |
404 | d.writeBlock( bf, bytesRead ); | 404 | d.writeBlock( bf, bytesRead ); |
405 | } | 405 | } |
406 | } else { | 406 | } else { |
407 | success = FALSE; | 407 | success = FALSE; |
408 | } | 408 | } |
409 | 409 | ||
410 | // Set file permissions | 410 | // Set file permissions |
411 | if( stat( (const char *) src, &status ) == 0 ){ | 411 | if( stat( (const char *) src, &status ) == 0 ){ |
412 | chmod( (const char *) dest, status.st_mode ); | 412 | chmod( (const char *) dest, status.st_mode ); |
413 | } | 413 | } |
414 | 414 | ||
@@ -422,11 +422,11 @@ void FileView::cut() | |||
422 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. | 422 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. |
423 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; | 423 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; |
424 | QStringList newflist; | 424 | QStringList newflist; |
425 | newflist.clear(); | 425 | newflist.clear(); |
426 | 426 | ||
427 | cmd = "rm -rf " + cd; | 427 | cmd = "rm -rf " + cd; |
428 | system ( (const char *) cmd ); | 428 | system ( (const char *) cmd ); |
429 | cmd = "mkdir " + cd; | 429 | cmd = "mkdir " + cd; |
430 | system( (const char *) cmd ); | 430 | system( (const char *) cmd ); |
431 | 431 | ||
432 | // get the names of the files to cut | 432 | // get the names of the files to cut |
@@ -449,5 +449,5 @@ void FileView::cut() | |||
449 | dest = cd + "/" + basename; | 449 | dest = cd + "/" + basename; |
450 | 450 | ||
451 | newflist += dest; | 451 | newflist += dest; |
452 | 452 | ||
453 | cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; | 453 | cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; |
@@ -474,6 +474,6 @@ void FileView::cut() | |||
474 | } | 474 | } |
475 | 475 | ||
476 | // update the filelist to point to tmp dir so paste works nicely | 476 | // update the filelist to point to tmp dir so paste works nicely |
477 | flist = newflist; | 477 | flist = newflist; |
478 | } | 478 | } |
479 | 479 | ||
@@ -488,27 +488,27 @@ void FileView::del() | |||
488 | 488 | ||
489 | while( i ){ | 489 | while( i ){ |
490 | if( i->isSelected() ){ | 490 | if( i->isSelected() ){ |
491 | fl += i->getFilePath(); | 491 | fl += i->getFilePath(); |
492 | } | 492 | } |
493 | i = (FileItem *) i->nextSibling(); | 493 | i = (FileItem *) i->nextSibling(); |
494 | } | 494 | } |
495 | if( fl.count() < 1 ) return; | 495 | if( fl.count() < 1 ) return; |
496 | 496 | ||
497 | if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), | 497 | if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), |
498 | tr("Yes"), tr("No") ) == 0) | 498 | tr("Yes"), tr("No") ) == 0) |
499 | { | 499 | { |
500 | // | 500 | // |
501 | // Dependant upon the "rm" command - will probably have to be replaced | 501 | // Dependant upon the "rm" command - will probably have to be replaced |
502 | // | 502 | // |
503 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | 503 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { |
504 | cmd = "/bin/rm -rf \"" + (*it) + "\""; | 504 | cmd = "/bin/rm -rf \"" + (*it) + "\""; |
505 | err = system( (const char *) cmd ); | 505 | err = system( (const char *) cmd ); |
506 | if ( err != 0 ) { | 506 | if ( err != 0 ) { |
507 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), | 507 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), |
508 | tr("Ok") ); | 508 | tr("Ok") ); |
509 | break; | 509 | break; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | updateDir(); | 512 | updateDir(); |
513 | } | 513 | } |
514 | } | 514 | } |
@@ -521,12 +521,12 @@ void FileView::newFolder() | |||
521 | 521 | ||
522 | while( QFile( nd ).exists() ){ | 522 | while( QFile( nd ).exists() ){ |
523 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); | 523 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); |
524 | } | 524 | } |
525 | 525 | ||
526 | if( mkdir( (const char *) nd, 0777 ) != 0){ | 526 | if( mkdir( (const char *) nd, 0777 ) != 0){ |
527 | QMessageBox::warning( this, tr( "New folder" ), | 527 | QMessageBox::warning( this, tr( "New folder" ), |
528 | tr( "Folder creation failed!" ), | 528 | tr( "Folder creation failed!" ), |
529 | tr( "Ok" ) ); | 529 | tr( "Ok" ) ); |
530 | return; | 530 | return; |
531 | } | 531 | } |
532 | updateDir(); | 532 | updateDir(); |
@@ -535,10 +535,10 @@ void FileView::newFolder() | |||
535 | 535 | ||
536 | while( i ){ | 536 | while( i ){ |
537 | if( i->isDir() && ( i->getFilePath() == nd ) ){ | 537 | if( i->isDir() && ( i->getFilePath() == nd ) ){ |
538 | setCurrentItem( i ); | 538 | setCurrentItem( i ); |
539 | rename(); | 539 | rename(); |
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | i = (FileItem *) i->nextSibling(); | 542 | i = (FileItem *) i->nextSibling(); |
543 | } | 543 | } |
544 | } | 544 | } |
@@ -556,5 +556,5 @@ void FileView::itemClicked( QListViewItem * i) | |||
556 | if( t == NULL ) return; | 556 | if( t == NULL ) return; |
557 | if( t->isDir() ){ | 557 | if( t->isDir() ){ |
558 | setDir( t->getFilePath() ); | 558 | setDir( t->getFilePath() ); |
559 | } | 559 | } |
560 | } | 560 | } |
@@ -566,6 +566,6 @@ void FileView::itemDblClicked( QListViewItem * i) | |||
566 | if(t == NULL) return; | 566 | if(t == NULL) return; |
567 | if(t->launch() == -1){ | 567 | if(t->launch() == -1){ |
568 | QMessageBox::warning( this, tr( "Launch Application" ), | 568 | QMessageBox::warning( this, tr( "Launch Application" ), |
569 | tr( "Launch failed!" ), tr( "Ok" ) ); | 569 | tr( "Launch failed!" ), tr( "Ok" ) ); |
570 | } | 570 | } |
571 | } | 571 | } |
@@ -600,5 +600,5 @@ void FileView::cancelMenuTimer() | |||
600 | { | 600 | { |
601 | if( menuTimer.isActive() ) | 601 | if( menuTimer.isActive() ) |
602 | menuTimer.stop(); | 602 | menuTimer.stop(); |
603 | } | 603 | } |
604 | 604 | ||
@@ -624,11 +624,11 @@ void FileView::showFileMenu() | |||
624 | FileItem * i = (FileItem *) currentItem(); | 624 | FileItem * i = (FileItem *) currentItem(); |
625 | if ( !i ) | 625 | if ( !i ) |
626 | return; | 626 | return; |
627 | 627 | ||
628 | QPopupMenu * m = new QPopupMenu( this ); | 628 | QPopupMenu * m = new QPopupMenu( this ); |
629 | 629 | ||
630 | if ( !i->isDir() ) { | 630 | if ( !i->isDir() ) { |
631 | m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) ); | 631 | m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) ); |
632 | m->insertSeparator(); | 632 | m->insertSeparator(); |
633 | } | 633 | } |
634 | 634 | ||
@@ -637,22 +637,23 @@ void FileView::showFileMenu() | |||
637 | 637 | ||
638 | if ( !i->isDir() ) { | 638 | if ( !i->isDir() ) { |
639 | if ( app ) | 639 | if ( app ) |
640 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) ); | 640 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) ); |
641 | else if( i->isExecutable() ) | 641 | else if( i->isExecutable() ) |
642 | m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) ); | 642 | m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) ); |
643 | 643 | ||
644 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ), | 644 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ), |
645 | this, SLOT( viewAsText() ) ); | 645 | this, SLOT( viewAsText() ) ); |
646 | 646 | ||
647 | m->insertSeparator(); | 647 | m->insertSeparator(); |
648 | } | 648 | } |
649 | 649 | ||
650 | m->insertItem( tr( "Rename" ), this, SLOT( rename() ) ); | 650 | m->insertItem( tr( "Rename" ), this, SLOT( rename() ) ); |
651 | m->insertItem( Resource::loadPixmap("cut"), | 651 | m->insertItem( Resource::loadPixmap("cut"), |
652 | tr( "Cut" ), this, SLOT( cut() ) ); | 652 | tr( "Cut" ), this, SLOT( cut() ) ); |
653 | m->insertItem( Resource::loadPixmap("copy"), | 653 | m->insertItem( Resource::loadPixmap("copy"), |
654 | tr( "Copy" ), this, SLOT( copy() ) ); | 654 | tr( "Copy" ), this, SLOT( copy() ) ); |
655 | m->insertItem( Resource::loadPixmap("paste"), | 655 | m->insertItem( Resource::loadPixmap("paste"), |
656 | tr( "Paste" ), this, SLOT( paste() ) ); | 656 | tr( "Paste" ), this, SLOT( paste() ) ); |
657 | m->insertItem( tr( "change permissions" ), this, SLOT( chPerm() ) ); | ||
657 | m->insertItem( tr( "Delete" ), this, SLOT( del() ) ); | 658 | m->insertItem( tr( "Delete" ), this, SLOT( del() ) ); |
658 | m->insertSeparator(); | 659 | m->insertSeparator(); |
@@ -667,5 +668,5 @@ void FileView::showFileMenu() | |||
667 | 668 | ||
668 | FileBrowser::FileBrowser( QWidget * parent, | 669 | FileBrowser::FileBrowser( QWidget * parent, |
669 | const char * name, WFlags f ) : | 670 | const char * name, WFlags f ) : |
670 | QMainWindow( parent, name, f ) | 671 | QMainWindow( parent, name, f ) |
671 | { | 672 | { |
@@ -674,5 +675,5 @@ FileBrowser::FileBrowser( QWidget * parent, | |||
674 | 675 | ||
675 | FileBrowser::FileBrowser( const QString & dir, QWidget * parent, | 676 | FileBrowser::FileBrowser( const QString & dir, QWidget * parent, |
676 | const char * name, WFlags f ) : | 677 | const char * name, WFlags f ) : |
677 | QMainWindow( parent, name, f ) | 678 | QMainWindow( parent, name, f ) |
678 | { | 679 | { |
@@ -713,5 +714,5 @@ void FileBrowser::init(const QString & dir) | |||
713 | 714 | ||
714 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), | 715 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), |
715 | QString::null, 0, this, 0 ); | 716 | QString::null, 0, this, 0 ); |
716 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); | 717 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); |
717 | lastAction->addTo( toolBar ); | 718 | lastAction->addTo( toolBar ); |
@@ -719,25 +720,25 @@ void FileBrowser::init(const QString & dir) | |||
719 | 720 | ||
720 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), | 721 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), |
721 | QString::null, 0, this, 0 ); | 722 | QString::null, 0, this, 0 ); |
722 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); | 723 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); |
723 | upAction->addTo( toolBar ); | 724 | upAction->addTo( toolBar ); |
724 | 725 | ||
725 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), | 726 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), |
726 | QString::null, 0, this, 0 ); | 727 | QString::null, 0, this, 0 ); |
727 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); | 728 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); |
728 | a->addTo( toolBar ); | 729 | a->addTo( toolBar ); |
729 | 730 | ||
730 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), | 731 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), |
731 | QString::null, 0, this, 0 ); | 732 | QString::null, 0, this, 0 ); |
732 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); | 733 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); |
733 | a->addTo( toolBar ); | 734 | a->addTo( toolBar ); |
734 | 735 | ||
735 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), | 736 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), |
736 | QString::null, 0, this, 0 ); | 737 | QString::null, 0, this, 0 ); |
737 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); | 738 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); |
738 | a->addTo( toolBar ); | 739 | a->addTo( toolBar ); |
739 | 740 | ||
740 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), | 741 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), |
741 | QString::null, 0, this, 0 ); | 742 | QString::null, 0, this, 0 ); |
742 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); | 743 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); |
743 | pasteAction->addTo( toolBar ); | 744 | pasteAction->addTo( toolBar ); |
@@ -749,5 +750,5 @@ void FileBrowser::init(const QString & dir) | |||
749 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 750 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
750 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 751 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
751 | this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); | 752 | this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); |
752 | } | 753 | } |
753 | 754 | ||
@@ -755,5 +756,5 @@ void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) | |||
755 | { | 756 | { |
756 | if ( msg == "mtabChanged()" ) { | 757 | if ( msg == "mtabChanged()" ) { |
757 | // ## Only really needed if current dir is on a card | 758 | // ## Only really needed if current dir is on a card |
758 | fileView->updateDir(); | 759 | fileView->updateDir(); |
759 | } | 760 | } |
@@ -767,7 +768,7 @@ void FileBrowser::dirSelected( int id ) | |||
767 | // Bulid target dir from menu | 768 | // Bulid target dir from menu |
768 | while( (j = dirMenu->idAt( i )) != id ){ | 769 | while( (j = dirMenu->idAt( i )) != id ){ |
769 | dir += dirMenu->text( j ).stripWhiteSpace(); | 770 | dir += dirMenu->text( j ).stripWhiteSpace(); |
770 | if( dirMenu->text( j ) != "/" ) dir += "/"; | 771 | if( dirMenu->text( j ) != "/" ) dir += "/"; |
771 | i++; | 772 | i++; |
772 | } | 773 | } |
773 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); | 774 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); |
@@ -786,7 +787,7 @@ void FileBrowser::updateDirMenu() | |||
786 | 787 | ||
787 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { | 788 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { |
788 | spc.fill( ' ', i++); | 789 | spc.fill( ' ', i++); |
789 | dirMenu->insertItem( spc + (*it), this, | 790 | dirMenu->insertItem( spc + (*it), this, |
790 | SLOT( dirSelected(int) ) ); | 791 | SLOT( dirSelected(int) ) ); |
791 | } | 792 | } |
792 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); | 793 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); |
@@ -841,10 +842,39 @@ void FileBrowser::updateSorting() | |||
841 | 842 | ||
842 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) | 843 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) |
843 | sortName(); | 844 | sortName(); |
844 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) | 845 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) |
845 | sortSize(); | 846 | sortSize(); |
846 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) | 847 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) |
847 | sortDate(); | 848 | sortDate(); |
848 | else | 849 | else |
849 | sortType(); | 850 | sortType(); |
851 | } | ||
852 | |||
853 | void FileView::chPerm() { | ||
854 | FileItem * i; | ||
855 | QStringList fl; | ||
856 | QString cmd; | ||
857 | int err; | ||
858 | |||
859 | if((i = (FileItem *) firstChild()) == 0) return; | ||
860 | |||
861 | while( i ){ | ||
862 | if( i->isSelected() ){ | ||
863 | fl += i->getFilePath(); | ||
864 | } | ||
865 | i = (FileItem *) i->nextSibling(); | ||
866 | } | ||
867 | if( fl.count() < 1 ) return; | ||
868 | if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), | ||
869 | tr("Yes"), tr("No") ) == 0) { | ||
870 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | ||
871 | filePermissions *filePerm; | ||
872 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); | ||
873 | filePerm->exec(); | ||
874 | if( filePerm) | ||
875 | delete filePerm; | ||
876 | break; | ||
877 | } | ||
878 | updateDir(); | ||
879 | } | ||
850 | } | 880 | } |