Fix khelpcenter service group entry appearing when no child service items have documentation

This relates to Bug 1968
Fix khelpcenter services showing tree expansion hints
pull/2/head
Timothy Pearson 10 years ago
parent 07d87c947a
commit 485ab965cd

@ -225,8 +225,9 @@ void Navigator::insertParentAppDocs( const TQString &name, NavigatorItem *topIte
KServiceGroup::List::ConstIterator end = entries.end(); KServiceGroup::List::ConstIterator end = entries.end();
for ( ; it != end; ++it ) { for ( ; it != end; ++it ) {
TQString desktopFile = ( *it )->entryPath(); TQString desktopFile = ( *it )->entryPath();
if ( TQDir::isRelativePath( desktopFile ) ) if ( TQDir::isRelativePath( desktopFile ) ) {
desktopFile = locate( "apps", desktopFile ); desktopFile = locate( "apps", desktopFile );
}
createItemFromDesktopFile( topItem, desktopFile ); createItemFromDesktopFile( topItem, desktopFile );
} }
} }

@ -78,20 +78,21 @@ void NavigatorAppItem::setOpen(bool open)
TQListViewItem::setOpen(open); TQListViewItem::setOpen(open);
} }
void NavigatorAppItem::populate( bool recursive ) bool NavigatorAppItem::populate( bool recursive )
{ {
if ( mPopulated ) return; bool entriesAdded = false;
if ( mPopulated ) return false;
KServiceGroup::Ptr root = KServiceGroup::group(mRelpath); KServiceGroup::Ptr root = KServiceGroup::group(mRelpath);
if ( !root ) { if ( !root ) {
kdWarning() << "No Service groups\n"; kdWarning() << "No Service groups\n";
return; return false;
} }
KServiceGroup::List list = root->entries(); KServiceGroup::List list = root->entries();
for ( KServiceGroup::List::ConstIterator it = list.begin(); for ( KServiceGroup::List::ConstIterator it = list.begin(); it != list.end(); ++it )
it != list.end(); ++it )
{ {
KSycocaEntry * e = *it; KSycocaEntry * e = *it;
KService::Ptr s; KService::Ptr s;
@ -108,20 +109,41 @@ void NavigatorAppItem::populate( bool recursive )
DocEntry *entry = new DocEntry( s->name(), url, s->icon() ); DocEntry *entry = new DocEntry( s->name(), url, s->icon() );
item = new NavigatorItem( entry, this ); item = new NavigatorItem( entry, this );
item->setAutoDeleteDocEntry( true ); item->setAutoDeleteDocEntry( true );
item->setExpandable( true ); item->setExpandable( false );
entriesAdded = true;
} }
break; break;
} }
case KST_KServiceGroup: case KST_KServiceGroup:
{ {
g = static_cast<KServiceGroup*>(e); g = static_cast<KServiceGroup*>(e);
if ( ( g->childCount() == 0 ) || g->name().startsWith( "." ) ) if ( ( g->childCount() == 0 ) || g->name().startsWith( "." ) ) {
continue; continue;
}
KServiceGroup::List entryList = g->entries(false, true, false, false);
if (entryList.count() > 0) {
int entryCount = 0;
for( KServiceGroup::List::ConstIterator it2 = entryList.begin(); it2 != entryList.end(); it2++)
{
KSycocaEntry *p = (*it2);
if (p->isType(KST_KService))
{
KService *s = static_cast<KService *>(p);
url = documentationURL( s );
if ( !url.isEmpty() ){
entryCount++;
}
}
}
if (entryCount > 0) {
DocEntry *entry = new DocEntry( g->caption(), "", g->icon() ); DocEntry *entry = new DocEntry( g->caption(), "", g->icon() );
NavigatorAppItem *appItem; NavigatorAppItem *appItem;
appItem = new NavigatorAppItem( entry, this, g->relPath() ); appItem = new NavigatorAppItem( entry, this, g->relPath() );
appItem->setAutoDeleteDocEntry( true ); appItem->setAutoDeleteDocEntry( true );
if ( recursive ) appItem->populate( recursive ); if ( recursive ) appItem->populate( recursive );
entriesAdded = true;
}
}
break; break;
} }
default: default:
@ -130,6 +152,8 @@ void NavigatorAppItem::populate( bool recursive )
} }
sortChildItems( 0, true /* ascending */ ); sortChildItems( 0, true /* ascending */ );
mPopulated = true; mPopulated = true;
return entriesAdded;
} }
TQString NavigatorAppItem::documentationURL( KService *s ) TQString NavigatorAppItem::documentationURL( KService *s )

@ -42,7 +42,7 @@ class NavigatorAppItem : public NavigatorItem
void setRelpath( const TQString & ); void setRelpath( const TQString & );
virtual void setOpen(bool); virtual void setOpen(bool);
void populate( bool recursive = false ); bool populate( bool recursive = false );
protected: protected:
TQString documentationURL( KService *s ); TQString documentationURL( KService *s );

Loading…
Cancel
Save