Index: src/qhp.h
===================================================================
--- src/qhp.h	(Revision 693)
+++ src/qhp.h	(Arbeitskopie)
@@ -61,6 +61,9 @@
 
     int m_prevSectionLevel;
     int m_sectionLevel;
+
+    QCString m_prevIdName;
+    QCString m_prevIdRef;
 };
 
 #endif // DOXYGEN_QHP_H
Index: src/qhp.cpp
===================================================================
--- src/qhp.cpp	(Revision 693)
+++ src/qhp.cpp	(Arbeitskopie)
@@ -3,8 +3,8 @@
  * Copyright (C) 2008 Dimitri van Heesch.
  *
  * Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby 
- * granted. No representations are made about the suitability of this software 
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
  * for any purpose. It is provided "as is" without express or implied warranty.
  * See the GNU General Public License for more details.
  *
@@ -30,7 +30,7 @@
 
 static QCString makeRef(const char * withoutExtension, const char * anchor)
 {
-  if (!withoutExtension) return QCString(); 
+  if (!withoutExtension) return QCString();
   QCString result = makeFileName(withoutExtension);
   if (!anchor) return result;
   return result+"#"+anchor;
@@ -78,7 +78,7 @@
   QCString filterName = Config_getString("QHP_CUST_FILTER_NAME");
   if (!filterName.isEmpty())
   {
-    const char * tagAttributes[] = 
+    const char * tagAttributes[] =
     { "name", filterName, 0 };
     m_doc.open("customFilter", tagAttributes);
 
@@ -132,7 +132,7 @@
   m_toc.close("toc");
   m_doc.insert(m_toc);
 
-  // Finish index  
+  // Finish index
   m_index.close("keywords");
   m_doc.insert(m_index);
 
@@ -167,8 +167,8 @@
   m_sectionLevel--;
 }
 
-void Qhp::addContentsItem(bool /*isDir*/, const char * name, 
-                          const char * /*ref*/, const char * file, 
+void Qhp::addContentsItem(bool /*isDir*/, const char * name,
+                          const char * /*ref*/, const char * file,
                           const char * /*anchor*/)
 {
   // Backup difference before modification
@@ -185,20 +185,35 @@
 }
 
 void Qhp::addIndexItem(const char * level1, const char * level2,
-                       const char * contRef, const char * /*memRef*/, 
+                       const char * contRef, const char * /*memRef*/,
                        const char * anchor, const MemberDef * /*md*/)
 {
+  QCString ref;
+  if ((m_prevIdName!=level1) || (m_prevIdRef!=contRef))
+  {
+    m_prevIdName = level1;
+    m_prevIdRef = contRef;
+
+    ref = makeFileName(contRef);
+    const char * attributes[] =
+    { "name", level1,
+      "id",   level1,
+      "ref",  ref,
+      0
+    };
+    m_index.openClose("keyword", attributes);
+  }
   /*
   <keyword name="foo" id="MyApplication::foo" ref="doc.html#foo"/>
   */
-  QCString ref = makeRef(contRef, anchor);
+  ref = makeRef(contRef, anchor);
   QCString id(level1);
   id += "::";
   id += level2;
   const char * attributes[] =
-  { "name", level2, 
-    "id",   id, 
-    "ref",  ref, 
+  { "name", level2,
+    "id",   id,
+    "ref",  ref,
     0
   };
   m_index.openClose("keyword", attributes);
