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.

83  : m_help(help)
84 {
85  dict = new IndexFieldSDict;
87 }
IndexFieldSDict * dict
Definition: htmlhelp.cpp:78
void setAutoDelete(bool val)
Definition: sortdict.h:222
const bool TRUE
Definition: qglobal.h:371
HtmlHelp * m_help
Definition: htmlhelp.cpp:79
HtmlHelpIndex::~HtmlHelpIndex ( )

Destroys the HtmlHelp index

Definition at line 90 of file htmlhelp.cpp.

91 {
92  delete dict;
93 }
IndexFieldSDict * dict
Definition: htmlhelp.cpp:78

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.

111 {
112  QCString key = level1;
113  if (level2) key+= (QCString)"?" + level2;
114  if (key.find(QRegExp("@[0-9]+"))!=-1) // skip anonymous stuff
115  {
116  return;
117  }
118  if (dict->find(key)==0) // new key
119  {
120  //printf(">>>>>>>>> HtmlHelpIndex::addItem(%s,%s,%s,%s)\n",
121  // level1,level2,url,anchor);
122  IndexField *f = new IndexField;
123  f->name = key;
124  f->url = url;
125  f->anchor = anchor;
126  f->link = hasLink;
127  f->reversed = reversed;
128  dict->append(key,f);
129  }
130 }
bool reversed
Definition: htmlhelp.cpp:49
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
QCString url
Definition: htmlhelp.cpp:46
IndexFieldSDict * dict
Definition: htmlhelp.cpp:78
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
void append(const char *key, const T *d)
Definition: sortdict.h:135
def key(type, name=None)
Definition: graph.py:13
QCString name
Definition: htmlhelp.cpp:45
bool link
Definition: htmlhelp.cpp:48
QCString anchor
Definition: htmlhelp.cpp:47
T * find(const char *key)
Definition: sortdict.h:232
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 168 of file htmlhelp.cpp.

169 {
170  dict->sort();
172  IndexField *f;
173  QCString lastLevel1;
174  bool level2Started=FALSE;
175  for (;(f=ifli.current());++ifli)
176  {
177  QCString level1,level2;
178  int i;
179  if ((i=f->name.find('?'))!=-1)
180  {
181  level1 = f->name.left(i);
182  level2 = f->name.right(f->name.length()-i-1);
183  }
184  else
185  {
186  level1 = f->name.copy();
187  }
188 
189  if (level1!=lastLevel1)
190  { // finish old list at level 2
191  if (level2Started) t << " </UL>" << endl;
192  level2Started=FALSE;
193 
194  // <Antony>
195  // Added this code so that an item with only one subitem is written
196  // without any subitem.
197  // For example:
198  // a1, b1 -> will create only a1, not separate subitem for b1
199  // a2, b2
200  // a2, b3
201  QCString nextLevel1;
202  IndexField* fnext = ++ifli;
203  if (fnext)
204  {
205  nextLevel1 = fnext->name.left(fnext->name.find('?'));
206  --ifli;
207  }
208  if (level1 != nextLevel1)
209  {
210  level2 = "";
211  }
212  // </Antony>
213 
214  if (level2.isEmpty())
215  {
216  t << " <LI><OBJECT type=\"text/sitemap\">";
217  t << "<param name=\"Local\" value=\"" << field2URL(f,TRUE);
218  t << "\">";
219  t << "<param name=\"Name\" value=\"" << m_help->recode(level1) << "\">"
220  "</OBJECT>\n";
221  }
222  else
223  {
224  if (f->link)
225  {
226  t << " <LI><OBJECT type=\"text/sitemap\">";
227  t << "<param name=\"Local\" value=\"" << field2URL(f,TRUE);
228  t << "\">";
229  t << "<param name=\"Name\" value=\"" << m_help->recode(level1) << "\">"
230  "</OBJECT>\n";
231  }
232  else
233  {
234  t << " <LI><OBJECT type=\"text/sitemap\">";
235  t << "<param name=\"See Also\" value=\"" << m_help->recode(level1) << "\">";
236  t << "<param name=\"Name\" value=\"" << m_help->recode(level1) << "\">"
237  "</OBJECT>\n";
238  }
239  }
240  }
241  if (!level2Started && !level2.isEmpty())
242  { // start new list at level 2
243  t << " <UL>" << endl;
244  level2Started=TRUE;
245  }
246  else if (level2Started && level2.isEmpty())
247  { // end list at level 2
248  t << " </UL>" << endl;
249  level2Started=FALSE;
250  }
251  if (level2Started)
252  {
253  t << " <LI><OBJECT type=\"text/sitemap\">";
254  t << "<param name=\"Local\" value=\"" << field2URL(f,FALSE);
255  t << "\">";
256  t << "<param name=\"Name\" value=\"" << m_help->recode(level2) << "\">"
257  "</OBJECT>\n";
258  }
259  lastLevel1 = level1.copy();
260  }
261  if (level2Started) t << " </UL>" << endl;
262 }
bool isEmpty() const
Definition: qcstring.h:189
IndexFieldSDict * dict
Definition: htmlhelp.cpp:78
uint length() const
Definition: qcstring.h:195
const bool FALSE
Definition: qglobal.h:370
QCString left(uint len) const
Definition: qcstring.cpp:213
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
QCString copy() const
Definition: qcstring.h:250
QCString right(uint len) const
Definition: qcstring.cpp:231
QCString recode(const QCString &s)
Definition: htmlhelp.cpp:595
QCString name
Definition: htmlhelp.cpp:45
bool link
Definition: htmlhelp.cpp:48
static QCString field2URL(const IndexField *f, bool checkReversed)
Definition: htmlhelp.cpp:132
void sort()
Definition: sortdict.h:188
friend class Iterator
Definition: sortdict.h:289
const bool TRUE
Definition: qglobal.h:371
QTextStream & endl(QTextStream &s)
HtmlHelp * m_help
Definition: htmlhelp.cpp:79

Member Data Documentation

IndexFieldSDict* HtmlHelpIndex::dict
private

Definition at line 78 of file htmlhelp.cpp.

HtmlHelp* HtmlHelpIndex::m_help
private

Definition at line 79 of file htmlhelp.cpp.


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