author | zecke <zecke> | 2004-09-23 13:53:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-23 13:53:49 (UTC) |
commit | b31b9fd0b3ef2cddef4343e565fe0330c076da57 (patch) (unidiff) | |
tree | d41af1ba728077bd1546994d629dd32ddd51f7dc | |
parent | 763823cd6707432c515dd0eb2f8c699f4668df93 (diff) | |
download | opie-b31b9fd0b3ef2cddef4343e565fe0330c076da57.zip opie-b31b9fd0b3ef2cddef4343e565fe0330c076da57.tar.gz opie-b31b9fd0b3ef2cddef4343e565fe0330c076da57.tar.bz2 |
-Filter de_DE@euro to de_DE@euro, de_DE, de
-Load the right translation file at the right location
-rw-r--r-- | libopie2/opiecore/opluginloader.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp index b8b6b79..ec19fa0 100644 --- a/libopie2/opiecore/opluginloader.cpp +++ b/libopie2/opiecore/opluginloader.cpp | |||
@@ -393,97 +393,97 @@ OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const { | |||
393 | * @param sorted If the list should be sorted | 393 | * @param sorted If the list should be sorted |
394 | */ | 394 | */ |
395 | OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { | 395 | OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { |
396 | OPluginItem::List lst; | 396 | OPluginItem::List lst; |
397 | for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) | 397 | for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) |
398 | lst += plugins( *it, sorted, true ); | 398 | lst += plugins( *it, sorted, true ); |
399 | 399 | ||
400 | if ( sorted ) | 400 | if ( sorted ) |
401 | qHeapSort( lst ); | 401 | qHeapSort( lst ); |
402 | return lst; | 402 | return lst; |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | /** | 406 | /** |
407 | * \brief Load a OPluginItem for the specified interface | 407 | * \brief Load a OPluginItem for the specified interface |
408 | * This will open the resource of the OPluginItem::path() and then will query | 408 | * This will open the resource of the OPluginItem::path() and then will query |
409 | * if the Interface specified in the uuid is available and then will manage the | 409 | * if the Interface specified in the uuid is available and then will manage the |
410 | * resource and Interface. | 410 | * resource and Interface. |
411 | * | 411 | * |
412 | * @param item The OPluginItem that should be loaded | 412 | * @param item The OPluginItem that should be loaded |
413 | * @param uuid The Interface to query for | 413 | * @param uuid The Interface to query for |
414 | * | 414 | * |
415 | * @return Either 0 in case of failure or the Plugin as QUnknownInterface* | 415 | * @return Either 0 in case of failure or the Plugin as QUnknownInterface* |
416 | */ | 416 | */ |
417 | QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) { | 417 | QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) { |
418 | /* | 418 | /* |
419 | * Check if there could be a library | 419 | * Check if there could be a library |
420 | */ | 420 | */ |
421 | QString pa = item.path(); | 421 | QString pa = item.path(); |
422 | if ( pa.isEmpty() ) | 422 | if ( pa.isEmpty() ) |
423 | return 0l; | 423 | return 0l; |
424 | 424 | ||
425 | /* | 425 | /* |
426 | * See if we get a library | 426 | * See if we get a library |
427 | * return if we've none | 427 | * return if we've none |
428 | */ | 428 | */ |
429 | setSafeMode( pa, true ); | 429 | setSafeMode( pa, true ); |
430 | QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa ); | 430 | QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa ); |
431 | if ( !lib ) { | 431 | if ( !lib ) { |
432 | setSafeMode(); | 432 | setSafeMode(); |
433 | return 0l; | 433 | return 0l; |
434 | } | 434 | } |
435 | 435 | ||
436 | /** | 436 | /** |
437 | * try to load the plugin and just in case initialize the pointer to a pointer again | 437 | * try to load the plugin and just in case initialize the pointer to a pointer again |
438 | */ | 438 | */ |
439 | QUnknownInterface* iface=0; | 439 | QUnknownInterface* iface=0; |
440 | if ( lib->queryInterface( uuid, &iface ) == QS_OK ) { | 440 | if ( lib->queryInterface( uuid, &iface ) == QS_OK ) { |
441 | installTranslators(pa.left( pa.find("."))); | 441 | installTranslators( item.name() ); |
442 | m_library.insert( iface, lib ); | 442 | m_library.insert( iface, lib ); |
443 | }else | 443 | }else |
444 | iface = 0; | 444 | iface = 0; |
445 | 445 | ||
446 | setSafeMode(); | 446 | setSafeMode(); |
447 | 447 | ||
448 | return iface; | 448 | return iface; |
449 | } | 449 | } |
450 | 450 | ||
451 | /** | 451 | /** |
452 | * @internal and reads in the safe mode | 452 | * @internal and reads in the safe mode |
453 | */ | 453 | */ |
454 | void OGenericPluginLoader::readConfig() { | 454 | void OGenericPluginLoader::readConfig() { |
455 | 455 | ||
456 | 456 | ||
457 | /* read the config for SafeMode */ | 457 | /* read the config for SafeMode */ |
458 | OConfig conf( m_dir + "-odpplugins" ); | 458 | OConfig conf( m_dir + "-odpplugins" ); |
459 | conf.setGroup( "General" ); | 459 | conf.setGroup( "General" ); |
460 | m_isSafeMode = conf.readBoolEntry( "SafeMode", false ); | 460 | m_isSafeMode = conf.readBoolEntry( "SafeMode", false ); |
461 | } | 461 | } |
462 | 462 | ||
463 | /** | 463 | /** |
464 | * @internal Enter or leave SafeMode | 464 | * @internal Enter or leave SafeMode |
465 | */ | 465 | */ |
466 | void OGenericPluginLoader::setSafeMode(const QString& str, bool b) { | 466 | void OGenericPluginLoader::setSafeMode(const QString& str, bool b) { |
467 | OConfig conf( m_dir + "-odpplugins" ); | 467 | OConfig conf( m_dir + "-odpplugins" ); |
468 | conf.setGroup( "General" ); | 468 | conf.setGroup( "General" ); |
469 | conf.writeEntry( "SafeMode", b ); | 469 | conf.writeEntry( "SafeMode", b ); |
470 | conf.writeEntry( "CrashedPlugin", str ); | 470 | conf.writeEntry( "CrashedPlugin", str ); |
471 | } | 471 | } |
472 | 472 | ||
473 | /** | 473 | /** |
474 | * @internal | 474 | * @internal |
475 | * | 475 | * |
476 | * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype | 476 | * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype |
477 | * is used as plugin dir | 477 | * is used as plugin dir |
478 | */ | 478 | */ |
479 | void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) { | 479 | void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) { |
480 | m_plugDirs = lst; | 480 | m_plugDirs = lst; |
481 | } | 481 | } |
482 | 482 | ||
483 | /** | 483 | /** |
484 | * | 484 | * |
485 | * @internal | 485 | * @internal |
486 | * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs | 486 | * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs |
487 | */ | 487 | */ |
488 | void OGenericPluginLoader::setPluginDir( const QString& str) { | 488 | void OGenericPluginLoader::setPluginDir( const QString& str) { |
489 | m_plugDirs.clear(); | 489 | m_plugDirs.clear(); |
@@ -558,132 +558,138 @@ OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorte | |||
558 | 558 | ||
559 | if ( sorted ) { | 559 | if ( sorted ) { |
560 | QStringList pos = cfg.readListEntry( "Positions", '.' ); | 560 | QStringList pos = cfg.readListEntry( "Positions", '.' ); |
561 | QStringList::Iterator it = pos.begin(); | 561 | QStringList::Iterator it = pos.begin(); |
562 | QString tmp; int i; | 562 | QString tmp; int i; |
563 | while ( it != pos.end() ) { | 563 | while ( it != pos.end() ) { |
564 | tmp = *it++; i = (*it++).toInt(); | 564 | tmp = *it++; i = (*it++).toInt(); |
565 | positionMap.insert( tmp, i ); | 565 | positionMap.insert( tmp, i ); |
566 | } | 566 | } |
567 | 567 | ||
568 | } | 568 | } |
569 | 569 | ||
570 | 570 | ||
571 | 571 | ||
572 | 572 | ||
573 | QStringList list = dir.entryList(); | 573 | QStringList list = dir.entryList(); |
574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
575 | QString str = unlibify( *it ); | 575 | QString str = unlibify( *it ); |
576 | OPluginItem item( str, _dir + "/" + *it ); | 576 | OPluginItem item( str, _dir + "/" + *it ); |
577 | 577 | ||
578 | bool ex = excludedMap.contains( str ); | 578 | bool ex = excludedMap.contains( str ); |
579 | /* | 579 | /* |
580 | * if disabled but we should show all mark it as disabled | 580 | * if disabled but we should show all mark it as disabled |
581 | * else continue because we don't want to add the item | 581 | * else continue because we don't want to add the item |
582 | * else if sorted we assign the right position | 582 | * else if sorted we assign the right position |
583 | */ | 583 | */ |
584 | if ( ex && !disabled) | 584 | if ( ex && !disabled) |
585 | item.setEnabled( false ); | 585 | item.setEnabled( false ); |
586 | else if ( ex && disabled ) | 586 | else if ( ex && disabled ) |
587 | continue; | 587 | continue; |
588 | else if ( sorted ) | 588 | else if ( sorted ) |
589 | item.setPosition( positionMap[str] ); | 589 | item.setPosition( positionMap[str] ); |
590 | 590 | ||
591 | 591 | ||
592 | lst.append( item ); | 592 | lst.append( item ); |
593 | } | 593 | } |
594 | 594 | ||
595 | return lst; | 595 | return lst; |
596 | } | 596 | } |
597 | 597 | ||
598 | /** | 598 | /** |
599 | * @internal generate a list of languages from $LANG | 599 | * @internal generate a list of languages from $LANG |
600 | */ | 600 | */ |
601 | QStringList OGenericPluginLoader::languageList() { | 601 | QStringList OGenericPluginLoader::languageList() { |
602 | if ( m_languages.isEmpty() ) { | 602 | if ( m_languages.isEmpty() ) { |
603 | /* | 603 | /* |
604 | * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be | 604 | * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be |
605 | * to our list of languages. | 605 | * to our list of languages. |
606 | * Also for de_DE@euro we will add de_DE@eurp, de_DE, de | ||
607 | * to our list of languages | ||
606 | */ | 608 | */ |
607 | QString str = ::getenv( "LANG" ); | 609 | QString str = ::getenv( "LANG" ); |
608 | m_languages += str; | 610 | m_languages += str; |
609 | int pos = str.find( '.' ); | 611 | int pos = str.find( '@' ); |
610 | 612 | if( pos > 0 ) | |
613 | m_languages += str.left( pos ); | ||
614 | |||
615 | |||
616 | pos = str.find( '.' ); | ||
611 | if ( pos > 0 ) | 617 | if ( pos > 0 ) |
612 | m_languages += str.left( pos ); | 618 | m_languages += str.left( pos ); |
613 | 619 | ||
614 | int n_pos = str.find( '_' ); | 620 | int n_pos = str.find( '_' ); |
615 | if ( pos > 0 && n_pos >= pos ) | 621 | if ( n_pos > 0 ) |
616 | m_languages += str.left( n_pos ); | 622 | m_languages += str.left( n_pos ); |
617 | 623 | ||
618 | } | 624 | } |
619 | return m_languages; | 625 | return m_languages; |
620 | } | 626 | } |
621 | 627 | ||
622 | /** | 628 | /** |
623 | * @internal | 629 | * @internal |
624 | * Tries to install languages using the languageList for the type | 630 | * Tries to install languages using the languageList for the type |
625 | */ | 631 | */ |
626 | void OGenericPluginLoader::installTranslators(const QString& type) { | 632 | void OGenericPluginLoader::installTranslators(const QString& type) { |
627 | QStringList lst = languageList(); | 633 | QStringList lst = languageList(); |
628 | 634 | ||
629 | /* | 635 | /* |
630 | * for each language and maybe later for each language dir... | 636 | * for each language and maybe later for each language dir... |
631 | * try to load a Translator | 637 | * try to load a Translator |
632 | */ | 638 | */ |
633 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 639 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
634 | QTranslator* trans = new QTranslator( qApp ); | 640 | QTranslator* trans = new QTranslator( qApp ); |
635 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/" + type + ".qm" ; | 641 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/lib" + type + ".qm" ; |
636 | 642 | ||
637 | /* | 643 | /* |
638 | * If loaded then install else clean up and don't leak | 644 | * If loaded then install else clean up and don't leak |
639 | */ | 645 | */ |
640 | if ( trans->load( tfn ) ) | 646 | if ( trans->load( tfn ) ) |
641 | qApp->installTranslator( trans ); | 647 | qApp->installTranslator( trans ); |
642 | else | 648 | else |
643 | delete trans; | 649 | delete trans; |
644 | } | 650 | } |
645 | } | 651 | } |
646 | 652 | ||
647 | /** | 653 | /** |
648 | * \brief Simple c'tor. | 654 | * \brief Simple c'tor. |
649 | * | 655 | * |
650 | * Simple C'tor same as the one of the base class. Additional this | 656 | * Simple C'tor same as the one of the base class. Additional this |
651 | * class can cast for you if you nee it. | 657 | * class can cast for you if you nee it. |
652 | * | 658 | * |
653 | * | 659 | * |
654 | * @param name The name of your plugin class | 660 | * @param name The name of your plugin class |
655 | * @param sorted If plugins are sorted | 661 | * @param sorted If plugins are sorted |
656 | * | 662 | * |
657 | * @see OGenericPluginLoader | 663 | * @see OGenericPluginLoader |
658 | */ | 664 | */ |
659 | OPluginLoader::OPluginLoader( const QString& name, bool sorted ) | 665 | OPluginLoader::OPluginLoader( const QString& name, bool sorted ) |
660 | : OGenericPluginLoader( name, sorted ) | 666 | : OGenericPluginLoader( name, sorted ) |
661 | { | 667 | { |
662 | } | 668 | } |
663 | 669 | ||
664 | /** | 670 | /** |
665 | * d'tor | 671 | * d'tor |
666 | * @see OGenericPluginLoader::~OGenericPluginLoader | 672 | * @see OGenericPluginLoader::~OGenericPluginLoader |
667 | */ | 673 | */ |
668 | OPluginLoader::~OPluginLoader() { | 674 | OPluginLoader::~OPluginLoader() { |
669 | } | 675 | } |
670 | 676 | ||
671 | /** | 677 | /** |
672 | * \brief C'Tor using a OGenericPluginLoader | 678 | * \brief C'Tor using a OGenericPluginLoader |
673 | * The C'tor. Pass your OGenericPluginLoader to manage | 679 | * The C'tor. Pass your OGenericPluginLoader to manage |
674 | * OGenericPluginLoader::allAvailable plugins. | 680 | * OGenericPluginLoader::allAvailable plugins. |
675 | * | 681 | * |
676 | * | 682 | * |
677 | * @param loader A Pointer to your OGenericPluginLoader | 683 | * @param loader A Pointer to your OGenericPluginLoader |
678 | * @param name The name | 684 | * @param name The name |
679 | */ | 685 | */ |
680 | OPluginManager::OPluginManager( OGenericPluginLoader* loader) | 686 | OPluginManager::OPluginManager( OGenericPluginLoader* loader) |
681 | : m_loader( loader ), m_isSorted( false ) | 687 | : m_loader( loader ), m_isSorted( false ) |
682 | { | 688 | { |
683 | } | 689 | } |
684 | 690 | ||
685 | /** | 691 | /** |
686 | * \brief Overloaded c'tor using a List of Plugins and a type name | 692 | * \brief Overloaded c'tor using a List of Plugins and a type name |
687 | * Overloaded Constructor to work with a 'Type' of plugins | 693 | * Overloaded Constructor to work with a 'Type' of plugins |
688 | * and a correspending list of those. In this case calling load | 694 | * and a correspending list of those. In this case calling load |
689 | * is a no operation. | 695 | * is a no operation. |