1 /****************************************************************************** |
1 /****************************************************************************** |
2 * |
2 * |
3 * |
3 * |
4 * |
4 * |
5 * Copyright (C) 1997-2008 by Dimitri van Heesch. |
5 * Copyright (C) 1997-2010 by Dimitri van Heesch. |
6 * |
6 * |
7 * Permission to use, copy, modify, and distribute this software and its |
7 * Permission to use, copy, modify, and distribute this software and its |
8 * documentation under the terms of the GNU General Public License is hereby |
8 * documentation under the terms of the GNU General Public License is hereby |
9 * granted. No representations are made about the suitability of this software |
9 * granted. No representations are made about the suitability of this software |
10 * for any purpose. It is provided "as is" without express or implied warranty. |
10 * for any purpose. It is provided "as is" without express or implied warranty. |
41 QCString anchor; |
42 QCString anchor; |
42 bool link; |
43 bool link; |
43 bool reversed; |
44 bool reversed; |
44 }; |
45 }; |
45 |
46 |
46 class IndexFieldList : public QList<IndexField> |
47 class IndexFieldSDict : public SDict<IndexField> |
47 { |
48 { |
48 public: |
49 public: |
|
50 IndexFieldSDict() : SDict<IndexField>(17) {} |
|
51 ~IndexFieldSDict() {} |
49 int compareItems(GCI item1, GCI item2) |
52 int compareItems(GCI item1, GCI item2) |
50 { |
53 { |
51 return stricmp(((IndexField *)item1)->name,((IndexField *)item2)->name); |
54 return stricmp(((IndexField *)item1)->name,((IndexField *)item2)->name); |
52 } |
55 } |
53 ~IndexFieldList() {} |
|
54 }; |
|
55 |
|
56 class IndexFieldListIterator : public QListIterator<IndexField> |
|
57 { |
|
58 public: |
|
59 IndexFieldListIterator( const IndexFieldList &list) : |
|
60 QListIterator<IndexField>(list) {} |
|
61 }; |
|
62 |
|
63 class IndexFieldDict : public QDict<IndexField> |
|
64 { |
|
65 public: |
|
66 IndexFieldDict(int size) : QDict<IndexField>(size) {} |
|
67 ~IndexFieldDict() {} |
|
68 }; |
56 }; |
69 |
57 |
70 /*! A helper class for HtmlHelp that manages a two level index in |
58 /*! A helper class for HtmlHelp that manages a two level index in |
71 * alphabetical order |
59 * alphabetical order |
72 */ |
60 */ |
78 void addItem(const char *first,const char *second, |
66 void addItem(const char *first,const char *second, |
79 const char *url, const char *anchor, |
67 const char *url, const char *anchor, |
80 bool hasLink,bool reversed); |
68 bool hasLink,bool reversed); |
81 void writeFields(QTextStream &t); |
69 void writeFields(QTextStream &t); |
82 private: |
70 private: |
83 IndexFieldList *list; |
71 IndexFieldSDict *dict; |
84 IndexFieldDict *dict; |
|
85 }; |
72 }; |
86 |
73 |
87 /*! Constructs a new HtmlHelp index */ |
74 /*! Constructs a new HtmlHelp index */ |
88 HtmlHelpIndex::HtmlHelpIndex() |
75 HtmlHelpIndex::HtmlHelpIndex() |
89 { |
76 { |
90 list = new IndexFieldList; |
77 dict = new IndexFieldSDict; |
91 dict = new IndexFieldDict(10007); |
78 dict->setAutoDelete(TRUE); |
92 list->setAutoDelete(TRUE); |
|
93 } |
79 } |
94 |
80 |
95 /*! Destroys the HtmlHelp index */ |
81 /*! Destroys the HtmlHelp index */ |
96 HtmlHelpIndex::~HtmlHelpIndex() |
82 HtmlHelpIndex::~HtmlHelpIndex() |
97 { |
83 { |
98 delete list; |
|
99 delete dict; |
84 delete dict; |
100 } |
85 } |
101 |
86 |
102 /*! Stores an item in the index if it is not already present. |
87 /*! Stores an item in the index if it is not already present. |
103 * Items are stored in alphetical order, by sorting on the |
88 * Items are stored in alphetical order, by sorting on the |
163 * b1 -> link to url#anchor |
147 * b1 -> link to url#anchor |
164 * </pre> |
148 * </pre> |
165 */ |
149 */ |
166 void HtmlHelpIndex::writeFields(QTextStream &t) |
150 void HtmlHelpIndex::writeFields(QTextStream &t) |
167 { |
151 { |
168 IndexFieldListIterator ifli(*list); |
152 dict->sort(); |
|
153 IndexFieldSDict::Iterator ifli(*dict); |
169 IndexField *f; |
154 IndexField *f; |
170 QCString lastLevel1; |
155 QCString lastLevel1; |
171 bool level2Started=FALSE; |
156 bool level2Started=FALSE; |
172 for (;(f=ifli.current());++ifli) |
157 for (;(f=ifli.current());++ifli) |
173 { |
158 { |
504 { |
489 { |
505 t << s << endl; |
490 t << s << endl; |
506 s = indexFiles.next(); |
491 s = indexFiles.next(); |
507 } |
492 } |
508 t << "tabs.css" << endl; |
493 t << "tabs.css" << endl; |
509 t << "tab_b.gif" << endl; |
494 t << "tab_a.png" << endl; |
510 t << "tab_l.gif" << endl; |
495 t << "tab_b.png" << endl; |
511 t << "tab_r.gif" << endl; |
496 t << "tab_h.png" << endl; |
|
497 t << "tab_s.png" << endl; |
|
498 t << "nav_h.png" << endl; |
512 if (Config_getBool("HTML_DYNAMIC_SECTIONS")) |
499 if (Config_getBool("HTML_DYNAMIC_SECTIONS")) |
513 { |
500 { |
514 t << "open.gif" << endl; |
501 t << "open.gif" << endl; |
515 t << "closed.gif" << endl; |
502 t << "closed.gif" << endl; |
516 } |
503 } |