1/* This file is part of the KDE project
2 Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#ifndef KDED_KBUILD_SERVICE_GROUP_FACTORY_H
20#define KDED_KBUILD_SERVICE_GROUP_FACTORY_H
21
22#include <kservice.h>
23#include <kservicegroupfactory.h>
24#include <QtCore/QStringList>
25
26/**
27 * Service group factory for building ksycoca
28 * @internal
29 */
30class KBuildServiceGroupFactory : public KServiceGroupFactory
31{
32public:
33 /**
34 * Create factory
35 */
36 KBuildServiceGroupFactory();
37
38 virtual ~KBuildServiceGroupFactory();
39
40 /**
41 * Create new entry.
42 */
43 virtual KServiceGroup * createEntry(const QString &, const char *) const;
44
45 virtual KServiceGroup * createEntry(int) const { assert(0); return 0L; }
46
47 /**
48 * Adds the entry @p newEntry to the menu @p menuName
49 */
50 void addNewEntryTo( const QString &menuName, const KService::Ptr& newEntry);
51
52 /**
53 * Adds the entry @p newEntry to the "parent group" @p parent, creating
54 * the group if necassery.
55 * A "parent group" is a group of services that all have the same
56 * "X-KDE-ParentApp".
57 */
58 void addNewChild( const QString &parent, const KSycocaEntry::Ptr& newEntry);
59
60 /**
61 * Add new menu @p menuName defined by @p file
62 * When @p entry is non-null it is re-used, otherwise a new group is created.
63 * A pointer to the group is returned.
64 */
65 KServiceGroup::Ptr addNew( const QString &menuName, const QString& file, KServiceGroup::Ptr entry, bool isDeleted);
66
67 /**
68 * Find a group ( by desktop path, e.g. "Applications/Editors")
69 */
70 virtual KServiceGroup::Ptr findGroupByDesktopPath( const QString &_name, bool deep = true );
71
72 /**
73 * Add a new menu entry
74 */
75 virtual void addEntry(const KSycocaEntry::Ptr& newEntry);
76
77 /**
78 * Write out servicegroup specific index files.
79 */
80 virtual void save(QDataStream &str);
81
82 /**
83 * Write out header information
84 */
85 virtual void saveHeader(QDataStream &str);
86
87 /**
88 * Returns all resource types for this service factory
89 */
90 static QStringList resourceTypes();
91};
92
93#endif
94