summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/factory.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kresources/factory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/factory.cpp44
1 files changed, 39 insertions, 5 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
@@ -30,45 +30,45 @@
#include <klibloader.h>
//#endif
#include <qfile.h>
#include "resource.h"
#include "factory.h"
using namespace KRES;
QDict<Factory> *Factory::mSelves = 0;
static KStaticDeleter< QDict<Factory> > staticDeleter;
-Factory *Factory::self( const QString& resourceFamily )
+Factory *Factory::self( const QString& resourceFamily)
{
Factory *factory = 0;
if ( !mSelves )
{
mSelves = staticDeleter.setObject( new QDict<Factory> );
}
factory = mSelves->find( resourceFamily );
if ( !factory ) {
- factory = new Factory( resourceFamily );
+ factory = new Factory( resourceFamily);
mSelves->insert( resourceFamily, factory );
}
return factory;
}
-Factory::Factory( const QString& resourceFamily ) :
+Factory::Factory( const QString& resourceFamily) :
mResourceFamily( resourceFamily )
{
//US so far we have three types available for resourceFamily "contact"
// and that are "file", "dir", "ldap"
/*US
KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
.arg( resourceFamily ) );
KTrader::OfferList::ConstIterator it;
for ( it = plugins.begin(); it != plugins.end(); ++it ) {
QVariant type = (*it)->property( "X-KDE-ResourceType" );
if ( !type.toString().isEmpty() )
@@ -178,49 +178,83 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
}
ConfigWidget *wdg = pluginFactory->configWidget( parent );
if ( !wdg ) {
//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
return 0;
}
return wdg;
}
+SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent )
+{
+ if ( type.isEmpty() || !mTypeMap.contains( type ) )
+ return 0;
+
+//US KService::Ptr ptr = mTypeMap[ type ];
+//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
+ PluginInfo* pi = mTypeMap[ type ];
+ KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
+ if ( !factory ) {
+ qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1());
+ kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl;
+ return 0;
+ }
+
+ PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
+
+ if ( !pluginFactory ) {
+ qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1());
+ kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl;
+ return 0;
+ }
+
+ SyncWidget *wdg = pluginFactory->syncWidget( parent );
+ if ( !wdg ) {
+//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
+ qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
+ return 0;
+ }
+ return wdg;
+
+}
+
+
QString Factory::typeName( const QString &type ) const
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return QString();
//US KService::Ptr ptr = mTypeMap[ type ];
//US return ptr->name();
PluginInfo* pi = mTypeMap[ type ];
return pi->nameLabel;
}
QString Factory::typeDescription( const QString &type ) const
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return QString();
//US KService::Ptr ptr = mTypeMap[ type ];
//US return ptr->comment();
PluginInfo* pi = mTypeMap[ type ];
return pi->descriptionLabel;
}
-Resource *Factory::resource( const QString& type, const KConfig *config )
+Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable )
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return 0;
/*US load the lib not dynamicly. !!
KService::Ptr ptr = mTypeMap[ type ];
KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
if ( !factory ) {
kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
return 0;
@@ -233,23 +267,23 @@ Resource *Factory::resource( const QString& type, const KConfig *config )
kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
return 0;
}
PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
if ( !pluginFactory ) {
qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
return 0;
}
- Resource *resource = pluginFactory->resource( config );
+ Resource *resource = pluginFactory->resource( config, syncable );
if ( !resource ) {
//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
return 0;
}
resource->setType( type );
return resource;
}