[Kst] branches/work/kst/portto4/kst/src/datasources/netcdf

Peter Kümmel syntheticpp at gmx.net
Mon Jan 10 15:57:26 CET 2011


SVN commit 1213484 by kuemmel:

split out plugin code

 M  +2 -123    kstnetcdf.cpp  
 M  +2 -54     kstnetcdf.h  
 M  +4 -2      netcdf.pro  
 AM            netcdfplugin.cpp   [License: GPL (v2+)]
 AM            netcdfplugin.h   [License: GPL (v2+)]


--- branches/work/kst/portto4/kst/src/datasources/netcdf/kstnetcdf.cpp #1213483:1213484
@@ -615,140 +615,19 @@
 
 
 
-
-
 bool NetcdfSource::isEmpty() const {
   return frameCount() < 1;
 }
 
 
 
-
-//
-// NetCdfPlugin
-//
-
-QString NetCdfPlugin::pluginName() const { return "netCDF Reader"; }
-QString NetCdfPlugin::pluginDescription() const { return "netCDF Reader"; }
-
-
-Kst::DataSource *NetCdfPlugin::create(Kst::ObjectStore *store,
-                                            QSettings *cfg,
-                                            const QString &filename,
-                                            const QString &type,
-                                            const QDomElement &element) const
-{
-  return new NetcdfSource(store, cfg, filename, type, element);
-}
-
-
-
-QStringList NetCdfPlugin::matrixList(QSettings *cfg,
-                                             const QString& filename,
-                                             const QString& type,
-                                             QString *typeSuggestion,
-                                             bool *complete) const
-{
-  return QStringList();
-}
-
-
 const QString& NetcdfSource::typeString() const
 {
   return netCdfTypeString;
 }
 
 
-
-QStringList NetCdfPlugin::scalarList(QSettings *cfg,
-                                            const QString& filename,
-                                            const QString& type,
-                                            QString *typeSuggestion,
-                                            bool *complete) const
+const QString NetcdfSource::netcdfTypeKey()
 {
-
-  Q_UNUSED(cfg);
-  Q_UNUSED(type)
-  QStringList scalarList;
-  return scalarList;
+  return ::netCdfTypeString;
 }
-
-QStringList NetCdfPlugin::stringList(QSettings *cfg,
-                                      const QString& filename,
-                                      const QString& type,
-                                      QString *typeSuggestion,
-                                      bool *complete) const {
-  Q_UNUSED(cfg);
-  Q_UNUSED(type)
-  QStringList stringList;
-
-  return stringList;
-}
-
-QStringList NetCdfPlugin::fieldList(QSettings *cfg,
-                                            const QString& filename,
-                                            const QString& type,
-                                            QString *typeSuggestion,
-                                            bool *complete) const {
-  Q_UNUSED(cfg);
-  Q_UNUSED(type)
-
-  QStringList fieldList;
-
-  return fieldList;
-}
-
-
-
-
-
-bool NetCdfPlugin::supportsTime(QSettings *cfg, const QString& filename) const {
-  //FIXME
-  Q_UNUSED(cfg)
-  Q_UNUSED(filename)
-  return true;
-}
-
-
-QStringList NetCdfPlugin::provides() const
-{
-  return QStringList() << netCdfTypeString;
-}
-
-
-Kst::DataSourceConfigWidget *NetCdfPlugin::configWidget(QSettings *cfg, const QString& filename) const {
-
-  Q_UNUSED(cfg)
-  Q_UNUSED(filename)
-  return 0;;
-
-}
-
-
-
-
-  /** understands_netcdf: returns true if:
-    - the file is readable (!)
-    - the file can be opened by the netcdf library **/
-int NetCdfPlugin::understands(QSettings *cfg, const QString& filename) const
-{
-    QFile f(filename);
-
-    if (!f.open(QFile::ReadOnly)) {
-      KST_DBG qDebug() << "Unable to read file !" << endl;
-      return 0;
-    }
-
-    NcFile *ncfile = new NcFile(filename.toUtf8().data());
-    if (ncfile->is_valid()) {
-      KST_DBG qDebug() << filename << " looks like netCDF !" << endl;
-      delete ncfile;
-      return 80;
-    } else {
-      delete ncfile;
-      return 0;
-    }
-  }
-
-
-Q_EXPORT_PLUGIN2(kstdata_netcdfsource, NetCdfPlugin)
--- branches/work/kst/portto4/kst/src/datasources/netcdf/kstnetcdf.h #1213483:1213484
@@ -44,7 +44,9 @@
 
     virtual const QString& typeString() const;
 
+    static const QString netcdfTypeKey();
 
+
     int readScalar(double *v, const QString& field);
 
     int readString(QString *stringValue, const QString& stringName);
@@ -92,59 +94,5 @@
 
 
 
-class NetCdfPlugin : public QObject, public Kst::DataSourcePluginInterface
-{
-    Q_OBJECT
-    Q_INTERFACES(Kst::DataSourcePluginInterface)
-
-  public:
-    virtual ~NetCdfPlugin() {}
-
-    virtual QString pluginName() const;
-    virtual QString pluginDescription() const;
-
-    virtual bool hasConfigWidget() const { return false; }
-
-    virtual Kst::DataSource *create(Kst::ObjectStore *store,
-                                  QSettings *cfg,
-                                  const QString &filename,
-                                  const QString &type,
-                                  const QDomElement &element) const;
-
-    virtual QStringList matrixList(QSettings *cfg,
-                                  const QString& filename,
-                                  const QString& type,
-                                  QString *typeSuggestion,
-                                  bool *complete) const;
-
-    virtual QStringList fieldList(QSettings *cfg,
-                                  const QString& filename,
-                                  const QString& type,
-                                  QString *typeSuggestion,
-                                  bool *complete) const;
-
-    virtual QStringList scalarList(QSettings *cfg,
-                                  const QString& filename,
-                                  const QString& type,
-                                  QString *typeSuggestion,
-                                  bool *complete) const;
-
-    virtual QStringList stringList(QSettings *cfg,
-                                  const QString& filename,
-                                  const QString& type,
-                                  QString *typeSuggestion,
-                                  bool *complete) const;
-
-    virtual int understands(QSettings *cfg, const QString& filename) const;
-
-    virtual bool supportsTime(QSettings *cfg, const QString& filename) const;
-
-    virtual QStringList provides() const;
-
-    virtual Kst::DataSourceConfigWidget *configWidget(QSettings *cfg, const QString& filename) const;
-};
-
-
-
 #endif
 
--- branches/work/kst/portto4/kst/src/datasources/netcdf/netcdf.pro #1213483:1213484
@@ -9,7 +9,9 @@
 LIBS += -l$$kstlib(netcdf_c++) -l$$kstlib(netcdf) 
 
 SOURCES += \
-    kstnetcdf.cpp
+    kstnetcdf.cpp \
+    netcdfplugin.cpp
 
 HEADERS += \
-    kstnetcdf.h
+    kstnetcdf.h \
+    netcdfplugin.h


More information about the Kst mailing list