1 | /* This file is part of the KDE project |
2 | Copyright (C) 2000 Waldo Bastian <bastian@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License version 2 as published by the Free Software Foundation. |
7 | |
8 | This library is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | Library General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU Library General Public License |
14 | along with this library; see the file COPYING.LIB. If not, write to |
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
16 | Boston, MA 02110-1301, USA. |
17 | */ |
18 | |
19 | #ifndef KSERVICEGROUPFACTORY_H |
20 | #define KSERVICEGROUPFACTORY_H |
21 | |
22 | #include <QtCore/QStringList> |
23 | |
24 | #include "kservicegroup.h" |
25 | #include "ksycocafactory.h" |
26 | #include <assert.h> |
27 | |
28 | class KSycoca; |
29 | class KSycocaDict; |
30 | |
31 | /** |
32 | * @internal |
33 | * A sycoca factory for service groups (e.g. list of applications) |
34 | * It loads the services from parsing directories (e.g. applnk/) |
35 | * |
36 | * Exported for kbuildsycoca, but not installed. |
37 | */ |
38 | class KDECORE_EXPORT KServiceGroupFactory : public KSycocaFactory |
39 | { |
40 | K_SYCOCAFACTORY( KST_KServiceGroupFactory ) |
41 | public: |
42 | /** |
43 | * Create factory |
44 | */ |
45 | KServiceGroupFactory(); |
46 | virtual ~KServiceGroupFactory(); |
47 | |
48 | /** |
49 | * Construct a KServiceGroup from a config file. |
50 | */ |
51 | virtual KSycocaEntry *createEntry(const QString &, const char *) const |
52 | { assert(0); return 0; } |
53 | |
54 | /** |
55 | * Find a group ( by desktop path, e.g. "Applications/Editors") |
56 | */ |
57 | virtual KServiceGroup::Ptr findGroupByDesktopPath( const QString &_name, bool deep = true ); |
58 | |
59 | /** |
60 | * Find a base group by name, e.g. "settings" |
61 | */ |
62 | KServiceGroup::Ptr findBaseGroup( const QString &_baseGroupName, bool deep = true ); |
63 | |
64 | /** |
65 | * @return the unique service group factory, creating it if necessary |
66 | */ |
67 | static KServiceGroupFactory * self(); |
68 | protected: |
69 | KServiceGroup* createGroup(int offset, bool deep) const; |
70 | KServiceGroup* createEntry(int offset) const; |
71 | KSycocaDict *m_baseGroupDict; |
72 | int m_baseGroupDictOffset; |
73 | |
74 | protected: |
75 | virtual void virtual_hook( int id, void* data ); |
76 | private: |
77 | class KServiceGroupFactoryPrivate* d; |
78 | }; |
79 | |
80 | #endif |
81 | |