blob: bc9113cc31ff9839c8fa22da7875b1797dce03c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
#ifndef KDEEDUGLOSSARY_H
#define KDEEDUGLOSSARY_H
/***************************************************************************
copyright : (C) 2005 by Carsten Niehaus
email : cniehaus@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <khtml_part.h>
#include <kdialogbase.h>
class TQChar;
class TQDomDocument;
class TQListViewItem;
class KListView;
class KListViewSearchLine;
class KActionCollection;
class GlossaryItem;
/**
* @class Glossary
* @author Carsten Niehaus
*
* This class stores all items to be displayed. It also
* has access-methods to the items
*/
class Glossary
{
public:
Glossary();
virtual ~Glossary();
/**
* add the item @p item to the glossary
*/
void addItem( GlossaryItem* item ){
m_itemlist.append( item );
}
TQValueList<GlossaryItem*> itemlist()const{
return m_itemlist;
}
/**
* clear the Glossary
*/
void clear(){
m_itemlist.clear();
}
/**
* does this glossary have items?
*/
bool isEmpty() const;
/**
* Every glossary can have a name. It will be
* set to @p name
*/
void setName( const TQString& name ){
m_name = name;
}
/**
* @returns the name of the glossary
*/
TQString name()const{
return m_name;
}
/**
* sets the internal list of items to @p list
*/
void setItemlist( TQValueList<GlossaryItem*> list ){
m_itemlist = list;
}
/**
* Read a glossary from an XML file.
*
* @param url The path of the file to load
* @param path The path of the pictures. Will be used as m_picturepath
*
* @return a pointer to the loaded glossary. Even in case of
* error, this won't return 0 but an empty Glossary.
*/
static Glossary* readFromXML( const KURL& url, const TQString& path = 0 );
/**
* Every glossaryitem can show pictures. [img src="foo.png]
* will look for the file foo.png in the path defined be
* @p path
*/
void setPicturePath( const TQString& path ){
m_picturepath = path;
}
TQString picturePath()const{
return m_picturepath;
}
/**
* defines which picture to use as the background
* of the htmlview. The dialog
* will use the file specifiec by the @p filename
*/
void setBackgroundPicture( const TQString& filename ){
m_backgroundpicture = filename;
}
/**
* @return the picuture used as the background in
* this background
*/
TQString backgroundPicture()const{
return m_backgroundpicture;
}
private:
/**
* This methods parses the given xml-code. It will extract
* the information of the items and return them as a
* TQValueList<GlossaryItem*>
*/
virtual TQValueList<GlossaryItem*> readItems( TQDomDocument &itemDocument );
TQString m_backgroundpicture;
/**
* tqreplaces the [img]-pseudocode with valid html. The path where
* the pictures are stored will be used for pictures
*/
void fixImagePath();
/**
* the path in which pictures of the glossary will be searched
*/
TQString m_picturepath;
/**
* Load the tqlayout from an XML file.
*
* @param doc The TQDomDocument which will contain the read XML
* contents.
* @param url The path of the file to load
*
* @return a bool indicating whether the loading of the XML was
* successfull or not
*/
bool loadLayout( TQDomDocument& doc, const KURL& url );
TQValueList<GlossaryItem*> m_itemlist;
/**
* the name of the glossary
*/
TQString m_name;
};
/**
* @class GlossaryItem
* @author Carsten Niehaus
*
* A GlossaryItem stores the information of the content of
* the item and its name. Furthermore, every item can have
* a number of pictures or references associated to it.
* These are stored as QStringLists.
*/
class GlossaryItem
{
public:
GlossaryItem(){}
~GlossaryItem(){}
void setName( const TQString& s ){
m_name = s;
}
void setDesc( const TQString& s){
m_desc = s;
}
void setRef( const TQStringList& s){
m_ref = s;
}
void setPictures( const TQString& s ){
m_pic = s;
}
TQString name() const {
return m_name;
}
TQString desc() const {
return m_desc;
}
TQStringList ref() const {
return m_ref;
}
TQStringList pictures() const {
return m_pic;
}
/**
* @return the formated HTML code for current item.
**/
TQString toHtml() const;
/**
* This method parses the references.
* @return the HTML code with the references as HTML links
*/
TQString parseReferences() const;
private:
TQString m_name;
TQString m_desc;
TQStringList m_ref;
TQStringList m_pic;
};
/**
* @class GlossaryDialog
* @author Pino Toscano
* @author Carsten Niehaus
*/
class GlossaryDialog : public KDialogBase
{
Q_OBJECT
public:
GlossaryDialog( bool folded = true, TQWidget *parent=0, const char *name=0);
~GlossaryDialog();
void keyPressEvent(TQKeyEvent*);
/**
* add a new glossary
*
* @param newgloss the new glossary to add
*/
void addGlossary( Glossary* newgloss );
private:
TQValueList<Glossary*> m_glossaries;
/**
* if true the items will be displayed folded
*/
bool m_folded;
void updateTree();
KHTMLPart *m_htmlpart;
KListView *m_glosstree;
TQString m_htmlbasestring;
KActionCollection* m_actionCollection;
TQListViewItem* findTreeWithLetter( const TQChar&, TQListViewItem* );
KListViewSearchLine *m_search;
private slots:
void slotClicked( TQListViewItem * );
/**
* The user clicked on a href. Emit the corresponding item
*/
void displayItem( const KURL& url, const KParts::URLArgs& args );
protected slots:
virtual void slotClose();
signals:
void closed();
};
#endif // KDEEDUGLOSSARY_H
|