|
1 /****************************************************************************** |
|
2 * |
|
3 * |
|
4 * |
|
5 * |
|
6 * Copyright (C) 1997-2008 by Dimitri van Heesch. |
|
7 * |
|
8 * Permission to use, copy, modify, and distribute this software and its |
|
9 * documentation under the terms of the GNU General Public License is hereby |
|
10 * granted. No representations are made about the suitability of this software |
|
11 * for any purpose. It is provided "as is" without express or implied warranty. |
|
12 * See the GNU General Public License for more details. |
|
13 * |
|
14 * Documents produced by Doxygen are derivative works derived from the |
|
15 * input used in their production; they are not affected by this license. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <stdio.h> |
|
20 #include "reflist.h" |
|
21 #include "util.h" |
|
22 |
|
23 /*! Create a list of items that are cross referenced with documentation blocks |
|
24 * @param listName String representing the name of the list. |
|
25 * @param pageTitle String representing the title of the list page. |
|
26 * @param secTitle String representing the title of the section. |
|
27 */ |
|
28 RefList::RefList(const char *listName, |
|
29 const char *pageTitle, |
|
30 const char *secTitle |
|
31 ) |
|
32 { |
|
33 m_itemList = 0; |
|
34 m_dict = 0; |
|
35 m_dictIterator = 0; |
|
36 m_id = 0; |
|
37 m_listName = listName; |
|
38 m_pageTitle = pageTitle; |
|
39 m_secTitle = secTitle; |
|
40 } |
|
41 |
|
42 /*! Destroy the todo list. Currently not called! */ |
|
43 RefList::~RefList() |
|
44 { |
|
45 delete m_dictIterator; |
|
46 delete m_dict; |
|
47 delete m_itemList; |
|
48 } |
|
49 |
|
50 /*! Adds a new item to the list. |
|
51 * \returns A unique id for this item. |
|
52 */ |
|
53 int RefList::addRefItem() |
|
54 { |
|
55 if (m_dict==0) |
|
56 { |
|
57 m_dict = new QIntDict<RefItem>(1009); |
|
58 m_dict->setAutoDelete(TRUE); |
|
59 m_dictIterator = new QIntDictIterator<RefItem>(*m_dict); |
|
60 } |
|
61 RefItem *item = new RefItem; |
|
62 m_id++; |
|
63 m_dict->insert(m_id,item); |
|
64 return m_id; |
|
65 } |
|
66 |
|
67 /*! Returns an item given it's id that is obtained with addRefItem() |
|
68 * \param itemId item's identifier. |
|
69 * \returns A pointer to the todo item's structure. |
|
70 */ |
|
71 RefItem *RefList::getRefItem(int itemId) |
|
72 { |
|
73 return m_dict ? m_dict->find(itemId) : 0; |
|
74 } |
|
75 |
|
76 /*! Returns the first item in the dictionary or 0 if |
|
77 * non is available. |
|
78 * Items are not sorted. |
|
79 */ |
|
80 RefItem *RefList::getFirstRefItem() |
|
81 { |
|
82 return m_dictIterator ? m_dictIterator->toFirst() : 0; |
|
83 } |
|
84 |
|
85 /*! Returns the next item in the dictionary or 0 if |
|
86 * we are at the end of the list. |
|
87 * Items are not sorted. |
|
88 */ |
|
89 RefItem *RefList::getNextRefItem() |
|
90 { |
|
91 return m_dictIterator ? m_dictIterator->operator++() : 0; |
|
92 } |
|
93 |
|
94 /*! Returns the name of the list as set in the constructor. */ |
|
95 QCString RefList::listName() const |
|
96 { |
|
97 return m_listName; |
|
98 } |
|
99 |
|
100 QCString RefList::pageTitle() const |
|
101 { |
|
102 return m_pageTitle; |
|
103 } |
|
104 |
|
105 QCString RefList::sectionTitle() const |
|
106 { |
|
107 return m_secTitle; |
|
108 } |
|
109 |
|
110 void RefList::insertIntoList(const char *key,RefItem *item) |
|
111 { |
|
112 if (m_itemList==0) |
|
113 { |
|
114 m_itemList = new SortedRefItems(1009); |
|
115 } |
|
116 RefItem *ri = m_itemList->find(key); |
|
117 if (ri==0) |
|
118 { |
|
119 m_itemList->append(key,item); |
|
120 } |
|
121 else // item already added to the list (i.e. multiple item for the same |
|
122 // entity) |
|
123 { |
|
124 if (ri!=item) |
|
125 { |
|
126 ri->extraItems.append(item); |
|
127 } |
|
128 } |
|
129 } |
|
130 |
|
131 void RefList::generatePage() |
|
132 { |
|
133 if (m_itemList==0) return; |
|
134 m_itemList->sort(); |
|
135 SDict<RefItem>::Iterator it(*m_itemList); |
|
136 RefItem *item; |
|
137 for (it.toFirst();(item=it.current());++it) |
|
138 { |
|
139 QCString doc; |
|
140 doc = "\\anchor "; |
|
141 doc += item->listAnchor; |
|
142 doc += " <dl><dt>"; |
|
143 doc += item->prefix; |
|
144 doc += " \\_internalref "; |
|
145 doc += item->name; |
|
146 doc += " \""; |
|
147 doc += item->title; |
|
148 doc += "\""; |
|
149 if (!item->args.isEmpty()) doc += item->args; |
|
150 doc += "</dt>\n<dd>"; |
|
151 doc += item->text; |
|
152 QListIterator<RefItem> li(item->extraItems); |
|
153 RefItem *extraItem; |
|
154 for (li.toFirst();(extraItem=li.current());++li) |
|
155 { |
|
156 doc += "<p>" + extraItem->text; |
|
157 } |
|
158 doc += "</dd></dl>\n"; |
|
159 addRelatedPage(m_listName,m_pageTitle,doc,0,m_listName,1,0,0,0); |
|
160 } |
|
161 } |
|
162 |