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