-rw-r--r-- | libopie/ofileselector.cc | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 53616f7..c9abde1 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -40,2 +40,4 @@ | |||
40 | #include <qpe/fileselector.h> | 40 | #include <qpe/fileselector.h> |
41 | #include <qpe/applnk.h> | ||
42 | #include <qpe/global.h> | ||
41 | 43 | ||
@@ -51,2 +53,5 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
51 | m_mimetypes = mimetypes; | 53 | m_mimetypes = mimetypes; |
54 | if( mimetypes.isEmpty() ) | ||
55 | m_autoMime = true; | ||
56 | |||
52 | m_mode = mode; | 57 | m_mode = mode; |
@@ -84,2 +89,3 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
84 | init(); | 89 | init(); |
90 | m_edit->setText( fileName ); | ||
85 | } | 91 | } |
@@ -328,8 +334,28 @@ void OFileSelector::initializeChooser() | |||
328 | 334 | ||
335 | if(!m_autoMime ) | ||
336 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); | ||
337 | else{ // check | ||
338 | updateMimes(); | ||
339 | m_mimeCheck->insertStringList( m_mimetypes ); | ||
340 | } | ||
341 | |||
329 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), | 342 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), |
330 | this, SLOT(slotViewCheck(const QString & ) ) ); | 343 | this, SLOT(slotViewCheck(const QString & ) ) ); |
331 | 344 | ||
345 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), | ||
346 | this, SLOT(slotMimeCheck(const QString & ) ) ); | ||
332 | } | 347 | } |
348 | void OFileSelector::slotMimeCheck(const QString &view ){ | ||
349 | if(m_selector == NORMAL ){ | ||
350 | delete m_select; | ||
351 | m_select = new FileSelector(view == "All" ? QString::null : view | ||
352 | , m_stack, "fileselector", FALSE, FALSE ); | ||
353 | m_stack->addWidget( m_select, NORMAL ); | ||
354 | m_stack->raiseWidget( NORMAL ); | ||
355 | }else{ | ||
333 | 356 | ||
334 | 357 | ||
358 | } | ||
359 | } | ||
360 | |||
335 | void OFileSelector::slotViewCheck(const QString &view ){ | 361 | void OFileSelector::slotViewCheck(const QString &view ){ |
@@ -337,3 +363,3 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
337 | // if the current view is the one | 363 | // if the current view is the one |
338 | 364 | QString currMime = m_mimeCheck->currentText(); | |
339 | if( view == QString::fromLatin1("Documents") ){ | 365 | if( view == QString::fromLatin1("Documents") ){ |
@@ -341,2 +367,9 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
341 | // check if we're the current widget and return | 367 | // check if we're the current widget and return |
368 | delete m_select; | ||
369 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime, | ||
370 | m_stack,"fileselector", FALSE, FALSE ); | ||
371 | m_stack->addWidget( m_select, NORMAL ); | ||
372 | m_stack->raiseWidget( NORMAL ); | ||
373 | m_selector = NORMAL; | ||
374 | |||
342 | }else if(view == QString::fromLatin1("Files") ){ | 375 | }else if(view == QString::fromLatin1("Files") ){ |
@@ -346,2 +379,6 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
346 | m_select = 0; | 379 | m_select = 0; |
380 | m_selector = EXTENDED; | ||
381 | // create the ListView or IconView | ||
382 | |||
383 | reparse(); | ||
347 | } | 384 | } |
@@ -351,3 +388,26 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
351 | m_select = 0; | 388 | m_select = 0; |
389 | m_selector = EXTENDED_ALL; | ||
390 | |||
391 | reparse(); | ||
352 | }; | 392 | }; |
353 | }; | 393 | }; |
394 | |||
395 | |||
396 | void OFileSelector::updateMimes() // lets check which mode is active | ||
397 | // check the current dir for items then | ||
398 | { | ||
399 | m_mimetypes.clear(); | ||
400 | m_mimetypes.append("All" ); | ||
401 | if( m_selector == NORMAL ){ | ||
402 | DocLnkSet set; | ||
403 | Global::findDocuments(&set, QString::null ); | ||
404 | QListIterator<DocLnk> dit( set.children() ); | ||
405 | for ( ; dit.current(); ++dit ) { | ||
406 | if( !m_mimetypes.contains((*dit)->type() ) ) | ||
407 | m_mimetypes.append( (*dit)->type() ); | ||
408 | } | ||
409 | }else{ | ||
410 | |||
411 | |||
412 | } | ||
413 | }; | ||