-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 48332b7..9cb9aba 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -307,196 +307,191 @@ void AdvancedFm::fillCombo(const QString ¤tPath) { | |||
307 | // if ( whichTab == 1) { | 307 | // if ( whichTab == 1) { |
308 | currentPathCombo->lineEdit()->setText( currentPath); | 308 | currentPathCombo->lineEdit()->setText( currentPath); |
309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
310 | currentPathCombo->clear(); | 310 | currentPathCombo->clear(); |
311 | localDirPathStringList.prepend( currentPath ); | 311 | localDirPathStringList.prepend( currentPath ); |
312 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 312 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
313 | } | 313 | } |
314 | } else { | 314 | } else { |
315 | currentPathCombo->lineEdit()->setText( currentPath); | 315 | currentPathCombo->lineEdit()->setText( currentPath); |
316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
317 | currentPathCombo->clear(); | 317 | currentPathCombo->clear(); |
318 | remoteDirPathStringList.prepend( currentPath ); | 318 | remoteDirPathStringList.prepend( currentPath ); |
319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
325 | chdir( currentPath.latin1() ); | 325 | chdir( currentPath.latin1() ); |
326 | CurrentDir()->cd( currentPath, TRUE); | 326 | CurrentDir()->cd( currentPath, TRUE); |
327 | populateView(); | 327 | populateView(); |
328 | update(); | 328 | update(); |
329 | } | 329 | } |
330 | 330 | ||
331 | QStringList AdvancedFm::getPath() { | 331 | QStringList AdvancedFm::getPath() { |
332 | QStringList strList; | 332 | QStringList strList; |
333 | QListView *thisView=CurrentView(); | 333 | QListView *thisView=CurrentView(); |
334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
335 | QListViewItemIterator it( thisView ); | 335 | QListViewItemIterator it( thisView ); |
336 | for ( ; it.current(); ++it ) { | 336 | for ( ; it.current(); ++it ) { |
337 | if ( it.current()->isSelected() ) { | 337 | if ( it.current()->isSelected() ) { |
338 | strList << it.current()->text(0); | 338 | strList << it.current()->text(0); |
339 | // odebug << it.current()->text(0) << oendl; | 339 | // odebug << it.current()->text(0) << oendl; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | return strList; | 342 | return strList; |
343 | } | 343 | } |
344 | 344 | ||
345 | void AdvancedFm::changeTo(QString dir) { | 345 | void AdvancedFm::changeTo(QString dir) { |
346 | chdir( dir.latin1()); | 346 | chdir( dir.latin1()); |
347 | CurrentDir()->cd(dir, TRUE); | 347 | CurrentDir()->cd(dir, TRUE); |
348 | populateView(); | 348 | populateView(); |
349 | update(); | 349 | update(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void AdvancedFm::homeButtonPushed() { | 352 | void AdvancedFm::homeButtonPushed() { |
353 | changeTo(QDir::homeDirPath()); | 353 | changeTo(QDir::homeDirPath()); |
354 | } | 354 | } |
355 | 355 | ||
356 | void AdvancedFm::docButtonPushed() { | 356 | void AdvancedFm::docButtonPushed() { |
357 | changeTo(QPEApplication::documentDir()); | 357 | changeTo(QPEApplication::documentDir()); |
358 | } | 358 | } |
359 | 359 | ||
360 | void AdvancedFm::SDButtonPushed() { | 360 | void AdvancedFm::SDButtonPushed() { |
361 | changeTo("/mnt/card");// this can change so fix | 361 | changeTo("/mnt/card");// this can change so fix |
362 | } | 362 | } |
363 | 363 | ||
364 | void AdvancedFm::CFButtonPushed() { | 364 | void AdvancedFm::CFButtonPushed() { |
365 | if(zaurusDevice) | 365 | if(zaurusDevice) |
366 | changeTo("/mnt/cf"); //zaurus | 366 | changeTo("/mnt/cf"); //zaurus |
367 | else | 367 | else |
368 | changeTo("/mnt/hda"); //ipaq | 368 | changeTo("/mnt/hda"); //ipaq |
369 | } | 369 | } |
370 | 370 | ||
371 | void AdvancedFm::QPEButtonPushed() { | ||
372 | changeTo(QPEApplication::qpeDir()); | ||
373 | } | ||
371 | 374 | ||
372 | void AdvancedFm::doAbout() { | 375 | void AdvancedFm::doAbout() { |
373 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 376 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
374 | } | 377 | } |
375 | 378 | ||
376 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 379 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
377 | qDebug("keypressevent"); | 380 | qDebug("keypressevent"); |
378 | } | 381 | } |
379 | 382 | ||
380 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 383 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
381 | qDebug("key release"); | 384 | qDebug("key release"); |
382 | if( CurrentView()->hasFocus() ) | 385 | if( CurrentView()->hasFocus() ) |
383 | e->ignore(); | 386 | e->ignore(); |
384 | if( e->key() == Key_Left ) | 387 | if( e->key() == Key_Left ) |
385 | upDir(); | 388 | upDir(); |
386 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 389 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
387 | navigateToSelected(); | 390 | navigateToSelected(); |
388 | else if( e->key() == Key_Tab) | 391 | else if( e->key() == Key_Tab) |
389 | setOtherTabCurrent(); | 392 | setOtherTabCurrent(); |
390 | else if( e->key() == Key_Delete ) | 393 | else if( e->key() == Key_Delete ) |
391 | del(); | 394 | del(); |
392 | else if( e->key() == Key_A) | 395 | else if( e->key() == Key_A) |
393 | copyAs(); | 396 | copyAs(); |
394 | else if( e->key() == Key_C) | 397 | else if( e->key() == Key_C) |
395 | copy(); | 398 | copy(); |
396 | else if( e->key() == Key_E) | 399 | else if( e->key() == Key_E) |
397 | runThis(); | 400 | runThis(); |
398 | else if( e->key() == Key_G) | 401 | else if( e->key() == Key_G) |
399 | currentPathCombo->lineEdit()->setFocus(); | 402 | currentPathCombo->lineEdit()->setFocus(); |
400 | else if( e->key() == Key_H ) | 403 | else if( e->key() == Key_H ) |
401 | showHidden(); | 404 | showHidden(); |
402 | else if( e->key() == Key_I) | 405 | else if( e->key() == Key_I) |
403 | fileStatus(); | 406 | fileStatus(); |
404 | else if( e->key() == Key_M) | 407 | else if( e->key() == Key_M) |
405 | move(); | 408 | move(); |
406 | else if( e->key() == Key_N ) | 409 | else if( e->key() == Key_N ) |
407 | mkDir(); | 410 | mkDir(); |
408 | else if( e->key() == Key_P) | 411 | else if( e->key() == Key_P) |
409 | filePerms(); | 412 | filePerms(); |
410 | else if( e->key() == Key_R ) | 413 | else if( e->key() == Key_R ) |
411 | rn(); | 414 | rn(); |
412 | else if( e->key() == Key_U ) | 415 | else if( e->key() == Key_U ) |
413 | upDir(); | 416 | upDir(); |
414 | else if( e->key() == Key_1) | 417 | else if( e->key() == Key_1) |
415 | switchToLocalTab(); | 418 | switchToLocalTab(); |
416 | else if( e->key() == Key_2) | 419 | else if( e->key() == Key_2) |
417 | switchToRemoteTab(); | 420 | switchToRemoteTab(); |
418 | else if( e->key() == Key_3) | 421 | else if( e->key() == Key_3) |
419 | CFButtonPushed(); | 422 | CFButtonPushed(); |
420 | else if( e->key() == Key_4) | 423 | else if( e->key() == Key_4) |
421 | SDButtonPushed(); | 424 | SDButtonPushed(); |
422 | else if( e->key() == Key_5 ) | 425 | else if( e->key() == Key_5 ) |
423 | homeButtonPushed(); | 426 | homeButtonPushed(); |
424 | else if( e->key() == Key_6 ) | 427 | else if( e->key() == Key_6 ) |
425 | docButtonPushed(); | 428 | docButtonPushed(); |
426 | else | 429 | else |
427 | e->accept(); | 430 | e->accept(); |
428 | } | 431 | } |
429 | 432 | ||
430 | 433 | ||
431 | void AdvancedFm::QPEButtonPushed() { | ||
432 | QString current = QPEApplication::qpeDir(); | ||
433 | chdir( current.latin1() ); | ||
434 | CurrentDir()->cd( current, TRUE); | ||
435 | populateView(); | ||
436 | update(); | ||
437 | } | ||
438 | |||
439 | void AdvancedFm::parsetab(const QString &fileName) { | 434 | void AdvancedFm::parsetab(const QString &fileName) { |
440 | 435 | ||
441 | fileSystemTypeList.clear(); | 436 | fileSystemTypeList.clear(); |
442 | fsList.clear(); | 437 | fsList.clear(); |
443 | struct mntent *me; | 438 | struct mntent *me; |
444 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 439 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
445 | if ( mntfp ) { | 440 | if ( mntfp ) { |
446 | while ( (me = getmntent( mntfp )) != 0 ) { | 441 | while ( (me = getmntent( mntfp )) != 0 ) { |
447 | QString deviceName = me->mnt_fsname; | 442 | QString deviceName = me->mnt_fsname; |
448 | QString filesystemType = me->mnt_type; | 443 | QString filesystemType = me->mnt_type; |
449 | QString mountDir = me->mnt_dir; | 444 | QString mountDir = me->mnt_dir; |
450 | if(deviceName != "none") { | 445 | if(deviceName != "none") { |
451 | if( fsList.contains(filesystemType) == 0 | 446 | if( fsList.contains(filesystemType) == 0 |
452 | & filesystemType.find("proc",0,TRUE) == -1 | 447 | & filesystemType.find("proc",0,TRUE) == -1 |
453 | & filesystemType.find("cramfs",0,TRUE) == -1 | 448 | & filesystemType.find("cramfs",0,TRUE) == -1 |
454 | & filesystemType.find("auto",0,TRUE) == -1) | 449 | & filesystemType.find("auto",0,TRUE) == -1) |
455 | fsList << filesystemType; | 450 | fsList << filesystemType; |
456 | fileSystemTypeList << mountDir+"::"+filesystemType; | 451 | fileSystemTypeList << mountDir+"::"+filesystemType; |
457 | } | 452 | } |
458 | } | 453 | } |
459 | } | 454 | } |
460 | endmntent( mntfp ); | 455 | endmntent( mntfp ); |
461 | } | 456 | } |
462 | 457 | ||
463 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 458 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
464 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 459 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
465 | QString current = currentText;//.right( currentText.length()-1); | 460 | QString current = currentText;//.right( currentText.length()-1); |
466 | QString baseFs; | 461 | QString baseFs; |
467 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 462 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
468 | QString temp = (*it); | 463 | QString temp = (*it); |
469 | QString path = temp.left(temp.find("::",0,TRUE) ); | 464 | QString path = temp.left(temp.find("::",0,TRUE) ); |
470 | path = path.right( path.length()-1); | 465 | path = path.right( path.length()-1); |
471 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 466 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
472 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 467 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
473 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 468 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
474 | } | 469 | } |
475 | } | 470 | } |
476 | return baseFs; | 471 | return baseFs; |
477 | } | 472 | } |
478 | 473 | ||
479 | QString AdvancedFm::getDiskSpace( const QString &path) { | 474 | QString AdvancedFm::getDiskSpace( const QString &path) { |
480 | struct statfs fss; | 475 | struct statfs fss; |
481 | if ( !statfs( path.latin1(), &fss ) ) { | 476 | if ( !statfs( path.latin1(), &fss ) ) { |
482 | int blkSize = fss.f_bsize; | 477 | int blkSize = fss.f_bsize; |
483 | // int totalBlks = fs.f_blocks; | 478 | // int totalBlks = fs.f_blocks; |
484 | int availBlks = fss.f_bavail; | 479 | int availBlks = fss.f_bavail; |
485 | 480 | ||
486 | long mult = blkSize / 1024; | 481 | long mult = blkSize / 1024; |
487 | long div = 1024 / blkSize; | 482 | long div = 1024 / blkSize; |
488 | if ( !mult ) mult = 1; | 483 | if ( !mult ) mult = 1; |
489 | if ( !div ) div = 1; | 484 | if ( !div ) div = 1; |
490 | 485 | ||
491 | return QString::number(availBlks * mult / div); | 486 | return QString::number(availBlks * mult / div); |
492 | } | 487 | } |
493 | return ""; | 488 | return ""; |
494 | } | 489 | } |
495 | 490 | ||
496 | 491 | ||
497 | void AdvancedFm::showFileMenu() { | 492 | void AdvancedFm::showFileMenu() { |
498 | QString curApp; | 493 | QString curApp; |
499 | curApp = CurrentView()->currentItem()->text(0); | 494 | curApp = CurrentView()->currentItem()->text(0); |
500 | 495 | ||
501 | MimeType mt(curApp); | 496 | MimeType mt(curApp); |
502 | const AppLnk* app = mt.application(); | 497 | const AppLnk* app = mt.application(); |