1 | /****************************************************************************
|
---|
2 | ** $Id: dirview.h 160 2006-12-11 20:15:57Z dmik $
|
---|
3 | **
|
---|
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
5 | **
|
---|
6 | ** This file is part of an example program for Qt. This example
|
---|
7 | ** program may be used, distributed and modified without limitation.
|
---|
8 | **
|
---|
9 | *****************************************************************************/
|
---|
10 |
|
---|
11 | #ifndef DIRVIEW_H
|
---|
12 | #define DIRVIEW_H
|
---|
13 |
|
---|
14 | #include <qlistview.h>
|
---|
15 | #include <qstring.h>
|
---|
16 | #include <qfile.h>
|
---|
17 | #include <qfileinfo.h>
|
---|
18 | #include <qtimer.h>
|
---|
19 |
|
---|
20 | class QWidget;
|
---|
21 | class QDragEnterEvent;
|
---|
22 | class QDragMoveEvent;
|
---|
23 | class QDragLeaveEvent;
|
---|
24 | class QDropEvent;
|
---|
25 |
|
---|
26 | class FileItem : public QListViewItem
|
---|
27 | {
|
---|
28 | public:
|
---|
29 | FileItem( QListViewItem *parent, const QString &s1, const QString &s2 )
|
---|
30 | : QListViewItem( parent, s1, s2 ), pix( 0 ) {}
|
---|
31 |
|
---|
32 | const QPixmap *pixmap( int i ) const;
|
---|
33 | #if !defined(Q_NO_USING_KEYWORD)
|
---|
34 | using QListViewItem::setPixmap;
|
---|
35 | #endif
|
---|
36 | void setPixmap( QPixmap *p );
|
---|
37 |
|
---|
38 | private:
|
---|
39 | QPixmap *pix;
|
---|
40 |
|
---|
41 | };
|
---|
42 |
|
---|
43 | class Directory : public QListViewItem
|
---|
44 | {
|
---|
45 | public:
|
---|
46 | Directory( QListView * parent, const QString& filename );
|
---|
47 | Directory( Directory * parent, const QString& filename, const QString &col2 )
|
---|
48 | : QListViewItem( parent, filename, col2 ), pix( 0 ) {}
|
---|
49 | Directory( Directory * parent, const QString& filename );
|
---|
50 |
|
---|
51 | QString text( int column ) const;
|
---|
52 |
|
---|
53 | QString fullName();
|
---|
54 |
|
---|
55 | void setOpen( bool );
|
---|
56 | void setup();
|
---|
57 |
|
---|
58 | const QPixmap *pixmap( int i ) const;
|
---|
59 | #if !defined(Q_NO_USING_KEYWORD)
|
---|
60 | using QListViewItem::setPixmap;
|
---|
61 | #endif
|
---|
62 | void setPixmap( QPixmap *p );
|
---|
63 |
|
---|
64 | private:
|
---|
65 | QFile f;
|
---|
66 | Directory * p;
|
---|
67 | bool readable;
|
---|
68 | bool showDirsOnly;
|
---|
69 | QPixmap *pix;
|
---|
70 |
|
---|
71 | };
|
---|
72 |
|
---|
73 | class DirectoryView : public QListView
|
---|
74 | {
|
---|
75 | Q_OBJECT
|
---|
76 |
|
---|
77 | public:
|
---|
78 | DirectoryView( QWidget *parent = 0, const char *name = 0, bool sdo = FALSE );
|
---|
79 | bool showDirsOnly() { return dirsOnly; }
|
---|
80 |
|
---|
81 | public slots:
|
---|
82 | void setDir( const QString & );
|
---|
83 |
|
---|
84 | signals:
|
---|
85 | void folderSelected( const QString & );
|
---|
86 |
|
---|
87 | protected slots:
|
---|
88 | void slotFolderSelected( QListViewItem * );
|
---|
89 | void openFolder();
|
---|
90 |
|
---|
91 | protected:
|
---|
92 | void contentsDragEnterEvent( QDragEnterEvent *e );
|
---|
93 | void contentsDragMoveEvent( QDragMoveEvent *e );
|
---|
94 | void contentsDragLeaveEvent( QDragLeaveEvent *e );
|
---|
95 | void contentsDropEvent( QDropEvent *e );
|
---|
96 | void contentsMouseMoveEvent( QMouseEvent *e );
|
---|
97 | void contentsMousePressEvent( QMouseEvent *e );
|
---|
98 | void contentsMouseReleaseEvent( QMouseEvent *e );
|
---|
99 |
|
---|
100 | private:
|
---|
101 | QString fullPath(QListViewItem* item);
|
---|
102 | bool dirsOnly;
|
---|
103 | QListViewItem *oldCurrent;
|
---|
104 | QListViewItem *dropItem;
|
---|
105 | QTimer* autoopen_timer;
|
---|
106 | QPoint presspos;
|
---|
107 | bool mousePressed;
|
---|
108 |
|
---|
109 | };
|
---|
110 |
|
---|
111 | #endif
|
---|