1 | |
2 | /* This file is part of the KDE project |
3 | Copyright 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | |
5 | This program is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU General Public |
7 | License version 2 or at your option version 3 as published |
8 | by the Free Software Foundation. |
9 | |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU General Public License |
16 | along with this program; see the file COPYING. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef KHC_DOCMETAINFO_H |
22 | #define KHC_DOCMETAINFO_H |
23 | |
24 | #include <QDir> |
25 | #include <QMap> |
26 | |
27 | #include "docentry.h" |
28 | |
29 | namespace KHC { |
30 | |
31 | class HTMLSearch; |
32 | class DocEntryTraverser; |
33 | |
34 | /*! |
35 | This class provides some meta information about help documents. |
36 | */ |
37 | class DocMetaInfo |
38 | { |
39 | public: |
40 | /*! |
41 | Return instance of DocMetaInfo. There can only be one instance at a time. |
42 | */ |
43 | static DocMetaInfo *self(); |
44 | |
45 | ~DocMetaInfo(); |
46 | |
47 | void scanMetaInfo( bool force = false ); |
48 | |
49 | DocEntry *addDocEntry( const QString &fileName ); |
50 | |
51 | void addDocEntry( DocEntry * ); |
52 | |
53 | DocEntry::List docEntries(); |
54 | |
55 | DocEntry::List searchEntries(); |
56 | |
57 | void traverseEntries( DocEntryTraverser * ); |
58 | |
59 | void startTraverseEntries( DocEntryTraverser *traverser ); |
60 | void startTraverseEntry( DocEntry *entry, DocEntryTraverser *traverser ); |
61 | void endProcess( DocEntry *entry, DocEntryTraverser *traverser ); |
62 | void endTraverseEntries( DocEntryTraverser * ); |
63 | |
64 | static QString languageName( const QString &langcode ); |
65 | |
66 | protected: |
67 | DocEntry *scanMetaInfoDir( const QString &filename, DocEntry *parent ); |
68 | DocEntry *addDirEntry( const QDir &dir, DocEntry *parent ); |
69 | void traverseEntry( DocEntry *, DocEntryTraverser * ); |
70 | |
71 | private: |
72 | /*! |
73 | DocMetaInfo is a singleton. Private constructor prevents direct |
74 | instantisation. |
75 | */ |
76 | DocMetaInfo(); |
77 | |
78 | DocEntry::List mDocEntries; |
79 | DocEntry::List mSearchEntries; |
80 | |
81 | DocEntry mRootEntry; |
82 | |
83 | QStringList mLanguages; |
84 | |
85 | QMap<QString,QString> mLanguageNames; |
86 | |
87 | HTMLSearch *mHtmlSearch; |
88 | |
89 | static bool mLoaded; |
90 | |
91 | static DocMetaInfo *mSelf; |
92 | }; |
93 | |
94 | } |
95 | |
96 | #endif //KHC_DOCMETAINFO_H |
97 | // vim:ts=2:sw=2:et |
98 | |