-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index d9aabfd..6f82f95 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -179,67 +179,64 @@ FileView::FileView( const QString & dir, QWidget * parent, | |||
179 | showingHidden=FALSE; | 179 | showingHidden=FALSE; |
180 | 180 | ||
181 | setMultiSelection( TRUE ); | 181 | setMultiSelection( TRUE ); |
182 | header()->hide(); | 182 | header()->hide(); |
183 | 183 | ||
184 | setColumnWidthMode( 0, Manual ); | 184 | setColumnWidthMode( 0, Manual ); |
185 | setColumnWidthMode( 3, Manual ); | 185 | setColumnWidthMode( 3, Manual ); |
186 | 186 | ||
187 | // right align yize column | 187 | // right align yize column |
188 | setColumnAlignment( 1, AlignRight ); | 188 | setColumnAlignment( 1, AlignRight ); |
189 | 189 | ||
190 | generateDir( dir ); | 190 | generateDir( dir ); |
191 | 191 | ||
192 | connect( this, SIGNAL( clicked( QListViewItem * )), | 192 | connect( this, SIGNAL( clicked( QListViewItem * )), |
193 | SLOT( itemClicked( QListViewItem * )) ); | 193 | SLOT( itemClicked( QListViewItem * )) ); |
194 | connect( this, SIGNAL( doubleClicked( QListViewItem * )), | 194 | connect( this, SIGNAL( doubleClicked( QListViewItem * )), |
195 | SLOT( itemDblClicked( QListViewItem * )) ); | 195 | SLOT( itemDblClicked( QListViewItem * )) ); |
196 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 196 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
197 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 197 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
198 | } | 198 | } |
199 | 199 | ||
200 | void FileView::resizeEvent( QResizeEvent *e ) | 200 | void FileView::resizeEvent( QResizeEvent *e ) |
201 | { | 201 | { |
202 | setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); | 202 | setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); |
203 | 203 | ||
204 | // hide type column, we use it for "sort by type" only | 204 | // hide type column, we use it for "sort by type" only |
205 | setColumnWidth( 3, 0 ); | 205 | setColumnWidth( 3, 0 ); |
206 | QListView::resizeEvent( e ); | 206 | QListView::resizeEvent( e ); |
207 | } | 207 | } |
208 | 208 | ||
209 | void FileView::updateDir() | 209 | void FileView::updateDir() |
210 | { | 210 | { |
211 | setCaption( "Boogie on boogieboy"); | ||
212 | //qDebug("Caption should be "+currentDir); | ||
213 | |||
214 | generateDir( currentDir ); | 211 | generateDir( currentDir ); |
215 | } | 212 | } |
216 | 213 | ||
217 | void FileView::setDir( const QString & dir ) | 214 | void FileView::setDir( const QString & dir ) |
218 | { | 215 | { |
219 | if ( dir.startsWith( "/dev" ) ) { | 216 | if ( dir.startsWith( "/dev" ) ) { |
220 | QMessageBox::warning( this, tr( "File Manager" ), | 217 | QMessageBox::warning( this, tr( "File Manager" ), |
221 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); | 218 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); |
222 | return; | 219 | return; |
223 | } | 220 | } |
224 | dirHistory += currentDir; | 221 | dirHistory += currentDir; |
225 | generateDir( dir ); | 222 | generateDir( dir ); |
226 | } | 223 | } |
227 | 224 | ||
228 | void FileView::generateDir( const QString & dir ) | 225 | void FileView::generateDir( const QString & dir ) |
229 | { | 226 | { |
230 | QDir d( dir ); | 227 | QDir d( dir ); |
231 | 228 | ||
232 | if( d.exists() && !d.isReadable() ) return; | 229 | if( d.exists() && !d.isReadable() ) return; |
233 | 230 | ||
234 | currentDir = d.canonicalPath(); | 231 | currentDir = d.canonicalPath(); |
235 | 232 | ||
236 | if( !showingHidden) | 233 | if( !showingHidden) |
237 | d.setFilter( QDir::Dirs | QDir::Files ); | 234 | d.setFilter( QDir::Dirs | QDir::Files ); |
238 | else | 235 | else |
239 | d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); | 236 | d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); |
240 | 237 | ||
241 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); | 238 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); |
242 | 239 | ||
243 | 240 | ||
244 | const QFileInfoList * list = d.entryInfoList(); | 241 | const QFileInfoList * list = d.entryInfoList(); |
245 | QFileInfoListIterator it( *list ); | 242 | QFileInfoListIterator it( *list ); |
@@ -693,65 +690,66 @@ FileBrowser::FileBrowser( const QString & dir, QWidget * parent, | |||
693 | init( dir ); | 690 | init( dir ); |
694 | } | 691 | } |
695 | 692 | ||
696 | void FileBrowser::init(const QString & dir) | 693 | void FileBrowser::init(const QString & dir) |
697 | { | 694 | { |
698 | setCaption( tr("File Manager") ); | 695 | setCaption( tr("File Manager") ); |
699 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); | 696 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); |
700 | 697 | ||
701 | fileView = new FileView( dir, this ); | 698 | fileView = new FileView( dir, this ); |
702 | fileView->setAllColumnsShowFocus( TRUE ); | 699 | fileView->setAllColumnsShowFocus( TRUE ); |
703 | 700 | ||
704 | setCentralWidget( fileView ); | 701 | setCentralWidget( fileView ); |
705 | setToolBarsMovable( FALSE ); | 702 | setToolBarsMovable( FALSE ); |
706 | 703 | ||
707 | QPEToolBar* toolBar = new QPEToolBar( this ); | 704 | QPEToolBar* toolBar = new QPEToolBar( this ); |
708 | toolBar->setHorizontalStretchable( TRUE ); | 705 | toolBar->setHorizontalStretchable( TRUE ); |
709 | 706 | ||
710 | QPEMenuBar* menuBar = new QPEMenuBar( toolBar ); | 707 | QPEMenuBar* menuBar = new QPEMenuBar( toolBar ); |
711 | 708 | ||
712 | dirMenu = new QPopupMenu( this ); | 709 | dirMenu = new QPopupMenu( this ); |
713 | menuBar->insertItem( tr( "Dir" ), dirMenu ); | 710 | menuBar->insertItem( tr( "Dir" ), dirMenu ); |
714 | 711 | ||
715 | sortMenu = new QPopupMenu( this ); | 712 | sortMenu = new QPopupMenu( this ); |
716 | menuBar->insertItem( tr( "Sort" ), sortMenu ); | 713 | menuBar->insertItem( tr( "Sort" ), sortMenu ); |
717 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); | 714 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); |
718 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); | 715 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); |
719 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); | 716 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); |
720 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); | 717 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); |
721 | sortMenu->insertSeparator(); | 718 | sortMenu->insertSeparator(); |
722 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); | 719 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); |
723 | sortMenu->insertSeparator(); | 720 | sortMenu->insertSeparator(); |
724 | sortMenu->insertItem( tr( "Show Hidden "), this, SLOT( showHidden() ) ); | 721 | sortMenu->insertItem( tr( "Show Hidden "), this, SLOT( showHidden() ) ); |
725 | fileView->showingHidden=FALSE; | 722 | |
723 | // fileView->showingHidden=FALSE; | ||
726 | 724 | ||
727 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); | 725 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); |
728 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 726 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
729 | 727 | ||
730 | toolBar = new QPEToolBar( this ); | 728 | toolBar = new QPEToolBar( this ); |
731 | 729 | ||
732 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), | 730 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), |
733 | QString::null, 0, this, 0 ); | 731 | QString::null, 0, this, 0 ); |
734 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); | 732 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); |
735 | lastAction->addTo( toolBar ); | 733 | lastAction->addTo( toolBar ); |
736 | lastAction->setEnabled( FALSE ); | 734 | lastAction->setEnabled( FALSE ); |
737 | 735 | ||
738 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), | 736 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), |
739 | QString::null, 0, this, 0 ); | 737 | QString::null, 0, this, 0 ); |
740 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); | 738 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); |
741 | upAction->addTo( toolBar ); | 739 | upAction->addTo( toolBar ); |
742 | 740 | ||
743 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), | 741 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), |
744 | QString::null, 0, this, 0 ); | 742 | QString::null, 0, this, 0 ); |
745 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); | 743 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); |
746 | a->addTo( toolBar ); | 744 | a->addTo( toolBar ); |
747 | 745 | ||
748 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), | 746 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), |
749 | QString::null, 0, this, 0 ); | 747 | QString::null, 0, this, 0 ); |
750 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); | 748 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); |
751 | a->addTo( toolBar ); | 749 | a->addTo( toolBar ); |
752 | 750 | ||
753 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), | 751 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), |
754 | QString::null, 0, this, 0 ); | 752 | QString::null, 0, this, 0 ); |
755 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); | 753 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); |
756 | a->addTo( toolBar ); | 754 | a->addTo( toolBar ); |
757 | 755 | ||
@@ -844,65 +842,65 @@ void FileBrowser::sortDate() | |||
844 | fileView->sort(); | 842 | fileView->sort(); |
845 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 843 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
846 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 844 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
847 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); | 845 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); |
848 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 846 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
849 | } | 847 | } |
850 | 848 | ||
851 | void FileBrowser::sortType() | 849 | void FileBrowser::sortType() |
852 | { | 850 | { |
853 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 851 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
854 | fileView->sort(); | 852 | fileView->sort(); |
855 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 853 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
856 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 854 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
857 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 855 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
858 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); | 856 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); |
859 | } | 857 | } |
860 | 858 | ||
861 | void FileBrowser::updateSorting() | 859 | void FileBrowser::updateSorting() |
862 | { | 860 | { |
863 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 861 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
864 | 862 | ||
865 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) | 863 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) |
866 | sortName(); | 864 | sortName(); |
867 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) | 865 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) |
868 | sortSize(); | 866 | sortSize(); |
869 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) | 867 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) |
870 | sortDate(); | 868 | sortDate(); |
871 | else | 869 | else |
872 | sortType(); | 870 | sortType(); |
873 | } | 871 | } |
874 | 872 | ||
875 | void FileBrowser::showHidden() { | 873 | void FileBrowser::showHidden() { |
876 | if(! fileView->showingHidden) { | 874 | if(!fileView->showingHidden) { |
877 | fileView->showingHidden=TRUE; | 875 | fileView->showingHidden=TRUE; |
878 | sortMenu->setItemChecked( sortMenu->idAt( 7),TRUE); | 876 | sortMenu->setItemChecked( sortMenu->idAt( 7),TRUE); |
879 | } else { | 877 | } else { |
880 | fileView->showingHidden=FALSE; | 878 | fileView->showingHidden=FALSE; |
881 | sortMenu->setItemChecked( sortMenu->idAt( 7),FALSE); | 879 | sortMenu->setItemChecked( sortMenu->idAt( 7),FALSE); |
882 | } | 880 | } |
883 | fileView->updateDir(); | 881 | fileView->updateDir(); |
884 | } | 882 | } |
885 | 883 | ||
886 | void FileView::chPerm() { | 884 | void FileView::chPerm() { |
887 | FileItem * i; | 885 | FileItem * i; |
888 | QStringList fl; | 886 | QStringList fl; |
889 | QString cmd; | 887 | QString cmd; |
890 | int err; | 888 | int err; |
891 | 889 | ||
892 | if((i = (FileItem *) firstChild()) == 0) return; | 890 | if((i = (FileItem *) firstChild()) == 0) return; |
893 | 891 | ||
894 | while( i ){ | 892 | while( i ){ |
895 | if( i->isSelected() ){ | 893 | if( i->isSelected() ){ |
896 | fl += i->getFilePath(); | 894 | fl += i->getFilePath(); |
897 | } | 895 | } |
898 | i = (FileItem *) i->nextSibling(); | 896 | i = (FileItem *) i->nextSibling(); |
899 | } | 897 | } |
900 | if( fl.count() < 1 ) return; | 898 | if( fl.count() < 1 ) return; |
901 | if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), | 899 | if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), |
902 | tr("Yes"), tr("No") ) == 0) { | 900 | tr("Yes"), tr("No") ) == 0) { |
903 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | 901 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { |
904 | filePermissions *filePerm; | 902 | filePermissions *filePerm; |
905 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); | 903 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); |
906 | filePerm->exec(); | 904 | filePerm->exec(); |
907 | if( filePerm) | 905 | if( filePerm) |
908 | delete filePerm; | 906 | delete filePerm; |