-rw-r--r-- | libopie/ofileselector_p.h | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/libopie/ofileselector_p.h b/libopie/ofileselector_p.h new file mode 100644 index 0000000..7fd0c50 --- a/dev/null +++ b/libopie/ofileselector_p.h | |||
@@ -0,0 +1,151 @@ | |||
1 | #ifndef OPIE_OFILE_SELECTOR_PRIVATE_H | ||
2 | #define OPIE_OFILE_SELECTOR_PRIVATE_H | ||
3 | |||
4 | #include <qmap.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qwidget.h> | ||
7 | #include <qlistview.h> | ||
8 | |||
9 | #include <qpe/applnk.h> | ||
10 | #include <qpe/fileselector.h> | ||
11 | |||
12 | |||
13 | /* | ||
14 | * How to avoid having really two different objects | ||
15 | * for Extended and ExtendedAll | ||
16 | * The only difference is the Lister... | ||
17 | * a) static object? | ||
18 | * b) leave some object inside the OFileSelector which can be used? | ||
19 | * c) when switching views tell which view we want o have.. internally we can switch then | ||
20 | * | ||
21 | * I'll take c) -zecke | ||
22 | */ | ||
23 | |||
24 | |||
25 | /* the View Interface */ | ||
26 | class OFileSelector; | ||
27 | typedef QMap<QString, QStringList> MimeTypes; | ||
28 | class QFileInfo; | ||
29 | class QToolButton; | ||
30 | class OFileViewInterface { | ||
31 | public: | ||
32 | OFileViewInterface( OFileSelector* selector ); | ||
33 | virtual ~OFileViewInterface(); | ||
34 | virtual QString selectedName()const = 0; | ||
35 | virtual QString selectedPath()const = 0; | ||
36 | virtual QString directory()const = 0; | ||
37 | virtual void reread() = 0; | ||
38 | virtual int fileCount()const = 0; | ||
39 | virtual DocLnk selectedDocument()const; | ||
40 | virtual QWidget* widget( QWidget* parent) = 0; | ||
41 | virtual void activate( const QString& ); | ||
42 | QString name()const; | ||
43 | protected: | ||
44 | OFileSelector* selector()const; | ||
45 | void setName( const QString& ); | ||
46 | bool showNew()const; | ||
47 | bool showClose()const; | ||
48 | MimeTypes mimeTypes()const; | ||
49 | QStringList currentMimeType()const; | ||
50 | QString startDirectory()const; | ||
51 | protected: | ||
52 | void ok(); | ||
53 | void cancel(); | ||
54 | void closeMe(); | ||
55 | void fileSelected( const QString& ); | ||
56 | void fileSelected( const DocLnk& ); | ||
57 | void setCurrentFileName( const QString& ); | ||
58 | QString currentFileName()const; | ||
59 | |||
60 | private: | ||
61 | QString m_name; | ||
62 | OFileSelector* m_selector; | ||
63 | }; | ||
64 | |||
65 | |||
66 | /* THE Document View hosting a FileSelector*/ | ||
67 | class ODocumentFileView : public OFileViewInterface { | ||
68 | public: | ||
69 | ODocumentFileView( OFileSelector* selector ); | ||
70 | ~ODocumentFileView(); | ||
71 | |||
72 | QString selectedName() const; | ||
73 | QString selectedPath() const; | ||
74 | |||
75 | QString directory() const; | ||
76 | void reread(); | ||
77 | int fileCount()const; | ||
78 | DocLnk selectedDocument()const; | ||
79 | |||
80 | QWidget* widget( QWidget* parent ); | ||
81 | |||
82 | private: | ||
83 | mutable FileSelector* m_selector; | ||
84 | |||
85 | }; | ||
86 | |||
87 | class OFileSelectorItem : public QListViewItem { | ||
88 | public: | ||
89 | OFileSelectorItem( QListView* view, const QPixmap& pixmap, | ||
90 | const QString& path, const QString& date, | ||
91 | const QString& size, const QString& mDir, | ||
92 | bool isLocked = false, bool isDir = false ); | ||
93 | ~OFileSelectorItem(); | ||
94 | bool isLocked()const; | ||
95 | bool isDir()const; | ||
96 | QString directory()const; | ||
97 | QString path()const; | ||
98 | QString key(int id, bool )const; | ||
99 | |||
100 | private: | ||
101 | bool m_locked : 1; | ||
102 | bool m_isDir : 1; | ||
103 | QString m_dir; | ||
104 | }; | ||
105 | |||
106 | class OFileViewFileListView : public QWidget { | ||
107 | Q_OBJECT | ||
108 | public: | ||
109 | OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); | ||
110 | ~OFileViewFileListView(); | ||
111 | |||
112 | OFileSelectorItem* currentItem()const; | ||
113 | void reread( bool all = false ); | ||
114 | int fileCount()const; | ||
115 | QString currentDir()const; | ||
116 | protected: | ||
117 | bool eventFilter (QObject *o, QEvent *e); | ||
118 | private slots: | ||
119 | void slotNew(); // will emit newSelected | ||
120 | void cdUP(); | ||
121 | void cdHome(); | ||
122 | void cdDoc(); | ||
123 | void changeDir( const QString& ); | ||
124 | void slotCurrentChanged( QListViewItem* ); | ||
125 | void slotClicked(int, QListViewItem*, const QPoint&, int ); | ||
126 | void slotFSActivated(int); | ||
127 | |||
128 | protected: | ||
129 | |||
130 | OFileSelector* selector(); | ||
131 | |||
132 | private: | ||
133 | QMap<QString, QString> m_dev; | ||
134 | bool m_all : 1; | ||
135 | OFileSelector* m_sel; | ||
136 | QPopupMenu* m_fsPop; | ||
137 | bool compliesMime( const QString& ); | ||
138 | QStringList m_mimes; // used in compy mime | ||
139 | QString m_currentDir; | ||
140 | QToolButton *m_btnNew, *m_btnClose; | ||
141 | void connectSlots(); | ||
142 | void addFile( QFileInfo* info, bool symlink = FALSE ); | ||
143 | void addDir ( QFileInfo* info, bool symlink = FALSE ); | ||
144 | void addSymlink( QFileInfo* info, bool = FALSE ); | ||
145 | |||
146 | |||
147 | private: | ||
148 | QListView* m_view; | ||
149 | }; | ||
150 | |||
151 | #endif | ||