File indexing completed on 2024-12-01 06:46:31

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2000 Waldo Bastian <bastian@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KSERVICEGROUPFACTORY_P_H
0009 #define KSERVICEGROUPFACTORY_P_H
0010 
0011 #include "kservicegroup.h"
0012 #include "ksycocafactory_p.h"
0013 #include <assert.h>
0014 
0015 class KSycoca;
0016 class KSycocaDict;
0017 
0018 /**
0019  * @internal
0020  * A sycoca factory for service groups (e.g. list of applications)
0021  * It loads the services from parsing directories (e.g. share/applications/)
0022  *
0023  * Exported for kbuildsycoca, but not installed.
0024  */
0025 class KServiceGroupFactory : public KSycocaFactory
0026 {
0027     K_SYCOCAFACTORY(KST_KServiceGroupFactory)
0028 public:
0029     /**
0030      * Create factory
0031      */
0032     explicit KServiceGroupFactory(KSycoca *db);
0033     ~KServiceGroupFactory() override;
0034 
0035     /**
0036      * Construct a KServiceGroup from a config file.
0037      */
0038     KSycocaEntry *createEntry(const QString &) const override
0039     {
0040         assert(0);
0041         return nullptr;
0042     }
0043 
0044     /**
0045      * Find a group ( by desktop path, e.g. "Applications/Editors")
0046      */
0047     virtual KServiceGroup::Ptr findGroupByDesktopPath(const QString &_name, bool deep = true);
0048 
0049     /**
0050      * Find a base group by name, e.g. "settings"
0051      */
0052     KServiceGroup::Ptr findBaseGroup(const QString &_baseGroupName, bool deep = true);
0053 
0054     /**
0055      * @return the unique service group factory, creating it if necessary
0056      */
0057     static KServiceGroupFactory *self();
0058 
0059 protected:
0060     KServiceGroup *createGroup(int offset, bool deep) const;
0061     KServiceGroup *createEntry(int offset) const override;
0062     KSycocaDict *m_baseGroupDict;
0063     int m_baseGroupDictOffset;
0064 
0065 protected:
0066     void virtual_hook(int id, void *data) override;
0067 
0068 private:
0069     class KServiceGroupFactoryPrivate *d;
0070 };
0071 
0072 #endif