File indexing completed on 2024-10-27 06:48:36
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 1999, 2007 David Faure <faure@kde.org> 0004 SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KBUILD_SERVICE_FACTORY_H 0010 #define KBUILD_SERVICE_FACTORY_H 0011 0012 #include <QStringList> 0013 0014 #include "kmimeassociations_p.h" 0015 #include <kservicefactory_p.h> 0016 // We export the services to the service group factory! 0017 class KBuildServiceGroupFactory; 0018 class KBuildMimeTypeFactory; 0019 0020 /** 0021 * Service factory for building ksycoca 0022 * @internal 0023 */ 0024 class KBuildServiceFactory : public KServiceFactory 0025 { 0026 public: 0027 /** 0028 * Create factory 0029 */ 0030 KBuildServiceFactory(KBuildMimeTypeFactory *mimeTypeFactory, KBuildServiceGroupFactory *serviceGroupFactory); 0031 0032 ~KBuildServiceFactory() override; 0033 0034 /// Reimplemented from KServiceFactory 0035 KService::Ptr findServiceByDesktopName(const QString &name) override; 0036 /// Reimplemented from KServiceFactory 0037 KService::Ptr findServiceByDesktopPath(const QString &name) override; 0038 /// Reimplemented from KServiceFactory 0039 KService::Ptr findServiceByMenuId(const QString &menuId) override; 0040 0041 /** 0042 * Construct a KService from a config file. 0043 */ 0044 KSycocaEntry *createEntry(const QString &file) const override; 0045 0046 KService *createEntry(int) const override 0047 { 0048 assert(0); 0049 return nullptr; 0050 } 0051 0052 /** 0053 * Add a new entry. 0054 */ 0055 void addEntry(const KSycocaEntry::Ptr &newEntry) override; 0056 0057 /** 0058 * Write out service specific index files. 0059 */ 0060 void save(QDataStream &str) override; 0061 0062 /** 0063 * Write out header information 0064 * 0065 * Don't forget to call the parent first when you override 0066 * this function. 0067 */ 0068 void saveHeader(QDataStream &str) override; 0069 0070 void postProcessServices(); 0071 0072 private: 0073 void populateServiceTypes(); 0074 void saveOfferList(QDataStream &str); 0075 void collectInheritedServices(); 0076 void collectInheritedServices(const QString &mime, QSet<QString> &visitedMimes); 0077 0078 QHash<QString, KService::Ptr> m_nameMemoryHash; // m_nameDict is not usable while building ksycoca 0079 QHash<QString, KService::Ptr> m_relNameMemoryHash; // m_relNameDict is not usable while building ksycoca 0080 QHash<QString, KService::Ptr> m_menuIdMemoryHash; // m_menuIdDict is not usable while building ksycoca 0081 QSet<KSycocaEntry::Ptr> m_dupeDict; 0082 0083 KOfferHash m_offerHash; 0084 0085 KBuildMimeTypeFactory *m_mimeTypeFactory; 0086 KBuildServiceGroupFactory *m_serviceGroupFactory; 0087 }; 0088 0089 #endif