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

Adam Treat treat at kde.org
Tue Sep 12 16:54:07 CEST 2006


SVN commit 583533 by treat:

* Reimplement the Line Fit plugin using the new KDE C++ style
plugins and remove the old C style version.

* Modify kstdoc to parse the .kst file for these new plugins and
create them on demand.

* Add a createPlugin( const QString &name, const QDomElement &e ) method
which creates the new plugins and initializes them with their bit of dom
snippet.

* Add a load( const QDomElement &e ) method to KstDataObject which allows to 
create the plugin and use this method rather than the constructor of the same
argument.

* Add some skeleton files for the Cross Power Spectrum plugin.  This will be
ported to the new KDE C++ style plugins next.


 M  +6 -0      libkstapp/kstdoc.cpp  
 M  +34 -1     libkstmath/kstdataobject.cpp  
 M  +2 -0      libkstmath/kstdataobject.h  
 M  +6 -6      plugins/crossspectrum/Makefile.am  
 A             plugins/crossspectrum/crosspowerspectrum.cpp   [License: GPL (v2+)]
 A             plugins/crossspectrum/crosspowerspectrum.h   [License: GPL (v2+)]
 M  +7 -7      plugins/linefit/Makefile.am  
 D             plugins/linefit/linefit.cpp  
 D             plugins/linefit/linefit.xml  
 A             plugins/linefit/linefitplugin.cpp   [License: GPL (v2+)]
 A             plugins/linefit/linefitplugin.h   [License: GPL (v2+)]


--- branches/work/kst/pluginify/kst/src/libkstapp/kstdoc.cpp #583532:583533
@@ -383,6 +383,12 @@
         KstDataObjectPtr p = new KstPlugin(e);
         KstWriteLocker dowl(&KST::dataObjectList.lock());
         KST::dataObjectList.append(p);
+      } else if (e.tagName() == "newplugin") {
+        const QString name = e.attribute("name");
+        Q_ASSERT( !name.isEmpty() );
+        KstDataObjectPtr p = KstDataObject::createPlugin(name, e);
+        KstWriteLocker dowl(&KST::dataObjectList.lock());
+        KST::dataObjectList.append(p);
       } else if (e.tagName() == "curve") {
         KstDataObjectPtr p = new KstVCurve(e);
         KstWriteLocker dowl(&KST::dataObjectList.lock());
--- branches/work/kst/pluginify/kst/src/libkstmath/kstdataobject.cpp #583532:583533
@@ -111,9 +111,13 @@
                                                                             QStringList(), &err );
     if ( object ) {
       pluginInfo.insert( service->name(), KstDataObjectPtr( object ) );
+      kdDebug() << "SUCCESS! " << service->name() << endl;
     }
     else
-        kdDebug() << "FAILURE! " << k_funcinfo << " " << err << endl;
+    {
+      kdDebug() << "FAILURE! " << k_funcinfo << " " << service->name() << " error=" << err << endl;
+      kdDebug() << "KLibLoader::lastErrorMessage! " << KLibLoader::self()->lastErrorMessage() << endl;
+    }
   }
 }
 
@@ -132,6 +136,32 @@
         return 0;
 }
 
+KstDataObjectPtr KstDataObject::createPlugin( const QString &name, const QDomElement &e )
+{
+  KService::List sl = KServiceType::offers("Kst Data Object");
+  for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) {
+    int err = 0;
+    KService::Ptr service = ( *it );
+    if ( service->name() != name )
+      continue;
+    KstDataObject *object =
+        KParts::ComponentFactory::createInstanceFromService<KstDataObject>( service, 0, "",
+        QStringList(), &err );
+    object->load( e );
+    if ( object ) {
+      pluginInfo.insert( service->name(), KstDataObjectPtr( object ) );
+      kdDebug() << "SUCCESS! " << service->name() << endl;
+    }
+    else
+    {
+      kdDebug() << "FAILURE! " << k_funcinfo << " " << service->name() << " error=" << err << endl;
+      kdDebug() << "KLibLoader::lastErrorMessage! " << KLibLoader::self()->lastErrorMessage() << endl;
+    }
+    return object;
+  }
+  return 0;
+}
+
 double *KstDataObject::vectorRealloced(KstVectorPtr v, double *memptr, int newSize) const {
   if (!v) {
     return 0L;
@@ -144,6 +174,9 @@
   return v->realloced(memptr, newSize);
 }
 
+void KstDataObject::load(const QDomElement &e) {
+  Q_UNUSED(e)
+}
 void KstDataObject::save(QTextStream& ts, const QString& indent) {
   Q_UNUSED(ts)
   Q_UNUSED(indent)
--- branches/work/kst/pluginify/kst/src/libkstmath/kstdataobject.h #583532:583533
@@ -43,6 +43,7 @@
     /** Returns a list of object plugins found on the system. */
     static QStringList pluginList();
     static KstDataObjectPtr plugin( const QString &name );
+    static KstDataObjectPtr createPlugin( const QString &name, const QDomElement& e );
 
     virtual UpdateType update(int updateCounter = -1) = 0;
     virtual const QString& typeString() const { return _typeString; }
@@ -73,6 +74,7 @@
     KstMatrixMap& inputMatrices() { return _inputMatrices; }
     KstMatrixMap& outputMatrices() { return _outputMatrices; }
 
+    virtual void load(const QDomElement &e);
     virtual void save(QTextStream& ts, const QString& indent = QString::null);
 
     void showDialog();
--- branches/work/kst/pluginify/kst/src/plugins/crossspectrum/Makefile.am #583532:583533
@@ -1,11 +1,11 @@
-installdir=$(kde_moduledir)/kstplugins
 INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES = crossspectrum.la
+kde_module_LTLIBRARIES=kst_crossspectrum.la
 
-crossspectrum_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
-crossspectrum_la_SOURCES = crossspectrum.cpp fftsg_h.c
+kst_crossspectrum_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kst_crossspectrum_la_SOURCES=crosspowerspectrum.cpp crossspectrum.cpp fftsg_h.c
 
+services_DATA=kst_crossspectrum.desktop
+servicesdir=$(kde_servicesdir)/kst
+
 METASOURCES=AUTO
-
-install_DATA=crossspectrum.xml
--- branches/work/kst/pluginify/kst/src/plugins/linefit/Makefile.am #583532:583533
@@ -1,11 +1,11 @@
-installdir=$(kde_moduledir)/kstplugins
-INCLUDES=-I$(srcdir)/../../../kst $(all_includes)
+INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES=linefit.la
+kde_module_LTLIBRARIES=kst_linefit.la
 
-linefit_la_LDFLAGS=-module $(KDE_PLUGIN)
-linefit_la_SOURCES=linefit.cpp
+kst_linefit_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kst_linefit_la_SOURCES=linefitplugin.cpp
 
+services_DATA=kst_linefit.desktop
+servicesdir=$(kde_servicesdir)/kst
+
 METASOURCES=AUTO
-
-install_DATA=linefit.xml


More information about the Kst mailing list