branches/KDE/3.5/kdevelop/parts/documentation/plugins/doxygen

Andras Mantia amantia at kde.org
Fri Aug 19 19:31:06 UTC 2005


SVN commit 450999 by amantia:

Search recursively for doxygen tag files.
Fixes browsing of the KDE 3.5/trunk apidocs.

CCMAIL:kdevelop-devel at kdevelop.org

 M  +81 -27    docdoxygenplugin.cpp  
 M  +8 -1      docdoxygenplugin.h  


--- branches/KDE/3.5/kdevelop/parts/documentation/plugins/doxygen/docdoxygenplugin.cpp #450998:450999
@@ -331,40 +331,50 @@
     //@todo list html files in the directory if tag was not found
     if (!QFile::exists(tagName))
         return;
-    
-    QFile f(tagName);
-    if (!f.open(IO_ReadOnly))
-    {
-        kdDebug(9002) << "Could not open tag file: " << f.name() << endl;
-        return;
-    }
 
-    QDomDocument dom;
-    if (!dom.setContent(&f) || dom.documentElement().nodeName() != "tagfile")
-    {
-        kdDebug(9002) << "No valid tag file" << endl;
-        return;
-    }
-    f.close();
+    QStringList tagFileList;
+    if (tagName.endsWith(".tag"))
+        tagFileList = tagFiles(QFileInfo(tagName).dirPath() + "/");
+    else
+        tagFileList += tagName;
 
-    QDomElement docEl = dom.documentElement();
-
-    QDomElement childEl = docEl.lastChild().toElement();
-    while (!childEl.isNull())
+    QStringList::ConstIterator end = tagFileList.constEnd();
+    for (QStringList::ConstIterator it = tagFileList.constBegin(); it != end; ++it)
     {
-        if (childEl.tagName() == "compound" && childEl.attribute("kind") == "class")
+        QFile f(*it);
+        if (!f.open(IO_ReadOnly))
         {
-            QString classname = childEl.namedItem("name").firstChild().toText().data();
-            QString filename = childEl.namedItem("filename").firstChild().toText().data();
-
-            if (QFile::exists(baseUrl + filename))
+            kdDebug(9002) << "Could not open tag file: " << f.name() << endl;
+            return;
+        }
+    
+        QDomDocument dom;
+        if (!dom.setContent(&f) || dom.documentElement().nodeName() != "tagfile")
+        {
+            kdDebug(9002) << "No valid tag file" << endl;
+            return;
+        }
+        f.close();
+    
+        QDomElement docEl = dom.documentElement();
+    
+        QDomElement childEl = docEl.lastChild().toElement();
+        while (!childEl.isNull())
+        {
+            if (childEl.tagName() == "compound" && childEl.attribute("kind") == "class")
             {
-                DocumentationItem *docItem = new DocumentationItem(DocumentationItem::Document,
-                    item, classname);
-                docItem->setURL(KURL(baseUrl + filename));
+                QString classname = childEl.namedItem("name").firstChild().toText().data();
+                QString filename = childEl.namedItem("filename").firstChild().toText().data();
+    
+                if (QFile::exists(baseUrl + filename))
+                {
+                    DocumentationItem *docItem = new DocumentationItem(DocumentationItem::Document,
+                        item, classname);
+                    docItem->setURL(KURL(baseUrl + filename));
+                }
             }
+            childEl = childEl.previousSibling().toElement();
         }
-        childEl = childEl.previousSibling().toElement();
     }
 }
 
@@ -444,4 +454,48 @@
     return DocumentationPlugin::projectDocumentationPlugin(type);
 }
 
+QStringList DocDoxygenPlugin::tagFiles(const QString& path, int level)
+{
+  QStringList r;
+  QDir dir(path);
+  if (level > 10) return r;
+  if (!dir.isReadable()) return r;
+  if (!dir.exists()) return r;
+
+  QStringList  dirList;
+  QStringList  fileList;
+  QStringList::Iterator it;
+
+  dir.setFilter ( QDir::Dirs);
+  dirList = dir.entryList();
+
+  dirList.remove(".");
+  dirList.remove("..");
+
+  dir.setFilter(QDir::Files | QDir::Hidden | QDir::System);
+  fileList = dir.entryList();
+  QStringList::Iterator end = dirList.end();
+  for ( it = dirList.begin(); it != end; ++it )
+  {
+    QString name = *it;
+    if (QFileInfo( dir, *it ).isSymLink())
+      continue;
+    r += tagFiles(path + name + "/", level + 1 );
+  }
+
+  QStringList::Iterator fend = fileList.end();
+  for ( it = fileList.begin(); it != fend; ++it )
+  {
+    QString name = *it;
+    QFileInfo fi( dir, *it );
+    if (fi.isSymLink() || !fi.isFile())
+      continue;
+
+    if (QDir::match(QString("*.tag"), name))
+      r += (path+name);
+  }
+
+  return r;
+}
+
 #include "docdoxygenplugin.moc"
--- branches/KDE/3.5/kdevelop/parts/documentation/plugins/doxygen/docdoxygenplugin.h #450998:450999
@@ -61,7 +61,14 @@
     
     void autoSetupDocs(const QString &defaultDir, const QString &searchDir, 
         const QString &name);
-    
+
+    /**
+     * Returns all the tag files from a directory and its subdirectories.
+     * @param startDir the directory to start with
+     * @param level the depth of the current search
+     * @return a list with the absolute path to the ".tag" files in startDir
+     */
+    QStringList tagFiles(const QString &startDir, int level = 0);    
 };
 
 




More information about the KDevelop-devel mailing list