00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef DIRVIEW_H
00018 #define DIRVIEW_H
00019
00020 #include <qlistview.h>
00021 #include <qstring.h>
00022 #include <qfile.h>
00023 #include <qfileinfo.h>
00024 #include <qtimer.h>
00025
00026 class QWidget;
00027 class QDragEnterEvent;
00028 class QDragMoveEvent;
00029 class QDragLeaveEvent;
00030 class QDropEvent;
00031
00033 class FileItem : public QListViewItem
00034 {
00035 public:
00036 FileItem( QListViewItem *parent, const QString &s1, const QString &s2 )
00037 : QListViewItem( parent, s1, s2 ), pix( 0 ) {}
00038
00039 const QPixmap *pixmap( int i ) const;
00040 void setPixmap( QPixmap *p );
00041 QString className() { return "FileItem"; }
00042 private:
00043 QPixmap *pix;
00044 };
00045
00047 class Directory : public QListViewItem
00048 {
00049 public:
00050 Directory( QListView * parent, const QString& filename );
00051 Directory( Directory * parent, const QString& filename, const QString &col2 )
00052 : QListViewItem( parent, filename, col2 ), pix( 0 ) {}
00053 Directory( Directory * parent, const QString& filename );
00054
00055 QString text( int column ) const;
00056
00057 QString fullName();
00059 void setOpen( bool );
00060 void setup();
00061
00062 const QPixmap *pixmap( int i ) const;
00063 void setPixmap( QPixmap *p );
00064 QString className() { return "Directory"; }
00065 private:
00066 QFile f;
00067 Directory * p;
00068 bool readable;
00069 bool showDirsOnly;
00070 QPixmap *pix;
00071 };
00072
00074 class DirectoryView : public QListView
00075 {
00076 Q_OBJECT
00077 public:
00078 DirectoryView( QWidget *parent = 0, const char* name=0, QString dir = "/", bool sdo = FALSE );
00079 bool showDirsOnly() { return dirsOnly; }
00080 public slots:
00081 void setDir( const QString & );
00082
00083 signals:
00084 void folderSelected( const QString & );
00085 void fileSelected( const QString & );
00086
00087 protected slots:
00088 void slotFolderSelected( QListViewItem * );
00089 void openFolder();
00090
00091 protected:
00092 void contentsMousePressEvent( QMouseEvent *e );
00093 void contentsMouseReleaseEvent( QMouseEvent *e );
00094 void contentsMouseDoubleClickEvent( QMouseEvent *e );
00095
00096 private:
00097 QString fullPath(QListViewItem* item);
00098 bool dirsOnly;
00099 QListViewItem *oldCurrent;
00100 QListViewItem *dropItem;
00101 QTimer* autoopen_timer;
00102 QPoint presspos;
00103 bool mousePressed;
00104 };
00105
00106 #endif