diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-24 23:13:44 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-24 23:13:44 -0500 |
commit | 485ab965cd717c5b94bf2d941e4efa6293b57642 (patch) | |
tree | 2b9124a3ec47faa9956842e603e711bbdd28269e | |
parent | 07d87c947a409c095cec678e7c36b022a58e2567 (diff) | |
download | tdebase-485ab965cd717c5b94bf2d941e4efa6293b57642.tar.gz tdebase-485ab965cd717c5b94bf2d941e4efa6293b57642.zip |
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
-rw-r--r-- | khelpcenter/application.cpp | 2 | ||||
-rw-r--r-- | khelpcenter/docentry.cpp | 2 | ||||
-rw-r--r-- | khelpcenter/navigator.cpp | 3 | ||||
-rw-r--r-- | khelpcenter/navigatorappitem.cpp | 48 | ||||
-rw-r--r-- | khelpcenter/navigatorappitem.h | 2 |
5 files changed, 41 insertions, 16 deletions
diff --git a/khelpcenter/application.cpp b/khelpcenter/application.cpp index 7adafeb04..631818dfa 100644 --- a/khelpcenter/application.cpp +++ b/khelpcenter/application.cpp @@ -34,7 +34,7 @@ Application::Application() : KUniqueApplication(), mMainWindow( 0 ) int Application::newInstance() { if (restoringSession()) return 0; - + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); KURL url; diff --git a/khelpcenter/docentry.cpp b/khelpcenter/docentry.cpp index 05f3ffac0..e2feedcee 100644 --- a/khelpcenter/docentry.cpp +++ b/khelpcenter/docentry.cpp @@ -269,7 +269,7 @@ void DocEntry::addChild( DocEntry *entry ) if ( i == 0 ) { if ( entry->weight() < mChildren.first()->weight() ) { entry->setNextSibling( mChildren.first() ); - mChildren.prepend( entry ); + mChildren.prepend( entry ); break; } } diff --git a/khelpcenter/navigator.cpp b/khelpcenter/navigator.cpp index e05671ef2..7d865d9a8 100644 --- a/khelpcenter/navigator.cpp +++ b/khelpcenter/navigator.cpp @@ -225,8 +225,9 @@ void Navigator::insertParentAppDocs( const TQString &name, NavigatorItem *topIte KServiceGroup::List::ConstIterator end = entries.end(); for ( ; it != end; ++it ) { TQString desktopFile = ( *it )->entryPath(); - if ( TQDir::isRelativePath( desktopFile ) ) + if ( TQDir::isRelativePath( desktopFile ) ) { desktopFile = locate( "apps", desktopFile ); + } createItemFromDesktopFile( topItem, desktopFile ); } } diff --git a/khelpcenter/navigatorappitem.cpp b/khelpcenter/navigatorappitem.cpp index b2bee736e..2c175386c 100644 --- a/khelpcenter/navigatorappitem.cpp +++ b/khelpcenter/navigatorappitem.cpp @@ -78,20 +78,21 @@ void NavigatorAppItem::setOpen(bool 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); if ( !root ) { kdWarning() << "No Service groups\n"; - return; + return false; } KServiceGroup::List list = root->entries(); - for ( KServiceGroup::List::ConstIterator it = list.begin(); - it != list.end(); ++it ) + for ( KServiceGroup::List::ConstIterator it = list.begin(); it != list.end(); ++it ) { KSycocaEntry * e = *it; KService::Ptr s; @@ -108,20 +109,41 @@ void NavigatorAppItem::populate( bool recursive ) DocEntry *entry = new DocEntry( s->name(), url, s->icon() ); item = new NavigatorItem( entry, this ); item->setAutoDeleteDocEntry( true ); - item->setExpandable( true ); + item->setExpandable( false ); + entriesAdded = true; } break; } case KST_KServiceGroup: { g = static_cast<KServiceGroup*>(e); - if ( ( g->childCount() == 0 ) || g->name().startsWith( "." ) ) + if ( ( g->childCount() == 0 ) || g->name().startsWith( "." ) ) { continue; - DocEntry *entry = new DocEntry( g->caption(), "", g->icon() ); - NavigatorAppItem *appItem; - appItem = new NavigatorAppItem( entry, this, g->relPath() ); - appItem->setAutoDeleteDocEntry( true ); - if ( recursive ) appItem->populate( recursive ); + } + 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() ); + NavigatorAppItem *appItem; + appItem = new NavigatorAppItem( entry, this, g->relPath() ); + appItem->setAutoDeleteDocEntry( true ); + if ( recursive ) appItem->populate( recursive ); + entriesAdded = true; + } + } break; } default: @@ -130,6 +152,8 @@ void NavigatorAppItem::populate( bool recursive ) } sortChildItems( 0, true /* ascending */ ); mPopulated = true; + + return entriesAdded; } TQString NavigatorAppItem::documentationURL( KService *s ) diff --git a/khelpcenter/navigatorappitem.h b/khelpcenter/navigatorappitem.h index 8ae3eac0d..ddebe964a 100644 --- a/khelpcenter/navigatorappitem.h +++ b/khelpcenter/navigatorappitem.h @@ -42,7 +42,7 @@ class NavigatorAppItem : public NavigatorItem void setRelpath( const TQString & ); virtual void setOpen(bool); - void populate( bool recursive = false ); + bool populate( bool recursive = false ); protected: TQString documentationURL( KService *s ); |