File indexing completed on 2024-12-08 06:41: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-only 0006 */ 0007 0008 #ifndef KBUILD_SERVICE_GROUP_FACTORY_H 0009 #define KBUILD_SERVICE_GROUP_FACTORY_H 0010 0011 #include <QStringList> 0012 #include <kservice.h> 0013 #include <kservicegroupfactory_p.h> 0014 0015 /** 0016 * Service group factory for building ksycoca 0017 * @internal 0018 */ 0019 class KBuildServiceGroupFactory : public KServiceGroupFactory 0020 { 0021 public: 0022 /** 0023 * Create factory 0024 */ 0025 explicit KBuildServiceGroupFactory(KSycoca *db); 0026 0027 ~KBuildServiceGroupFactory() override; 0028 0029 /** 0030 * Create new entry. 0031 */ 0032 KServiceGroup *createEntry(const QString &) const override; 0033 0034 KServiceGroup *createEntry(int) const override 0035 { 0036 assert(0); 0037 return nullptr; 0038 } 0039 0040 /** 0041 * Adds the entry @p newEntry to the menu @p menuName 0042 */ 0043 void addNewEntryTo(const QString &menuName, const KService::Ptr &newEntry); 0044 0045 /** 0046 * Adds the entry @p newEntry to the "parent group" @p parent, creating 0047 * the group if necessary. 0048 * A "parent group" is a group of services that all have the same 0049 * "X-KDE-ParentApp". 0050 */ 0051 void addNewChild(const QString &parent, const KSycocaEntry::Ptr &newEntry); 0052 0053 /** 0054 * Add new menu @p menuName defined by @p file 0055 * When @p entry is non-null it is re-used, otherwise a new group is created. 0056 * A pointer to the group is returned. 0057 */ 0058 KServiceGroup::Ptr addNew(const QString &menuName, const QString &file, KServiceGroup::Ptr entry, bool isDeleted); 0059 0060 /** 0061 * Find a group ( by desktop path, e.g. "Applications/Editors") 0062 */ 0063 KServiceGroup::Ptr findGroupByDesktopPath(const QString &_name, bool deep = true) override; 0064 0065 /** 0066 * Add a new menu entry 0067 */ 0068 void addEntry(const KSycocaEntry::Ptr &newEntry) override; 0069 0070 /** 0071 * Write out servicegroup specific index files. 0072 */ 0073 void save(QDataStream &str) override; 0074 0075 /** 0076 * Write out header information 0077 */ 0078 void saveHeader(QDataStream &str) override; 0079 }; 0080 0081 #endif