summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-12 23:18:37 (UTC)
committer zecke <zecke>2004-09-12 23:18:37 (UTC)
commitf05a19bd1e248ea8cea29d361a1a8085ca145c6a (patch) (unidiff)
treeae7204968f4e8841232a976eb9cc341db65dca50
parent8123b75c55cb5140ae5b0c5aeddb4644a0a8ffbb (diff)
downloadopie-f05a19bd1e248ea8cea29d361a1a8085ca145c6a.zip
opie-f05a19bd1e248ea8cea29d361a1a8085ca145c6a.tar.gz
opie-f05a19bd1e248ea8cea29d361a1a8085ca145c6a.tar.bz2
If there is no 'excluded' plugin the excluded-list wasn't made
empty and the old/prior setting still was used. This fix makes sure that an empty string is written if no plugin is excluded
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/opluginloader.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index 1edf3a1..b8b6b79 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -546,58 +546,62 @@ OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorte
546 */ 546 */
547 QMap<QString, int> positionMap; 547 QMap<QString, int> positionMap;
548 QMap<QString, int> excludedMap; 548 QMap<QString, int> excludedMap;
549 549
550 550
551 OConfig cfg( m_dir+"-odpplugins" ); 551 OConfig cfg( m_dir+"-odpplugins" );
552 cfg.setGroup( _dir ); 552 cfg.setGroup( _dir );
553 553
554 554
555 QStringList excludes = cfg.readListEntry( "Excluded", ',' ); 555 QStringList excludes = cfg.readListEntry( "Excluded", ',' );
556 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) 556 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it )
557 excludedMap.insert( *it, -2 ); 557 excludedMap.insert( *it, -2 );
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 while ( it != pos.end() ) 562 QString tmp; int i;
563 positionMap.insert( *it++, (*it++).toInt() ); 563 while ( it != pos.end() ) {
564 tmp = *it++; i = (*it++).toInt();
565 positionMap.insert( tmp, i );
566 }
564 567
565 } 568 }
566 569
567 570
568 571
569 572
570 QStringList list = dir.entryList(); 573 QStringList list = dir.entryList();
571 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
572 QString str = unlibify( *it ); 575 QString str = unlibify( *it );
573 OPluginItem item( str, _dir + "/" + *it ); 576 OPluginItem item( str, _dir + "/" + *it );
574 577
575 bool ex = excludedMap.contains( str ); 578 bool ex = excludedMap.contains( str );
576 /* 579 /*
577 * if disabled but we should show all mark it as disabled 580 * if disabled but we should show all mark it as disabled
578 * else continue because we don't want to add the item 581 * else continue because we don't want to add the item
579 * else if sorted we assign the right position 582 * else if sorted we assign the right position
580 */ 583 */
581 if ( ex && !disabled) 584 if ( ex && !disabled)
582 item.setEnabled( false ); 585 item.setEnabled( false );
583 else if ( ex && disabled ) 586 else if ( ex && disabled )
584 continue; 587 continue;
585 else if ( sorted ) 588 else if ( sorted )
586 item.setPosition( positionMap[str] ); 589 item.setPosition( positionMap[str] );
587 590
591
588 lst.append( item ); 592 lst.append( item );
589 } 593 }
590 594
591 return lst; 595 return lst;
592} 596}
593 597
594/** 598/**
595 * @internal generate a list of languages from $LANG 599 * @internal generate a list of languages from $LANG
596 */ 600 */
597QStringList OGenericPluginLoader::languageList() { 601QStringList OGenericPluginLoader::languageList() {
598 if ( m_languages.isEmpty() ) { 602 if ( m_languages.isEmpty() ) {
599 /* 603 /*
600 * 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
601 * to our list of languages. 605 * to our list of languages.
602 */ 606 */
603 QString str = ::getenv( "LANG" ); 607 QString str = ::getenv( "LANG" );
@@ -821,32 +825,35 @@ void OPluginManager::save() {
821 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs 825 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs
822 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted; 826 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted;
823 827
824 /* 828 /*
825 * We will create some maps for the groups to include positions a 829 * We will create some maps for the groups to include positions a
826 */ 830 */
827 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) { 831 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) {
828 OPluginItem item = *it; 832 OPluginItem item = *it;
829 QString path = QFileInfo( item.path() ).dirPath(true); 833 QString path = QFileInfo( item.path() ).dirPath(true);
830 if ( sorted ) { 834 if ( sorted ) {
831 positions[path].append( item.name() ); 835 positions[path].append( item.name() );
832 positions[path].append( QString::number( item.position() ) ); 836 positions[path].append( QString::number( item.position() ) );
833 } 837 }
834 838
835 if ( !item.isEnabled() ) 839 if ( !item.isEnabled() )
836 excluded[path].append( item.name() ); 840 excluded[path].append( item.name() );
841 if ( !excluded.contains( path ) )
842 excluded[path] = QString::null;
843
837 } 844 }
838 845
839/* 846/*
840 * The code below wouldn't work because we can't delete groups/keys from the config 847 * The code below wouldn't work because we can't delete groups/keys from the config
841 * ### for ODP make Config right! 848 * ### for ODP make Config right!
842 */ 849 */
843// if ( excluded.isEmpty() && positions.isEmpty() ) return; 850// if ( excluded.isEmpty() && positions.isEmpty() ) return;
844 /* 851 /*
845 * Now safe for each path 852 * Now safe for each path
846 */ 853 */
847 OConfig cfg( configName() ); 854 OConfig cfg( configName() );
848 855
849 /* safe excluded items */ 856 /* safe excluded items */
850 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) { 857 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) {
851 OConfigGroupSaver saver( &cfg, it.key() ); 858 OConfigGroupSaver saver( &cfg, it.key() );
852 cfg.writeEntry("Excluded", it.data(), ',' ); 859 cfg.writeEntry("Excluded", it.data(), ',' );