File indexing completed on 2024-12-22 04:17:04
0001 /*************************************************************************** 0002 dmcplugin.cpp 0003 ------------------- 0004 copyright : (C) 2010 The University of Toronto 0005 email : netterfield@astro.utoronto.ca 0006 ***************************************************************************/ 0007 0008 /*************************************************************************** 0009 * * 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 ***************************************************************************/ 0016 0017 #include "dmcplugin.h" 0018 #include "dmcsource.h" 0019 0020 0021 using namespace Kst; 0022 0023 0024 // 0025 // DmcPlugin 0026 // 0027 static const char* plugin_name= "PLANCK DMC I/O plugin"; 0028 QString DmcPlugin::pluginName() const { return plugin_name; } 0029 QString DmcPlugin::pluginDescription() const { return plugin_name; } 0030 0031 0032 0033 Kst::DataSource *DmcPlugin::create( Kst::ObjectStore *store, 0034 QSettings *cfg, 0035 const QString &filename, 0036 const QString &type, 0037 const QDomElement &element) const 0038 { 0039 return new DmcSource(store, cfg, filename, type, element); 0040 } 0041 0042 0043 QStringList DmcPlugin::matrixList(QSettings *cfg, 0044 const QString& filename, 0045 const QString& type, 0046 QString *typeSuggestion, 0047 bool *complete) const 0048 { 0049 Q_UNUSED(cfg); 0050 Q_UNUSED(filename); 0051 Q_UNUSED(type); 0052 Q_UNUSED(typeSuggestion); 0053 Q_UNUSED(complete); 0054 return QStringList(); 0055 } 0056 0057 0058 QStringList DmcPlugin::scalarList(QSettings *cfg, 0059 const QString& filename, 0060 const QString& type, 0061 QString *typeSuggestion, 0062 bool *complete) const 0063 { 0064 Q_UNUSED(cfg); 0065 Q_UNUSED(filename); 0066 Q_UNUSED(type); 0067 Q_UNUSED(typeSuggestion); 0068 Q_UNUSED(complete); 0069 return QStringList(); 0070 } 0071 0072 0073 QStringList DmcPlugin::stringList(QSettings *cfg, 0074 const QString& filename, 0075 const QString& type, 0076 QString *typeSuggestion, 0077 bool *complete) const 0078 { 0079 Q_UNUSED(cfg); 0080 Q_UNUSED(filename); 0081 Q_UNUSED(type); 0082 Q_UNUSED(typeSuggestion); 0083 Q_UNUSED(complete); 0084 QStringList stringList; 0085 0086 return stringList; 0087 } 0088 0089 0090 0091 0092 QStringList DmcPlugin::fieldList( QSettings *cfg, 0093 const QString& filename, 0094 const QString& type, 0095 QString *typeSuggestion, 0096 bool *complete) const 0097 0098 { 0099 /* old code 0100 QStringList fieldList_dmc(KConfig*, const QString& filename, const QString& type, QString *typeSuggestion, bool *complete) { 0101 if (!type.isEmpty() && !provides_dmc().contains(type)) { 0102 return QStringList(); 0103 } 0104 0105 KstSharedPtr<DMC::Object> pobj = new DMC::Object; 0106 if (!pobj->setGroup(filename) || !pobj->isValid()) { 0107 return QStringList(); 0108 } 0109 0110 if (complete) { 0111 *complete = true; 0112 } 0113 0114 if (typeSuggestion) { 0115 *typeSuggestion = "PLANCK DMC I/O"; 0116 } 0117 0118 QStringList rc = pobj->fields(); 0119 rc.prepend("INDEX"); 0120 return rc; 0121 } 0122 */ 0123 Q_UNUSED(cfg); 0124 Q_UNUSED(filename); 0125 Q_UNUSED(type); 0126 Q_UNUSED(typeSuggestion); 0127 Q_UNUSED(complete); 0128 0129 if (!type.isEmpty() && !provides().contains(type)) { 0130 return QStringList(); 0131 } 0132 0133 SharedPtr<DMC::Object> pobj = new DMC::Object; 0134 if (!pobj->setGroup(filename) || !pobj->isValid()) { 0135 return QStringList(); 0136 } 0137 0138 if (complete) { 0139 *complete = true; 0140 } 0141 0142 if (typeSuggestion) { 0143 *typeSuggestion = DmcSource::dmcTypeKey(); 0144 } 0145 0146 QStringList rc = pobj->fields(); 0147 rc.prepend("INDEX"); 0148 return rc; 0149 } 0150 0151 0152 bool DmcPlugin::supportsTime( QSettings *cfg, 0153 const QString& filename) const 0154 { 0155 /* old code 0156 bool supportsTime_dmc(KConfig*, const QString& filename) { 0157 KstSharedPtr<DMC::Object> pobj = new DMC::Object; 0158 if (!pobj->setGroup(filename) || !pobj->isValid()) { 0159 return false; 0160 } 0161 return pobj->fields().contains("TIMES_OF_SAMPLES") || pobj->fields().contains("TIMESEC"); 0162 }*/ 0163 0164 Q_UNUSED(cfg) 0165 Q_UNUSED(filename) 0166 0167 SharedPtr<DMC::Object> pobj = new DMC::Object; 0168 if (!pobj->setGroup(filename) || !pobj->isValid()) { 0169 return false; 0170 } 0171 return pobj->fields().contains("TIMES_OF_SAMPLES") || pobj->fields().contains("TIMESEC"); 0172 } 0173 0174 0175 QStringList DmcPlugin::provides() const 0176 { 0177 return QStringList() << DmcSource::dmcTypeKey(); 0178 } 0179 0180 0181 Kst::DataSourceConfigWidget *DmcPlugin::configWidget( QSettings *cfg, 0182 const QString& filename) const 0183 { 0184 0185 Q_UNUSED(cfg) 0186 Q_UNUSED(filename) 0187 return 0;; 0188 0189 } 0190 0191 0192 0193 0194 0195 int DmcPlugin::understands( QSettings *cfg, 0196 const QString& filename) const 0197 { 0198 /* old code 0199 int understands_dmc(KConfig*, const QString& filename) { 0200 bool rc = DMC::validDatabase(filename); 0201 qDebug() << "-> Valid dmc database? " << rc << endl; 0202 return rc ? 100 : 0; 0203 }*/ 0204 0205 bool rc = DMC::validDatabase(filename); 0206 qDebug() << "-> Valid dmc database? " << rc << endl; 0207 return rc ? 100 : 0; 0208 } 0209 0210 0211 Q_EXPORT_PLUGIN2(kstdata_dmcsource, DmcPlugin) 0212 0213 0214 // vim: ts=2 sw=2 et