Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / runtime / khelpcenter / glossary.h
blobffcb3ee332d2c1637a4974811e5e3f21f022a371
1 /*
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>
26 #include <QList>
27 #include <ksharedconfig.h>
28 #include <QHash>
29 #include <KProcess>
31 class EntryItem;
33 namespace KHC {
35 class GlossaryEntryXRef
37 friend QDataStream &operator>>( QDataStream &, GlossaryEntryXRef & );
38 public:
39 typedef QList<GlossaryEntryXRef> List;
41 GlossaryEntryXRef() {}
42 GlossaryEntryXRef( const QString &term, const QString &id ) :
43 m_term( term ),
44 m_id( id )
48 QString term() const { return m_term; }
49 QString id() const { return m_id; }
51 private:
52 QString m_term;
53 QString 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;
66 class GlossaryEntry
68 friend QDataStream &operator>>( QDataStream &, GlossaryEntry & );
69 public:
70 GlossaryEntry() {}
71 GlossaryEntry( const QString &term, const QString &definition,
72 const GlossaryEntryXRef::List &seeAlso ) :
73 m_term( term ),
74 m_definition( definition ),
75 m_seeAlso( seeAlso )
79 QString term() const { return m_term; }
80 QString definition() const { return m_definition; }
81 GlossaryEntryXRef::List seeAlso() const { return m_seeAlso; }
83 private:
84 QString m_term;
85 QString m_definition;
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
101 Q_OBJECT
102 public:
103 Glossary( QWidget *parent );
104 virtual ~Glossary();
106 const GlossaryEntry &entry( const QString &id ) const;
108 static QString entryToHtml( const GlossaryEntry &entry );
110 public Q_SLOTS:
111 void slotSelectGlossEntry( const QString &id );
113 Q_SIGNALS:
114 void entrySelected( const GlossaryEntry &entry );
116 private Q_SLOTS:
117 void meinprocFinished(int exitCode, QProcess::ExitStatus exitStatus);
118 void treeItemSelected( Q3ListViewItem *item );
120 protected:
121 virtual void showEvent(QShowEvent *event);
123 private:
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;
136 QString m_cacheFile;
137 CacheStatus m_status;
138 QHash<QString, GlossaryEntry*> m_glossEntries;
139 QHash<QString, EntryItem*> m_idDict;
140 bool m_initialized;
141 static bool m_alreadyWarned;
146 #endif // KHC_GLOSSARY_H
147 // vim:ts=2:sw=2:et