-rw-r--r-- | libopie/ofileselector.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 824acf2..3c3a6c4 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -309,51 +309,55 @@ QString text; | |||
309 | break; | 309 | break; |
310 | case EXTENDED_ALL: | 310 | case EXTENDED_ALL: |
311 | text = tr("All Files"); | 311 | text = tr("All Files"); |
312 | break; | 312 | break; |
313 | } | 313 | } |
314 | slotViewCheck( text ); | 314 | slotViewCheck( text ); |
315 | } | 315 | } |
316 | 316 | ||
317 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) | 317 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) |
318 | { | 318 | { |
319 | m_custom = popup; | 319 | m_custom = popup; |
320 | m_showPopup = true; | 320 | m_showPopup = true; |
321 | } | 321 | } |
322 | 322 | ||
323 | //void OFileSelector::updateL | 323 | //void OFileSelector::updateL |
324 | 324 | ||
325 | QString OFileSelector::selectedName() const | 325 | QString OFileSelector::selectedName() const |
326 | { | 326 | { |
327 | QString name; | 327 | QString name; |
328 | if( m_selector == NORMAL ){ | 328 | if( m_selector == NORMAL ){ |
329 | const DocLnk *lnk = m_select->selected(); | 329 | const DocLnk *lnk = m_select->selected(); |
330 | name = lnk->file(); | 330 | name = lnk->file(); |
331 | delete lnk; | 331 | delete lnk; |
332 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 332 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
333 | QListViewItem *item = m_View->currentItem(); | 333 | if ( m_shLne ) { |
334 | if( item != 0 ) | 334 | name = m_currentDir + "/" +m_edit->text(); |
335 | name = m_currentDir + "/" + item->text( 1 ); | 335 | }else{ |
336 | QListViewItem *item = m_View->currentItem(); | ||
337 | if( item != 0 ) | ||
338 | name = m_currentDir + "/" + item->text( 1 ); | ||
339 | } | ||
336 | }else { // installed view | 340 | }else { // installed view |
337 | ; | 341 | ; |
338 | } | 342 | } |
339 | return name; | 343 | return name; |
340 | } | 344 | } |
341 | QStringList OFileSelector::selectedNames()const | 345 | QStringList OFileSelector::selectedNames()const |
342 | { | 346 | { |
343 | QStringList list; | 347 | QStringList list; |
344 | if( m_selector == NORMAL ){ | 348 | if( m_selector == NORMAL ){ |
345 | list << selectedName(); | 349 | list << selectedName(); |
346 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 350 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
347 | list << selectedName(); // FIXME implement multiple Selections | 351 | list << selectedName(); // FIXME implement multiple Selections |
348 | } | 352 | } |
349 | return list; | 353 | return list; |
350 | } | 354 | } |
351 | /** If mode is set to the Dir selection this will return the selected path. | 355 | /** If mode is set to the Dir selection this will return the selected path. |
352 | * | 356 | * |
353 | * | 357 | * |
354 | */ | 358 | */ |
355 | QString OFileSelector::selectedPath()const | 359 | QString OFileSelector::selectedPath()const |
356 | { | 360 | { |
357 | QString path; | 361 | QString path; |
358 | if( m_selector == NORMAL ){ | 362 | if( m_selector == NORMAL ){ |
359 | path = QPEApplication::documentDir(); | 363 | path = QPEApplication::documentDir(); |
@@ -500,75 +504,96 @@ void OFileSelector::slotMimeCheck(const QString &mime) | |||
500 | m_stack, "fileselector", | 504 | m_stack, "fileselector", |
501 | m_shNew, m_shClose); | 505 | m_shNew, m_shClose); |
502 | 506 | ||
503 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 507 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
504 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 508 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
505 | connect(m_select, SIGNAL(closeMe() ), | 509 | connect(m_select, SIGNAL(closeMe() ), |
506 | this, SIGNAL(closeMe() ) ); | 510 | this, SIGNAL(closeMe() ) ); |
507 | //connect to close me and other signals as well | 511 | //connect to close me and other signals as well |
508 | m_stack->addWidget( m_select, NORMAL ); | 512 | m_stack->addWidget( m_select, NORMAL ); |
509 | m_stack->raiseWidget( NORMAL ); | 513 | m_stack->raiseWidget( NORMAL ); |
510 | updateMimes(); | 514 | updateMimes(); |
511 | updateMimeCheck(); | 515 | updateMimeCheck(); |
512 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 516 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
513 | //} | 517 | //} |
514 | }else{ // others | 518 | }else{ // others |
515 | qWarning("Mime %s", mime.latin1() ); | 519 | qWarning("Mime %s", mime.latin1() ); |
516 | if(m_shChooser ){ | 520 | if(m_shChooser ){ |
517 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 521 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
518 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 522 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
519 | } | 523 | } |
520 | reparse(); | 524 | reparse(); |
521 | } | 525 | } |
522 | 526 | ||
523 | } | 527 | } |
528 | /* | ||
529 | * Ok if a non dir gets inserted into this combobox | ||
530 | * we need to change it | ||
531 | * QFileInfo and dirPath will give us the right Dir | ||
532 | */ | ||
524 | void OFileSelector::slotLocationActivated(const QString &file) | 533 | void OFileSelector::slotLocationActivated(const QString &file) |
525 | { | 534 | { |
526 | cd(file.left(file.find("<-",0,TRUE))); | 535 | qWarning("slotLocationActivated"); |
527 | reparse(); | 536 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
537 | QFileInfo info( name ); | ||
538 | if ( info.isFile() ) | ||
539 | cd(info.dirPath( TRUE ) ); //absolute | ||
540 | else | ||
541 | cd(name ); | ||
542 | reparse(); | ||
528 | } | 543 | } |
529 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 544 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
530 | { | 545 | { |
531 | QStringList pathList; | 546 | QStringList pathList; |
532 | bool underDog = FALSE; | 547 | bool underDog = FALSE; |
533 | for(int i=0;i<count;i++) { | 548 | for(int i=0;i<count;i++) { |
534 | pathList << m_location->text(i); | 549 | pathList << m_location->text(i); |
535 | if( m_location->text(i) == currentPath) | 550 | if( m_location->text(i) == currentPath) |
536 | underDog = TRUE; | 551 | underDog = TRUE; |
537 | } | 552 | } |
538 | if( !underDog) { | 553 | if( !underDog) { |
539 | m_location->clear(); | 554 | m_location->clear(); |
540 | if( currentPath.left(2)=="//") | 555 | if( currentPath.left(2)=="//") |
541 | pathList.append( currentPath.right(currentPath.length()-1) ); | 556 | pathList.append( currentPath.right(currentPath.length()-1) ); |
542 | else | 557 | else |
543 | pathList.append( currentPath ); | 558 | pathList.append( currentPath ); |
544 | m_location->insertStringList( pathList,-1); | 559 | m_location->insertStringList( pathList,-1); |
545 | } | 560 | } |
546 | } | 561 | } |
562 | /* | ||
563 | * Do not crash anymore | ||
564 | * don't try to change dir to a file | ||
565 | */ | ||
547 | void OFileSelector::locationComboChanged() | 566 | void OFileSelector::locationComboChanged() |
548 | { | 567 | { |
549 | cd( m_location->lineEdit()->text()); | 568 | QFileInfo info( m_location->lineEdit()->text() ); |
550 | reparse(); | 569 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
570 | if (info.isFile() ) | ||
571 | cd(info.dirPath(TRUE) ); //absolute path | ||
572 | else | ||
573 | cd( m_location->lineEdit()->text() ); | ||
574 | |||
575 | reparse(); | ||
551 | } | 576 | } |
552 | void OFileSelector::init() | 577 | void OFileSelector::init() |
553 | { | 578 | { |
554 | m_lay = new QVBoxLayout( this ); | 579 | m_lay = new QVBoxLayout( this ); |
555 | m_lay->setSpacing(0 ); | 580 | m_lay->setSpacing(0 ); |
556 | 581 | ||
557 | m_stack = new QWidgetStack( this ); | 582 | m_stack = new QWidgetStack( this ); |
558 | if( m_selector == NORMAL ){ | 583 | if( m_selector == NORMAL ){ |
559 | QString mime; | 584 | QString mime; |
560 | if (!m_autoMime) { | 585 | if (!m_autoMime) { |
561 | if (!m_mimetypes.isEmpty() ) { | 586 | if (!m_mimetypes.isEmpty() ) { |
562 | QMap<QString, QStringList>::Iterator it; | 587 | QMap<QString, QStringList>::Iterator it; |
563 | it = m_mimetypes.begin(); // cause we're in the init | 588 | it = m_mimetypes.begin(); // cause we're in the init |
564 | mime = it.data().join(";"); | 589 | mime = it.data().join(";"); |
565 | } | 590 | } |
566 | } | 591 | } |
567 | m_select = new FileSelector(mime, | 592 | m_select = new FileSelector(mime, |
568 | m_stack, "fileselector", | 593 | m_stack, "fileselector", |
569 | m_shNew, m_shClose); | 594 | m_shNew, m_shClose); |
570 | 595 | ||
571 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 596 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
572 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 597 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
573 | connect(m_select, SIGNAL(closeMe() ), | 598 | connect(m_select, SIGNAL(closeMe() ), |
574 | this, SIGNAL( closeMe() ) ); | 599 | this, SIGNAL( closeMe() ) ); |