1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2000 Waldo Bastian <bastian@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KSERVICEGROUPFACTORY_P_H
9#define KSERVICEGROUPFACTORY_P_H
10
11#include "kservicegroup.h"
12#include "ksycocafactory_p.h"
13#include <assert.h>
14
15class KSycoca;
16class KSycocaDict;
17
18/**
19 * @internal
20 * A sycoca factory for service groups (e.g. list of applications)
21 * It loads the services from parsing directories (e.g. share/applications/)
22 *
23 * Exported for kbuildsycoca, but not installed.
24 */
25class KServiceGroupFactory : public KSycocaFactory
26{
27 K_SYCOCAFACTORY(KST_KServiceGroupFactory)
28public:
29 /**
30 * Create factory
31 */
32 explicit KServiceGroupFactory(KSycoca *db);
33 ~KServiceGroupFactory() override;
34
35 /**
36 * Construct a KServiceGroup from a config file.
37 */
38 KSycocaEntry *createEntry(const QString &) const override
39 {
40 assert(0);
41 return nullptr;
42 }
43
44 /**
45 * Find a group ( by desktop path, e.g. "Applications/Editors")
46 */
47 virtual KServiceGroup::Ptr findGroupByDesktopPath(const QString &_name, bool deep = true);
48
49 /**
50 * Find a base group by name, e.g. "settings"
51 */
52 KServiceGroup::Ptr findBaseGroup(const QString &_baseGroupName, bool deep = true);
53
54 /**
55 * @return the unique service group factory, creating it if necessary
56 */
57 static KServiceGroupFactory *self();
58
59protected:
60 KServiceGroup *createGroup(int offset, bool deep) const;
61 KServiceGroup *createEntry(int offset) const override;
62 KSycocaDict *m_baseGroupDict;
63 int m_baseGroupDictOffset;
64
65protected:
66 void virtual_hook(int id, void *data) override;
67
68private:
69 class KServiceGroupFactoryPrivate *d;
70};
71
72#endif
73

source code of kservice/src/services/kservicegroupfactory_p.h