19 #include "kservicegroupfactory.h"
20 #include "tdesycoca.h"
21 #include "tdesycocatype.h"
22 #include "tdesycocadict.h"
27 #include <tdelocale.h>
29 #include <tdeglobal.h>
30 #include <kstandarddirs.h>
32 KServiceGroupFactory::KServiceGroupFactory()
33 : KSycocaFactory( KST_KServiceGroupFactory )
35 m_baseGroupDictOffset = 0;
41 m_baseGroupDictOffset = i;
43 int saveOffset = m_str->device()->at();
45 m_baseGroupDict =
new KSycocaDict(m_str, m_baseGroupDictOffset);
46 m_str->device()->at(saveOffset);
51 m_baseGroupDict =
new KSycocaDict();
56 KServiceGroupFactory::~KServiceGroupFactory()
59 delete m_baseGroupDict;
62 KServiceGroupFactory * KServiceGroupFactory::self()
65 _self =
new KServiceGroupFactory();
69 KServiceGroup * KServiceGroupFactory::findGroupByDesktopPath(
const TQString &_name,
bool deep)
71 if (!m_sycocaDict)
return 0;
77 int offset = m_sycocaDict->find_string( _name );
78 if (!offset)
return 0;
83 if (newGroup && (newGroup->
relPath() != _name))
92 KServiceGroup * KServiceGroupFactory::findBaseGroup(
const TQString &_baseGroupName,
bool deep)
94 if (!m_baseGroupDict)
return 0;
100 int offset = m_baseGroupDict->find_string( _baseGroupName );
101 if (!offset)
return 0;
106 if (newGroup && (newGroup->
baseGroupName() != _baseGroupName))
115 KServiceGroup* KServiceGroupFactory::createGroup(
int offset,
bool deep)
119 TQDataStream *str = KSycoca::self()->findEntry(offset, type);
122 case KST_KServiceGroup:
127 kdError(7011) << TQString(TQString(
"KServiceGroupFactory: unexpected object entry in KSycoca database (type = %1)").arg((
int)type)) << endl;
132 kdError(7011) <<
"KServiceGroupFactory: corrupt object in KSycoca database!\n" << endl;
141 return createGroup(offset,
true);
144 KServiceGroupFactory *KServiceGroupFactory::_self = 0;
146 void KServiceGroupFactory::virtual_hook(
int id,
void* data )
147 { KSycocaFactory::virtual_hook(
id, data ); }
KServiceGroup represents a group of service, for example screensavers.
TQString baseGroupName() const
Returns a non-empty string if the group is a special base group.
virtual TQString relPath() const
Returns the relative path of the service group.
bool isValid() const
Checks whether the entry is valid, returns always true.