Branch: master

c2924536 2014-10-04 14:02:26 Timothy Pearson
Sort non-root entries in KHelpCenter
Make KHelpCenter entry sorting case-insensitive
This resolves Bug 1849
M khelpcenter/navigator.cpp
M khelpcenter/navigatorappitem.cpp
M khelpcenter/navigatorappitem.h
M khelpcenter/navigatoritem.cpp
M khelpcenter/navigatoritem.h
diff --git a/khelpcenter/navigator.cpp b/khelpcenter/navigator.cpp
index 7d865d9..22f530a 100644
--- a/khelpcenter/navigator.cpp
+++ b/khelpcenter/navigator.cpp
@@ -230,6 +230,7 @@
     }
     createItemFromDesktopFile( topItem, desktopFile );
   }
+  topItem->sortChildItems( 0, true /* ascending */ );
 }
 
 void Navigator::insertIOSlaveDocs( const TQString &name, NavigatorItem *topItem )
@@ -269,8 +270,10 @@
   TQStringList files = appletDir.entryList( TQDir::Files | TQDir::Readable );
   TQStringList::ConstIterator it = files.begin();
   TQStringList::ConstIterator end = files.end();
-  for ( ; it != end; ++it )
+  for ( ; it != end; ++it ) {
     createItemFromDesktopFile( topItem, appletDir.absPath() + "/" + *it );
+  }
+  topItem->sortChildItems( 0, true /* ascending */ );
 }
 
 void Navigator::createItemFromDesktopFile( NavigatorItem *topItem,
diff --git a/khelpcenter/navigatorappitem.cpp b/khelpcenter/navigatorappitem.cpp
index 2c17538..f759a76 100644
--- a/khelpcenter/navigatorappitem.cpp
+++ b/khelpcenter/navigatorappitem.cpp
@@ -156,6 +156,11 @@
   return entriesAdded;
 }
 
+TQString NavigatorAppItem::key( int column, bool ascending ) const
+{
+  return text( column ).lower();
+}
+
 TQString NavigatorAppItem::documentationURL( KService *s )
 {
   TQString docPath = s->property( "DocPath" ).toString();
diff --git a/khelpcenter/navigatorappitem.h b/khelpcenter/navigatorappitem.h
index ddebe96..c89e1de 100644
--- a/khelpcenter/navigatorappitem.h
+++ b/khelpcenter/navigatorappitem.h
@@ -43,6 +43,7 @@
 
     virtual void setOpen(bool);
     bool populate( bool recursive = false );
+    virtual TQString key( int column, bool ascending ) const;
 
   protected:
     TQString documentationURL( KService *s );
diff --git a/khelpcenter/navigatoritem.cpp b/khelpcenter/navigatoritem.cpp
index e20d979..ad464ba 100644
--- a/khelpcenter/navigatoritem.cpp
+++ b/khelpcenter/navigatoritem.cpp
@@ -102,4 +102,9 @@
   }
 }
 
+TQString NavigatorItem::key( int column, bool ascending ) const
+{
+  return text( column ).lower();
+}
+
 // vim:ts=2:sw=2:et
diff --git a/khelpcenter/navigatoritem.h b/khelpcenter/navigatoritem.h
index e460f82..7808b9c 100644
--- a/khelpcenter/navigatoritem.h
+++ b/khelpcenter/navigatoritem.h
@@ -49,12 +49,14 @@
     TOC *toc() const { return mToc; }
 
     TOC *createTOC();
-  
+
     void setOpen( bool open );
+
+    virtual TQString key( int column, bool ascending ) const;
 
   private:
     void init( DocEntry * );
-    
+
     TOC *mToc;
 
     DocEntry *mEntry;