author | zecke <zecke> | 2002-10-05 22:20:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-05 22:20:57 (UTC) |
commit | 99425255c4afcd75ee6b2f903487cb958d3acdee (patch) (unidiff) | |
tree | 8cce0b096ce9a000291044def444f30934c79888 | |
parent | 94180a2019a945e6a492405dc6a30420c760529f (diff) | |
download | opie-99425255c4afcd75ee6b2f903487cb958d3acdee.zip opie-99425255c4afcd75ee6b2f903487cb958d3acdee.tar.gz opie-99425255c4afcd75ee6b2f903487cb958d3acdee.tar.bz2 |
So now switching is about to be implemented the next commit will have a completed OListe/OFileView switch
-rw-r--r-- | libopie/ofileselector/odefaultfactories.cpp | 15 | ||||
-rw-r--r-- | libopie/ofileselector/odefaultfactories.h | 14 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 34 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.h | 4 |
4 files changed, 50 insertions, 17 deletions
diff --git a/libopie/ofileselector/odefaultfactories.cpp b/libopie/ofileselector/odefaultfactories.cpp new file mode 100644 index 0000000..c41fbca --- a/dev/null +++ b/libopie/ofileselector/odefaultfactories.cpp | |||
@@ -0,0 +1,15 @@ | |||
1 | #include "ofilelistview.h" | ||
2 | #include "olocallister.h" | ||
3 | |||
4 | #include "odefaultfactories.h" | ||
5 | |||
6 | extern "C" { | ||
7 | |||
8 | OFileView* newFileListView( OFileSelector* sel, QWidget* par ) { | ||
9 | return new OFileListView(par, sel ); | ||
10 | } | ||
11 | OLister* newLocalLister( OFileSelector* sel) { | ||
12 | return new OLocalLister( sel ); | ||
13 | } | ||
14 | |||
15 | }; | ||
diff --git a/libopie/ofileselector/odefaultfactories.h b/libopie/ofileselector/odefaultfactories.h new file mode 100644 index 0000000..eb698d3 --- a/dev/null +++ b/libopie/ofileselector/odefaultfactories.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef OPIE_DEFAULT_FACTORIES_H | ||
2 | #define OPIE_DEFAULT_FACTORIES_H | ||
3 | |||
4 | #include "ofilefactory.h" | ||
5 | |||
6 | extern "C" { | ||
7 | |||
8 | OFileView* newFileListView( OFileSelector*, QWidget* parent ); | ||
9 | OLister* newLocalLister(OFileSelector* ); | ||
10 | |||
11 | }; | ||
12 | |||
13 | |||
14 | #endif | ||
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 458d432..91a510f 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp | |||
@@ -1,1024 +1,1024 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qabstractlayout.h> | 7 | #include <qabstractlayout.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | #include <qpainter.h> | 12 | #include <qpainter.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qwidgetstack.h> | 14 | #include <qwidgetstack.h> |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <qfile.h> | 17 | #include <qfile.h> |
18 | #include <qfileinfo.h> | 18 | #include <qfileinfo.h> |
19 | #include <qtimer.h> | 19 | #include <qtimer.h> |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/mimetype.h> | 24 | #include <qpe/mimetype.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | 27 | ||
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
31 | 31 | ||
32 | #include "ofileview.h" | 32 | #include "ofileview.h" |
33 | #include "ofileselectormain.h" | 33 | #include "ofileselectormain.h" |
34 | #include "ofileselector.h" | 34 | #include "ofileselector.h" |
35 | #include "olocallister.h" | 35 | #include "olocallister.h" |
36 | #include "olister.h" | 36 | #include "olister.h" |
37 | #include "odefaultfactories.h" | ||
37 | 38 | ||
38 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 39 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
39 | 40 | ||
40 | namespace { | 41 | namespace { |
41 | /* let's find the index for a specified string */ | 42 | /* let's find the index for a specified string */ |
42 | int indexByString( const QComboBox *box, const QString &str ){ | 43 | int indexByString( const QComboBox *box, const QString &str ){ |
43 | int index= 0; | 44 | int index= 0; |
44 | for(int i= 0; i < box->count(); i++ ){ | 45 | for(int i= 0; i < box->count(); i++ ){ |
45 | /* found */ | 46 | /* found */ |
46 | if( str == box->text(i ) ){ | 47 | if( str == box->text(i ) ){ |
47 | index= i; | 48 | index= i; |
48 | break; | 49 | break; |
49 | } | 50 | } |
50 | } | 51 | } |
51 | return index; | 52 | return index; |
52 | } | 53 | } |
53 | } | 54 | } |
54 | 55 | ||
55 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 56 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
56 | const QString &dirName, | 57 | const QString &dirName, |
57 | const QString &fileName, | 58 | const QString &fileName, |
58 | const QMap<QString,QStringList>& mimeTypes) | 59 | const QMap<QString,QStringList>& mimeTypes) |
59 | : QWidget( wid, "OFileSelector") | 60 | : QWidget( wid, "OFileSelector") |
60 | { | 61 | { |
61 | m_mimetypes = mimeTypes; | 62 | m_mimetypes = mimeTypes; |
62 | if (mode == Save ) | 63 | if (mode == Save ) |
63 | m_name = fileName; | 64 | m_name = fileName; |
64 | 65 | ||
65 | initVars(); | 66 | initVars(); |
66 | 67 | ||
67 | m_mode = mode; | 68 | m_mode = mode; |
68 | m_selector = selector; | 69 | m_selector = selector; |
69 | m_currentDir = dirName; | 70 | m_currentDir = dirName; |
70 | init(); | 71 | init(); |
71 | } | 72 | } |
72 | 73 | ||
73 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 74 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
74 | const char *name, bool newVisible, | 75 | const char *name, bool newVisible, |
75 | bool closeVisible ) | 76 | bool closeVisible ) |
76 | : QWidget( parent, name ) | 77 | : QWidget( parent, name ) |
77 | { | 78 | { |
78 | /* update the mimefilter */ | 79 | /* update the mimefilter */ |
79 | if (!mimeFilter.isEmpty() ) { | 80 | if (!mimeFilter.isEmpty() ) { |
80 | QStringList list = QStringList::split(";", mimeFilter ); | 81 | QStringList list = QStringList::split(";", mimeFilter ); |
81 | m_mimetypes.insert(mimeFilter, list ); | 82 | m_mimetypes.insert(mimeFilter, list ); |
82 | } | 83 | } |
83 | initVars(); | 84 | initVars(); |
84 | m_currentDir = QPEApplication::documentDir(); | 85 | m_currentDir = QPEApplication::documentDir(); |
85 | m_mode = Fileselector; | 86 | m_mode = Fileselector; |
86 | m_selector = Normal; | 87 | m_selector = Normal; |
87 | m_shClose = closeVisible; | 88 | m_shClose = closeVisible; |
88 | m_shNew = newVisible; | 89 | m_shNew = newVisible; |
89 | m_shLne = false; | 90 | m_shLne = false; |
90 | m_shPerm = false; | 91 | m_shPerm = false; |
91 | m_shYesNo = false; | 92 | m_shYesNo = false; |
92 | init(); | 93 | init(); |
93 | 94 | ||
94 | 95 | ||
95 | } | 96 | } |
96 | 97 | ||
97 | OFileSelector::~OFileSelector() | 98 | OFileSelector::~OFileSelector() |
98 | { | 99 | { |
99 | 100 | ||
100 | 101 | ||
101 | } | 102 | } |
102 | 103 | ||
103 | void OFileSelector::setNewVisible( bool visible ) | 104 | void OFileSelector::setNewVisible( bool visible ) |
104 | { | 105 | { |
105 | m_shNew = visible; | 106 | m_shNew = visible; |
106 | if (m_new ) | 107 | if (m_new ) |
107 | m_new->show(); | 108 | m_new->show(); |
108 | } | 109 | } |
109 | void OFileSelector::setCloseVisible( bool visible ) | 110 | void OFileSelector::setCloseVisible( bool visible ) |
110 | { | 111 | { |
111 | m_shClose = visible; | 112 | m_shClose = visible; |
112 | 113 | ||
113 | if( m_close ) | 114 | if( m_close ) |
114 | m_close->show(); | 115 | m_close->show(); |
115 | } | 116 | } |
116 | void OFileSelector::reread() | 117 | void OFileSelector::reread() |
117 | { | 118 | { |
118 | if( m_selector == Normal ) | 119 | if( m_selector == Normal ) |
119 | initializeOldSelector(); | 120 | initializeOldSelector(); |
120 | else | 121 | else |
121 | reparse(); | 122 | reparse(); |
122 | } | 123 | } |
123 | 124 | ||
124 | const DocLnk *OFileSelector::selected() | 125 | const DocLnk *OFileSelector::selected() |
125 | { | 126 | { |
126 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 127 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
127 | return lnk; | 128 | return lnk; |
128 | } | 129 | } |
129 | 130 | ||
130 | void OFileSelector::setYesCancelVisible( bool show ) | 131 | void OFileSelector::setYesCancelVisible( bool show ) |
131 | { | 132 | { |
132 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 133 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
133 | m_shYesNo = show; | 134 | m_shYesNo = show; |
134 | 135 | ||
135 | if( m_shYesNo ) | 136 | if( m_shYesNo ) |
136 | m_boxOk->show(); | 137 | m_boxOk->show(); |
137 | else | 138 | else |
138 | m_boxOk->hide(); | 139 | m_boxOk->hide(); |
139 | 140 | ||
140 | } | 141 | } |
141 | void OFileSelector::setToolbarVisible( bool show ) | 142 | void OFileSelector::setToolbarVisible( bool show ) |
142 | { | 143 | { |
143 | m_shTool = show; | 144 | m_shTool = show; |
144 | 145 | ||
145 | if(!m_shTool ){ | 146 | if(!m_shTool ){ |
146 | m_location->hide(); | 147 | m_location->hide(); |
147 | m_up->hide(); | 148 | m_up->hide(); |
148 | m_homeButton->hide(); | 149 | m_homeButton->hide(); |
149 | m_docButton->hide(); | 150 | m_docButton->hide(); |
150 | }else{ | 151 | }else{ |
151 | m_location->show(); | 152 | m_location->show(); |
152 | m_up->show(); | 153 | m_up->show(); |
153 | m_homeButton->show(); | 154 | m_homeButton->show(); |
154 | m_docButton->show(); | 155 | m_docButton->show(); |
155 | } | 156 | } |
156 | } | 157 | } |
157 | void OFileSelector::setPermissionBarVisible( bool show ) | 158 | void OFileSelector::setPermissionBarVisible( bool show ) |
158 | { | 159 | { |
159 | m_shPerm = show; | 160 | m_shPerm = show; |
160 | initializePerm(); | 161 | initializePerm(); |
161 | 162 | ||
162 | if( m_shPerm ) | 163 | if( m_shPerm ) |
163 | m_checkPerm->show(); | 164 | m_checkPerm->show(); |
164 | else | 165 | else |
165 | m_checkPerm->hide(); | 166 | m_checkPerm->hide(); |
166 | } | 167 | } |
167 | void OFileSelector::setLineEditVisible( bool show ) | 168 | void OFileSelector::setLineEditVisible( bool show ) |
168 | { | 169 | { |
169 | if( show ){ | 170 | if( show ){ |
170 | initializeName(); | 171 | initializeName(); |
171 | m_boxName->show(); | 172 | m_boxName->show(); |
172 | }else{ | 173 | }else{ |
173 | // check if we showed before this is the way to go | 174 | // check if we showed before this is the way to go |
174 | if( m_shLne && m_boxName != 0 ) | 175 | if( m_shLne && m_boxName != 0 ) |
175 | m_boxName->hide(); | 176 | m_boxName->hide(); |
176 | } | 177 | } |
177 | m_shLne = show; | 178 | m_shLne = show; |
178 | } | 179 | } |
179 | 180 | ||
180 | void OFileSelector::setChooserVisible( bool show ) | 181 | void OFileSelector::setChooserVisible( bool show ) |
181 | { | 182 | { |
182 | m_shChooser = show; | 183 | m_shChooser = show; |
183 | initializeChooser(); | 184 | initializeChooser(); |
184 | 185 | ||
185 | if( m_shChooser ) | 186 | if( m_shChooser ) |
186 | m_boxView->hide(); | 187 | m_boxView->hide(); |
187 | else | 188 | else |
188 | m_boxView->show(); | 189 | m_boxView->show(); |
189 | 190 | ||
190 | } | 191 | } |
191 | 192 | ||
192 | QCheckBox* OFileSelector::permissionCheckbox() | 193 | QCheckBox* OFileSelector::permissionCheckbox() |
193 | { | 194 | { |
194 | if( m_selector == Normal ) | 195 | if( m_selector == Normal ) |
195 | return 0l; | 196 | return 0l; |
196 | else | 197 | else |
197 | return m_checkPerm; | 198 | return m_checkPerm; |
198 | } | 199 | } |
199 | bool OFileSelector::setPermission()const | 200 | bool OFileSelector::setPermission()const |
200 | { | 201 | { |
201 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 202 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
202 | } | 203 | } |
203 | void OFileSelector::setPermissionChecked( bool check ) | 204 | void OFileSelector::setPermissionChecked( bool check ) |
204 | { | 205 | { |
205 | if( m_checkPerm ) | 206 | if( m_checkPerm ) |
206 | m_checkPerm->setChecked( check ); | 207 | m_checkPerm->setChecked( check ); |
207 | } | 208 | } |
208 | 209 | ||
209 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 210 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
210 | { | 211 | { |
211 | m_mode = mode; | 212 | m_mode = mode; |
212 | if( m_selector == Normal ) | 213 | if( m_selector == Normal ) |
213 | return; | 214 | return; |
214 | } | 215 | } |
215 | void OFileSelector::setShowDirs(bool dir) | 216 | void OFileSelector::setShowDirs(bool dir) |
216 | { | 217 | { |
217 | m_dir = dir; | 218 | m_dir = dir; |
218 | if ( m_selector != Fileselector ) | 219 | if ( m_selector != Fileselector ) |
219 | reparse(); | 220 | reparse(); |
220 | } | 221 | } |
221 | void OFileSelector::setCaseSensetive(bool caSe ) | 222 | void OFileSelector::setCaseSensetive(bool caSe ) |
222 | { | 223 | { |
223 | m_case = caSe; | 224 | m_case = caSe; |
224 | 225 | ||
225 | if ( m_selector != Fileselector ) | 226 | if ( m_selector != Fileselector ) |
226 | reparse(); | 227 | reparse(); |
227 | } | 228 | } |
228 | void OFileSelector::setShowFiles(bool show ) | 229 | void OFileSelector::setShowFiles(bool show ) |
229 | { | 230 | { |
230 | m_files = show; | 231 | m_files = show; |
231 | reparse(); | 232 | reparse(); |
232 | } | 233 | } |
233 | /// | 234 | /// |
234 | bool OFileSelector::cd(const QString &path ) | 235 | bool OFileSelector::cd(const QString &path ) |
235 | { | 236 | { |
236 | m_currentDir = path; | 237 | m_currentDir = path; |
237 | reparse(); | 238 | reparse(); |
238 | return true; | 239 | return true; |
239 | } | 240 | } |
240 | void OFileSelector::setSelector(int mode ) | 241 | void OFileSelector::setSelector(int mode ) |
241 | { | 242 | { |
242 | QString text; | 243 | QString text; |
243 | switch( mode ){ | 244 | switch( mode ){ |
244 | case Normal: | 245 | case Normal: |
245 | text = tr("Documents"); | 246 | text = tr("Documents"); |
246 | break; | 247 | break; |
247 | case Extended: | 248 | case Extended: |
248 | text = tr("Files"); | 249 | text = tr("Files"); |
249 | break; | 250 | break; |
250 | case ExtendedAll: | 251 | case ExtendedAll: |
251 | text = tr("All Files"); | 252 | text = tr("All Files"); |
252 | break; | 253 | break; |
253 | } | 254 | } |
254 | slotViewCheck( text ); | 255 | slotViewCheck( text ); |
255 | } | 256 | } |
256 | 257 | ||
257 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) | 258 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) |
258 | { | 259 | { |
259 | /* m_custom = popup; | 260 | /* m_custom = popup; |
260 | m_showPopup = true; | 261 | m_showPopup = true; |
261 | */ | 262 | */ |
262 | } | 263 | } |
263 | 264 | ||
264 | //void OFileSelector::updateL | 265 | //void OFileSelector::updateL |
265 | 266 | ||
266 | QString OFileSelector::selectedName() const | 267 | QString OFileSelector::selectedName() const |
267 | { | 268 | { |
268 | QString name; | 269 | QString name; |
269 | if( m_selector == Normal ){ | 270 | if( m_selector == Normal ){ |
270 | DocLnk lnk = m_select->selectedDocument(); | 271 | DocLnk lnk = m_select->selectedDocument(); |
271 | name = lnk.file(); | 272 | name = lnk.file(); |
272 | }else { | 273 | }else { |
273 | if ( m_shLne ) { | 274 | if ( m_shLne ) { |
274 | name = m_currentDir + "/" +m_edit->text(); | 275 | name = m_currentDir + "/" +m_edit->text(); |
275 | }else{ | 276 | }else{ |
276 | name = m_currentDir + "/" + currentView()->selectedName(); | 277 | name = m_currentDir + "/" + currentView()->selectedName(); |
277 | } | 278 | } |
278 | } | 279 | } |
279 | return name; | 280 | return name; |
280 | } | 281 | } |
281 | QStringList OFileSelector::selectedNames()const | 282 | QStringList OFileSelector::selectedNames()const |
282 | { | 283 | { |
283 | QStringList list; | 284 | QStringList list; |
284 | if( m_selector == Normal ){ | 285 | if( m_selector == Normal ){ |
285 | list << selectedName(); | 286 | list << selectedName(); |
286 | }else { | 287 | }else { |
287 | list << selectedName(); // FIXME implement multiple Selections | 288 | list << selectedName(); // FIXME implement multiple Selections |
288 | } | 289 | } |
289 | return list; | 290 | return list; |
290 | } | 291 | } |
291 | /** If mode is set to the Dir selection this will return the selected path. | 292 | /** If mode is set to the Dir selection this will return the selected path. |
292 | * | 293 | * |
293 | * | 294 | * |
294 | */ | 295 | */ |
295 | QString OFileSelector::selectedPath()const | 296 | QString OFileSelector::selectedPath()const |
296 | { | 297 | { |
297 | QString path; | 298 | QString path; |
298 | if( m_selector == Normal ){ | 299 | if( m_selector == Normal ){ |
299 | path = QPEApplication::documentDir(); | 300 | path = QPEApplication::documentDir(); |
300 | } /*else if( m_selector == Extended || m_selector == ExtendedAll ){ | 301 | } /* normal case to do */ |
301 | ; | ||
302 | }*/ | ||
303 | return path; | 302 | return path; |
304 | } | 303 | } |
305 | QStringList OFileSelector::selectedPaths() const | 304 | QStringList OFileSelector::selectedPaths() const |
306 | { | 305 | { |
307 | QStringList list; | 306 | QStringList list; |
308 | list << selectedPath(); | 307 | list << selectedPath(); |
309 | return list; | 308 | return list; |
310 | } | 309 | } |
311 | QString OFileSelector::directory()const | 310 | QString OFileSelector::directory()const |
312 | { | 311 | { |
313 | if( m_selector == Normal ) | 312 | if( m_selector == Normal ) |
314 | return QPEApplication::documentDir(); | 313 | return QPEApplication::documentDir(); |
315 | 314 | ||
316 | return QDir(m_currentDir).absPath(); | 315 | return QDir(m_currentDir).absPath(); |
317 | } | 316 | } |
318 | 317 | ||
319 | int OFileSelector::fileCount() | 318 | int OFileSelector::fileCount() |
320 | { | 319 | { |
321 | int count; | 320 | int count; |
322 | switch( m_selector ){ | 321 | switch( m_selector ){ |
323 | case Normal: | 322 | case Normal: |
324 | count = m_select->fileCount(); | 323 | count = m_select->fileCount(); |
325 | break; | 324 | break; |
326 | case Extended: | 325 | case Extended: |
327 | case ExtendedAll: | 326 | case ExtendedAll: |
328 | default: | 327 | default: |
329 | count = currentView()->fileCount(); | 328 | count = currentView()->fileCount(); |
330 | break; | 329 | break; |
331 | } | 330 | } |
332 | return count; | 331 | return count; |
333 | } | 332 | } |
334 | DocLnk OFileSelector::selectedDocument() const | 333 | DocLnk OFileSelector::selectedDocument() const |
335 | { | 334 | { |
336 | DocLnk lnk; | 335 | DocLnk lnk; |
337 | switch( m_selector ){ | 336 | switch( m_selector ){ |
338 | case Normal:{ | 337 | case Normal:{ |
339 | lnk = m_select->selectedDocument(); | 338 | lnk = m_select->selectedDocument(); |
340 | break; | 339 | break; |
341 | } | 340 | } |
342 | case Extended: | 341 | case Extended: |
343 | case ExtendedAll: | 342 | case ExtendedAll: |
344 | default: | 343 | default: |
345 | lnk = DocLnk( selectedName() ); | 344 | lnk = DocLnk( selectedName() ); |
346 | break; | 345 | break; |
347 | } | 346 | } |
348 | return lnk; | 347 | return lnk; |
349 | } | 348 | } |
350 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 349 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
351 | { | 350 | { |
352 | QValueList<DocLnk> docs; | 351 | QValueList<DocLnk> docs; |
353 | docs.append( selectedDocument() ); | 352 | docs.append( selectedDocument() ); |
354 | return docs; | 353 | return docs; |
355 | } | 354 | } |
356 | 355 | ||
357 | 356 | ||
358 | // slots internal | 357 | // slots internal |
359 | 358 | ||
360 | void OFileSelector::slotOk() | 359 | void OFileSelector::slotOk() |
361 | { | 360 | { |
362 | emit ok(); | 361 | emit ok(); |
363 | } | 362 | } |
364 | void OFileSelector::slotCancel() | 363 | void OFileSelector::slotCancel() |
365 | { | 364 | { |
366 | emit cancel(); | 365 | emit cancel(); |
367 | } | 366 | } |
368 | /* switch the views */ | 367 | /* switch the views */ |
369 | void OFileSelector::slotViewCheck(const QString &sel) | 368 | void OFileSelector::slotViewCheck(const QString &sel) |
370 | { | 369 | { |
371 | if( sel == tr("Documents" ) ){ | 370 | if( sel == tr("Documents" ) ){ |
372 | initializeOldSelector(); | 371 | initializeOldSelector(); |
373 | m_selector = Normal; | 372 | m_selector = Normal; |
374 | 373 | ||
375 | }else if( sel == tr("Files") ){ | 374 | }else { |
376 | m_selector = Extended; | 375 | ; |
377 | |||
378 | // FIXME call the factory | ||
379 | //reparse(); | ||
380 | }else if( sel == tr("All Files") ){ | ||
381 | m_selector = ExtendedAll; | ||
382 | /* see above | ||
383 | reparse(); */ | ||
384 | } | 376 | } |
385 | } | 377 | } |
386 | 378 | ||
387 | QString OFileSelector::currentMimeType() const{ | 379 | QString OFileSelector::currentMimeType() const{ |
388 | QString mime; | 380 | QString mime; |
389 | QString currentText; | 381 | QString currentText; |
390 | if (m_shChooser && m_mimeCheck ) | 382 | if (m_shChooser && m_mimeCheck ) |
391 | currentText = m_mimeCheck->currentText(); | 383 | currentText = m_mimeCheck->currentText(); |
392 | 384 | ||
393 | qWarning("CurrentText" + currentText ); | 385 | qWarning("CurrentText" + currentText ); |
394 | if (tr("All") == currentText ) return QString::null; | 386 | if (tr("All") == currentText ) return QString::null; |
395 | else if (currentText.isEmpty() ) { | 387 | else if (currentText.isEmpty() ) { |
396 | ; | 388 | ; |
397 | }else { | 389 | }else { |
398 | QMap<QString, QStringList>::ConstIterator it; | 390 | QMap<QString, QStringList>::ConstIterator it; |
399 | it = m_mimetypes.find( currentText ); | 391 | it = m_mimetypes.find( currentText ); |
400 | if ( it != m_mimetypes.end() ) { | 392 | if ( it != m_mimetypes.end() ) { |
401 | mime = it.data().join(";"); | 393 | mime = it.data().join(";"); |
402 | }else{ | 394 | }else{ |
403 | mime = currentText; | 395 | mime = currentText; |
404 | } | 396 | } |
405 | } | 397 | } |
406 | return mime; | 398 | return mime; |
407 | } | 399 | } |
408 | void OFileSelector::slotMimeCheck(const QString &mime) | 400 | void OFileSelector::slotMimeCheck(const QString &mime) |
409 | { | 401 | { |
410 | if( m_selector == Normal ){ | 402 | if( m_selector == Normal ){ |
411 | initializeOldSelector(); | 403 | initializeOldSelector(); |
412 | 404 | ||
413 | updateMimes(); | 405 | updateMimes(); |
414 | updateMimeCheck(); | 406 | updateMimeCheck(); |
415 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 407 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
416 | }else{ // others | 408 | }else{ // others |
417 | qWarning("Mime %s", mime.latin1() ); | 409 | qWarning("Mime %s", mime.latin1() ); |
418 | if(m_shChooser ){ | 410 | if(m_shChooser ){ |
419 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 411 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
420 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 412 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
421 | } | 413 | } |
422 | reparse(); | 414 | reparse(); |
423 | } | 415 | } |
424 | 416 | ||
425 | } | 417 | } |
426 | /* | 418 | /* |
427 | * Ok if a non dir gets inserted into this combobox | 419 | * Ok if a non dir gets inserted into this combobox |
428 | * we need to change it | 420 | * we need to change it |
429 | * QFileInfo and dirPath will give us the right Dir | 421 | * QFileInfo and dirPath will give us the right Dir |
430 | */ | 422 | */ |
431 | void OFileSelector::slotLocationActivated(const QString &file) | 423 | void OFileSelector::slotLocationActivated(const QString &file) |
432 | { | 424 | { |
433 | qWarning("slotLocationActivated"); | 425 | qWarning("slotLocationActivated"); |
434 | QString name = file.left( file.find("<-", 0, TRUE ) ); | 426 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
435 | QFileInfo info( name ); | 427 | QFileInfo info( name ); |
436 | if ( info.isFile() ) | 428 | if ( info.isFile() ) |
437 | cd(info.dirPath( TRUE ) ); //absolute | 429 | cd(info.dirPath( TRUE ) ); //absolute |
438 | else | 430 | else |
439 | cd(name ); | 431 | cd(name ); |
440 | reparse(); | 432 | reparse(); |
441 | } | 433 | } |
442 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 434 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
443 | { | 435 | { |
444 | QStringList pathList; | 436 | QStringList pathList; |
445 | bool underDog = FALSE; | 437 | bool underDog = FALSE; |
446 | for(int i=0;i<count;i++) { | 438 | for(int i=0;i<count;i++) { |
447 | pathList << m_location->text(i); | 439 | pathList << m_location->text(i); |
448 | if( m_location->text(i) == currentPath) | 440 | if( m_location->text(i) == currentPath) |
449 | underDog = TRUE; | 441 | underDog = TRUE; |
450 | } | 442 | } |
451 | if( !underDog) { | 443 | if( !underDog) { |
452 | m_location->clear(); | 444 | m_location->clear(); |
453 | if( currentPath.left(2)=="//") | 445 | if( currentPath.left(2)=="//") |
454 | pathList.append( currentPath.right(currentPath.length()-1) ); | 446 | pathList.append( currentPath.right(currentPath.length()-1) ); |
455 | else | 447 | else |
456 | pathList.append( currentPath ); | 448 | pathList.append( currentPath ); |
457 | m_location->insertStringList( pathList,-1); | 449 | m_location->insertStringList( pathList,-1); |
458 | } | 450 | } |
459 | } | 451 | } |
460 | /* | 452 | /* |
461 | * Do not crash anymore | 453 | * Do not crash anymore |
462 | * don't try to change dir to a file | 454 | * don't try to change dir to a file |
463 | */ | 455 | */ |
464 | void OFileSelector::locationComboChanged() | 456 | void OFileSelector::locationComboChanged() |
465 | { | 457 | { |
466 | QFileInfo info( m_location->lineEdit()->text() ); | 458 | QFileInfo info( m_location->lineEdit()->text() ); |
467 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | 459 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
468 | if (info.isFile() ) | 460 | if (info.isFile() ) |
469 | cd(info.dirPath(TRUE) ); //absolute path | 461 | cd(info.dirPath(TRUE) ); //absolute path |
470 | else | 462 | else |
471 | cd( m_location->lineEdit()->text() ); | 463 | cd( m_location->lineEdit()->text() ); |
472 | 464 | ||
473 | reparse(); | 465 | reparse(); |
474 | } | 466 | } |
475 | void OFileSelector::init() | 467 | void OFileSelector::init() |
476 | { | 468 | { |
469 | initFactory(); | ||
477 | m_lay = new QVBoxLayout( this ); | 470 | m_lay = new QVBoxLayout( this ); |
478 | m_lay->setSpacing(0 ); | 471 | m_lay->setSpacing(0 ); |
479 | 472 | ||
480 | /* take care of the main view... */ | 473 | /* take care of the main view... */ |
481 | initToolbar(); | 474 | initToolbar(); |
482 | 475 | ||
483 | /* initialize the file lister */ | 476 | /* initialize the file lister */ |
484 | initLister(); | 477 | initLister(); |
485 | if( m_selector == Normal ){ | 478 | if( m_selector == Normal ){ |
486 | QString mime; | 479 | QString mime; |
487 | if (!m_autoMime) { | 480 | if (!m_autoMime) { |
488 | if (!m_mimetypes.isEmpty() ) { | 481 | if (!m_mimetypes.isEmpty() ) { |
489 | QMap<QString, QStringList>::Iterator it; | 482 | QMap<QString, QStringList>::Iterator it; |
490 | it = m_mimetypes.begin(); // cause we're in the init | 483 | it = m_mimetypes.begin(); // cause we're in the init |
491 | mime = it.data().join(";"); | 484 | mime = it.data().join(";"); |
492 | } | 485 | } |
493 | } | 486 | } |
494 | initializeOldSelector(); | 487 | initializeOldSelector(); |
495 | }else{ | 488 | }else{ |
496 | initializeView(); | 489 | initializeView(); |
497 | } | 490 | } |
498 | 491 | ||
499 | if( m_shLne ) // the LineEdit with the current FileName | 492 | if( m_shLne ) // the LineEdit with the current FileName |
500 | initializeName(); | 493 | initializeName(); |
501 | 494 | ||
502 | if( m_shPerm ) // the Permission QCheckBox | 495 | if( m_shPerm ) // the Permission QCheckBox |
503 | initializePerm(); | 496 | initializePerm(); |
504 | 497 | ||
505 | if( m_shChooser ) // the Chooser for the view and Mimetypes | 498 | if( m_shChooser ) // the Chooser for the view and Mimetypes |
506 | initializeChooser(); | 499 | initializeChooser(); |
507 | 500 | ||
508 | if( m_shYesNo ) // the Yes No button row | 501 | if( m_shYesNo ) // the Yes No button row |
509 | initializeYes( ); | 502 | initializeYes( ); |
510 | 503 | ||
511 | if (m_selector != Normal ) | 504 | if (m_selector != Normal ) |
512 | reparse(); | 505 | reparse(); |
513 | } | 506 | } |
514 | void OFileSelector::updateMimes() | 507 | void OFileSelector::updateMimes() |
515 | { | 508 | { |
516 | if( m_autoMime ){ | 509 | if( m_autoMime ){ |
517 | m_mimetypes.clear(); | 510 | m_mimetypes.clear(); |
518 | m_mimetypes.insert( tr("All"), QString::null ); | 511 | m_mimetypes.insert( tr("All"), QString::null ); |
519 | if( m_selector == Normal ){ | 512 | if( m_selector == Normal ){ |
520 | DocLnkSet set; | 513 | DocLnkSet set; |
521 | Global::findDocuments(&set, QString::null ); | 514 | Global::findDocuments(&set, QString::null ); |
522 | QListIterator<DocLnk> dit( set.children() ); | 515 | QListIterator<DocLnk> dit( set.children() ); |
523 | for( ; dit.current(); ++dit ){ | 516 | for( ; dit.current(); ++dit ){ |
524 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 517 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
525 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 518 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
526 | } | 519 | } |
527 | }// else done in reparse | 520 | }// else done in reparse |
528 | } | 521 | } |
529 | } | 522 | } |
530 | void OFileSelector::initVars() | 523 | void OFileSelector::initVars() |
531 | { | 524 | { |
532 | if( m_mimetypes.isEmpty() ) | 525 | if( m_mimetypes.isEmpty() ) |
533 | m_autoMime = true; | 526 | m_autoMime = true; |
534 | else | 527 | else |
535 | m_autoMime = false; | 528 | m_autoMime = false; |
536 | 529 | ||
537 | m_shClose = false; | 530 | m_shClose = false; |
538 | m_shNew = false; | 531 | m_shNew = false; |
539 | m_shTool = true; | 532 | m_shTool = true; |
540 | m_shPerm = false; | 533 | m_shPerm = false; |
541 | m_shLne = true; | 534 | m_shLne = true; |
542 | m_shChooser = true; | 535 | m_shChooser = true; |
543 | m_shYesNo = true; | 536 | m_shYesNo = true; |
544 | m_case = false; | 537 | m_case = false; |
545 | m_dir = true; | 538 | m_dir = true; |
546 | m_files = true; | 539 | m_files = true; |
547 | m_showPopup = false; | 540 | m_showPopup = false; |
548 | m_mainView = 0l; | 541 | m_mainView = 0l; |
549 | m_fileView = 0l; | 542 | m_fileView = 0l; |
550 | m_lister = 0l; | 543 | m_lister = 0l; |
551 | 544 | ||
552 | if(m_pixmaps == 0 ) // init the pixmaps | 545 | if(m_pixmaps == 0 ) // init the pixmaps |
553 | initPics(); | 546 | initPics(); |
554 | 547 | ||
555 | // pointers | 548 | // pointers |
556 | m_location = 0; | 549 | m_location = 0; |
557 | m_mimeCheck = 0; | 550 | m_mimeCheck = 0; |
558 | m_viewCheck = 0; | 551 | m_viewCheck = 0; |
559 | m_homeButton = 0; | 552 | m_homeButton = 0; |
560 | m_docButton = 0; | 553 | m_docButton = 0; |
561 | m_hideButton = 0; | 554 | m_hideButton = 0; |
562 | m_ok = 0; | 555 | m_ok = 0; |
563 | m_cancel = 0; | 556 | m_cancel = 0; |
564 | m_reread = 0; | 557 | m_reread = 0; |
565 | m_up = 0; | 558 | m_up = 0; |
566 | m_View = 0; | 559 | m_View = 0; |
567 | m_checkPerm = 0; | 560 | m_checkPerm = 0; |
568 | m_pseudo = 0; | 561 | m_pseudo = 0; |
569 | m_pseudoLayout = 0; | 562 | m_pseudoLayout = 0; |
570 | m_select = 0; | 563 | m_select = 0; |
571 | m_lay = 0; | 564 | m_lay = 0; |
572 | m_Oselector = 0; | 565 | m_Oselector = 0; |
573 | m_boxToolbar = 0; | 566 | m_boxToolbar = 0; |
574 | m_boxOk = 0; | 567 | m_boxOk = 0; |
575 | m_boxName = 0; | 568 | m_boxName = 0; |
576 | m_boxView = 0; | 569 | m_boxView = 0; |
577 | m_edit = 0; | 570 | m_edit = 0; |
578 | m_fnLabel = 0; | 571 | m_fnLabel = 0; |
579 | m_new = 0; | 572 | m_new = 0; |
580 | m_close = 0; | 573 | m_close = 0; |
581 | } | 574 | } |
582 | void OFileSelector::initializeName() | 575 | void OFileSelector::initializeName() |
583 | { | 576 | { |
584 | /** Name Layout Line | 577 | /** Name Layout Line |
585 | * This is the Layout line arranged in | 578 | * This is the Layout line arranged in |
586 | * horizontal way each components | 579 | * horizontal way each components |
587 | * are next to each other | 580 | * are next to each other |
588 | * but we will only do this if | 581 | * but we will only do this if |
589 | * we didn't initialize a while ago. | 582 | * we didn't initialize a while ago. |
590 | */ | 583 | */ |
591 | if( m_boxName == 0 ){ | 584 | if( m_boxName == 0 ){ |
592 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 585 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
593 | m_fnLabel = new QLabel( m_boxName ); | 586 | m_fnLabel = new QLabel( m_boxName ); |
594 | m_fnLabel->setText( tr("Name:") ); | 587 | m_fnLabel->setText( tr("Name:") ); |
595 | m_edit = new QLineEdit( m_boxName ); | 588 | m_edit = new QLineEdit( m_boxName ); |
596 | m_edit->setText( m_name ); | 589 | m_edit->setText( m_name ); |
597 | //m_boxName->addWidget( m_fnLabel ); | 590 | //m_boxName->addWidget( m_fnLabel ); |
598 | m_boxName->setMargin( 5 ); | 591 | m_boxName->setMargin( 5 ); |
599 | m_boxName->setSpacing( 8 ); | 592 | m_boxName->setSpacing( 8 ); |
600 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | 593 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor |
601 | 594 | ||
602 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | 595 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout |
603 | }// else we already initialized | 596 | }// else we already initialized |
604 | // maybe show the components? | 597 | // maybe show the components? |
605 | // | 598 | // |
606 | } | 599 | } |
607 | void OFileSelector::initializeYes() | 600 | void OFileSelector::initializeYes() |
608 | { | 601 | { |
609 | /** The Save Cancel bar | 602 | /** The Save Cancel bar |
610 | * | 603 | * |
611 | */ | 604 | */ |
612 | if( m_boxOk == 0 ){ | 605 | if( m_boxOk == 0 ){ |
613 | m_boxOk = new QHBox( this ); | 606 | m_boxOk = new QHBox( this ); |
614 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | 607 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); |
615 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | 608 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); |
616 | 609 | ||
617 | //m_boxOk->addWidget( m_ok ); | 610 | //m_boxOk->addWidget( m_ok ); |
618 | //m_boxOk->addWidget( m_cancel ); | 611 | //m_boxOk->addWidget( m_cancel ); |
619 | m_boxOk->setMargin( 5 ); | 612 | m_boxOk->setMargin( 5 ); |
620 | m_boxOk->setSpacing( 10 ); | 613 | m_boxOk->setSpacing( 10 ); |
621 | m_lay->addWidget( m_boxOk, 0 ); | 614 | m_lay->addWidget( m_boxOk, 0 ); |
622 | 615 | ||
623 | connect( m_ok, SIGNAL( clicked() ), | 616 | connect( m_ok, SIGNAL( clicked() ), |
624 | this, SLOT(slotOk() ) ); | 617 | this, SLOT(slotOk() ) ); |
625 | connect( m_cancel, SIGNAL( clicked() ), | 618 | connect( m_cancel, SIGNAL( clicked() ), |
626 | this, SLOT( slotCancel() ) ); | 619 | this, SLOT( slotCancel() ) ); |
627 | } | 620 | } |
628 | } | 621 | } |
629 | /* | 622 | /* |
630 | * OK m_mimeCheck is a QComboBox we now want to fill | 623 | * OK m_mimeCheck is a QComboBox we now want to fill |
631 | * out that combobox | 624 | * out that combobox |
632 | * if automime we need to update the mimetypes | 625 | * if automime we need to update the mimetypes |
633 | */ | 626 | */ |
634 | void OFileSelector::updateMimeCheck() { | 627 | void OFileSelector::updateMimeCheck() { |
635 | m_mimeCheck->clear(); | 628 | m_mimeCheck->clear(); |
636 | if (m_autoMime ) { | 629 | if (m_autoMime ) { |
637 | //m_mimeCheck->insertItem( tr("All") ); | 630 | //m_mimeCheck->insertItem( tr("All") ); |
638 | updateMimes(); | 631 | updateMimes(); |
639 | } | 632 | } |
640 | 633 | ||
641 | QMap<QString, QStringList>::Iterator it; | 634 | QMap<QString, QStringList>::Iterator it; |
642 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | 635 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { |
643 | m_mimeCheck->insertItem( it.key() ); | 636 | m_mimeCheck->insertItem( it.key() ); |
644 | } | 637 | } |
645 | } | 638 | } |
646 | 639 | ||
647 | void OFileSelector::initializeChooser() | 640 | void OFileSelector::initializeChooser() |
648 | { | 641 | { |
649 | if( m_boxView == 0 ){ | 642 | if( m_boxView == 0 ){ |
650 | m_boxView = new QHBox( this ); | 643 | m_boxView = new QHBox( this ); |
651 | m_viewCheck = new QComboBox( m_boxView, "view check"); | 644 | m_viewCheck = new QComboBox( m_boxView, "view check"); |
652 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | 645 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); |
653 | m_boxView->setSpacing( 8 ); | 646 | m_boxView->setSpacing( 8 ); |
654 | m_lay->addWidget(m_boxView, 0 ); | 647 | m_lay->addWidget(m_boxView, 0 ); |
655 | 648 | ||
656 | m_viewCheck->insertItem( tr("Documents") ); | ||
657 | m_viewCheck->insertItem( tr("Files") ); | ||
658 | m_viewCheck->insertItem( tr("All Files") ); | ||
659 | /* update to custom views */ | ||
660 | 649 | ||
661 | updateMimeCheck(); | 650 | updateMimeCheck(); |
662 | 651 | ||
663 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 652 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
664 | this, SLOT( slotViewCheck(const QString & ) ) ); | 653 | this, SLOT( slotViewCheck(const QString & ) ) ); |
665 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 654 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
666 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 655 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
667 | } | 656 | } |
668 | } | 657 | } |
669 | /* generate the buttons for the toolbar */ | 658 | /* generate the buttons for the toolbar */ |
670 | void OFileSelector::initToolbar() { | 659 | void OFileSelector::initToolbar() { |
671 | m_mainView = new OFileSelectorMain( this ); | 660 | m_mainView = new OFileSelectorMain( this ); |
672 | 661 | ||
673 | /* now generate the tool bar */ | 662 | /* now generate the tool bar */ |
674 | qWarning( "toolbar" ); | 663 | qWarning( "toolbar" ); |
675 | m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); | 664 | m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); |
676 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | 665 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); |
677 | 666 | ||
678 | m_boxToolbar = new QHBox( m_pseudo ); | 667 | m_boxToolbar = new QHBox( m_pseudo ); |
679 | m_boxToolbar->setSpacing( 0 ); | 668 | m_boxToolbar->setSpacing( 0 ); |
680 | 669 | ||
681 | // tool bar members now | 670 | // tool bar members now |
682 | m_location = new QComboBox( m_boxToolbar ); | 671 | m_location = new QComboBox( m_boxToolbar ); |
683 | m_location->setEditable( TRUE ); | 672 | m_location->setEditable( TRUE ); |
684 | m_location->setDuplicatesEnabled( FALSE ); | 673 | m_location->setDuplicatesEnabled( FALSE ); |
685 | connect( m_location, SIGNAL(activated(const QString& ) ), | 674 | connect( m_location, SIGNAL(activated(const QString& ) ), |
686 | this, SLOT(slotLocationActivated(const QString& )) ); | 675 | this, SLOT(slotLocationActivated(const QString& )) ); |
687 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , | 676 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , |
688 | this, SLOT(locationComboChanged() ) ); | 677 | this, SLOT(locationComboChanged() ) ); |
689 | 678 | ||
690 | // UP Button | 679 | // UP Button |
691 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, | 680 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, |
692 | m_boxToolbar, "cdUpButton" ); | 681 | m_boxToolbar, "cdUpButton" ); |
693 | m_up->setFixedSize( QSize(20, 20 ) ); | 682 | m_up->setFixedSize( QSize(20, 20 ) ); |
694 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); | 683 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); |
695 | m_up->setFlat( TRUE ); | 684 | m_up->setFlat( TRUE ); |
696 | 685 | ||
697 | // Home Button | 686 | // Home Button |
698 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), | 687 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), |
699 | QString::null, m_boxToolbar ); | 688 | QString::null, m_boxToolbar ); |
700 | m_homeButton->setFixedSize( QSize(20, 20 ) ); | 689 | m_homeButton->setFixedSize( QSize(20, 20 ) ); |
701 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); | 690 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); |
702 | m_homeButton->setFlat( TRUE ); | 691 | m_homeButton->setFlat( TRUE ); |
703 | 692 | ||
704 | // Documents Button | 693 | // Documents Button |
705 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), | 694 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), |
706 | QString::null, m_boxToolbar, | 695 | QString::null, m_boxToolbar, |
707 | "docsButton" ); | 696 | "docsButton" ); |
708 | m_docButton->setFixedSize( QSize(20, 20 ) ); | 697 | m_docButton->setFixedSize( QSize(20, 20 ) ); |
709 | m_docButton->setFlat( true ); | 698 | m_docButton->setFlat( true ); |
710 | connect( m_docButton, SIGNAL(clicked() ), | 699 | connect( m_docButton, SIGNAL(clicked() ), |
711 | this, SLOT(slotDoc() ) ); | 700 | this, SLOT(slotDoc() ) ); |
712 | 701 | ||
713 | // close button | 702 | // close button |
714 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 703 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
715 | m_boxToolbar ); | 704 | m_boxToolbar ); |
716 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 705 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
717 | m_close->setFixedSize( 20, 20 ); | 706 | m_close->setFixedSize( 20, 20 ); |
718 | 707 | ||
719 | m_boxToolbar->setFixedHeight( 20 ); | 708 | m_boxToolbar->setFixedHeight( 20 ); |
720 | m_pseudoLayout->addWidget(m_boxToolbar ); | 709 | m_pseudoLayout->addWidget(m_boxToolbar ); |
721 | 710 | ||
722 | /* init the locations */ | 711 | /* init the locations */ |
723 | initLocations(); | 712 | initLocations(); |
724 | 713 | ||
725 | if( !m_shTool ){ | 714 | if( !m_shTool ){ |
726 | m_location->hide( ); | 715 | m_location->hide( ); |
727 | m_up->hide( ); | 716 | m_up->hide( ); |
728 | m_homeButton->hide( ); | 717 | m_homeButton->hide( ); |
729 | m_docButton->hide( ); | 718 | m_docButton->hide( ); |
730 | } | 719 | } |
731 | if(!m_shClose ) | 720 | if(!m_shClose ) |
732 | m_close->hide(); | 721 | m_close->hide(); |
733 | 722 | ||
734 | m_mainView->setToolbar( m_pseudo ); | 723 | m_mainView->setToolbar( m_pseudo ); |
735 | m_lay->addWidget( m_mainView, 100 ); | 724 | m_lay->addWidget( m_mainView, 100 ); |
736 | } | 725 | } |
737 | /* initialize the OLocalLister */ | 726 | /* initialize the OLocalLister */ |
738 | void OFileSelector::initLister() { | 727 | void OFileSelector::initLister() { |
739 | m_lister = new OLocalLister(this); | 728 | m_lister = new OLocalLister(this); |
740 | } | 729 | } |
741 | /* put default locations into the bar */ | 730 | /* put default locations into the bar */ |
742 | void OFileSelector::initLocations () { | 731 | void OFileSelector::initLocations () { |
743 | 732 | ||
744 | // let;s fill the Location ComboBox | 733 | // let;s fill the Location ComboBox |
745 | StorageInfo storage; | 734 | StorageInfo storage; |
746 | const QList<FileSystem> &fs = storage.fileSystems(); | 735 | const QList<FileSystem> &fs = storage.fileSystems(); |
747 | QListIterator<FileSystem> it ( fs ); | 736 | QListIterator<FileSystem> it ( fs ); |
748 | for( ; it.current(); ++it ){ | 737 | for( ; it.current(); ++it ){ |
749 | const QString disk = (*it)->name(); | 738 | const QString disk = (*it)->name(); |
750 | const QString path = (*it)->path(); | 739 | const QString path = (*it)->path(); |
751 | m_location->insertItem(path+ "<-"+disk ); | 740 | m_location->insertItem(path+ "<-"+disk ); |
752 | } | 741 | } |
753 | int count = m_location->count(); | 742 | int count = m_location->count(); |
754 | m_location->insertItem( m_currentDir ); | 743 | m_location->insertItem( m_currentDir ); |
755 | m_location->setCurrentItem( count ); | 744 | m_location->setCurrentItem( count ); |
756 | 745 | ||
757 | } | 746 | } |
758 | void OFileSelector::initializePerm() | 747 | void OFileSelector::initializePerm() |
759 | { | 748 | { |
760 | if( m_checkPerm == 0 ){ | 749 | if( m_checkPerm == 0 ){ |
761 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); | 750 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); |
762 | m_checkPerm->setChecked( false ); | 751 | m_checkPerm->setChecked( false ); |
763 | m_lay->addWidget( m_checkPerm ); | 752 | m_lay->addWidget( m_checkPerm ); |
764 | } | 753 | } |
765 | } | 754 | } |
766 | void OFileSelector::initPics() | 755 | void OFileSelector::initPics() |
767 | { | 756 | { |
768 | m_pixmaps = new QMap<QString,QPixmap>; | 757 | m_pixmaps = new QMap<QString,QPixmap>; |
769 | QPixmap pm = Resource::loadPixmap( "folder" ); | 758 | QPixmap pm = Resource::loadPixmap( "folder" ); |
770 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 759 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
771 | 760 | ||
772 | QPainter painter( &pm ); | 761 | QPainter painter( &pm ); |
773 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 762 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
774 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 763 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
775 | m_pixmaps->insert("dirsymlink", pm ); | 764 | m_pixmaps->insert("dirsymlink", pm ); |
776 | 765 | ||
777 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 766 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
778 | QPainter pen(&pm2 ); | 767 | QPainter pen(&pm2 ); |
779 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 768 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
780 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 769 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
781 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 770 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
782 | } | 771 | } |
783 | // if a mime complies with the m_mimeCheck->currentItem | 772 | // if a mime complies with the m_mimeCheck->currentItem |
784 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 773 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
785 | { | 774 | { |
786 | if( mime == "All" ) | 775 | if( mime == "All" ) |
787 | return true; | 776 | return true; |
788 | MimeType type( path ); | 777 | MimeType type( path ); |
789 | if( type.id() == mime ) | 778 | if( type.id() == mime ) |
790 | return true; | 779 | return true; |
791 | return false; | 780 | return false; |
792 | } | 781 | } |
793 | /* check if the mimetype in mime | 782 | /* check if the mimetype in mime |
794 | * complies with the one which is current | 783 | * complies with the one which is current |
795 | */ | 784 | */ |
796 | /* | 785 | /* |
797 | * We've the mimetype of the file | 786 | * We've the mimetype of the file |
798 | * We need to get the stringlist of the current mimetype | 787 | * We need to get the stringlist of the current mimetype |
799 | * | 788 | * |
800 | * mime = image/jpeg | 789 | * mime = image/jpeg |
801 | * QStringList = 'image/*' | 790 | * QStringList = 'image/*' |
802 | * or QStringList = image/jpeg;image/png;application/x-ogg | 791 | * or QStringList = image/jpeg;image/png;application/x-ogg |
803 | * or QStringList = application/x-ogg;image/*; | 792 | * or QStringList = application/x-ogg;image/*; |
804 | * with all these mime filters it should get acceptes | 793 | * with all these mime filters it should get acceptes |
805 | * to do so we need to look if mime is contained inside | 794 | * to do so we need to look if mime is contained inside |
806 | * the stringlist | 795 | * the stringlist |
807 | * if it's contained return true | 796 | * if it's contained return true |
808 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | 797 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' |
809 | * is contained in the mimefilter and then we will | 798 | * is contained in the mimefilter and then we will |
810 | * look if both are equal until the '/' | 799 | * look if both are equal until the '/' |
811 | */ | 800 | */ |
812 | bool OFileSelector::compliesMime( const QString& mime ) { | 801 | bool OFileSelector::compliesMime( const QString& mime ) { |
813 | qWarning("mimetype is %s", mime.latin1() ); | 802 | qWarning("mimetype is %s", mime.latin1() ); |
814 | QString currentText; | 803 | QString currentText; |
815 | if (m_shChooser ) | 804 | if (m_shChooser ) |
816 | currentText = m_mimeCheck->currentText(); | 805 | currentText = m_mimeCheck->currentText(); |
817 | 806 | ||
818 | qWarning("current text is %s", currentText.latin1() ); | 807 | qWarning("current text is %s", currentText.latin1() ); |
819 | QMap<QString, QStringList>::Iterator it; | 808 | QMap<QString, QStringList>::Iterator it; |
820 | QStringList list; | 809 | QStringList list; |
821 | if ( currentText == tr("All") ) return true; | 810 | if ( currentText == tr("All") ) return true; |
822 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | 811 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { |
823 | it = m_mimetypes.begin(); | 812 | it = m_mimetypes.begin(); |
824 | list = it.data(); | 813 | list = it.data(); |
825 | }else if ( currentText.isEmpty() ) return true; | 814 | }else if ( currentText.isEmpty() ) return true; |
826 | else{ | 815 | else{ |
827 | it = m_mimetypes.find(currentText ); | 816 | it = m_mimetypes.find(currentText ); |
828 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | 817 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; |
829 | else qWarning("found"), list = it.data(); | 818 | else qWarning("found"), list = it.data(); |
830 | } | 819 | } |
831 | 820 | ||
832 | 821 | ||
833 | if ( list.contains(mime) ) return true; | 822 | if ( list.contains(mime) ) return true; |
834 | qWarning("list doesn't contain it "); | 823 | qWarning("list doesn't contain it "); |
835 | QStringList::Iterator it2; | 824 | QStringList::Iterator it2; |
836 | int pos; | 825 | int pos; |
837 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | 826 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { |
838 | pos = (*it2).findRev("/*"); | 827 | pos = (*it2).findRev("/*"); |
839 | if ( pos >= 0 ) { | 828 | if ( pos >= 0 ) { |
840 | if ( mime.contains( (*it2).left(pos) ) ) return true; | 829 | if ( mime.contains( (*it2).left(pos) ) ) return true; |
841 | } | 830 | } |
842 | } | 831 | } |
843 | return false; | 832 | return false; |
844 | } | 833 | } |
845 | void OFileSelector::slotFileSelected( const QString &string ) | 834 | void OFileSelector::slotFileSelected( const QString &string ) |
846 | { | 835 | { |
847 | if( m_shLne ) | 836 | if( m_shLne ) |
848 | m_edit->setText( string ); | 837 | m_edit->setText( string ); |
849 | emit fileSelected( string ); | 838 | emit fileSelected( string ); |
850 | } | 839 | } |
851 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 840 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
852 | { | 841 | { |
853 | slotFileSelected( lnk.name() ); | 842 | slotFileSelected( lnk.name() ); |
854 | // emit fileSelected( lnk ); | 843 | // emit fileSelected( lnk ); |
855 | } | 844 | } |
856 | 845 | ||
857 | 846 | ||
858 | void OFileSelector::slotDelete() | 847 | void OFileSelector::slotDelete() |
859 | { | 848 | { |
860 | /* | 849 | /* |
861 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 850 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
862 | QStringList list = QStringList::split("->", sel->text(1) ); | 851 | QStringList list = QStringList::split("->", sel->text(1) ); |
863 | if( sel->isDir() ){ | 852 | if( sel->isDir() ){ |
864 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | 853 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry |
865 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | 854 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
866 | tr("Yes"),tr("No"),0,1,1) ) { | 855 | tr("Yes"),tr("No"),0,1,1) ) { |
867 | case 0: | 856 | case 0: |
868 | ::system(str.utf8().data() ); | 857 | ::system(str.utf8().data() ); |
869 | break; | 858 | break; |
870 | } | 859 | } |
871 | } else { | 860 | } else { |
872 | QFile::remove( list[0] ); | 861 | QFile::remove( list[0] ); |
873 | } | 862 | } |
874 | m_View->takeItem( sel ); | 863 | m_View->takeItem( sel ); |
875 | delete sel; | 864 | delete sel; |
876 | */ | 865 | */ |
877 | } | 866 | } |
878 | void OFileSelector::cdUP() | 867 | void OFileSelector::cdUP() |
879 | { | 868 | { |
880 | QDir dir( m_currentDir ); | 869 | QDir dir( m_currentDir ); |
881 | dir.cdUp(); | 870 | dir.cdUp(); |
882 | if(dir.exists() ){ | 871 | if(dir.exists() ){ |
883 | m_currentDir = dir.absPath(); | 872 | m_currentDir = dir.absPath(); |
884 | reparse(); | 873 | reparse(); |
885 | int count = m_location->count(); | 874 | int count = m_location->count(); |
886 | slotInsertLocationPath( m_currentDir, count); | 875 | slotInsertLocationPath( m_currentDir, count); |
887 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | 876 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); |
888 | //this wont work in all instances | 877 | //this wont work in all instances |
889 | // FIXME | 878 | // FIXME |
890 | } | 879 | } |
891 | } | 880 | } |
892 | void OFileSelector::slotHome() | 881 | void OFileSelector::slotHome() |
893 | { | 882 | { |
894 | cd(QDir::homeDirPath() ); | 883 | cd(QDir::homeDirPath() ); |
895 | } | 884 | } |
896 | void OFileSelector::slotDoc() | 885 | void OFileSelector::slotDoc() |
897 | { | 886 | { |
898 | cd(QPEApplication::documentDir() ); | 887 | cd(QPEApplication::documentDir() ); |
899 | } | 888 | } |
900 | void OFileSelector::slotNavigate( ) | 889 | void OFileSelector::slotNavigate( ) |
901 | { | 890 | { |
902 | 891 | ||
903 | } | 892 | } |
904 | // fill the View with life | 893 | // fill the View with life |
905 | void OFileSelector::reparse() | 894 | void OFileSelector::reparse() |
906 | { | 895 | { |
907 | if( m_selector == Normal ) | 896 | if( m_selector == Normal ) |
908 | return; | 897 | return; |
909 | 898 | ||
910 | currentView()->clear(); | 899 | currentView()->clear(); |
911 | 900 | ||
912 | if( m_shChooser) | 901 | if( m_shChooser) |
913 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | 902 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); |
914 | 903 | ||
915 | QString currentMimeType; | 904 | QString currentMimeType; |
916 | 905 | ||
917 | // let's update the mimetype | 906 | // let's update the mimetype |
918 | if( m_autoMime ){ | 907 | if( m_autoMime ){ |
919 | m_mimetypes.clear(); | 908 | m_mimetypes.clear(); |
920 | // ok we can change mimetype so we need to be able to give a selection | 909 | // ok we can change mimetype so we need to be able to give a selection |
921 | if( m_shChooser ) { | 910 | if( m_shChooser ) { |
922 | currentMimeType = m_mimeCheck->currentText(); | 911 | currentMimeType = m_mimeCheck->currentText(); |
923 | m_mimeCheck->clear(); | 912 | m_mimeCheck->clear(); |
924 | 913 | ||
925 | // let's find possible mimetypes | 914 | // let's find possible mimetypes |
926 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); | 915 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); |
927 | 916 | ||
928 | // add them to the chooser | 917 | // add them to the chooser |
929 | updateMimeCheck(); | 918 | updateMimeCheck(); |
930 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 919 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
931 | currentMimeType = m_mimeCheck->currentText(); | 920 | currentMimeType = m_mimeCheck->currentText(); |
932 | } | 921 | } |
933 | }else { // no autoMime | 922 | }else { // no autoMime |
934 | // let the mimetype be set from out side the m_mimeCheck FEATURE | 923 | // let the mimetype be set from out side the m_mimeCheck FEATURE |
935 | 924 | ||
936 | if( m_shChooser ) | 925 | if( m_shChooser ) |
937 | currentMimeType = m_mimeCheck->currentText(); | 926 | currentMimeType = m_mimeCheck->currentText(); |
938 | 927 | ||
939 | } | 928 | } |
940 | // now we got our mimetypes we can add the files | 929 | // now we got our mimetypes we can add the files |
941 | 930 | ||
942 | currentLister()->reparse( m_currentDir ); | 931 | currentLister()->reparse( m_currentDir ); |
943 | /* we're done with adding let's sort */ | 932 | /* we're done with adding let's sort */ |
944 | currentView()->sort(); | 933 | currentView()->sort(); |
945 | 934 | ||
946 | 935 | ||
947 | if( m_shTool ){ | 936 | if( m_shTool ){ |
948 | m_location->insertItem( m_currentDir ); | 937 | m_location->insertItem( m_currentDir ); |
949 | 938 | ||
950 | } | 939 | } |
951 | // reenable painting and updates | 940 | // reenable painting and updates |
952 | } | 941 | } |
953 | 942 | ||
943 | /* | ||
944 | * the factory | ||
945 | */ | ||
946 | void OFileSelector::initFactory() { | ||
947 | m_fileFactory = new OFileFactory(); | ||
948 | m_fileFactory->addLister(tr("Files"), newLocalLister ); | ||
949 | m_fileFactory->addView(tr("List View"), newFileListView ); | ||
950 | /* the factory is just a dummy */ | ||
951 | m_fileFactory->addView(tr("Documents"), newFileListView ); | ||
952 | } | ||
953 | |||
954 | 954 | ||
955 | OFileView* OFileSelector::currentView() { | 955 | OFileView* OFileSelector::currentView() { |
956 | return m_fileView; | 956 | return m_fileView; |
957 | } | 957 | } |
958 | OFileView* OFileSelector::currentView() const{ | 958 | OFileView* OFileSelector::currentView() const{ |
959 | return m_fileView; | 959 | return m_fileView; |
960 | } | 960 | } |
961 | int OFileSelector::filter() { | 961 | int OFileSelector::filter() { |
962 | int filter; | 962 | int filter; |
963 | if ( m_selector == ExtendedAll ) | 963 | if ( m_selector == ExtendedAll ) |
964 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 964 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
965 | else | 965 | else |
966 | filter = QDir::Files | QDir::Dirs | QDir::All ; | 966 | filter = QDir::Files | QDir::Dirs | QDir::All ; |
967 | 967 | ||
968 | return filter; | 968 | return filter; |
969 | } | 969 | } |
970 | int OFileSelector::sorting() { | 970 | int OFileSelector::sorting() { |
971 | int sort; | 971 | int sort; |
972 | 972 | ||
973 | if (m_case ) | 973 | if (m_case ) |
974 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 974 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
975 | else | 975 | else |
976 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 976 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
977 | 977 | ||
978 | return sort; | 978 | return sort; |
979 | } | 979 | } |
980 | void OFileSelector::internFileSelected( const QString& s) { | 980 | void OFileSelector::internFileSelected( const QString& s) { |
981 | emit fileSelected( s ); | 981 | emit fileSelected( s ); |
982 | } | 982 | } |
983 | void OFileSelector::internFileSelected( const DocLnk& d ) { | 983 | void OFileSelector::internFileSelected( const DocLnk& d ) { |
984 | emit fileSelected( d ); | 984 | emit fileSelected( d ); |
985 | } | 985 | } |
986 | void OFileSelector::internContextMenu() { | 986 | void OFileSelector::internContextMenu() { |
987 | emit contextMenu(); | 987 | emit contextMenu(); |
988 | } | 988 | } |
989 | void OFileSelector::internChangedDir( const QString& s) { | 989 | void OFileSelector::internChangedDir( const QString& s) { |
990 | emit dirSelected( s ); | 990 | emit dirSelected( s ); |
991 | cd(s ); | 991 | cd(s ); |
992 | } | 992 | } |
993 | void OFileSelector::internChangedDir( const QDir& s) { | 993 | void OFileSelector::internChangedDir( const QDir& s) { |
994 | emit dirSelected( s ); | 994 | emit dirSelected( s ); |
995 | } | 995 | } |
996 | QPixmap OFileSelector::pixmap( const QString& s ) { | 996 | QPixmap OFileSelector::pixmap( const QString& s ) { |
997 | 997 | ||
998 | return (*m_pixmaps)[s]; | 998 | return (*m_pixmaps)[s]; |
999 | } | 999 | } |
1000 | OLister* OFileSelector::currentLister()const { | 1000 | OLister* OFileSelector::currentLister()const { |
1001 | return m_lister; | 1001 | return m_lister; |
1002 | } | 1002 | } |
1003 | void OFileSelector::initializeOldSelector() { | 1003 | void OFileSelector::initializeOldSelector() { |
1004 | qWarning("initializeOldSelector"); | 1004 | qWarning("initializeOldSelector"); |
1005 | 1005 | ||
1006 | delete m_select; | 1006 | delete m_select; |
1007 | 1007 | ||
1008 | // we need to initialize but keep the selected mimetype | 1008 | // we need to initialize but keep the selected mimetype |
1009 | /* we default not to show close and new buttons */ | 1009 | /* we default not to show close and new buttons */ |
1010 | QString mime = currentMimeType(); | 1010 | QString mime = currentMimeType(); |
1011 | qWarning("MimeType " + mime ); | 1011 | qWarning("MimeType " + mime ); |
1012 | m_select = new FileSelector( mime , | 1012 | m_select = new FileSelector( mime , |
1013 | m_mainView, "fileselector", | 1013 | m_mainView, "fileselector", |
1014 | FALSE, FALSE); | 1014 | FALSE, FALSE); |
1015 | m_select->setCategorySelectVisible( FALSE ); | 1015 | m_select->setCategorySelectVisible( FALSE ); |
1016 | m_select->setTypeComboVisible( FALSE ); | 1016 | m_select->setTypeComboVisible( FALSE ); |
1017 | 1017 | ||
1018 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 1018 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
1019 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 1019 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
1020 | connect(m_select, SIGNAL(closeMe() ), | 1020 | connect(m_select, SIGNAL(closeMe() ), |
1021 | this, SIGNAL(closeMe() ) ); | 1021 | this, SIGNAL(closeMe() ) ); |
1022 | //connect to close me and other signals as well | 1022 | //connect to close me and other signals as well |
1023 | m_mainView->setWidget( m_select ); | 1023 | m_mainView->setWidget( m_select ); |
1024 | } | 1024 | } |
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h index bf9a26b..3e834fb 100644 --- a/libopie/ofileselector/ofileselector.h +++ b/libopie/ofileselector/ofileselector.h | |||
@@ -1,484 +1,488 @@ | |||
1 | /* | 1 | /* |
2 | This is based on code and ideas of | 2 | This is based on code and ideas of |
3 | L. J. Potter ljp@llornkcor.com | 3 | L. J. Potter ljp@llornkcor.com |
4 | Thanks a lot | 4 | Thanks a lot |
5 | 5 | ||
6 | 6 | ||
7 | =. This file is part of the OPIE Project | 7 | =. This file is part of the OPIE Project |
8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This library is free software; you can | 10 | _;:, .> :=|. This library is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This library is distributed in the hope that | 17 | .i_,=:_. -<s. This library is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef opiefileselector_h | 34 | #ifndef opiefileselector_h |
35 | #define opiefileselector_h | 35 | #define opiefileselector_h |
36 | 36 | ||
37 | #include <qpe/fileselector.h> | 37 | #include <qpe/fileselector.h> |
38 | 38 | ||
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qstring.h> | 41 | #include <qstring.h> |
42 | #include <qpixmap.h> | 42 | #include <qpixmap.h> |
43 | #include <qstringlist.h> | 43 | #include <qstringlist.h> |
44 | #include <qmap.h> | 44 | #include <qmap.h> |
45 | #include <qvaluelist.h> | 45 | #include <qvaluelist.h> |
46 | 46 | ||
47 | #include <qpe/applnk.h> | 47 | #include <qpe/applnk.h> |
48 | #include <qlistview.h> | 48 | #include <qlistview.h> |
49 | 49 | ||
50 | /** This is OPIEs FileDialog Widget. You can use it | 50 | /** This is OPIEs FileDialog Widget. You can use it |
51 | * as a dropin replacement of the fileselector and | 51 | * as a dropin replacement of the fileselector and |
52 | * or use any of the new features. | 52 | * or use any of the new features. |
53 | * This is also a complete FileSave and FileLoad widget | 53 | * This is also a complete FileSave and FileLoad widget |
54 | * If you look for a Dialog check OFileDialog | 54 | * If you look for a Dialog check OFileDialog |
55 | * | 55 | * |
56 | */ | 56 | */ |
57 | class DocLnk; | 57 | class DocLnk; |
58 | class QCheckBox; | 58 | class QCheckBox; |
59 | class QComboBox; | 59 | class QComboBox; |
60 | class QPushButton; | 60 | class QPushButton; |
61 | class QGridLayout; | 61 | class QGridLayout; |
62 | class QLineEdit; | 62 | class QLineEdit; |
63 | class QLabel; | 63 | class QLabel; |
64 | class QWidgetStack; | 64 | class QWidgetStack; |
65 | class QHBoxLayout; | 65 | class QHBoxLayout; |
66 | class QVBoxLayout; | 66 | class QVBoxLayout; |
67 | class QPopupMenu; | 67 | class QPopupMenu; |
68 | class QFileInfo; | 68 | class QFileInfo; |
69 | class QHBox; | 69 | class QHBox; |
70 | class OFileView; | 70 | class OFileView; |
71 | class OLister; | 71 | class OLister; |
72 | class OFileSelectorMain; | 72 | class OFileSelectorMain; |
73 | class OFileFactory; | ||
73 | // | 74 | // |
74 | 75 | ||
75 | /* the mimetypes one name and a list of mimetypes */ | 76 | /* the mimetypes one name and a list of mimetypes */ |
76 | typedef QMap< QString, QStringList> MimeTypes; | 77 | typedef QMap< QString, QStringList> MimeTypes; |
77 | 78 | ||
78 | /** | 79 | /** |
79 | * FIXME later | 80 | * FIXME later |
80 | */ | 81 | */ |
81 | struct OPopupMenuFactory { | 82 | struct OPopupMenuFactory { |
82 | OPopupMenuFactory() {} | 83 | OPopupMenuFactory() {} |
83 | 84 | ||
84 | }; | 85 | }; |
85 | 86 | ||
86 | 87 | ||
87 | /** | 88 | /** |
88 | * Opie the default OFileSelector | 89 | * Opie the default OFileSelector |
89 | * It features multiple views. | 90 | * It features multiple views. |
90 | */ | 91 | */ |
91 | class OFileSelector : public QWidget { | 92 | class OFileSelector : public QWidget { |
92 | Q_OBJECT | 93 | Q_OBJECT |
93 | 94 | ||
94 | /* friends are evil but I don't want to make the | 95 | /* friends are evil but I don't want to make the |
95 | * methods public | 96 | * methods public |
96 | */ | 97 | */ |
97 | friend class OLister; | 98 | friend class OLister; |
98 | friend class OFileView; | 99 | friend class OFileView; |
99 | public: | 100 | public: |
100 | /** | 101 | /** |
101 | * The mode of the file selector | 102 | * The mode of the file selector |
102 | * Either open, save, fileselector or dir browsing mode | 103 | * Either open, save, fileselector or dir browsing mode |
103 | * | 104 | * |
104 | */ | 105 | */ |
105 | enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 }; | 106 | enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 }; |
106 | 107 | ||
107 | /** | 108 | /** |
108 | * Selector. Either Normal for the one shipped with | 109 | * Selector. Either Normal for the one shipped with |
109 | * libqpe or Extended. for the Extended | 110 | * libqpe or Extended. for the Extended |
110 | * ExtendedAll also shows 'hidden' files | 111 | * ExtendedAll also shows 'hidden' files |
111 | */ | 112 | */ |
112 | enum Selector{Normal=0, Extended = 1, ExtendedAll = 2}; | 113 | enum Selector{Normal=0, Extended = 1, ExtendedAll = 2}; |
113 | 114 | ||
114 | /** | 115 | /** |
115 | * This is reserved for futrue views | 116 | * This is reserved for futrue views |
116 | */ | 117 | */ |
117 | enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 }; | 118 | enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 }; |
118 | 119 | ||
119 | /** | 120 | /** |
120 | * A c'tor which should be used for advanced mode | 121 | * A c'tor which should be used for advanced mode |
121 | * @param wid the parent | 122 | * @param wid the parent |
122 | * @param mode the Mode of the Selector | 123 | * @param mode the Mode of the Selector |
123 | * @param selector the current View of the Selector | 124 | * @param selector the current View of the Selector |
124 | * @param dirName in which dir to start | 125 | * @param dirName in which dir to start |
125 | * @param fileName a proposed filename | 126 | * @param fileName a proposed filename |
126 | * @param mimetypes A list of mimetypes \ | 127 | * @param mimetypes A list of mimetypes \ |
127 | * QString is for a identifier name like "Text files" | 128 | * QString is for a identifier name like "Text files" |
128 | * the coresponding QStringList is used for the mimetypes | 129 | * the coresponding QStringList is used for the mimetypes |
129 | * if empty it'll fill the list of mimetypes depending | 130 | * if empty it'll fill the list of mimetypes depending |
130 | * on the content of the current directory | 131 | * on the content of the current directory |
131 | */ | 132 | */ |
132 | 133 | ||
133 | OFileSelector(QWidget *wid, int mode, int selector, | 134 | OFileSelector(QWidget *wid, int mode, int selector, |
134 | const QString &dirName, | 135 | const QString &dirName, |
135 | const QString &fileName = QString::null, | 136 | const QString &fileName = QString::null, |
136 | const MimeTypes &mimetypes = MimeTypes() ); | 137 | const MimeTypes &mimetypes = MimeTypes() ); |
137 | 138 | ||
138 | 139 | ||
139 | /** | 140 | /** |
140 | * This is a QPE compatible c'tor | 141 | * This is a QPE compatible c'tor |
141 | */ | 142 | */ |
142 | OFileSelector(const QString &mimeFilter, QWidget *parent, | 143 | OFileSelector(const QString &mimeFilter, QWidget *parent, |
143 | const char *name, bool newVisible = TRUE, | 144 | const char *name, bool newVisible = TRUE, |
144 | bool closeVisible = FALSE ); | 145 | bool closeVisible = FALSE ); |
145 | 146 | ||
146 | ~OFileSelector(); | 147 | ~OFileSelector(); |
147 | 148 | ||
148 | // currently only for the FileSelector Mode | 149 | // currently only for the FileSelector Mode |
149 | /* compability mode but only work | 150 | /* compability mode but only work |
150 | * with FileSelector | 151 | * with FileSelector |
151 | */ | 152 | */ |
152 | void setNewVisible( bool /*b*/ ); | 153 | void setNewVisible( bool /*b*/ ); |
153 | void setCloseVisible(bool /*b*/ ); | 154 | void setCloseVisible(bool /*b*/ ); |
154 | 155 | ||
155 | // end file selector mode | 156 | // end file selector mode |
156 | // deprecated | 157 | // deprecated |
157 | void reread(); | 158 | void reread(); |
158 | // make sure not to leak please | 159 | // make sure not to leak please |
159 | const DocLnk *selected(); | 160 | const DocLnk *selected(); |
160 | // end deprecated | 161 | // end deprecated |
161 | 162 | ||
162 | /** | 163 | /** |
163 | * @return if the toolbar is visible | 164 | * @return if the toolbar is visible |
164 | */ | 165 | */ |
165 | bool isToolbarVisible() const { return m_shTool; }; | 166 | bool isToolbarVisible() const { return m_shTool; }; |
166 | 167 | ||
167 | /** | 168 | /** |
168 | * @return if the permissionBas is visible | 169 | * @return if the permissionBas is visible |
169 | */ | 170 | */ |
170 | bool isPermissionBarVisible() const { return m_shPerm; }; | 171 | bool isPermissionBarVisible() const { return m_shPerm; }; |
171 | 172 | ||
172 | /** | 173 | /** |
173 | * @return if the lineEdit is visible | 174 | * @return if the lineEdit is visible |
174 | */ | 175 | */ |
175 | bool isLineEditVisible()const { return m_shLne; }; | 176 | bool isLineEditVisible()const { return m_shLne; }; |
176 | 177 | ||
177 | /** | 178 | /** |
178 | * if the chooser is visible | 179 | * if the chooser is visible |
179 | */ | 180 | */ |
180 | bool isChooserVisible( )const { return m_shChooser; }; | 181 | bool isChooserVisible( )const { return m_shChooser; }; |
181 | 182 | ||
182 | /** | 183 | /** |
183 | * @return if the yesCancel Bar is visible | 184 | * @return if the yesCancel Bar is visible |
184 | */ | 185 | */ |
185 | bool isYesCancelVisible()const { return m_shYesNo; }; | 186 | bool isYesCancelVisible()const { return m_shYesNo; }; |
186 | 187 | ||
187 | /** | 188 | /** |
188 | * set Yes/Cancel visible | 189 | * set Yes/Cancel visible |
189 | */ | 190 | */ |
190 | void setYesCancelVisible( bool show ); | 191 | void setYesCancelVisible( bool show ); |
191 | 192 | ||
192 | /** | 193 | /** |
193 | * set the toolbar visible | 194 | * set the toolbar visible |
194 | */ | 195 | */ |
195 | void setToolbarVisible( bool show ); | 196 | void setToolbarVisible( bool show ); |
196 | 197 | ||
197 | /** | 198 | /** |
198 | * set the permissionBar to be visible | 199 | * set the permissionBar to be visible |
199 | */ | 200 | */ |
200 | void setPermissionBarVisible( bool show ); | 201 | void setPermissionBarVisible( bool show ); |
201 | 202 | ||
202 | /** | 203 | /** |
203 | * set the lineedit for file entering visible | 204 | * set the lineedit for file entering visible |
204 | */ | 205 | */ |
205 | void setLineEditVisible(bool show) ; | 206 | void setLineEditVisible(bool show) ; |
206 | 207 | ||
207 | /** | 208 | /** |
208 | * set the chooser is visible | 209 | * set the chooser is visible |
209 | */ | 210 | */ |
210 | void setChooserVisible( bool chooser ); | 211 | void setChooserVisible( bool chooser ); |
211 | 212 | ||
212 | /** | 213 | /** |
213 | * The permissionCheckbox | 214 | * The permissionCheckbox |
214 | * | 215 | * |
215 | */ | 216 | */ |
216 | QCheckBox* permissionCheckbox(); | 217 | QCheckBox* permissionCheckbox(); |
217 | 218 | ||
218 | /** | 219 | /** |
219 | * setPermission | 220 | * setPermission |
220 | */ | 221 | */ |
221 | bool setPermission() const; | 222 | bool setPermission() const; |
222 | 223 | ||
223 | /** | 224 | /** |
224 | * set ther permission to bool | 225 | * set ther permission to bool |
225 | */ | 226 | */ |
226 | void setPermissionChecked( bool check ); | 227 | void setPermissionChecked( bool check ); |
227 | 228 | ||
228 | /** | 229 | /** |
229 | * set the Selector Mode | 230 | * set the Selector Mode |
230 | */ | 231 | */ |
231 | void setMode( int ); | 232 | void setMode( int ); |
232 | 233 | ||
233 | /** | 234 | /** |
234 | * whether or not to show dirs | 235 | * whether or not to show dirs |
235 | */ | 236 | */ |
236 | bool showDirs()const { return m_dir; } | 237 | bool showDirs()const { return m_dir; } |
237 | 238 | ||
238 | /** | 239 | /** |
239 | * setShowDirs | 240 | * setShowDirs |
240 | */ | 241 | */ |
241 | void setShowDirs(bool ); | 242 | void setShowDirs(bool ); |
242 | 243 | ||
243 | /** | 244 | /** |
244 | * set CaseSensetive | 245 | * set CaseSensetive |
245 | */ | 246 | */ |
246 | bool isCaseSensetive()const { return m_case; } | 247 | bool isCaseSensetive()const { return m_case; } |
247 | 248 | ||
248 | /** | 249 | /** |
249 | * set if to be case sensetive | 250 | * set if to be case sensetive |
250 | */ | 251 | */ |
251 | void setCaseSensetive(bool caSe ); | 252 | void setCaseSensetive(bool caSe ); |
252 | 253 | ||
253 | /** | 254 | /** |
254 | * @return if to show files | 255 | * @return if to show files |
255 | */ | 256 | */ |
256 | bool showFiles()const { return m_files; }; | 257 | bool showFiles()const { return m_files; }; |
257 | 258 | ||
258 | /** | 259 | /** |
259 | * set if files should be shown | 260 | * set if files should be shown |
260 | */ | 261 | */ |
261 | void setShowFiles(bool ); | 262 | void setShowFiles(bool ); |
262 | 263 | ||
263 | /** | 264 | /** |
264 | * change dir to path | 265 | * change dir to path |
265 | */ | 266 | */ |
266 | bool cd(const QString &path ); | 267 | bool cd(const QString &path ); |
267 | 268 | ||
268 | 269 | ||
269 | /** | 270 | /** |
270 | * return the mode of the fileselector | 271 | * return the mode of the fileselector |
271 | */ | 272 | */ |
272 | int mode()const { return m_mode; }; | 273 | int mode()const { return m_mode; }; |
273 | 274 | ||
274 | /** | 275 | /** |
275 | * return the selector | 276 | * return the selector |
276 | */ | 277 | */ |
277 | int selector()const { return m_selector; }; | 278 | int selector()const { return m_selector; }; |
278 | 279 | ||
279 | /** | 280 | /** |
280 | * set the Selector | 281 | * set the Selector |
281 | */ | 282 | */ |
282 | void setSelector( int ); | 283 | void setSelector( int ); |
283 | 284 | ||
284 | /** | 285 | /** |
285 | * wether or not to show popups | 286 | * wether or not to show popups |
286 | */ | 287 | */ |
287 | bool showPopup()const { return m_showPopup; }; | 288 | bool showPopup()const { return m_showPopup; }; |
288 | 289 | ||
289 | /** | 290 | /** |
290 | * set show popups | 291 | * set show popups |
291 | */ | 292 | */ |
292 | void setShowPopup( bool pop ) { m_showPopup = pop; } | 293 | void setShowPopup( bool pop ) { m_showPopup = pop; } |
293 | 294 | ||
294 | /** | 295 | /** |
295 | * set the popup factory | 296 | * set the popup factory |
296 | */ | 297 | */ |
297 | void setPopupFactory( OPopupMenuFactory * ); | 298 | void setPopupFactory( OPopupMenuFactory * ); |
298 | 299 | ||
299 | /** | 300 | /** |
300 | * reparse the current directory and updates | 301 | * reparse the current directory and updates |
301 | * the views + mimetypes | 302 | * the views + mimetypes |
302 | */ | 303 | */ |
303 | void reparse(); // re reads the dir | 304 | void reparse(); // re reads the dir |
304 | 305 | ||
305 | /** | 306 | /** |
306 | * return the selected name | 307 | * return the selected name |
307 | */ | 308 | */ |
308 | QString selectedName( )const; | 309 | QString selectedName( )const; |
309 | 310 | ||
310 | /** | 311 | /** |
311 | * for multiple selections return multiple | 312 | * for multiple selections return multiple |
312 | * filenames | 313 | * filenames |
313 | */ | 314 | */ |
314 | QStringList selectedNames()const; | 315 | QStringList selectedNames()const; |
315 | 316 | ||
316 | /** | 317 | /** |
317 | * return the complete to the file | 318 | * return the complete to the file |
318 | */ | 319 | */ |
319 | QString selectedPath() const; | 320 | QString selectedPath() const; |
320 | 321 | ||
321 | /** | 322 | /** |
322 | * return the completed paths | 323 | * return the completed paths |
323 | */ | 324 | */ |
324 | QStringList selectedPaths() const; | 325 | QStringList selectedPaths() const; |
325 | 326 | ||
326 | /** | 327 | /** |
327 | * the current directory | 328 | * the current directory |
328 | */ | 329 | */ |
329 | QString directory()const; | 330 | QString directory()const; |
330 | 331 | ||
331 | /** | 332 | /** |
332 | * fileCount | 333 | * fileCount |
333 | */ | 334 | */ |
334 | int fileCount(); | 335 | int fileCount(); |
335 | 336 | ||
336 | DocLnk selectedDocument()const; | 337 | DocLnk selectedDocument()const; |
337 | 338 | ||
338 | QValueList<DocLnk> selectedDocuments()const; | 339 | QValueList<DocLnk> selectedDocuments()const; |
339 | 340 | ||
340 | OFileView* currentView(); | 341 | OFileView* currentView(); |
341 | OFileView* currentView()const; | 342 | OFileView* currentView()const; |
342 | OLister* currentLister()const; | 343 | OLister* currentLister()const; |
344 | OFileFactory* factory(); | ||
343 | int filter(); | 345 | int filter(); |
344 | int sorting(); | 346 | int sorting(); |
345 | QPixmap pixmap( const QString& ); | 347 | QPixmap pixmap( const QString& ); |
346 | /* our tool bar */ | 348 | /* our tool bar */ |
347 | QWidget* toolBar(); | 349 | QWidget* toolBar(); |
348 | 350 | ||
349 | signals: | 351 | signals: |
350 | void fileSelected( const DocLnk & ); | 352 | void fileSelected( const DocLnk & ); |
351 | void fileSelected( const QString & ); | 353 | void fileSelected( const QString & ); |
352 | void dirSelected(const QString &dir ); | 354 | void dirSelected(const QString &dir ); |
353 | void dirSelected( const QDir& ); | 355 | void dirSelected( const QDir& ); |
354 | void closeMe(); | 356 | void closeMe(); |
355 | void ok(); | 357 | void ok(); |
356 | void cancel(); | 358 | void cancel(); |
357 | void contextMenu(); | 359 | void contextMenu(); |
358 | 360 | ||
359 | private slots: | 361 | private slots: |
360 | void slotOk(); | 362 | void slotOk(); |
361 | void slotCancel(); | 363 | void slotCancel(); |
362 | void slotViewCheck(const QString & ); | 364 | void slotViewCheck(const QString & ); |
363 | void slotMimeCheck(const QString & ); | 365 | void slotMimeCheck(const QString & ); |
364 | void slotLocationActivated(const QString & ); | 366 | void slotLocationActivated(const QString & ); |
365 | void slotInsertLocationPath(const QString &, int); | 367 | void slotInsertLocationPath(const QString &, int); |
366 | void locationComboChanged(); | 368 | void locationComboChanged(); |
367 | 369 | ||
368 | private: | 370 | private: |
369 | void init(); | 371 | void init(); |
370 | void updateMimes(); | 372 | void updateMimes(); |
371 | 373 | ||
372 | 374 | ||
373 | private: | 375 | private: |
374 | 376 | ||
377 | OFileFactory* m_fileFactory; | ||
375 | OFileSelectorMain* m_mainView; | 378 | OFileSelectorMain* m_mainView; |
376 | OLister* m_lister; | 379 | OLister* m_lister; |
377 | OFileView* m_fileView; | 380 | OFileView* m_fileView; |
378 | FileSelector* m_select; | 381 | FileSelector* m_select; |
379 | int m_mode, m_selector; | 382 | int m_mode, m_selector; |
380 | QComboBox *m_location, | 383 | QComboBox *m_location, |
381 | *m_mimeCheck, | 384 | *m_mimeCheck, |
382 | *m_viewCheck; | 385 | *m_viewCheck; |
383 | 386 | ||
384 | QPushButton *m_homeButton, | 387 | QPushButton *m_homeButton, |
385 | *m_docButton, | 388 | *m_docButton, |
386 | *m_hideButton, | 389 | *m_hideButton, |
387 | *m_ok, *m_cancel; | 390 | *m_ok, *m_cancel; |
388 | QPushButton *m_reread, | 391 | QPushButton *m_reread, |
389 | *m_up, | 392 | *m_up, |
390 | *m_new, | 393 | *m_new, |
391 | *m_close; | 394 | *m_close; |
392 | QListView *m_View; | 395 | QListView *m_View; |
393 | QCheckBox *m_checkPerm; | 396 | QCheckBox *m_checkPerm; |
394 | QWidget *m_pseudo; | 397 | QWidget *m_pseudo; |
395 | QVBoxLayout *m_pseudoLayout; | 398 | QVBoxLayout *m_pseudoLayout; |
396 | 399 | ||
397 | QString m_currentDir; | 400 | QString m_currentDir; |
398 | QString m_name; | 401 | QString m_name; |
399 | 402 | ||
400 | QMap<QString, QStringList> m_mimetypes; | 403 | QMap<QString, QStringList> m_mimetypes; |
401 | 404 | ||
402 | QVBoxLayout *m_lay; | 405 | QVBoxLayout *m_lay; |
403 | QGridLayout *m_Oselector; | 406 | QGridLayout *m_Oselector; |
404 | 407 | ||
405 | QHBox *m_boxToolbar; | 408 | QHBox *m_boxToolbar; |
406 | QHBox *m_boxOk; | 409 | QHBox *m_boxOk; |
407 | QHBox *m_boxName; | 410 | QHBox *m_boxName; |
408 | QHBox *m_boxView; | 411 | QHBox *m_boxView; |
409 | 412 | ||
410 | 413 | ||
411 | QLineEdit *m_edit; | 414 | QLineEdit *m_edit; |
412 | QLabel *m_fnLabel; | 415 | QLabel *m_fnLabel; |
413 | 416 | ||
414 | bool m_shClose : 1; | 417 | bool m_shClose : 1; |
415 | bool m_shNew : 1; | 418 | bool m_shNew : 1; |
416 | bool m_shTool : 1; | 419 | bool m_shTool : 1; |
417 | bool m_shPerm : 1; | 420 | bool m_shPerm : 1; |
418 | bool m_shLne : 1; | 421 | bool m_shLne : 1; |
419 | bool m_shChooser : 1; | 422 | bool m_shChooser : 1; |
420 | bool m_shYesNo : 1; | 423 | bool m_shYesNo : 1; |
421 | bool m_boCheckPerm : 1; | 424 | bool m_boCheckPerm : 1; |
422 | bool m_autoMime : 1; | 425 | bool m_autoMime : 1; |
423 | bool m_case : 1; | 426 | bool m_case : 1; |
424 | bool m_dir : 1; | 427 | bool m_dir : 1; |
425 | bool m_files : 1; | 428 | bool m_files : 1; |
426 | bool m_showPopup : 1; | 429 | bool m_showPopup : 1; |
427 | bool m_showHidden : 1; | 430 | bool m_showHidden : 1; |
428 | 431 | ||
429 | void initVars(); | 432 | void initVars(); |
430 | 433 | ||
431 | void delItems(); | 434 | void delItems(); |
432 | void initializeName(); | 435 | void initializeName(); |
433 | void initializeYes(); | 436 | void initializeYes(); |
434 | void initializeChooser(); | 437 | void initializeChooser(); |
435 | void initializePerm(); | 438 | void initializePerm(); |
436 | void initPics(); | 439 | void initPics(); |
437 | bool compliesMime(const QString &path, | 440 | bool compliesMime(const QString &path, |
438 | const QString &mime); | 441 | const QString &mime); |
439 | bool compliesMime(const QString& mime ); | 442 | bool compliesMime(const QString& mime ); |
440 | /** | 443 | /** |
441 | * Updates the QComboBox with the current mimetypes | 444 | * Updates the QComboBox with the current mimetypes |
442 | */ | 445 | */ |
443 | void updateMimeCheck(); | 446 | void updateMimeCheck(); |
444 | 447 | ||
445 | void initializeOldSelector(); | 448 | void initializeOldSelector(); |
446 | void initLister(); | 449 | void initLister(); |
447 | void initToolbar(); | 450 | void initToolbar(); |
448 | void initLocations(); | 451 | void initLocations(); |
449 | void initializeView() {}; // FIXME | 452 | void initializeView() {}; // FIXME |
453 | void initFactory(); | ||
450 | /** | 454 | /** |
451 | * Returns the current mimetype | 455 | * Returns the current mimetype |
452 | */ | 456 | */ |
453 | QString currentMimeType()const; | 457 | QString currentMimeType()const; |
454 | class OFileSelectorPrivate; | 458 | class OFileSelectorPrivate; |
455 | OFileSelectorPrivate *d; | 459 | OFileSelectorPrivate *d; |
456 | static QMap<QString,QPixmap> *m_pixmaps; | 460 | static QMap<QString,QPixmap> *m_pixmaps; |
457 | 461 | ||
458 | private slots: | 462 | private slots: |
459 | void slotFileSelected(const QString & ); // not really meant to be a slot | 463 | void slotFileSelected(const QString & ); // not really meant to be a slot |
460 | void slotFileBridgeSelected( const DocLnk & ); | 464 | void slotFileBridgeSelected( const DocLnk & ); |
461 | // listview above | 465 | // listview above |
462 | // popup below | 466 | // popup below |
463 | virtual void slotDelete(); | 467 | virtual void slotDelete(); |
464 | virtual void cdUP(); | 468 | virtual void cdUP(); |
465 | virtual void slotHome(); | 469 | virtual void slotHome(); |
466 | virtual void slotDoc(); | 470 | virtual void slotDoc(); |
467 | virtual void slotNavigate( ); | 471 | virtual void slotNavigate( ); |
468 | 472 | ||
469 | /* for OLister */ | 473 | /* for OLister */ |
470 | private: | 474 | private: |
471 | 475 | ||
472 | /* for OFileView */ | 476 | /* for OFileView */ |
473 | private: | 477 | private: |
474 | void internFileSelected( const QString& ); | 478 | void internFileSelected( const QString& ); |
475 | void internFileSelected( const DocLnk& ); | 479 | void internFileSelected( const DocLnk& ); |
476 | void internContextMenu(); | 480 | void internContextMenu(); |
477 | void internChangedDir( const QString& ); | 481 | void internChangedDir( const QString& ); |
478 | void internChangedDir( const QDir& ) ; | 482 | void internChangedDir( const QDir& ) ; |
479 | 483 | ||
480 | }; | 484 | }; |
481 | 485 | ||
482 | 486 | ||
483 | #endif | 487 | #endif |
484 | 488 | ||