source: trunk/examples/dirview/dirview.h@ 164

Last change on this file since 164 was 160, checked in by dmik, 19 years ago

Imported table and iconview modules and a bunch of dependent examples from the official release 3.3.1 from Trolltech.

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
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
20class QWidget;
21class QDragEnterEvent;
22class QDragMoveEvent;
23class QDragLeaveEvent;
24class QDropEvent;
25
26class FileItem : public QListViewItem
27{
28public:
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
38private:
39 QPixmap *pix;
40
41};
42
43class Directory : public QListViewItem
44{
45public:
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
64private:
65 QFile f;
66 Directory * p;
67 bool readable;
68 bool showDirsOnly;
69 QPixmap *pix;
70
71};
72
73class DirectoryView : public QListView
74{
75 Q_OBJECT
76
77public:
78 DirectoryView( QWidget *parent = 0, const char *name = 0, bool sdo = FALSE );
79 bool showDirsOnly() { return dirsOnly; }
80
81public slots:
82 void setDir( const QString & );
83
84signals:
85 void folderSelected( const QString & );
86
87protected slots:
88 void slotFolderSelected( QListViewItem * );
89 void openFolder();
90
91protected:
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
100private:
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
Note: See TracBrowser for help on using the repository browser.