[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Thu Apr 14 03:03:00 CEST 2005
CVS commit by staikos:
add a new static symbol so that data sources can load settings. Make the ascii
source load its settings.
M +27 -3 kstdatasource.cpp 1.64
M +8 -1 datasources/ascii/ascii.cpp 1.54
M +1 -1 datasources/ascii/ascii.h 1.21
--- kdeextragear-2/kst/kst/kstdatasource.cpp #1.63:1.64
@@ -71,4 +71,28 @@ namespace KST {
}
+ KstDataSource *create(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e) const {
+ KstDataSource *(*sym)(KConfig*, const QString&, const QString&, const QDomElement&) = (KstDataSource*(*)(KConfig*, const QString&, const QString&, const QDomElement&))symbol("load");
+ if (sym) {
+ //kdDebug() << "Trying to create " << filename << " type=" << type << " with " << service->property("Name").toString() << endl;
+ KstDataSource *ds = (sym)(cfg, filename, type, e);
+ if (ds) {
+ ds->_source = service->property("Name").toString();
+ }
+ //kdDebug() << (ds ? "SUCCESS" : "FAILED") << endl;
+ return ds;
+ } else {
+ KstDataSource *(*sym)(KConfig*, const QString&, const QString&) = (KstDataSource*(*)(KConfig*, const QString&, const QString&))symbol("load");
+ if (sym) {
+ KstDataSource *ds = (sym)(cfg, filename, type);
+ if (ds) {
+ ds->_source = service->property("Name").toString();
+ }
+ return ds;
+ }
+ }
+
+ return 0L;
+ }
+
QStringList fieldList(KConfig *cfg, const QString& filename, const QString& type = QString::null, QString *typeSuggestion = 0L, bool *complete = 0L) const {
QStringList (*sym)(KConfig*, const QString&, const QString&, QString*, bool*) = (QStringList(*)(KConfig*, const QString&, const QString&, QString*, bool*))symbol("fieldList");
@@ -318,10 +342,10 @@ static QValueList<PluginSortContainer> b
-static KstDataSourcePtr findPluginFor(const QString& filename, const QString& type) {
+static KstDataSourcePtr findPluginFor(const QString& filename, const QString& type, const QDomElement& e = QDomElement()) {
QValueList<PluginSortContainer> bestPlugins = bestPluginsForSource(filename, type);
for (QValueList<PluginSortContainer>::Iterator i = bestPlugins.begin(); i != bestPlugins.end(); ++i) {
- KstDataSourcePtr plugin = (*i).plugin->create(kConfigObject, filename);
+ KstDataSourcePtr plugin = (*i).plugin->create(kConfigObject, filename, QString::null, e);
if (plugin) {
return plugin;
@@ -466,5 +490,5 @@ KstDataSourcePtr KstDataSource::loadSour
}
- return findPluginFor(filename, type);
+ return findPluginFor(filename, type, e);
}
--- kdeextragear-2/kst/kst/datasources/ascii/ascii.cpp #1.53:1.54
@@ -150,5 +150,5 @@ class AsciiSource::Config {
-AsciiSource::AsciiSource(KConfig *cfg, const QString& filename, const QString& type)
+AsciiSource::AsciiSource(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e)
: KstDataSource(cfg, filename, type), _rowIndex(0L), _config(0L), _tmpBuf(0L), _tmpBufSize(0) {
_valid = false;
@@ -161,4 +161,7 @@ AsciiSource::AsciiSource(KConfig *cfg, c
_config = new AsciiSource::Config;
_config->read(cfg, filename);
+ if (!e.isNull()) {
+ _config->load(e);
+ }
_valid = true;
@@ -701,4 +704,8 @@ KstDataSource *create_ascii(KConfig *cfg
}
+KstDataSource *load_ascii(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e) {
+ return new AsciiSource(cfg, filename, type, e);
+}
+
QStringList provides_ascii() {
QStringList rc;
--- kdeextragear-2/kst/kst/datasources/ascii/ascii.h #1.20:1.21
@@ -24,5 +24,5 @@
class AsciiSource : public KstDataSource {
public:
- AsciiSource(KConfig *cfg, const QString& filename, const QString& type);
+ AsciiSource(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e = QDomElement());
~AsciiSource();
More information about the Kst
mailing list