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 <klistview.h>
27
#include <qstringlist.h>
36
class GlossaryEntryXRef
38
friend QDataStream &operator>>( QDataStream &, GlossaryEntryXRef & );
40
typedef QValueList<GlossaryEntryXRef> List;
42
GlossaryEntryXRef() {}
43
GlossaryEntryXRef( const QString &term, const QString &id ) :
49
QString term() const { return m_term; }
50
QString id() const { return m_id; }
57
inline QDataStream &operator<<( QDataStream &stream, const GlossaryEntryXRef &e )
59
return stream << e.term() << e.id();
62
inline QDataStream &operator>>( QDataStream &stream, GlossaryEntryXRef &e )
64
return stream >> e.m_term >> e.m_id;
69
friend QDataStream &operator>>( QDataStream &, GlossaryEntry & );
72
GlossaryEntry( const QString &term, const QString &definition,
73
const GlossaryEntryXRef::List &seeAlso ) :
75
m_definition( definition ),
80
QString term() const { return m_term; }
81
QString definition() const { return m_definition; }
82
GlossaryEntryXRef::List seeAlso() const { return m_seeAlso; }
87
GlossaryEntryXRef::List m_seeAlso;
90
inline QDataStream &operator<<( QDataStream &stream, const GlossaryEntry &e )
92
return stream << e.term() << e.definition() << e.seeAlso();
95
inline QDataStream &operator>>( QDataStream &stream, GlossaryEntry &e )
97
return stream >> e.m_term >> e.m_definition >> e.m_seeAlso;
100
class Glossary : public KListView
104
Glossary( QWidget *parent );
107
const GlossaryEntry &entry( const QString &id ) const;
109
static QString entryToHtml( const GlossaryEntry &entry );
114
void slotSelectGlossEntry( const QString &id );
117
void entrySelected( const GlossaryEntry &entry );
120
void meinprocExited( KProcess *meinproc );
121
void treeItemSelected( QListViewItem *item );
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 );
133
QListViewItem *m_byTopicItem;
134
QListViewItem *m_alphabItem;
135
QString m_sourceFile;
137
CacheStatus m_status;
138
QDict<GlossaryEntry> m_glossEntries;
139
QDict<EntryItem> m_idDict;
145
#endif // KHC_GLOSSARY_H