19 #include "kbuildservicegroupfactory.h"
21 #include "ksycocadict.h"
22 #include "kresourcelist.h"
25 #include <kstandarddirs.h>
26 #include <kmessageboxwrapper.h>
32 KServiceGroupFactory()
34 m_resourceList =
new KSycocaResourceList();
42 return TQStringList();
45 KBuildServiceGroupFactory::~KBuildServiceGroupFactory()
47 delete m_resourceList;
54 kdWarning(
"!!!! KBuildServiceGroupFactory::createEntry called!");
61 KServiceGroup *entry = 0;
62 KSycocaEntry::Ptr *ptr = m_entryDict->find(menuName);
64 entry =
dynamic_cast<KServiceGroup *
>(ptr->data());
68 kdWarning(7021) <<
"KBuildServiceGroupFactory::addNewEntryTo( " << menuName <<
", " << newEntry->name() <<
" ): menu does not exists!" << endl;
71 entry->addEntry( newEntry );
77 KSycocaEntry::Ptr *ptr = m_entryDict->find(menuName);
80 kdWarning(7021) <<
"KBuildServiceGroupFactory::addNew( " << menuName <<
", " << file <<
" ): menu already exists!" << endl;
81 return static_cast<KServiceGroup *
>(
static_cast<KSycocaEntry *
>(*ptr));
86 entry =
new KServiceGroup(file, menuName);
88 entry->m_childCount = -1;
95 KServiceGroup *parentEntry = 0;
96 TQString parent = menuName.left(menuName.length()-1);
97 int i = parent.findRev(
'/');
99 parent = parent.left(i+1);
104 ptr = m_entryDict->find(parent);
106 parentEntry =
dynamic_cast<KServiceGroup *
>(ptr->data());
109 kdWarning(7021) <<
"KBuildServiceGroupFactory::addNew( " << menuName <<
", " << file <<
" ): parent menu does not exist!" << endl;
113 if (!isDeleted && !entry->isDeleted())
114 parentEntry->addEntry( entry );
123 TQString name =
"#parent#"+parent;
125 KServiceGroup *entry = 0;
126 KSycocaEntry::Ptr *ptr = m_entryDict->find(name);
128 entry =
dynamic_cast<KServiceGroup *
>(ptr->data());
132 entry =
new KServiceGroup(name);
136 entry->addEntry( newEntry );
146 KServiceGroup * serviceGroup = (KServiceGroup *) newEntry;
147 serviceGroup->m_serviceList.clear();
149 if ( !serviceGroup->baseGroupName().isEmpty() )
151 m_baseGroupDict->add( serviceGroup->baseGroupName(), newEntry );
160 str << (TQ_INT32) m_baseGroupDictOffset;
168 m_baseGroupDictOffset = str.device()->at();
169 m_baseGroupDict->save(str);
171 int endOfFactoryData = str.device()->at();
177 str.device()->at(endOfFactoryData);