summaryrefslogtreecommitdiffstats
path: root/examples/dirview/dirview.h
diff options
context:
space:
mode:
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 000000000..b4e49b5a2
--- /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 TQt. 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 TQWidget;
+class TQDragEnterEvent;
+class TQDragMoveEvent;
+class TQDragLeaveEvent;
+class TQDropEvent;
+
+class FileItem : public TQListViewItem
+{
+public:
+ FileItem( TQListViewItem *parent, const TQString &s1, const TQString &s2 )
+ : TQListViewItem( parent, s1, s2 ), pix( 0 ) {}
+
+ const TQPixmap *pixmap( int i ) const;
+#if !defined(Q_NO_USING_KEYWORD)
+ using TQListViewItem::setPixmap;
+#endif
+ void setPixmap( TQPixmap *p );
+
+private:
+ TQPixmap *pix;
+
+};
+
+class Directory : public TQListViewItem
+{
+public:
+ Directory( TQListView * parent, const TQString& filename );
+ Directory( Directory * parent, const TQString& filename, const TQString &col2 )
+ : TQListViewItem( parent, filename, col2 ), pix( 0 ) {}
+ Directory( Directory * parent, const TQString& filename );
+
+ TQString text( int column ) const;
+
+ TQString fullName();
+
+ void setOpen( bool );
+ void setup();
+
+ const TQPixmap *pixmap( int i ) const;
+#if !defined(Q_NO_USING_KEYWORD)
+ using TQListViewItem::setPixmap;
+#endif
+ void setPixmap( TQPixmap *p );
+
+private:
+ TQFile f;
+ Directory * p;
+ bool readable;
+ bool showDirsOnly;
+ TQPixmap *pix;
+
+};
+
+class DirectoryView : public TQListView
+{
+ Q_OBJECT
+
+public:
+ DirectoryView( TQWidget *parent = 0, const char *name = 0, bool sdo = FALSE );
+ bool showDirsOnly() { return dirsOnly; }
+
+public slots:
+ void setDir( const TQString & );
+
+signals:
+ void folderSelected( const TQString & );
+
+protected slots:
+ void slotFolderSelected( TQListViewItem * );
+ void openFolder();
+
+protected:
+ void contentsDragEnterEvent( TQDragEnterEvent *e );
+ void contentsDragMoveEvent( TQDragMoveEvent *e );
+ void contentsDragLeaveEvent( TQDragLeaveEvent *e );
+ void contentsDropEvent( TQDropEvent *e );
+ void contentsMouseMoveEvent( TQMouseEvent *e );
+ void contentsMousePressEvent( TQMouseEvent *e );
+ void contentsMouseReleaseEvent( TQMouseEvent *e );
+
+private:
+ TQString fullPath(TQListViewItem* item);
+ bool dirsOnly;
+ TQListViewItem *oldCurrent;
+ TQListViewItem *dropItem;
+ TQTimer* autoopen_timer;
+ TQPoint presspos;
+ bool mousePressed;
+
+};
+
+#endif