My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions | Variables
ftvhelp.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <qlist.h>
#include <qdict.h>
#include <qfileinfo.h>
#include "ftvhelp.h"
#include "config.h"
#include "message.h"
#include "doxygen.h"
#include "language.h"
#include "htmlgen.h"
#include "layout.h"
#include "pagedef.h"
#include "docparser.h"
#include "htmldocvisitor.h"
#include "filedef.h"
#include "util.h"
#include "resourcemgr.h"

Go to the source code of this file.

Classes

struct  FTVNode
 
struct  NavIndexEntry
 
class  NavIndexEntryList
 

Macros

#define MAX_INDENT   1024
 

Functions

static QCString node2URL (FTVNode *n, bool overruleFile=FALSE, bool srcLink=FALSE)
 
static void generateBriefDoc (FTextStream &t, Definition *def)
 
static QCString pathToNode (FTVNode *leaf, FTVNode *n)
 
static bool dupOfParent (const FTVNode *n)
 
static void generateJSLink (FTextStream &t, FTVNode *n)
 
static QCString convertFileId2Var (const QCString &fileId)
 
static bool generateJSTree (NavIndexEntryList &navIndex, FTextStream &t, const QList< FTVNode > &nl, int level, bool &first)
 
static void generateJSNavTree (const QList< FTVNode > &nodeList)
 

Variables

static int folderId =1
 

Macro Definition Documentation

#define MAX_INDENT   1024

Definition at line 41 of file ftvhelp.cpp.

Referenced by FTVHelp::FTVHelp(), and FTVHelp::incContentsDepth().

Function Documentation

static QCString convertFileId2Var ( const QCString &  fileId)
static

Definition at line 482 of file ftvhelp.cpp.

References substitute().

Referenced by generateJSTree().

{
QCString varId = fileId;
int i=varId.findRev('/');
if (i>=0) varId = varId.mid(i+1);
return substitute(varId,"-","_");
}
static bool dupOfParent ( const FTVNode n)
static

Definition at line 460 of file ftvhelp.cpp.

References FTVNode::file, and FTVNode::parent.

Referenced by generateJSTree().

{
if (n->parent==0) return FALSE;
if (n->file==n->parent->file) return TRUE;
return FALSE;
}
static void generateBriefDoc ( FTextStream t,
Definition def 
)
static

Definition at line 308 of file ftvhelp.cpp.

References DocNode::accept(), brief, Definition::briefDescription(), Definition::briefFile(), Definition::briefLine(), Definition::getOutputFileBase(), relativePathToRoot(), and validatingParseDoc().

Referenced by FTVHelp::generateTree().

{
QCString brief = def->briefDescription(TRUE);
//printf("*** %p: generateBriefDoc(%s)='%s'\n",def,def->name().data(),brief.data());
if (!brief.isEmpty())
{
def,0,brief,FALSE,FALSE,0,TRUE,TRUE);
QCString relPath = relativePathToRoot(def->getOutputFileBase());
HtmlCodeGenerator htmlGen(t,relPath);
HtmlDocVisitor *visitor = new HtmlDocVisitor(t,htmlGen,def);
root->accept(visitor);
delete visitor;
delete root;
}
}
static void generateJSLink ( FTextStream t,
FTVNode n 
)
static

Definition at line 467 of file ftvhelp.cpp.

References convertToJSString(), externalRef(), FTVNode::file, FTVNode::name, node2URL(), and FTVNode::ref.

Referenced by generateJSTree().

{
if (n->file.isEmpty()) // no link
{
t << "\"" << convertToJSString(n->name) << "\", null, ";
}
else // link into other page
{
t << "\"" << convertToJSString(n->name) << "\", \"";
t << externalRef("",n->ref,TRUE);
t << node2URL(n);
t << "\", ";
}
}
static void generateJSNavTree ( const QList< FTVNode > &  nodeList)
static

Definition at line 580 of file ftvhelp.cpp.

References Config_getString, convertToJSString(), ResourceMgr::copyResource(), endl(), LayoutNavEntry::find(), generateJSTree(), Doxygen::htmlFileExtension, ResourceMgr::instance(), LayoutDocManager::instance(), Doxygen::mainPage, LayoutNavEntry::MainPage, NavIndexEntry::path, LayoutDocManager::rootNavEntry(), FTextStream::setDevice(), theTranslator, LayoutNavEntry::title(), Translator::trPanelSynchronisationTooltip(), and NavIndexEntry::url.

Referenced by FTVHelp::generateTreeViewScripts().

{
QCString htmlOutput = Config_getString(HTML_OUTPUT);
QFile f(htmlOutput+"/navtreedata.js");
if (f.open(IO_WriteOnly) /*&& fidx.open(IO_WriteOnly)*/)
{
//FTextStream tidx(&fidx);
//tidx << "var NAVTREEINDEX =" << endl;
//tidx << "{" << endl;
FTextStream t(&f);
t << "var NAVTREE =" << endl;
t << "[" << endl;
t << " [ ";
QCString &projName = Config_getString(PROJECT_NAME);
if (projName.isEmpty())
{
if (Doxygen::mainPage && !Doxygen::mainPage->title().isEmpty()) // Use title of main page as root
{
t << "\"" << convertToJSString(Doxygen::mainPage->title()) << "\", ";
}
else // Use default section title as root
{
t << "\"" << convertToJSString(lne->title()) << "\", ";
}
}
else // use PROJECT_NAME as root tree element
{
t << "\"" << convertToJSString(projName) << "\", ";
}
t << "\"index" << Doxygen::htmlFileExtension << "\", ";
// add special entry for index page
navIndex.append(new NavIndexEntry("index"+Doxygen::htmlFileExtension,""));
// related page index is written as a child of index.html, so add this as well
navIndex.append(new NavIndexEntry("pages"+Doxygen::htmlFileExtension,""));
bool first=TRUE;
generateJSTree(navIndex,t,nodeList,1,first);
if (first)
t << "]" << endl;
else
t << endl << " ] ]" << endl;
t << "];" << endl << endl;
// write the navigation index (and sub-indices)
navIndex.sort();
int subIndex=0;
int elemCount=0;
const int maxElemCount=250;
//QFile fidx(htmlOutput+"/navtreeindex.js");
QFile fsidx(htmlOutput+"/navtreeindex0.js");
if (/*fidx.open(IO_WriteOnly) &&*/ fsidx.open(IO_WriteOnly))
{
//FTextStream tidx(&fidx);
FTextStream tsidx(&fsidx);
t << "var NAVTREEINDEX =" << endl;
t << "[" << endl;
tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
tsidx << "{" << endl;
QListIterator<NavIndexEntry> li(navIndex);
bool first=TRUE;
for (li.toFirst();(e=li.current());) // for each entry
{
if (elemCount==0)
{
if (!first)
{
t << "," << endl;
}
else
{
first=FALSE;
}
t << "\"" << e->url << "\"";
}
tsidx << "\"" << e->url << "\":[" << e->path << "]";
++li;
if (li.current() && elemCount<maxElemCount-1) tsidx << ","; // not last entry
tsidx << endl;
elemCount++;
if (li.current() && elemCount>=maxElemCount) // switch to new sub-index
{
tsidx << "};" << endl;
elemCount=0;
fsidx.close();
subIndex++;
fsidx.setName(htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js");
if (!fsidx.open(IO_WriteOnly)) break;
tsidx.setDevice(&fsidx);
tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
tsidx << "{" << endl;
}
}
tsidx << "};" << endl;
t << endl << "];" << endl;
}
t << endl << "var SYNCONMSG = '" << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';";
t << endl << "var SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE) << "';";
}
ResourceMgr::instance().copyResource("navtree.js",htmlOutput);
}
static bool generateJSTree ( NavIndexEntryList navIndex,
FTextStream t,
const QList< FTVNode > &  nl,
int  level,
bool &  first 
)
static

Definition at line 490 of file ftvhelp.cpp.

References FTVNode::addToNavIndex, FTVNode::anchor, FTVNode::children, Config_getString, convertFileId2Var(), FTVNode::def, DefinitionIntf::definitionType(), doc, dupOfParent(), endl(), FTVNode::file, fileVisibleInIndex(), generateJSLink(), node2URL(), pathToNode(), FTVNode::separateIndex, and DefinitionIntf::TypeFile.

Referenced by generateJSNavTree().

{
static QCString htmlOutput = Config_getString(HTML_OUTPUT);
QCString indentStr;
indentStr.fill(' ',level*2);
bool found=FALSE;
QListIterator<FTVNode> nli(nl);
FTVNode *n;
for (nli.toFirst();(n=nli.current());++nli)
{
// terminate previous entry
if (!first) t << "," << endl;
first=FALSE;
// start entry
if (!found)
{
t << "[" << endl;
}
found=TRUE;
if (n->addToNavIndex) // add entry to the navigation index
{
{
FileDef *fd = (FileDef*)n->def;
bool doc,src;
doc = fileVisibleInIndex(fd,src);
if (doc)
{
navIndex.append(new NavIndexEntry(node2URL(n,TRUE,FALSE),pathToNode(n,n)));
}
if (src)
{
navIndex.append(new NavIndexEntry(node2URL(n,TRUE,TRUE),pathToNode(n,n)));
}
}
else
{
navIndex.append(new NavIndexEntry(node2URL(n),pathToNode(n,n)));
}
}
if (n->separateIndex) // store items in a separate file for dynamic loading
{
bool firstChild=TRUE;
t << indentStr << " [ ";
if (n->children.count()>0) // write children to separate file for dynamic loading
{
QCString fileId = n->file;
if (n->anchor)
{
fileId+="_"+n->anchor;
}
if (dupOfParent(n))
{
fileId+="_dup";
}
QFile f(htmlOutput+"/"+fileId+".js");
if (f.open(IO_WriteOnly))
{
FTextStream tt(&f);
tt << "var " << convertFileId2Var(fileId) << " =" << endl;
generateJSTree(navIndex,tt,n->children,1,firstChild);
tt << endl << "];";
}
t << "\"" << fileId << "\" ]";
}
else // no children
{
t << "null ]";
}
}
else // show items in this file
{
bool firstChild=TRUE;
t << indentStr << " [ ";
bool emptySection = !generateJSTree(navIndex,t,n->children,level+1,firstChild);
if (emptySection)
t << "null ]";
else
t << endl << indentStr << " ] ]";
}
}
return found;
}
static QCString node2URL ( FTVNode n,
bool  overruleFile = FALSE,
bool  srcLink = FALSE 
)
static

Definition at line 210 of file ftvhelp.cpp.

References FTVNode::anchor, FTVNode::def, DefinitionIntf::definitionType(), FTVNode::file, FileDef::getOutputFileBase(), FileDef::getSourceFileBase(), Doxygen::htmlFileExtension, and DefinitionIntf::TypeFile.

Referenced by generateJSLink(), generateJSTree(), and FTVHelp::generateLink().

{
QCString url = n->file;
if (!url.isEmpty() && url.at(0)=='!') // relative URL
{
// remove leading !
url = url.mid(1);
}
else if (!url.isEmpty() && url.at(0)=='^') // absolute URL
{
// skip, keep ^ in the output
}
else // local file (with optional anchor)
{
if (overruleFile && n->def && n->def->definitionType()==Definition::TypeFile)
{
FileDef *fd = (FileDef*)n->def;
if (srcLink)
{
url = fd->getSourceFileBase();
}
else
{
url = fd->getOutputFileBase();
}
}
if (!n->anchor.isEmpty()) url+="#"+n->anchor;
}
return url;
}
static QCString pathToNode ( FTVNode leaf,
FTVNode n 
)
static

Definition at line 448 of file ftvhelp.cpp.

References FTVNode::index, and FTVNode::parent.

Referenced by generateJSTree().

{
QCString result;
if (n->parent)
{
result+=pathToNode(leaf,n->parent);
}
result+=QCString().setNum(n->index);
if (leaf!=n) result+=",";
return result;
}

Variable Documentation

int folderId =1
static

Definition at line 43 of file ftvhelp.cpp.

Referenced by FTVHelp::generateTree().