Diffstat (limited to 'microkde/kresources/factory.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | microkde/kresources/factory.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp index f82e94c..7a5c2f6 100644 --- a/microkde/kresources/factory.cpp +++ b/microkde/kresources/factory.cpp | |||
@@ -178,49 +178,83 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) | |||
178 | } | 178 | } |
179 | 179 | ||
180 | ConfigWidget *wdg = pluginFactory->configWidget( parent ); | 180 | ConfigWidget *wdg = pluginFactory->configWidget( parent ); |
181 | if ( !wdg ) { | 181 | if ( !wdg ) { |
182 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 182 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
183 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | 183 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); |
184 | return 0; | 184 | return 0; |
185 | } | 185 | } |
186 | return wdg; | 186 | return wdg; |
187 | 187 | ||
188 | } | 188 | } |
189 | 189 | ||
190 | SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) | ||
191 | { | ||
192 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | ||
193 | return 0; | ||
194 | |||
195 | //US KService::Ptr ptr = mTypeMap[ type ]; | ||
196 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | ||
197 | PluginInfo* pi = mTypeMap[ type ]; | ||
198 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); | ||
199 | if ( !factory ) { | ||
200 | qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1()); | ||
201 | kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl; | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | ||
206 | |||
207 | if ( !pluginFactory ) { | ||
208 | qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1()); | ||
209 | kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl; | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | SyncWidget *wdg = pluginFactory->syncWidget( parent ); | ||
214 | if ( !wdg ) { | ||
215 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | ||
216 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | ||
217 | return 0; | ||
218 | } | ||
219 | return wdg; | ||
220 | |||
221 | } | ||
222 | |||
223 | |||
190 | QString Factory::typeName( const QString &type ) const | 224 | QString Factory::typeName( const QString &type ) const |
191 | { | 225 | { |
192 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 226 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
193 | return QString(); | 227 | return QString(); |
194 | 228 | ||
195 | 229 | ||
196 | //US KService::Ptr ptr = mTypeMap[ type ]; | 230 | //US KService::Ptr ptr = mTypeMap[ type ]; |
197 | //US return ptr->name(); | 231 | //US return ptr->name(); |
198 | PluginInfo* pi = mTypeMap[ type ]; | 232 | PluginInfo* pi = mTypeMap[ type ]; |
199 | return pi->nameLabel; | 233 | return pi->nameLabel; |
200 | 234 | ||
201 | } | 235 | } |
202 | 236 | ||
203 | QString Factory::typeDescription( const QString &type ) const | 237 | QString Factory::typeDescription( const QString &type ) const |
204 | { | 238 | { |
205 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 239 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
206 | return QString(); | 240 | return QString(); |
207 | 241 | ||
208 | //US KService::Ptr ptr = mTypeMap[ type ]; | 242 | //US KService::Ptr ptr = mTypeMap[ type ]; |
209 | //US return ptr->comment(); | 243 | //US return ptr->comment(); |
210 | PluginInfo* pi = mTypeMap[ type ]; | 244 | PluginInfo* pi = mTypeMap[ type ]; |
211 | return pi->descriptionLabel; | 245 | return pi->descriptionLabel; |
212 | } | 246 | } |
213 | 247 | ||
214 | Resource *Factory::resource( const QString& type, const KConfig *config ) | 248 | Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable ) |
215 | { | 249 | { |
216 | 250 | ||
217 | 251 | ||
218 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 252 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
219 | return 0; | 253 | return 0; |
220 | 254 | ||
221 | /*US load the lib not dynamicly. !! | 255 | /*US load the lib not dynamicly. !! |
222 | KService::Ptr ptr = mTypeMap[ type ]; | 256 | KService::Ptr ptr = mTypeMap[ type ]; |
223 | KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | 257 | KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); |
224 | if ( !factory ) { | 258 | if ( !factory ) { |
225 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; | 259 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; |
226 | return 0; | 260 | return 0; |
@@ -233,23 +267,23 @@ Resource *Factory::resource( const QString& type, const KConfig *config ) | |||
233 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; | 267 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; |
234 | return 0; | 268 | return 0; |
235 | } | 269 | } |
236 | 270 | ||
237 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | 271 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); |
238 | 272 | ||
239 | if ( !pluginFactory ) { | 273 | if ( !pluginFactory ) { |
240 | qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); | 274 | qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); |
241 | kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; | 275 | kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; |
242 | return 0; | 276 | return 0; |
243 | } | 277 | } |
244 | 278 | ||
245 | Resource *resource = pluginFactory->resource( config ); | 279 | Resource *resource = pluginFactory->resource( config, syncable ); |
246 | if ( !resource ) { | 280 | if ( !resource ) { |
247 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 281 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
248 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | 282 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); |
249 | return 0; | 283 | return 0; |
250 | } | 284 | } |
251 | 285 | ||
252 | resource->setType( type ); | 286 | resource->setType( type ); |
253 | 287 | ||
254 | return resource; | 288 | return resource; |
255 | } | 289 | } |