Diffstat (limited to 'noncore/unsupported/filebrowser/filebrowser.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.h | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.h b/noncore/unsupported/filebrowser/filebrowser.h new file mode 100644 index 0000000..2e9e444 --- a/dev/null +++ b/noncore/unsupported/filebrowser/filebrowser.h | |||
@@ -0,0 +1,141 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef FILEBROWSER_H | ||
21 | #define FILEBROWSER_H | ||
22 | |||
23 | #include <qlistview.h> | ||
24 | #include <qmainwindow.h> | ||
25 | #include <qfileinfo.h> | ||
26 | #include <qaction.h> | ||
27 | #include <qtimer.h> | ||
28 | #include <qstringlist.h> | ||
29 | |||
30 | class InlineEdit; | ||
31 | |||
32 | class FileItem : public QListViewItem | ||
33 | { | ||
34 | public: | ||
35 | FileItem( QListView * parent, const QFileInfo & fi ); | ||
36 | |||
37 | QString key( int column, bool ascending = TRUE ) const; | ||
38 | QString getFilePath(){ return fileInfo.filePath(); } | ||
39 | QString getFileName(){ return fileInfo.fileName(); } | ||
40 | bool isDir(){ return fileInfo.isDir(); } | ||
41 | bool isExecutable(){ return fileInfo.isExecutable(); } | ||
42 | bool isLib(); | ||
43 | int launch(); | ||
44 | bool rename( const QString & name ); | ||
45 | private: | ||
46 | QString sizeString( unsigned int size ); | ||
47 | QFileInfo fileInfo; | ||
48 | }; | ||
49 | |||
50 | |||
51 | class FileView : public QListView | ||
52 | { | ||
53 | Q_OBJECT | ||
54 | |||
55 | public: | ||
56 | FileView( const QString & dir, QWidget * parent = 0, | ||
57 | const char * name = 0 ); | ||
58 | void setDir( const QString & dir ); | ||
59 | QString cd(){ return currentDir; } | ||
60 | QStringList history() const { return dirHistory; } | ||
61 | |||
62 | public slots: | ||
63 | void updateDir(); | ||
64 | void parentDir(); | ||
65 | void lastDir(); | ||
66 | |||
67 | void rename(); | ||
68 | void copy(); | ||
69 | void paste(); | ||
70 | void del(); | ||
71 | void cut(); | ||
72 | void newFolder(); | ||
73 | void viewAsText(); | ||
74 | |||
75 | protected: | ||
76 | void generateDir( const QString & dir ); | ||
77 | void resizeEvent( QResizeEvent* ); | ||
78 | void contentsMousePressEvent( QMouseEvent * e ); | ||
79 | void contentsMouseReleaseEvent( QMouseEvent * e ); | ||
80 | |||
81 | protected slots: | ||
82 | void itemClicked( QListViewItem * i ); | ||
83 | void itemDblClicked( QListViewItem * i ); | ||
84 | void showFileMenu(); | ||
85 | void cancelMenuTimer(); | ||
86 | void selectAll(){ QListView::selectAll( TRUE ); } | ||
87 | void deselectAll(){ QListView::selectAll( FALSE ); } | ||
88 | void addToDocuments(); | ||
89 | void run(); | ||
90 | void endRenaming(); | ||
91 | |||
92 | private: | ||
93 | QString currentDir; | ||
94 | QStringList dirHistory, flist; | ||
95 | QTimer menuTimer; | ||
96 | InlineEdit * le; | ||
97 | FileItem * itemToRename; | ||
98 | bool selected; | ||
99 | |||
100 | bool copyFile( const QString & dest, const QString & src ); | ||
101 | |||
102 | signals: | ||
103 | void dirChanged(); | ||
104 | void textViewActivated( QWidget * w ); | ||
105 | void textViewDeactivated(); | ||
106 | }; | ||
107 | |||
108 | class FileBrowser : public QMainWindow | ||
109 | { | ||
110 | Q_OBJECT | ||
111 | |||
112 | public: | ||
113 | FileBrowser( QWidget * parent = 0, | ||
114 | const char * name = 0, WFlags f = 0 ); | ||
115 | FileBrowser( const QString & dir, QWidget * parent = 0, | ||
116 | const char * name = 0, WFlags f = 0 ); | ||
117 | private: | ||
118 | void init(const QString & dir); | ||
119 | QString fileToCopy; | ||
120 | QPopupMenu * dirMenu, * sortMenu; | ||
121 | FileView * fileView; | ||
122 | QAction * pasteAction; | ||
123 | QAction*lastAction; | ||
124 | QAction*upAction; | ||
125 | |||
126 | bool copyFile( const QString & dest, const QString & src ); | ||
127 | |||
128 | private slots: | ||
129 | void pcmciaMessage( const QCString &msg, const QByteArray &); | ||
130 | |||
131 | void sortName(); | ||
132 | void sortDate(); | ||
133 | void sortSize(); | ||
134 | void sortType(); | ||
135 | void updateSorting(); | ||
136 | |||
137 | void updateDirMenu(); | ||
138 | void dirSelected( int id ); | ||
139 | }; | ||
140 | |||
141 | #endif | ||