21 #include "kdatatool.h"
23 #include <kstandarddirs.h>
24 #include <klibloader.h>
26 #include <kinstance.h>
29 #include <tdeparts/componentfactory.h>
50 if ( !!m_service && !m_service->serviceTypes().contains(
"KDataTool" ) )
52 kdDebug(30003) <<
"The service " << m_service->name().latin1()
53 <<
" does not feature the service type KDataTool" << endl;
74 return TQString::null;
76 return m_service->property(
"DataType" ).toString();
82 return TQStringList();
84 return m_service->property(
"DataMimeTypes" ).toStringList();
92 return m_service->property(
"ReadOnly" ).toBool();
101 TQStringList lst = TDEGlobal::dirs()->resourceDirs(
"icon");
102 TQStringList::ConstIterator it = lst.begin();
103 while (!pix.load( *it +
"/" + m_service->icon() ) && it != lst.end() )
115 TQStringList lst = TDEGlobal::dirs()->resourceDirs(
"mini");
116 TQStringList::ConstIterator it = lst.begin();
117 while (!pix.load( *it +
"/" + m_service->icon() ) && it != lst.end() )
126 return TQString::null;
127 return m_service->icon();
135 return m_service->property(
"Commands" ).toStringList();
143 return TQStringList::split(
',', m_service->comment() );
151 KDataTool* tool = KParts::ComponentFactory::createInstanceFromService<KDataTool>( m_service, parent, name );
153 tool->setInstance( m_instance );
162 TQValueList<KDataToolInfo>
KDataToolInfo::query(
const TQString& datatype,
const TQString& mimetype, TDEInstance* instance )
164 TQValueList<KDataToolInfo> lst;
168 if ( !datatype.isEmpty() )
170 constr = TQString::fromLatin1(
"DataType == '%1'" ).arg( datatype );
172 if ( !mimetype.isEmpty() )
174 TQString tmp = TQString::fromLatin1(
"'%1' in DataMimeTypes" ).arg( mimetype );
175 if ( constr.isEmpty() )
178 constr = constr +
" and " + tmp;
194 TDETrader::OfferList::ConstIterator it = offers.begin();
195 for( ; it != offers.end(); ++it )
198 if ( !instance || !(*it)->property(
"ExcludeFrom").toStringList()
199 .contains( instance->instanceName() ) )
202 kdDebug() << (*it)->entryPath() <<
" excluded." << endl;
219 TQObject * parent,
const char * name )
220 : TDEAction( text, info.iconName(), 0, parent, name ),
221 m_command( command ),
226 void KDataToolAction::slotActivated()
233 TQPtrList<TDEAction> actionList;
234 if ( tools.isEmpty() )
237 actionList.append(
new TDEActionSeparator() );
238 TQValueList<KDataToolInfo>::ConstIterator entry = tools.begin();
239 for( ; entry != tools.end(); ++entry )
241 TQStringList userCommands = (*entry).userCommands();
242 TQStringList commands = (*entry).commands();
243 Q_ASSERT(!commands.isEmpty());
244 if ( commands.count() != userCommands.count() )
245 kdWarning() <<
"KDataTool desktop file error (" << (*entry).service()->entryPath()
246 <<
"). " << commands.count() <<
" commands and "
247 << userCommands.count() <<
" descriptions." << endl;
248 TQStringList::ConstIterator uit = userCommands.begin();
249 TQStringList::ConstIterator cit = commands.begin();
250 for (; uit != userCommands.end() && cit != commands.end(); ++uit, ++cit )
256 actionList.append( action );
270 : TQObject( parent, name ), m_instance( 0L )
279 void KDataToolAction::virtual_hook(
int id,
void* data )
280 { TDEAction::virtual_hook(
id, data ); }
282 void KDataTool::virtual_hook(
int,
void* )
285 #include "kdatatool.moc"