2 * glossary.h - part of the KDE Help Center
4 * Copyright (C) 2002 Frerich Raabe (raabe@kde.org)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef KHC_GLOSSARY_H
21 #define KHC_GLOSSARY_H
23 #include <k3listview.h>
25 #include <QDomElement>
27 #include <ksharedconfig.h>
35 class GlossaryEntryXRef
37 friend QDataStream
&operator>>( QDataStream
&, GlossaryEntryXRef
& );
39 typedef QList
<GlossaryEntryXRef
> List
;
41 GlossaryEntryXRef() {}
42 GlossaryEntryXRef( const QString
&term
, const QString
&id
) :
48 QString
term() const { return m_term
; }
49 QString
id() const { return m_id
; }
56 inline QDataStream
&operator<<( QDataStream
&stream
, const GlossaryEntryXRef
&e
)
58 return stream
<< e
.term() << e
.id();
61 inline QDataStream
&operator>>( QDataStream
&stream
, GlossaryEntryXRef
&e
)
63 return stream
>> e
.m_term
>> e
.m_id
;
68 friend QDataStream
&operator>>( QDataStream
&, GlossaryEntry
& );
71 GlossaryEntry( const QString
&term
, const QString
&definition
,
72 const GlossaryEntryXRef::List
&seeAlso
) :
74 m_definition( definition
),
79 QString
term() const { return m_term
; }
80 QString
definition() const { return m_definition
; }
81 GlossaryEntryXRef::List
seeAlso() const { return m_seeAlso
; }
86 GlossaryEntryXRef::List m_seeAlso
;
89 inline QDataStream
&operator<<( QDataStream
&stream
, const GlossaryEntry
&e
)
91 return stream
<< e
.term() << e
.definition() << e
.seeAlso();
94 inline QDataStream
&operator>>( QDataStream
&stream
, GlossaryEntry
&e
)
96 return stream
>> e
.m_term
>> e
.m_definition
>> e
.m_seeAlso
;
99 class Glossary
: public K3ListView
103 Glossary( QWidget
*parent
);
106 const GlossaryEntry
&entry( const QString
&id
) const;
108 static QString
entryToHtml( const GlossaryEntry
&entry
);
111 void slotSelectGlossEntry( const QString
&id
);
114 void entrySelected( const GlossaryEntry
&entry
);
117 void meinprocFinished(int exitCode
, QProcess::ExitStatus exitStatus
);
118 void treeItemSelected( Q3ListViewItem
*item
);
121 virtual void showEvent(QShowEvent
*event
);
124 enum CacheStatus
{ NeedRebuild
, CacheOk
};
126 CacheStatus
cacheStatus() const;
127 int glossaryCTime() const;
128 void rebuildGlossaryCache();
129 void buildGlossaryTree();
130 QDomElement
childElement( const QDomElement
&e
, const QString
&name
);
132 KSharedConfigPtr m_config
;
133 Q3ListViewItem
*m_byTopicItem
;
134 Q3ListViewItem
*m_alphabItem
;
135 QString m_sourceFile
;
137 CacheStatus m_status
;
138 QHash
<QString
, GlossaryEntry
*> m_glossEntries
;
139 QHash
<QString
, EntryItem
*> m_idDict
;
141 static bool m_alreadyWarned
;
146 #endif // KHC_GLOSSARY_H