summaryrefslogtreecommitdiffabout
path: root/microkde/ofileselector_p.h
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/ofileselector_p.h
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'microkde/ofileselector_p.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/ofileselector_p.h258
1 files changed, 258 insertions, 0 deletions
diff --git a/microkde/ofileselector_p.h b/microkde/ofileselector_p.h
new file mode 100644
index 0000000..b371806
--- a/dev/null
+++ b/microkde/ofileselector_p.h
@@ -0,0 +1,258 @@
1#ifndef OPIE_OFILE_SELECTOR_PRIVATE_H
2#define OPIE_OFILE_SELECTOR_PRIVATE_H
3
4//US
5#pragma message("microkde/ofileselector_p.h")
6
7#include <qmap.h>
8#include <qstringlist.h>
9#include <qwidget.h>
10#include <qlistview.h>
11
12#include <qpe/applnk.h>
13#include <qpe/fileselector.h>
14
15
16/*
17 * How to avoid having really two different objects
18 * for Extended and ExtendedAll
19 * The only difference is the Lister...
20 * a) static object?
21 * b) leave some object inside the OFileSelector which can be used?
22 * c) when switching views tell which view we want o have.. internally we can switch then
23 *
24 * I'll take c) -zecke
25 */
26
27
28/* the View Interface */
29class OFileSelector;
30typedef QMap<QString, QStringList> MimeTypes;
31class QFileInfo;
32class QToolButton;
33class OFileViewInterface {
34public:
35 OFileViewInterface( OFileSelector* selector );
36 virtual ~OFileViewInterface();
37 virtual QString selectedName()const = 0;
38 virtual QString selectedPath()const = 0;
39 virtual QString directory()const = 0;
40 virtual void reread() = 0;
41 virtual int fileCount()const = 0;
42 virtual DocLnk selectedDocument()const;
43 virtual QWidget* widget( QWidget* parent) = 0;
44 virtual void activate( const QString& );
45 QString name()const;
46protected:
47 OFileSelector* selector()const;
48 void setName( const QString& );
49 bool showNew()const;
50 bool showClose()const;
51 MimeTypes mimeTypes()const;
52 QStringList currentMimeType()const;
53 QString startDirectory()const;
54protected:
55 void ok();
56 void cancel();
57 void closeMe();
58 void fileSelected( const QString& );
59 void fileSelected( const DocLnk& );
60 void setCurrentFileName( const QString& );
61 QString currentFileName()const;
62
63private:
64 QString m_name;
65 OFileSelector* m_selector;
66};
67
68
69/* THE Document View hosting a FileSelector*/
70class ODocumentFileView : public OFileViewInterface {
71public:
72 ODocumentFileView( OFileSelector* selector );
73 ~ODocumentFileView();
74
75 QString selectedName() const;
76 QString selectedPath() const;
77
78 QString directory() const;
79 void reread();
80 int fileCount()const;
81 DocLnk selectedDocument()const;
82
83 QWidget* widget( QWidget* parent );
84
85private:
86 mutable FileSelector* m_selector;
87
88};
89
90class OFileSelectorItem : public QListViewItem {
91public:
92 OFileSelectorItem( QListView* view, const QPixmap& pixmap,
93 const QString& path, const QString& date,
94 const QString& size, const QString& mDir,
95 bool isLocked = false, bool isDir = false );
96 ~OFileSelectorItem();
97 bool isLocked()const;
98 bool isDir()const;
99 QString directory()const;
100 QString path()const;
101 QString key(int id, bool )const;
102
103private:
104 bool m_locked : 1;
105 bool m_isDir : 1;
106 QString m_dir;
107};
108
109class OFileViewFileListView : public QWidget {
110 Q_OBJECT
111public:
112 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
113 ~OFileViewFileListView();
114
115 OFileSelectorItem* currentItem()const;
116 void reread( bool all = false );
117 int fileCount()const;
118 QString currentDir()const;
119protected:
120 bool eventFilter (QObject *o, QEvent *e);
121private slots:
122 void slotNew(); // will emit newSelected
123 void cdUP();
124 void cdHome();
125 void cdDoc();
126 void changeDir( const QString& );
127 void slotCurrentChanged( QListViewItem* );
128 void slotClicked(int, QListViewItem*, const QPoint&, int );
129 void slotFSActivated(int);
130
131protected:
132
133 OFileSelector* selector();
134
135private:
136 QMap<QString, QString> m_dev;
137 bool m_all : 1;
138 OFileSelector* m_sel;
139 QPopupMenu* m_fsPop;
140 bool compliesMime( const QString& );
141 QStringList m_mimes; // used in compy mime
142 QString m_currentDir;
143 QToolButton *m_btnNew, *m_btnClose;
144 void connectSlots();
145 void addFile( QFileInfo* info, bool symlink = FALSE );
146 void addDir ( QFileInfo* info, bool symlink = FALSE );
147 void addSymlink( QFileInfo* info, bool = FALSE );
148
149
150private:
151 QListView* m_view;
152};
153
154typedef QMap<QString, QStringList> MimeTypes;
155
156class OFileViewInterface;
157class OFileViewFileListView;
158class QLineEdit;
159class QComboBox;
160class QWidgetStack;
161class QHBox;
162class OFileSelector : public QWidget {
163 Q_OBJECT
164 friend class OFileViewInterface;
165 friend class OFileViewFileListView;
166public:
167 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
168// enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
169 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
170// enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
171
172 OFileSelector(QWidget* parent, int mode, int selector,
173 const QString& dirName,
174 const QString& fileName,
175 const MimeTypes& mimetypes = MimeTypes(),
176 bool newVisible = FALSE, bool closeVisible = FALSE );
177
178 OFileSelector(const QString& mimeFilter, QWidget* parent,
179 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
180 ~OFileSelector();
181
182 const DocLnk* selected();
183
184 QString selectedName()const;
185 QString selectedPath()const;
186 QString directory()const;
187
188 DocLnk selectedDocument()const;
189
190 int fileCount()const;
191 void reread();
192
193 int mode()const;
194 int selector()const;
195
196
197 void setNewVisible( bool b );
198 void setCloseVisible( bool b );
199 void setNameVisible( bool b );
200
201signals:
202 void dirSelected( const QString& );
203 void fileSelected( const DocLnk& );
204 void fileSelected( const QString& );
205 void newSelected( const DocLnk& );
206 void closeMe();
207 void ok();
208 void cancel();
209
210/* used by the ViewInterface */
211private:
212 bool showNew()const;
213 bool showClose()const;
214 MimeTypes mimeTypes()const;
215 QStringList currentMimeType()const;
216
217private:
218 /* inits the Widgets */
219 void initUI();
220 /* inits the MimeType ComboBox content + connects signals and slots */
221 void initMime();
222 /* init the Views :) */
223 void initViews();
224
225private:
226 QLineEdit* m_lneEdit; // the LineEdit for the Name
227 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
228 QWidgetStack* m_stack; // our widget stack which will contain the views
229 OFileViewInterface* currentView()const; // returns the currentView
230 OFileViewInterface* m_current; // here is the view saved
231 bool m_shNew : 1; // should we show New?
232 bool m_shClose : 1; // should we show Close?
233 MimeTypes m_mimeType; // list of mimetypes
234
235 QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
236 QHBox* m_nameBox; // the LineEdit + Label is hold here
237 QHBox* m_cmbBox; // this holds the two combo boxes
238
239 QString m_startDir;
240 int m_mode;
241 int m_selector;
242
243 struct Data; // used for future versions
244 Data *d;
245
246private slots:
247 void slotMimeTypeChanged();
248
249 /* will set the text of the lineedit and emit a fileChanged signal */
250 void slotDocLnkBridge( const DocLnk& );
251 void slotFileBridge( const QString& );
252 void slotViewChange( const QString& );
253
254 bool eventFilter (QObject *o, QEvent *e);
255
256};
257
258#endif