File indexing completed on 2024-05-12 05:46:38

0001 /* This file is part of the KDE project
0002    Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License version 2as published by the Free Software Foundation.
0007 
0008    This library is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    Library General Public License for more details.
0012 
0013    You should have received a copy of the GNU Library General Public License
0014    along with this library; see the file COPYING.LIB.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #ifndef KBUILD_SERVICE_GROUP_FACTORY_H
0020 #define KBUILD_SERVICE_GROUP_FACTORY_H
0021 
0022 #include <kservice.h>
0023 #include <kservicegroupfactory_p.h>
0024 #include <QStringList>
0025 
0026 /**
0027  * Service group factory for building ksycoca
0028  * @internal
0029  */
0030 class KBuildServiceGroupFactory : public KServiceGroupFactory
0031 {
0032 public:
0033     /**
0034      * Create factory
0035      */
0036     explicit KBuildServiceGroupFactory(KSycoca *db);
0037 
0038     ~KBuildServiceGroupFactory() override;
0039 
0040     /**
0041      * Create new entry.
0042      */
0043     KServiceGroup *createEntry(const QString &) const override;
0044 
0045     KServiceGroup *createEntry(int) const override
0046     {
0047         assert(0);
0048         return nullptr;
0049     }
0050 
0051     /**
0052      * Adds the entry @p newEntry to the menu @p menuName
0053      */
0054     void addNewEntryTo(const QString &menuName, const KService::Ptr &newEntry);
0055 
0056     /**
0057      * Adds the entry @p newEntry to the "parent group" @p parent, creating
0058      * the group if necassery.
0059      * A "parent group" is a group of services that all have the same
0060      * "X-KDE-ParentApp".
0061      */
0062     void addNewChild(const QString &parent, const KSycocaEntry::Ptr &newEntry);
0063 
0064     /**
0065      * Add new menu @p menuName defined by @p file
0066      * When @p entry is non-null it is re-used, otherwise a new group is created.
0067      * A pointer to the group is returned.
0068      */
0069     KServiceGroup::Ptr addNew(const QString &menuName, const QString &file, KServiceGroup::Ptr entry, bool isDeleted);
0070 
0071     /**
0072      * Find a group ( by desktop path, e.g. "Applications/Editors")
0073      */
0074     KServiceGroup::Ptr findGroupByDesktopPath(const QString &_name, bool deep = true) override;
0075 
0076     /**
0077      * Add a new menu entry
0078      */
0079     void addEntry(const KSycocaEntry::Ptr &newEntry) override;
0080 
0081     /**
0082      * Write out servicegroup  specific index files.
0083      */
0084     void save(QDataStream &str) override;
0085 
0086     /**
0087      * Write out header information
0088      */
0089     void saveHeader(QDataStream &str) override;
0090 };
0091 
0092 #endif