Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

filebrowser.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef FILEBROWSER_H
00021 #define FILEBROWSER_H
00022 
00023 
00024 #include <qlistview.h>
00025 #include <qmainwindow.h>
00026 #include <qfileinfo.h>
00027 #include <qaction.h>
00028 #include <qtimer.h>
00029 #include <qstringlist.h>
00030 class QLabel;
00031 class InlineEdit;
00032 
00033 class FileItem : public QListViewItem
00034 {
00035 public:
00036     FileItem( QListView * parent, const QFileInfo & fi );
00037 
00038     QString key( int column, bool ascending = TRUE ) const;
00039     QString getFilePath(){ return fileInfo.filePath(); }
00040     QString getFileName(){ return fileInfo.fileName(); }
00041     bool    isDir(){ return fileInfo.isDir(); }
00042     bool    isExecutable(){ return fileInfo.isExecutable(); }
00043     bool    isLib();
00044     int     launch();
00045     bool    rename( const QString & name );
00046 private:
00047     QString sizeString( unsigned int size );
00048     QFileInfo fileInfo;
00049   QPixmap FileItem::drawThumbnail(const QFileInfo &file);
00050 };
00051 
00052 
00053 class FileView : public QListView
00054 {
00055     Q_OBJECT
00056 
00057 public:
00058     FileView( const QString & dir, QWidget * parent = 0,
00059         const char * name = 0, 
00060         bool hidden = FALSE,
00061         bool symlinks = FALSE,
00062         bool thumbnails = FALSE );
00063 
00064     void    setDir( const QString & dir );
00065     QString cd(){ return currentDir; }
00066     QStringList history() const { return dirHistory; }
00067     bool showingHidden;
00068 
00069   void setShowHidden(bool hidden);
00070   void setShowSymlinks(bool symlinks);
00071   void setShowThumbnails(bool thumbnails);
00072   bool getShowThumbnails () const { return showThumbnails; }
00073   void setMenuKeepsOpen(bool keepOpen);
00074   
00075 public slots:
00076     void updateDir();
00077     void parentDir();
00078     void lastDir();
00079 
00080     void rename();
00081     void copy();
00082     void paste();
00083     void del();
00084     void cut();
00085     void newFolder();
00086     void viewAsText();
00087     void chPerm();
00088 protected:
00089     void generateDir( const QString & dir );
00090     void resizeEvent( QResizeEvent* );
00091     void contentsMousePressEvent( QMouseEvent * e );
00092     void contentsMouseReleaseEvent( QMouseEvent * e );
00093 
00094 protected slots:
00095     void itemClicked( QListViewItem * i );
00096     void itemDblClicked( QListViewItem * i );
00097     void showFileMenu();
00098     void cancelMenuTimer();
00099     void selectAll(){ QListView::selectAll( TRUE ); }
00100     void deselectAll(){ QListView::selectAll( FALSE ); }
00101     void addToDocuments();
00102     void run();
00103     void endRenaming();
00104 private:
00105     QString     currentDir;
00106     QStringList dirHistory, flist;
00107     QTimer      menuTimer;
00108     InlineEdit * le;
00109     FileItem   * itemToRename;
00110     bool         selected;
00111     bool    showHidden;
00112     bool    showSymlinks;
00113   bool    showThumbnails;
00114   bool menuKeepsOpen; 
00115 
00116     bool copyFile( const QString & dest, const QString & src );
00117 
00118 signals:
00119     void dirChanged();
00120     void textViewActivated( QWidget * w );
00121     void textViewDeactivated();
00122 };
00123 
00124 class FileBrowser : public QMainWindow
00125 {
00126     Q_OBJECT
00127 
00128 public:
00129     FileBrowser( QWidget * parent = 0,
00130          const char * name = 0, WFlags f = 0 );
00131     FileBrowser( const QString & dir, QWidget * parent = 0,
00132          const char * name = 0, WFlags f = 0 );
00133 public slots:
00134         void changeCaption(const QString &);
00135 private:
00136     void init(const QString & dir);
00137     QString      fileToCopy;
00138     QPopupMenu * dirMenu, * sortMenu, *viewMenu;
00139     FileView   * fileView;
00140     QAction    * pasteAction;
00141     QAction *lastAction;
00142     QAction *upAction;
00143 
00144     bool         copyFile( const QString & dest, const QString & src );
00145 
00146 private slots:
00147     void pcmciaMessage( const QCString &msg, const QByteArray &);
00148 
00149     void sortName();
00150     void sortDate();
00151     void sortSize();
00152     void sortType();
00153     void updateSorting();
00154     void updateShowHidden();
00155     void updateShowSymlinks();
00156     void updateShowThumbnails();
00157     void updateDirMenu();
00158     void dirSelected( int id );
00159     void cleanUp();
00160     
00161 };
00162 
00163 #endif

Generated on Sat Nov 5 16:18:03 2005 for OPIE by  doxygen 1.4.2