[Kst] branches/work/kst/pluginify/kst/src

Adam Treat treat at kde.org
Tue Sep 5 21:06:46 CEST 2006


SVN commit 581233 by treat:

Store the plugins.  Not sure how we'll add these plugins
to the DataManager UI? hmm...


 M  +1 -0      libkstapp/kst.cpp  
 M  +17 -5     libkstmath/kstdataobject.cpp  
 M  +3 -0      libkstmath/kstdataobject.h  


--- branches/work/kst/pluginify/kst/src/libkstapp/kst.cpp #581232:581233
@@ -250,6 +250,7 @@
   }
 
   KstDataSource::cleanupForExit(); // must be before deletions
+  KstDataObject::cleanupForExit(); // must be before deletions
   delete _updateThread;
   _updateThread = 0L;
   delete _dcopIface;
--- branches/work/kst/pluginify/kst/src/libkstmath/kstdataobject.cpp #581232:581233
@@ -90,13 +90,18 @@
   delete _curveHints;
 }
 
-static QStringList pluginInfo;
+static QMap<QString, KstDataObjectPtr> pluginInfo;
+void KstDataObject::cleanupForExit() {
+  pluginInfo.clear(); //FIXME?
+}
 
 // Scans for plugins and stores the information for them
 static void scanPlugins() {
 
   KstDebug::self()->log(i18n("Scanning for data-object plugins."));
 
+  pluginInfo.clear(); //FIXME?
+
   KService::List sl = KServiceType::offers("Kst Data Object");
   for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) {
     int err = 0;
@@ -105,11 +110,10 @@
         KParts::ComponentFactory::createInstanceFromService<KstDataObject>( service, 0, "",
                                                                             QStringList(), &err );
     if ( object ) {
-        pluginInfo.append( object->name() );
+        pluginInfo.insert( object->name(), KstDataObjectPtr( object ) );
     }
     else
         kdDebug() << "FAILURE! " << k_funcinfo << " " << err << endl;
-
   }
 }
 
@@ -117,10 +121,18 @@
   if (pluginInfo.isEmpty()) {
     scanPlugins();
   }
-  kdDebug() << pluginInfo << endl;
-  return pluginInfo;
+  kdDebug() << pluginInfo.keys() << endl;
+  return pluginInfo.keys();
 }
 
+KstDataObjectPtr KstDataObject::plugin( const QString &name )
+{
+    if ( pluginInfo.contains( name ) )
+        return pluginInfo[ name ];
+    else
+        return 0;
+}
+
 double *KstDataObject::vectorRealloced(KstVectorPtr v, double *memptr, int newSize) const {
   if (!v) {
     return 0L;
--- branches/work/kst/pluginify/kst/src/libkstmath/kstdataobject.h #581232:581233
@@ -37,9 +37,12 @@
     KstDataObject(const KstDataObject& object);
     virtual ~KstDataObject();
 
+    static void cleanupForExit();
+
     // These static methods are not for plugins to use
     /** Returns a list of object plugins found on the system. */
     static QStringList pluginList();
+    static KstDataObjectPtr plugin( const QString &name );
 
     virtual QString name() const { return QString::null; }
     virtual QString xmlFile() const { return QString::null; }


More information about the Kst mailing list