summaryrefslogtreecommitdiff
path: root/noncore/unsupported
Unidiff
Diffstat (limited to 'noncore/unsupported') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.cpp39
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.h6
2 files changed, 39 insertions, 6 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp
index 41e7634..d9aabfd 100644
--- a/noncore/unsupported/filebrowser/filebrowser.cpp
+++ b/noncore/unsupported/filebrowser/filebrowser.cpp
@@ -167,24 +167,26 @@ bool FileItem::rename( const QString & name )
167FileView::FileView( const QString & dir, QWidget * parent, 167FileView::FileView( const QString & dir, QWidget * parent,
168 const char * name ) 168 const char * name )
169 : QListView( parent, name ), 169 : QListView( parent, name ),
170 menuTimer( this ), 170 menuTimer( this ),
171 le( NULL ), 171 le( NULL ),
172 itemToRename( NULL ) 172 itemToRename( NULL )
173{ 173{
174 addColumn( "Name" ); 174 addColumn( "Name" );
175 addColumn( "Date" ); 175 addColumn( "Date" );
176 addColumn( "Size" ); 176 addColumn( "Size" );
177 addColumn( "Type" ); 177 addColumn( "Type" );
178 178
179 showingHidden=FALSE;
180
179 setMultiSelection( TRUE ); 181 setMultiSelection( TRUE );
180 header()->hide(); 182 header()->hide();
181 183
182 setColumnWidthMode( 0, Manual ); 184 setColumnWidthMode( 0, Manual );
183 setColumnWidthMode( 3, Manual ); 185 setColumnWidthMode( 3, Manual );
184 186
185 // right align yize column 187 // right align yize column
186 setColumnAlignment( 1, AlignRight ); 188 setColumnAlignment( 1, AlignRight );
187 189
188 generateDir( dir ); 190 generateDir( dir );
189 191
190 connect( this, SIGNAL( clicked( QListViewItem * )), 192 connect( this, SIGNAL( clicked( QListViewItem * )),
@@ -197,64 +199,70 @@ FileView::FileView( const QString & dir, QWidget * parent,
197 199
198void FileView::resizeEvent( QResizeEvent *e ) 200void FileView::resizeEvent( QResizeEvent *e )
199{ 201{
200 setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); 202 setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) );
201 203
202 // hide type column, we use it for "sort by type" only 204 // hide type column, we use it for "sort by type" only
203 setColumnWidth( 3, 0 ); 205 setColumnWidth( 3, 0 );
204 QListView::resizeEvent( e ); 206 QListView::resizeEvent( e );
205} 207}
206 208
207void FileView::updateDir() 209void FileView::updateDir()
208{ 210{
211 setCaption( "Boogie on boogieboy");
212 //qDebug("Caption should be "+currentDir);
213
209 generateDir( currentDir ); 214 generateDir( currentDir );
210} 215}
211 216
212void FileView::setDir( const QString & dir ) 217void FileView::setDir( const QString & dir )
213{ 218{
214 if ( dir.startsWith( "/dev" ) ) { 219 if ( dir.startsWith( "/dev" ) ) {
215 QMessageBox::warning( this, tr( "File Manager" ), 220 QMessageBox::warning( this, tr( "File Manager" ),
216 tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); 221 tr( "Can't show /dev/ directory." ), tr( "&Ok" ) );
217 return; 222 return;
218 } 223 }
219 dirHistory += currentDir; 224 dirHistory += currentDir;
220 generateDir( dir ); 225 generateDir( dir );
221} 226}
222 227
223void FileView::generateDir( const QString & dir ) 228void FileView::generateDir( const QString & dir )
224{ 229{
225 QDir d( dir ); 230 QDir d( dir );
226 231
227 if( d.exists() && !d.isReadable() ) return; 232 if( d.exists() && !d.isReadable() ) return;
228 233
229 currentDir = d.canonicalPath(); 234 currentDir = d.canonicalPath();
230 235
236 if( !showingHidden)
231 d.setFilter( QDir::Dirs | QDir::Files ); 237 d.setFilter( QDir::Dirs | QDir::Files );
232 d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | 238 else
233 QDir::Reversed ); 239 d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All);
240
241 d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed );
242
234 243
235 const QFileInfoList * list = d.entryInfoList(); 244 const QFileInfoList * list = d.entryInfoList();
236 QFileInfoListIterator it( *list ); 245 QFileInfoListIterator it( *list );
237 QFileInfo *fi; 246 QFileInfo *fi;
238 247
239 clear(); 248 clear();
240 while( (fi = it.current()) ){ 249 while( (fi = it.current()) ){
241 if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ 250 if( (fi->fileName() == ".") || (fi->fileName() == "..") ){
242 ++it; 251 ++it;
243 continue; 252 continue;
244 } 253 }
245 (void) new FileItem( (QListView *) this, *fi ); 254 (void) new FileItem( (QListView *) this, *fi );
246 ++it; 255 ++it;
247 } 256 }
248
249 emit dirChanged(); 257 emit dirChanged();
250} 258}
251 259
252void FileView::rename() 260void FileView::rename()
253{ 261{
254 itemToRename = (FileItem *) currentItem(); 262 itemToRename = (FileItem *) currentItem();
255 const QPixmap * pm; 263 const QPixmap * pm;
256 int pmw; 264 int pmw;
257 265
258 if( itemToRename == NULL ) return; 266 if( itemToRename == NULL ) return;
259 267
260 if( ( pm = itemToRename->pixmap( 0 ) ) == NULL ) 268 if( ( pm = itemToRename->pixmap( 0 ) ) == NULL )
@@ -646,29 +654,30 @@ void FileView::showFileMenu()
646 m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) ); 654 m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) );
647 655
648 m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ), 656 m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ),
649 this, SLOT( viewAsText() ) ); 657 this, SLOT( viewAsText() ) );
650 658
651 m->insertSeparator(); 659 m->insertSeparator();
652 } 660 }
653 661
654 m->insertItem( tr( "Rename" ), this, SLOT( rename() ) ); 662 m->insertItem( tr( "Rename" ), this, SLOT( rename() ) );
655 m->insertItem( Resource::loadPixmap("cut"), 663 m->insertItem( Resource::loadPixmap("cut"),
656 tr( "Cut" ), this, SLOT( cut() ) ); 664 tr( "Cut" ), this, SLOT( cut() ) );
657 m->insertItem( Resource::loadPixmap("copy"), 665 m->insertItem( Resource::loadPixmap("copy"),
666
658 tr( "Copy" ), this, SLOT( copy() ) ); 667 tr( "Copy" ), this, SLOT( copy() ) );
659 m->insertItem( Resource::loadPixmap("paste"), 668 m->insertItem( Resource::loadPixmap("paste"),
660 tr( "Paste" ), this, SLOT( paste() ) ); 669 tr( "Paste" ), this, SLOT( paste() ) );
661 m->insertItem( tr( "Change Permissions" ), this, SLOT( chPerm() ) ); 670 m->insertItem( tr( "Change Permissions" ), this, SLOT( chPerm() ) );
662 m->insertItem( tr( "Delete" ), this, SLOT( del() ) ); 671 m->insertItem(Resource::loadPixmap( "close" ), tr( "Delete" ), this, SLOT( del() ) );
663 m->insertSeparator(); 672 m->insertSeparator();
664 m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) ); 673 m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) );
665 m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) ); 674 m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) );
666 m->popup( QCursor::pos() ); 675 m->popup( QCursor::pos() );
667} 676}
668 677
669// 678//
670// FileBrowser 679// FileBrowser
671// 680//
672 681
673FileBrowser::FileBrowser( QWidget * parent, 682FileBrowser::FileBrowser( QWidget * parent,
674 const char * name, WFlags f ) : 683 const char * name, WFlags f ) :
@@ -702,24 +711,28 @@ void FileBrowser::init(const QString & dir)
702 711
703 dirMenu = new QPopupMenu( this ); 712 dirMenu = new QPopupMenu( this );
704 menuBar->insertItem( tr( "Dir" ), dirMenu ); 713 menuBar->insertItem( tr( "Dir" ), dirMenu );
705 714
706 sortMenu = new QPopupMenu( this ); 715 sortMenu = new QPopupMenu( this );
707 menuBar->insertItem( tr( "Sort" ), sortMenu ); 716 menuBar->insertItem( tr( "Sort" ), sortMenu );
708 sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); 717 sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) );
709 sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); 718 sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) );
710 sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); 719 sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) );
711 sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); 720 sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) );
712 sortMenu->insertSeparator(); 721 sortMenu->insertSeparator();
713 sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); 722 sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) );
723 sortMenu->insertSeparator();
724 sortMenu->insertItem( tr( "Show Hidden "), this, SLOT( showHidden() ) );
725 fileView->showingHidden=FALSE;
726
714 sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); 727 sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE );
715 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); 728 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE );
716 729
717 toolBar = new QPEToolBar( this ); 730 toolBar = new QPEToolBar( this );
718 731
719 lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), 732 lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ),
720 QString::null, 0, this, 0 ); 733 QString::null, 0, this, 0 );
721 connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); 734 connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) );
722 lastAction->addTo( toolBar ); 735 lastAction->addTo( toolBar );
723 lastAction->setEnabled( FALSE ); 736 lastAction->setEnabled( FALSE );
724 737
725 upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), 738 upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ),
@@ -738,41 +751,46 @@ void FileBrowser::init(const QString & dir)
738 a->addTo( toolBar ); 751 a->addTo( toolBar );
739 752
740 a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), 753 a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ),
741 QString::null, 0, this, 0 ); 754 QString::null, 0, this, 0 );
742 connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); 755 connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) );
743 a->addTo( toolBar ); 756 a->addTo( toolBar );
744 757
745 pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), 758 pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ),
746 QString::null, 0, this, 0 ); 759 QString::null, 0, this, 0 );
747 connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); 760 connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) );
748 pasteAction->addTo( toolBar ); 761 pasteAction->addTo( toolBar );
749 762
763// dirLabel = new QLabel(this, "DirLabel");
750 764
751 connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); 765 connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) );
752 updateDirMenu(); 766 updateDirMenu();
753 767
754 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); 768 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this );
755 connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), 769 connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)),
756 this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); 770 this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) );
757} 771}
758 772
759void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) 773void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &)
760{ 774{
761 if ( msg == "mtabChanged()" ) { 775 if ( msg == "mtabChanged()" ) {
762 // ## Only really needed if current dir is on a card 776 // ## Only really needed if current dir is on a card
763 fileView->updateDir(); 777 fileView->updateDir();
764 } 778 }
765} 779}
766 780
781void FileBrowser::changeCaption(const QString & dir) {
782 setCaption( dir);
783}
784
767void FileBrowser::dirSelected( int id ) 785void FileBrowser::dirSelected( int id )
768{ 786{
769 int i = 0, j; 787 int i = 0, j;
770 QString dir; 788 QString dir;
771 789
772 // Bulid target dir from menu 790 // Bulid target dir from menu
773 while( (j = dirMenu->idAt( i )) != id ){ 791 while( (j = dirMenu->idAt( i )) != id ){
774 dir += dirMenu->text( j ).stripWhiteSpace(); 792 dir += dirMenu->text( j ).stripWhiteSpace();
775 if( dirMenu->text( j ) != "/" ) dir += "/"; 793 if( dirMenu->text( j ) != "/" ) dir += "/";
776 i++; 794 i++;
777 } 795 }
778 dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); 796 dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace();
@@ -845,24 +863,35 @@ void FileBrowser::updateSorting()
845 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 863 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
846 864
847 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) 865 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) )
848 sortName(); 866 sortName();
849 else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) 867 else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) )
850 sortSize(); 868 sortSize();
851 else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) 869 else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) )
852 sortDate(); 870 sortDate();
853 else 871 else
854 sortType(); 872 sortType();
855} 873}
856 874
875void FileBrowser::showHidden() {
876 if(! fileView->showingHidden) {
877 fileView->showingHidden=TRUE;
878 sortMenu->setItemChecked( sortMenu->idAt( 7),TRUE);
879 } else {
880 fileView->showingHidden=FALSE;
881 sortMenu->setItemChecked( sortMenu->idAt( 7),FALSE);
882 }
883 fileView->updateDir();
884}
885
857void FileView::chPerm() { 886void FileView::chPerm() {
858 FileItem * i; 887 FileItem * i;
859 QStringList fl; 888 QStringList fl;
860 QString cmd; 889 QString cmd;
861 int err; 890 int err;
862 891
863 if((i = (FileItem *) firstChild()) == 0) return; 892 if((i = (FileItem *) firstChild()) == 0) return;
864 893
865 while( i ){ 894 while( i ){
866 if( i->isSelected() ){ 895 if( i->isSelected() ){
867 fl += i->getFilePath(); 896 fl += i->getFilePath();
868 } 897 }
diff --git a/noncore/unsupported/filebrowser/filebrowser.h b/noncore/unsupported/filebrowser/filebrowser.h
index c214dbe..54856a0 100644
--- a/noncore/unsupported/filebrowser/filebrowser.h
+++ b/noncore/unsupported/filebrowser/filebrowser.h
@@ -17,25 +17,25 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef FILEBROWSER_H 20#ifndef FILEBROWSER_H
21#define FILEBROWSER_H 21#define FILEBROWSER_H
22 22
23#include <qlistview.h> 23#include <qlistview.h>
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qfileinfo.h> 25#include <qfileinfo.h>
26#include <qaction.h> 26#include <qaction.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29 29class QLabel;
30class InlineEdit; 30class InlineEdit;
31 31
32class FileItem : public QListViewItem 32class FileItem : public QListViewItem
33{ 33{
34public: 34public:
35 FileItem( QListView * parent, const QFileInfo & fi ); 35 FileItem( QListView * parent, const QFileInfo & fi );
36 36
37 QString key( int column, bool ascending = TRUE ) const; 37 QString key( int column, bool ascending = TRUE ) const;
38 QString getFilePath(){ return fileInfo.filePath(); } 38 QString getFilePath(){ return fileInfo.filePath(); }
39 QString getFileName(){ return fileInfo.fileName(); } 39 QString getFileName(){ return fileInfo.fileName(); }
40 bool isDir(){ return fileInfo.isDir(); } 40 bool isDir(){ return fileInfo.isDir(); }
41 bool isExecutable(){ return fileInfo.isExecutable(); } 41 bool isExecutable(){ return fileInfo.isExecutable(); }
@@ -49,24 +49,25 @@ private:
49 49
50 50
51class FileView : public QListView 51class FileView : public QListView
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54 54
55public: 55public:
56 FileView( const QString & dir, QWidget * parent = 0, 56 FileView( const QString & dir, QWidget * parent = 0,
57 const char * name = 0 ); 57 const char * name = 0 );
58 void setDir( const QString & dir ); 58 void setDir( const QString & dir );
59 QString cd(){ return currentDir; } 59 QString cd(){ return currentDir; }
60 QStringList history() const { return dirHistory; } 60 QStringList history() const { return dirHistory; }
61 bool showingHidden;
61 62
62public slots: 63public slots:
63 void updateDir(); 64 void updateDir();
64 void parentDir(); 65 void parentDir();
65 void lastDir(); 66 void lastDir();
66 67
67 void rename(); 68 void rename();
68 void copy(); 69 void copy();
69 void paste(); 70 void paste();
70 void del(); 71 void del();
71 void cut(); 72 void cut();
72 void newFolder(); 73 void newFolder();
@@ -105,37 +106,40 @@ signals:
105 void textViewDeactivated(); 106 void textViewDeactivated();
106}; 107};
107 108
108class FileBrowser : public QMainWindow 109class FileBrowser : public QMainWindow
109{ 110{
110 Q_OBJECT 111 Q_OBJECT
111 112
112public: 113public:
113 FileBrowser( QWidget * parent = 0, 114 FileBrowser( QWidget * parent = 0,
114 const char * name = 0, WFlags f = 0 ); 115 const char * name = 0, WFlags f = 0 );
115 FileBrowser( const QString & dir, QWidget * parent = 0, 116 FileBrowser( const QString & dir, QWidget * parent = 0,
116 const char * name = 0, WFlags f = 0 ); 117 const char * name = 0, WFlags f = 0 );
118public slots:
119 void changeCaption(const QString &);
117private: 120private:
118 void init(const QString & dir); 121 void init(const QString & dir);
119 QString fileToCopy; 122 QString fileToCopy;
120 QPopupMenu * dirMenu, * sortMenu; 123 QPopupMenu * dirMenu, * sortMenu;
121 FileView * fileView; 124 FileView * fileView;
122 QAction * pasteAction; 125 QAction * pasteAction;
123 QAction *lastAction; 126 QAction *lastAction;
124 QAction *upAction; 127 QAction *upAction;
125 128
126 bool copyFile( const QString & dest, const QString & src ); 129 bool copyFile( const QString & dest, const QString & src );
127 130
128private slots: 131private slots:
129 void pcmciaMessage( const QCString &msg, const QByteArray &); 132 void pcmciaMessage( const QCString &msg, const QByteArray &);
130 133
131 void sortName(); 134 void sortName();
132 void sortDate(); 135 void sortDate();
133 void sortSize(); 136 void sortSize();
134 void sortType(); 137 void sortType();
135 void updateSorting(); 138 void updateSorting();
136 139
137 void updateDirMenu(); 140 void updateDirMenu();
138 void dirSelected( int id ); 141 void dirSelected( int id );
142 void showHidden();
139}; 143};
140 144
141#endif 145#endif