-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 66353bb..d4351b0 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -586,294 +586,294 @@ void AdvancedFm::showFileMenu() | |||
586 | QPopupMenu *m = new QPopupMenu(0); | 586 | QPopupMenu *m = new QPopupMenu(0); |
587 | QPopupMenu *n = new QPopupMenu(0); | 587 | QPopupMenu *n = new QPopupMenu(0); |
588 | // QPopupMenu *o = new QPopupMenu(0); | 588 | // QPopupMenu *o = new QPopupMenu(0); |
589 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 589 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
590 | 590 | ||
591 | if ( QFileInfo(fi).isDir() ) | 591 | if ( QFileInfo(fi).isDir() ) |
592 | { | 592 | { |
593 | m->insertSeparator(); | 593 | m->insertSeparator(); |
594 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); | 594 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); |
595 | } | 595 | } |
596 | else | 596 | else |
597 | { | 597 | { |
598 | 598 | ||
599 | if ( app ) | 599 | if ( app ) |
600 | m->insertItem( app->pixmap(), tr( "Open in " | 600 | m->insertItem( app->pixmap(), tr( "Open in " |
601 | + app->name() ), this, SLOT( runThis() ) ); | 601 | + app->name() ), this, SLOT( runThis() ) ); |
602 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 602 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
603 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 603 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
604 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 604 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
605 | } | 605 | } |
606 | 606 | ||
607 | m->insertItem(tr("Actions"),n); | 607 | m->insertItem(tr("Actions"),n); |
608 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); | 608 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); |
609 | 609 | ||
610 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 610 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
611 | 611 | ||
612 | n->insertSeparator(); | 612 | n->insertSeparator(); |
613 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); | 613 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); |
614 | 614 | ||
615 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 615 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
616 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 616 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
617 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 617 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
618 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 618 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
619 | 619 | ||
620 | n->insertSeparator(); | 620 | n->insertSeparator(); |
621 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); | 621 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); |
622 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 622 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
623 | 623 | ||
624 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 624 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
625 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 625 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
626 | 626 | ||
627 | m->insertSeparator(); | 627 | m->insertSeparator(); |
628 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 628 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
629 | 629 | ||
630 | #if defined(QT_QWS_OPIE) | 630 | #if defined(QT_QWS_OPIE) |
631 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 631 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
632 | #endif | 632 | #endif |
633 | m->setCheckable(TRUE); | 633 | m->setCheckable(TRUE); |
634 | if (!b) | 634 | if (!b) |
635 | m->setItemChecked(m->idAt(0),TRUE); | 635 | m->setItemChecked(m->idAt(0),TRUE); |
636 | else | 636 | else |
637 | m->setItemChecked(m->idAt(0),FALSE); | 637 | m->setItemChecked(m->idAt(0),FALSE); |
638 | 638 | ||
639 | if(Ir::supported()) | 639 | if(Ir::supported()) |
640 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 640 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
641 | m->setFocus(); | 641 | m->setFocus(); |
642 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 642 | m->exec( QPoint( 4,QCursor::pos().y()) ); |
643 | 643 | ||
644 | if(m) delete m; | 644 | if(m) delete m; |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 | ||
648 | void AdvancedFm::cancelMenuTimer() | 648 | void AdvancedFm::cancelMenuTimer() |
649 | { | 649 | { |
650 | // qDebug("selectionChanged: cancel menu timer"); | 650 | // qDebug("selectionChanged: cancel menu timer"); |
651 | if( menuTimer.isActive() ) | 651 | if( menuTimer.isActive() ) |
652 | menuTimer.stop(); | 652 | menuTimer.stop(); |
653 | } | 653 | } |
654 | 654 | ||
655 | QString AdvancedFm::checkDiskSpace(const QString &path) | 655 | QString AdvancedFm::checkDiskSpace(const QString &path) |
656 | { | 656 | { |
657 | struct statfs fss; | 657 | struct statfs fss; |
658 | if ( !statfs( path.latin1(), &fss ) ) | 658 | if ( !statfs( path.latin1(), &fss ) ) |
659 | { | 659 | { |
660 | int blkSize = fss.f_bsize; | 660 | int blkSize = fss.f_bsize; |
661 | // int totalBlks = fs.f_blocks; | 661 | // int totalBlks = fs.f_blocks; |
662 | int availBlks = fss.f_bavail; | 662 | int availBlks = fss.f_bavail; |
663 | 663 | ||
664 | long mult = blkSize / 1024; | 664 | long mult = blkSize / 1024; |
665 | long div = 1024 / blkSize; | 665 | long div = 1024 / blkSize; |
666 | if ( !mult ) mult = 1; | 666 | if ( !mult ) mult = 1; |
667 | if ( !div ) div = 1; | 667 | if ( !div ) div = 1; |
668 | 668 | ||
669 | 669 | ||
670 | return QString::number(availBlks * mult / div); | 670 | return QString::number(availBlks * mult / div); |
671 | } | 671 | } |
672 | return ""; | 672 | return ""; |
673 | } | 673 | } |
674 | 674 | ||
675 | void AdvancedFm::addToDocs() | 675 | void AdvancedFm::addToDocs() |
676 | { | 676 | { |
677 | QStringList strListPaths = getPath(); | 677 | QStringList strListPaths = getPath(); |
678 | QDir *thisDir = CurrentDir(); | 678 | QDir *thisDir = CurrentDir(); |
679 | 679 | ||
680 | if( strListPaths.count() > 0) | 680 | if( strListPaths.count() > 0) |
681 | { | 681 | { |
682 | QString curFile; | 682 | QString curFile; |
683 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) | 683 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) |
684 | { | 684 | { |
685 | curFile = thisDir->canonicalPath()+"/"+(*it); | 685 | curFile = thisDir->canonicalPath()+"/"+(*it); |
686 | // qDebug(curFile); | 686 | // qDebug(curFile); |
687 | DocLnk f; | 687 | DocLnk f; |
688 | // curFile.replace(QRegExp("\\..*"),""); | 688 | // curFile.replace(QRegExp("\\..*"),""); |
689 | f.setName((*it)); | 689 | f.setName((*it)); |
690 | f.setFile( curFile); | 690 | f.setFile( curFile); |
691 | f.writeLink(); | 691 | f.writeLink(); |
692 | } | 692 | } |
693 | } | 693 | } |
694 | } | 694 | } |
695 | 695 | ||
696 | 696 | ||
697 | void AdvancedFm::customDirsToMenu() | 697 | void AdvancedFm::customDirsToMenu() |
698 | { | 698 | { |
699 | 699 | ||
700 | Config cfg("AdvancedFm"); | 700 | Config cfg("AdvancedFm"); |
701 | cfg.setGroup("Menu"); | 701 | cfg.setGroup("Menu"); |
702 | 702 | ||
703 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 703 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
704 | menuButton->insertItems(list ); | 704 | menuButton->insertItems(list ); |
705 | 705 | ||
706 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 706 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
707 | // { | 707 | // { |
708 | // customDirMenu->insertItem(*it ); | 708 | // customDirMenu->insertItem(*it ); |
709 | // } | 709 | // } |
710 | } | 710 | } |
711 | 711 | ||
712 | void AdvancedFm::dirMenuSelected(int item) | 712 | void AdvancedFm::dirMenuSelected(int item) |
713 | { | 713 | { |
714 | qDebug("menu item %d", item); | 714 | qDebug("menu item %d", item); |
715 | switch(item) | 715 | switch(item) |
716 | { | 716 | { |
717 | 717 | ||
718 | case -21: | 718 | case -21: |
719 | case 0: | 719 | case 0: |
720 | addCustomDir(); | 720 | addCustomDir(); |
721 | break; | 721 | break; |
722 | case -22: | 722 | case -22: |
723 | case 1: | 723 | case 1: |
724 | removeCustomDir(); | 724 | removeCustomDir(); |
725 | break; | 725 | break; |
726 | default: | 726 | default: |
727 | { | 727 | { |
728 | // gotoCustomDir( menuButton->text(item)); | 728 | // gotoCustomDir( menuButton->text(item)); |
729 | // gotoCustomDir( customDirMenu->text(item)); | 729 | // gotoCustomDir( customDirMenu->text(item)); |
730 | } | 730 | } |
731 | break; | 731 | break; |
732 | 732 | ||
733 | }; | 733 | }; |
734 | } | 734 | } |
735 | 735 | ||
736 | void AdvancedFm::addCustomDir() | 736 | void AdvancedFm::addCustomDir() |
737 | { | 737 | { |
738 | Config cfg("AdvancedFm"); | 738 | Config cfg("AdvancedFm"); |
739 | cfg.setGroup("Menu"); | 739 | cfg.setGroup("Menu"); |
740 | QString dir; | 740 | QString dir; |
741 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 741 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
742 | 742 | ||
743 | dir = CurrentDir()->canonicalPath(); | 743 | dir = CurrentDir()->canonicalPath(); |
744 | 744 | ||
745 | bool addIt=true; | 745 | bool addIt=true; |
746 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 746 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
747 | { | 747 | { |
748 | if( dir == (*it)) | 748 | if( dir == (*it)) |
749 | { | 749 | { |
750 | addIt=false; | 750 | addIt=false; |
751 | } | 751 | } |
752 | } | 752 | } |
753 | if(addIt) | 753 | if(addIt) |
754 | { | 754 | { |
755 | menuButton->insertItem(dir); | 755 | menuButton->insertItem(dir); |
756 | // customDirMenu->insertItem(dir); | 756 | // customDirMenu->insertItem(dir); |
757 | list << dir; | 757 | list << dir; |
758 | } | 758 | } |
759 | 759 | ||
760 | cfg.writeEntry("CustomDir", list, ','); | 760 | cfg.writeEntry("CustomDir", list, ','); |
761 | cfg.write(); | 761 | cfg.write(); |
762 | } | 762 | } |
763 | 763 | ||
764 | void AdvancedFm::removeCustomDir() | 764 | void AdvancedFm::removeCustomDir() |
765 | { | 765 | { |
766 | // qDebug("remove custom dir"); | 766 | // qDebug("remove custom dir"); |
767 | Config cfg("AdvancedFm"); | 767 | Config cfg("AdvancedFm"); |
768 | cfg.setGroup("Menu"); | 768 | cfg.setGroup("Menu"); |
769 | QString dir; | 769 | QString dir; |
770 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 770 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
771 | QStringList list2; | 771 | QStringList list2; |
772 | dir = CurrentDir()->canonicalPath(); | 772 | dir = CurrentDir()->canonicalPath(); |
773 | int ramble=2; | 773 | int ramble=2; |
774 | // int ramble=-24; | 774 | // int ramble=-24; |
775 | //first remove list | 775 | //first remove list |
776 | if(list.grep(dir,true).isEmpty()) | 776 | if(list.grep(dir,true).isEmpty()) |
777 | { | 777 | { |
778 | QMessageBox::message("AdvancedFm", | 778 | QMessageBox::message(tr( "AdvancedFm" ), |
779 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); | 779 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); |
780 | } | 780 | } |
781 | else | 781 | else |
782 | { | 782 | { |
783 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 783 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
784 | { | 784 | { |
785 | if((*it) != dir)//current item is not our current dir, so add it to temp list | 785 | if((*it) != dir)//current item is not our current dir, so add it to temp list |
786 | { | 786 | { |
787 | list2 <<(*it); | 787 | list2 <<(*it); |
788 | } | 788 | } |
789 | else | 789 | else |
790 | { | 790 | { |
791 | // customDirMenu->removeItem( ramble); | 791 | // customDirMenu->removeItem( ramble); |
792 | menuButton->remove( ramble); | 792 | menuButton->remove( ramble); |
793 | 793 | ||
794 | } | 794 | } |
795 | ramble++; | 795 | ramble++; |
796 | // ramble--; | 796 | // ramble--; |
797 | } | 797 | } |
798 | 798 | ||
799 | cfg.writeEntry("CustomDir", list2, ','); | 799 | cfg.writeEntry("CustomDir", list2, ','); |
800 | cfg.write(); | 800 | cfg.write(); |
801 | } | 801 | } |
802 | // customDirsToMenu(); | 802 | // customDirsToMenu(); |
803 | 803 | ||
804 | } | 804 | } |
805 | 805 | ||
806 | void AdvancedFm::gotoCustomDir(const QString &dir) | 806 | void AdvancedFm::gotoCustomDir(const QString &dir) |
807 | { | 807 | { |
808 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 808 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
809 | QString curDir = dir; | 809 | QString curDir = dir; |
810 | QDir *thisDir = CurrentDir(); | 810 | QDir *thisDir = CurrentDir(); |
811 | // if( curDir.isEmpty()) { | 811 | // if( curDir.isEmpty()) { |
812 | // } | 812 | // } |
813 | if( curDir == s_addBookmark) | 813 | if( curDir == s_addBookmark) |
814 | { | 814 | { |
815 | addCustomDir(); | 815 | addCustomDir(); |
816 | } | 816 | } |
817 | if( curDir == s_removeBookmark) | 817 | if( curDir == s_removeBookmark) |
818 | { | 818 | { |
819 | removeCustomDir( ); | 819 | removeCustomDir( ); |
820 | } | 820 | } |
821 | else | 821 | else |
822 | { | 822 | { |
823 | if(QDir( curDir).exists() ) | 823 | if(QDir( curDir).exists() ) |
824 | { | 824 | { |
825 | thisDir->setPath( curDir ); | 825 | thisDir->setPath( curDir ); |
826 | chdir( curDir.latin1() ); | 826 | chdir( curDir.latin1() ); |
827 | thisDir->cd( curDir, TRUE); | 827 | thisDir->cd( curDir, TRUE); |
828 | populateView(); | 828 | populateView(); |
829 | } | 829 | } |
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | QDir *AdvancedFm::CurrentDir() | 833 | QDir *AdvancedFm::CurrentDir() |
834 | { | 834 | { |
835 | if ( whichTab == 1) | 835 | if ( whichTab == 1) |
836 | { | 836 | { |
837 | return ¤tDir; | 837 | return ¤tDir; |
838 | } | 838 | } |
839 | else | 839 | else |
840 | { | 840 | { |
841 | return ¤tRemoteDir; | 841 | return ¤tRemoteDir; |
842 | } | 842 | } |
843 | } | 843 | } |
844 | 844 | ||
845 | QDir *AdvancedFm::OtherDir() | 845 | QDir *AdvancedFm::OtherDir() |
846 | { | 846 | { |
847 | if ( whichTab == 1) | 847 | if ( whichTab == 1) |
848 | { | 848 | { |
849 | return ¤tRemoteDir; | 849 | return ¤tRemoteDir; |
850 | } | 850 | } |
851 | else | 851 | else |
852 | { | 852 | { |
853 | return ¤tDir; | 853 | return ¤tDir; |
854 | } | 854 | } |
855 | } | 855 | } |
856 | 856 | ||
857 | QListView * AdvancedFm::CurrentView() | 857 | QListView * AdvancedFm::CurrentView() |
858 | { | 858 | { |
859 | if ( whichTab == 1) | 859 | if ( whichTab == 1) |
860 | return Local_View; | 860 | return Local_View; |
861 | else | 861 | else |
862 | return Remote_View; | 862 | return Remote_View; |
863 | } | 863 | } |
864 | 864 | ||
865 | QListView * AdvancedFm::OtherView() | 865 | QListView * AdvancedFm::OtherView() |
866 | { | 866 | { |
867 | if ( whichTab == 1) | 867 | if ( whichTab == 1) |
868 | return Remote_View; | 868 | return Remote_View; |
869 | else | 869 | else |
870 | return Local_View; | 870 | return Local_View; |
871 | } | 871 | } |
872 | 872 | ||
873 | void AdvancedFm::setOtherTabCurrent() | 873 | void AdvancedFm::setOtherTabCurrent() |
874 | { | 874 | { |
875 | if ( whichTab == 1) | 875 | if ( whichTab == 1) |
876 | TabWidget->setCurrentTab(1); | 876 | TabWidget->setCurrentTab(1); |
877 | else | 877 | else |
878 | TabWidget->setCurrentTab(0); | 878 | TabWidget->setCurrentTab(0); |
879 | } | 879 | } |