My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
HtmlHelpIndex Class Reference

Public Member Functions

 HtmlHelpIndex (HtmlHelp *help)
 
 ~HtmlHelpIndex ()
 
void addItem (const char *first, const char *second, const char *url, const char *anchor, bool hasLink, bool reversed)
 
void writeFields (FTextStream &t)
 

Private Attributes

IndexFieldSDictdict
 
HtmlHelpm_help
 

Detailed Description

A helper class for HtmlHelp that manages a two level index in alphabetical order.

Definition at line 68 of file htmlhelp.cpp.

Constructor & Destructor Documentation

HtmlHelpIndex::HtmlHelpIndex ( HtmlHelp help)

Constructs a new HtmlHelp index

Definition at line 83 of file htmlhelp.cpp.

References dict, and SDict< T >::setAutoDelete().

: m_help(help)
{
}
HtmlHelpIndex::~HtmlHelpIndex ( )

Destroys the HtmlHelp index

Definition at line 90 of file htmlhelp.cpp.

References dict.

{
delete dict;
}

Member Function Documentation

void HtmlHelpIndex::addItem ( const char *  level1,
const char *  level2,
const char *  url,
const char *  anchor,
bool  hasLink,
bool  reversed 
)

Stores an item in the index if it is not already present. Items are stored in alphetical order, by sorting on the concatenation of level1 and level2 (if present).

Parameters
level1the string at level 1 in the index.
level2the string at level 2 in the index (or 0 if not applicable).
urlthe url of the documentation (without .html extension).
anchorthe anchor of the documentation within the page.
hasLinkif true, the url (without anchor) can be used in the level1 item, when writing the header of a list of level2 items.
reversedTRUE if level1 is the member name and level2 the compound name.

Definition at line 108 of file htmlhelp.cpp.

References IndexField::anchor, SDict< T >::append(), dict, SDict< T >::find(), IndexField::link, IndexField::name, IndexField::reversed, and IndexField::url.

Referenced by HtmlHelp::addIndexItem().

{
QCString key = level1;
if (level2) key+= (QCString)"?" + level2;
if (key.find(QRegExp("@[0-9]+"))!=-1) // skip anonymous stuff
{
return;
}
if (dict->find(key)==0) // new key
{
//printf(">>>>>>>>> HtmlHelpIndex::addItem(%s,%s,%s,%s)\n",
// level1,level2,url,anchor);
f->name = key;
f->url = url;
f->anchor = anchor;
f->link = hasLink;
f->reversed = reversed;
dict->append(key,f);
}
}
void HtmlHelpIndex::writeFields ( FTextStream t)

Writes the sorted list of index items into a html like list.

An list of calls with name = level1,level2 as follows:

     a1,b1
     a1,b2
     a2,b1
     a2,b2
     a3
     a4,b1
   

Will result in the following list:

     a1       -> link to url if hasLink==TRUE
       b1     -> link to url::anchor
       b2     -> link to url::anchor
     a2       -> link to url if hasLink==TRUE
       b1     -> link to url::anchor
       b2     -> link to url::anchor
     a3       -> link to url if hasLink==TRUE
     a4       -> link to url if hasLink==TRUE
       b1     -> link to url::anchor 
   

Definition at line 169 of file htmlhelp.cpp.

References dict, endl(), field2URL(), SDict< IndexField >::Iterator, IndexField::link, m_help, IndexField::name, HtmlHelp::recode(), and SDict< T >::sort().

Referenced by HtmlHelp::finalize().

{
dict->sort();
QCString lastLevel1;
bool level2Started=FALSE;
for (;(f=ifli.current());++ifli)
{
QCString level1,level2;
int i;
if ((i=f->name.find('?'))!=-1)
{
level1 = f->name.left(i);
level2 = f->name.right(f->name.length()-i-1);
}
else
{
level1 = f->name.copy();
}
if (level1!=lastLevel1)
{ // finish old list at level 2
if (level2Started) t << " </UL>" << endl;
level2Started=FALSE;
// <Antony>
// Added this code so that an item with only one subitem is written
// without any subitem.
// For example:
// a1, b1 -> will create only a1, not separate subitem for b1
// a2, b2
// a2, b3
QCString nextLevel1;
IndexField* fnext = ++ifli;
if (fnext)
{
nextLevel1 = fnext->name.left(fnext->name.find('?'));
--ifli;
}
if (level1 != nextLevel1)
{
level2 = "";
}
// </Antony>
if (level2.isEmpty())
{
t << " <LI><OBJECT type=\"text/sitemap\">";
t << "<param name=\"Local\" value=\"" << field2URL(f,FALSE);
t << "\">";
t << "<param name=\"Name\" value=\"" << m_help->recode(level1) << "\">"
"</OBJECT>\n";
}
else
{
if (f->link)
{
t << " <LI><OBJECT type=\"text/sitemap\">";
t << "<param name=\"Local\" value=\"" << field2URL(f,TRUE);
t << "\">";
t << "<param name=\"Name\" value=\"" << m_help->recode(level1) << "\">"
"</OBJECT>\n";
}
else
{
t << " <LI><OBJECT type=\"text/sitemap\">";
t << "<param name=\"See Also\" value=\"" << m_help->recode(level1) << "\">";
t << "<param name=\"Name\" value=\"" << m_help->recode(level1) << "\">"
"</OBJECT>\n";
}
}
}
if (!level2Started && !level2.isEmpty())
{ // start new list at level 2
t << " <UL>" << endl;
level2Started=TRUE;
}
else if (level2Started && level2.isEmpty())
{ // end list at level 2
t << " </UL>" << endl;
level2Started=FALSE;
}
if (level2Started)
{
t << " <LI><OBJECT type=\"text/sitemap\">";
t << "<param name=\"Local\" value=\"" << field2URL(f,FALSE);
t << "\">";
t << "<param name=\"Name\" value=\"" << m_help->recode(level2) << "\">"
"</OBJECT>\n";
}
lastLevel1 = level1.copy();
}
if (level2Started) t << " </UL>" << endl;
}

Member Data Documentation

IndexFieldSDict* HtmlHelpIndex::dict
private

Definition at line 78 of file htmlhelp.cpp.

Referenced by addItem(), HtmlHelpIndex(), writeFields(), and ~HtmlHelpIndex().

HtmlHelp* HtmlHelpIndex::m_help
private

Definition at line 79 of file htmlhelp.cpp.

Referenced by writeFields().


The documentation for this class was generated from the following file: