-rw-r--r-- | libopie/ofileselector.cc | 118 | ||||
-rw-r--r-- | libopie/ofileselector.h | 12 |
2 files changed, 125 insertions, 5 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index c9abde1..b911d37 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -2,3 +2,3 @@ | |||
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
@@ -38,3 +38,6 @@ | |||
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qheader.h> | ||
40 | #include <qdir.h> | ||
39 | 41 | ||
42 | #include <qpe/qpeapplication.h> | ||
40 | #include <qpe/fileselector.h> | 43 | #include <qpe/fileselector.h> |
@@ -42,2 +45,3 @@ | |||
42 | #include <qpe/global.h> | 45 | #include <qpe/global.h> |
46 | #include <qpe/mimetype.h> | ||
43 | 47 | ||
@@ -270,5 +274,77 @@ void OFileSelector::updateLay() | |||
270 | } | 274 | } |
275 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | ||
276 | // insert QListViewItems with the right options | ||
277 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | ||
278 | { | ||
279 | if( mime == "All" ) | ||
280 | return true; | ||
281 | MimeType type( path ); | ||
282 | if( type.id() == mime ) | ||
283 | return true; | ||
284 | return false; | ||
285 | } | ||
286 | |||
271 | void OFileSelector::reparse() | 287 | void OFileSelector::reparse() |
272 | { | 288 | { |
289 | if(m_View== 0) | ||
290 | return; | ||
291 | |||
292 | m_View->clear(); | ||
293 | |||
294 | QDir dir( m_currentDir ); | ||
295 | QString currMime =m_mimeCheck->currentText(); | ||
296 | // update the mimetype now | ||
297 | if( m_autoMime ) { | ||
298 | m_mimetypes.clear(); | ||
299 | m_mimeCheck->clear(); | ||
300 | dir.setFilter( QDir::Files | QDir::Readable ); | ||
301 | dir.setSorting(QDir::Size ); | ||
302 | const QFileInfoList *list = dir.entryInfoList(); | ||
303 | QFileInfoListIterator it( *list ); | ||
304 | QFileInfo *fi; | ||
305 | while( (fi=it.current()) ){ | ||
306 | if(fi->extension() == QString::fromLatin1("desktop") ){ | ||
307 | ++it; | ||
308 | continue; | ||
309 | } | ||
310 | MimeType type(fi->filePath() ); | ||
311 | if( !m_mimetypes.contains( type.id() ) ) | ||
312 | m_mimetypes.append( type.id() ); | ||
313 | |||
314 | ++it; | ||
315 | } | ||
316 | m_mimeCheck->insertStringList(m_mimetypes ); | ||
317 | // set it to the current mimetype | ||
318 | }; | ||
319 | dir.setFilter(QDir::All ); | ||
320 | dir.setSorting(QDir::Name | QDir::DirsFirst ); | ||
321 | const QFileInfoList *list = dir.entryInfoList(); | ||
322 | QFileInfoListIterator it( *list ); | ||
323 | QFileInfo *fi; | ||
324 | while( (fi=it.current()) ){ | ||
325 | if(fi->isSymLink() ){ | ||
326 | QString file = fi->readLink(); | ||
327 | for(int i=0; i<=4; i++ ){ // prepend from dos | ||
328 | QFileInfo info( file ); | ||
329 | if( !info.exists() ){ | ||
330 | addSymlink(m_currentDir, info.fileName(), TRUE ); | ||
331 | break; | ||
332 | }else if( info.isDir() ){ | ||
333 | //addDir( ); | ||
334 | }else if( info.isFile() ){ | ||
273 | 335 | ||
336 | }else if( info.isSymLink() ){ | ||
337 | file = info.readLink(); | ||
338 | }else if( i == 4 ){ // just insert it and have the symlink symbol | ||
339 | addSymlink(m_currentDir, info.fileName() ); | ||
340 | } | ||
341 | } | ||
342 | }else if( fi->isDir() ){ | ||
343 | |||
344 | }else if( fi->isFile() ) { // file ? | ||
345 | |||
346 | |||
347 | } | ||
348 | ++it; | ||
349 | } | ||
274 | } | 350 | } |
@@ -367,2 +443,5 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
367 | // check if we're the current widget and return | 443 | // check if we're the current widget and return |
444 | if( m_View != 0) // delete 0 shouldn't crash but it did :( | ||
445 | delete m_View; | ||
446 | m_View = 0; | ||
368 | delete m_select; | 447 | delete m_select; |
@@ -375,3 +454,2 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
375 | }else if(view == QString::fromLatin1("Files") ){ | 454 | }else if(view == QString::fromLatin1("Files") ){ |
376 | if( m_select != 0 ){ | ||
377 | // remove from the stack | 455 | // remove from the stack |
@@ -379,7 +457,9 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
379 | m_select = 0; | 457 | m_select = 0; |
458 | delete m_View; | ||
459 | m_View = 0; | ||
380 | m_selector = EXTENDED; | 460 | m_selector = EXTENDED; |
381 | // create the ListView or IconView | 461 | // create the ListView or IconView |
462 | initializeListView(); | ||
382 | 463 | ||
383 | reparse(); | 464 | reparse(); |
384 | } | ||
385 | }else if(view == QString::fromLatin1("All Files") ) { | 465 | }else if(view == QString::fromLatin1("All Files") ) { |
@@ -388,4 +468,6 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
388 | m_select = 0; | 468 | m_select = 0; |
469 | delete m_View; | ||
470 | m_View = 0; | ||
389 | m_selector = EXTENDED_ALL; | 471 | m_selector = EXTENDED_ALL; |
390 | 472 | initializeListView(); | |
391 | reparse(); | 473 | reparse(); |
@@ -409,3 +491,3 @@ void OFileSelector::updateMimes() // lets check which mode is active | |||
409 | }else{ | 491 | }else{ |
410 | 492 | // should be allreday updatet | |
411 | 493 | ||
@@ -413 +495,27 @@ void OFileSelector::updateMimes() // lets check which mode is active | |||
413 | }; | 495 | }; |
496 | void OFileSelector::initializeListView() | ||
497 | { | ||
498 | m_View = new QListView(m_stack, "Extended view" ); | ||
499 | m_stack->addWidget( m_View, EXTENDED ); | ||
500 | m_stack->raiseWidget( EXTENDED ); | ||
501 | QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); | ||
502 | // set up the stuff | ||
503 | // Pixmap Name Date Size mime | ||
504 | //(m_View->header() )->hide(); | ||
505 | //m_View->setRootIsDecorated(false); | ||
506 | m_View->addColumn(" "); | ||
507 | m_View->addColumn(tr("Name") ); | ||
508 | m_View->addColumn(tr("Size") ); | ||
509 | m_View->addColumn(tr("Date"), 60 ); | ||
510 | m_View->addColumn(tr("Mime Type") ); | ||
511 | QHeader *header = m_View->header(); | ||
512 | header->hide(); | ||
513 | }; | ||
514 | |||
515 | |||
516 | |||
517 | |||
518 | |||
519 | |||
520 | |||
521 | |||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 757a960..a90219f 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -60,2 +60,4 @@ class QHBoxLayout; | |||
60 | class QVBoxLayout; | 60 | class QVBoxLayout; |
61 | class QPopupMenu; | ||
62 | |||
61 | 63 | ||
@@ -104,2 +106,4 @@ class OFileSelector : public QWidget { | |||
104 | void setMode( int ); | 106 | void setMode( int ); |
107 | void setShowDirs(bool dir ) { }; | ||
108 | bool showDirs() {bool turn; return turn; } | ||
105 | int mode()const { return m_mode; }; | 109 | int mode()const { return m_mode; }; |
@@ -108,2 +112,4 @@ class OFileSelector : public QWidget { | |||
108 | QString selectedName( ); | 112 | QString selectedName( ); |
113 | void setPopupMenu( const QPopupMenu * ); | ||
114 | |||
109 | const DocLnk* selectedDocument()const; | 115 | const DocLnk* selectedDocument()const; |
@@ -164,2 +170,6 @@ class OFileSelector : public QWidget { | |||
164 | private: | 170 | private: |
171 | // implementation todo | ||
172 | virtual void addFile(const QString &path, const QString &name, bool symlink = FALSE ) {}; | ||
173 | virtual void addDir( const QString &path, const QString &dir , bool symlink = FALSE ){}; | ||
174 | virtual void addSymlink(const QString &path, const QString &name, bool broken = FALSE ){}; | ||
165 | void delItems(); | 175 | void delItems(); |
@@ -168,2 +178,4 @@ class OFileSelector : public QWidget { | |||
168 | void initializeChooser(); | 178 | void initializeChooser(); |
179 | void initializeListView(); | ||
180 | bool compliesMime(const QString &path, const QString &mime); | ||
169 | 181 | ||