summaryrefslogtreecommitdiffstats
path: root/examples/dirview/dirview.h
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-07-10 15:24:15 -0500
committerTimothy Pearson <[email protected]>2011-07-10 15:24:15 -0500
commitbd0f3345a938b35ce6a12f6150373b0955b8dd12 (patch)
tree7a520322212d48ebcb9fbe1087e7fca28b76185c /examples/dirview/dirview.h
downloadqt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.tar.gz
qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.zip
Add Qt3 development HEAD version
Diffstat (limited to 'examples/dirview/dirview.h')
-rw-r--r--examples/dirview/dirview.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/examples/dirview/dirview.h b/examples/dirview/dirview.h
new file mode 100644
index 0000000..fd13e59
--- /dev/null
+++ b/examples/dirview/dirview.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for Qt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#ifndef DIRVIEW_H
+#define DIRVIEW_H
+
+#include <qlistview.h>
+#include <qstring.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qtimer.h>
+
+class QWidget;
+class QDragEnterEvent;
+class QDragMoveEvent;
+class QDragLeaveEvent;
+class QDropEvent;
+
+class FileItem : public QListViewItem
+{
+public:
+ FileItem( QListViewItem *parent, const QString &s1, const QString &s2 )
+ : QListViewItem( parent, s1, s2 ), pix( 0 ) {}
+
+ const QPixmap *pixmap( int i ) const;
+#if !defined(Q_NO_USING_KEYWORD)
+ using QListViewItem::setPixmap;
+#endif
+ void setPixmap( QPixmap *p );
+
+private:
+ QPixmap *pix;
+
+};
+
+class Directory : public QListViewItem
+{
+public:
+ Directory( QListView * parent, const QString& filename );
+ Directory( Directory * parent, const QString& filename, const QString &col2 )
+ : QListViewItem( parent, filename, col2 ), pix( 0 ) {}
+ Directory( Directory * parent, const QString& filename );
+
+ QString text( int column ) const;
+
+ QString fullName();
+
+ void setOpen( bool );
+ void setup();
+
+ const QPixmap *pixmap( int i ) const;
+#if !defined(Q_NO_USING_KEYWORD)
+ using QListViewItem::setPixmap;
+#endif
+ void setPixmap( QPixmap *p );
+
+private:
+ QFile f;
+ Directory * p;
+ bool readable;
+ bool showDirsOnly;
+ QPixmap *pix;
+
+};
+
+class DirectoryView : public QListView
+{
+ Q_OBJECT
+
+public:
+ DirectoryView( QWidget *parent = 0, const char *name = 0, bool sdo = FALSE );
+ bool showDirsOnly() { return dirsOnly; }
+
+public slots:
+ void setDir( const QString & );
+
+signals:
+ void folderSelected( const QString & );
+
+protected slots:
+ void slotFolderSelected( QListViewItem * );
+ void openFolder();
+
+protected:
+ void contentsDragEnterEvent( QDragEnterEvent *e );
+ void contentsDragMoveEvent( QDragMoveEvent *e );
+ void contentsDragLeaveEvent( QDragLeaveEvent *e );
+ void contentsDropEvent( QDropEvent *e );
+ void contentsMouseMoveEvent( QMouseEvent *e );
+ void contentsMousePressEvent( QMouseEvent *e );
+ void contentsMouseReleaseEvent( QMouseEvent *e );
+
+private:
+ QString fullPath(QListViewItem* item);
+ bool dirsOnly;
+ QListViewItem *oldCurrent;
+ QListViewItem *dropItem;
+ QTimer* autoopen_timer;
+ QPoint presspos;
+ bool mousePressed;
+
+};
+
+#endif