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

Peter Kümmel syntheticpp at yahoo.com
Tue Mar 16 19:54:31 CET 2010


SVN commit 1104116 by kuemmel:

rename AsciiSource::Config

 M  +2 -2      ascii.pro  
 M  +19 -19    asciiplugin.cpp  
 M  +19 -19    asciisource.cpp  
 M  +6 -5      asciisource.h  
 D             asciisource_p.cpp  
 D             asciisource_p.h  
 A             asciisourceconfig.cpp   asciisource_p.cpp#1103994 [License: GPL (v2+)]
 A             asciisourceconfig.h   asciisource_p.h#1103994 [License: GPL (v2+)]


--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.pro #1104115:1104116
@@ -7,14 +7,14 @@
 
 SOURCES += \
   asciisource.cpp \
-  asciisource_p.cpp \
+  asciisourceconfig.cpp \
   asciiplugin.cpp
 
 win32:SOURCES += kst_atof.cpp
 
 HEADERS += \
   asciisource.h \
-  asciisource_p.h \
+  asciisourceconfig.h \
   asciiplugin.h \
   namedparameter.h \
   ../../libkst/kst_inf.h
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiplugin.cpp #1104115:1104116
@@ -16,7 +16,7 @@
  ***************************************************************************/
 
 #include "asciiplugin.h"
-#include "asciisource_p.h"
+#include "asciisourceconfig.h"
 #include "ui_asciiconfig.h"
 
 #include <QFile>
@@ -33,8 +33,8 @@
   public:
     ConfigWidgetAsciiInternal(QWidget *parent);
 
-    AsciiSource::Config config();
-    void setConfig(const AsciiSource::Config&);
+    AsciiSourceConfig config();
+    void setConfig(const AsciiSourceConfig&);
 };
 
 
@@ -43,17 +43,17 @@
 }
 
 
-AsciiSource::Config ConfigWidgetAsciiInternal::config()
+AsciiSourceConfig ConfigWidgetAsciiInternal::config()
 {
-  AsciiSource::Config config;
+  AsciiSourceConfig config;
   config._fileNamePattern = _fileNamePattern->text();
-  config._indexInterpretation = (AsciiSource::Config::Interpretation) (1 + _indexType->currentIndex());
+  config._indexInterpretation = (AsciiSourceConfig::Interpretation) (1 + _indexType->currentIndex());
   config._delimiters = _delimiters->text();
-  AsciiSource::Config::ColumnType ct = AsciiSource::Config::Whitespace;
+  AsciiSourceConfig::ColumnType ct = AsciiSourceConfig::Whitespace;
   if (_fixed->isChecked()) {
-    ct = AsciiSource::Config::Fixed;
+    ct = AsciiSourceConfig::Fixed;
   } else if (_custom->isChecked()) {
-    ct = AsciiSource::Config::Custom;
+    ct = AsciiSourceConfig::Custom;
   }
   config._columnType = ct;
   config._columnDelimiter = _columnDelimiter->text();
@@ -67,7 +67,7 @@
 }
 
 
-void ConfigWidgetAsciiInternal::setConfig(const AsciiSource::Config& config)
+void ConfigWidgetAsciiInternal::setConfig(const AsciiSourceConfig& config)
 {
   _delimiters->setText(config._delimiters);
   _fileNamePattern->setText(config._fileNamePattern);
@@ -77,10 +77,10 @@
   _readFields->setChecked(config._readFields);
   _useDot->setChecked(config._useDot);
   _fieldsLine->setValue(config._fieldsLine);
-  AsciiSource::Config::ColumnType ct = config._columnType;
-  if (ct == AsciiSource::Config::Fixed) {
+  AsciiSourceConfig::ColumnType ct = config._columnType;
+  if (ct == AsciiSourceConfig::Fixed) {
     _fixed->setChecked(true);
-  } else if (ct == AsciiSource::Config::Custom) {
+  } else if (ct == AsciiSourceConfig::Custom) {
     _custom->setChecked(true);
   } else {
     _whitespace->setChecked(true);
@@ -118,7 +118,7 @@
 
 
 void ConfigWidgetAscii::load() {
-  AsciiSource::Config config;
+  AsciiSourceConfig config;
   if (hasInstance())
     config.readGroup(settings(), instance()->fileName());
   else
@@ -222,7 +222,7 @@
     *typeSuggestion = AsciiSource::asciiTypeKey();
   }
 
-  AsciiSource::Config config;
+  AsciiSourceConfig config;
   config.readGroup(*cfg, filename);
   QStringList rc = AsciiSource::fieldListFor(filename, &config);
 
@@ -253,7 +253,7 @@
     *typeSuggestion = AsciiSource::asciiTypeKey();
   }
 
-  AsciiSource::Config config;
+  AsciiSourceConfig config;
   config.readGroup(*cfg, filename);
   QStringList rc = AsciiSource::scalarListFor(filename, &config);
 
@@ -284,7 +284,7 @@
     *typeSuggestion = AsciiSource::asciiTypeKey();
   }
 
-  AsciiSource::Config config;
+  AsciiSourceConfig config;
   config.readGroup(*cfg, filename);
   QStringList rc = AsciiSource::stringListFor(filename, &config);
 
@@ -298,7 +298,7 @@
 
 
 int AsciiPlugin::understands(QSettings *cfg, const QString& filename) const {
-  AsciiSource::Config config;
+  AsciiSourceConfig config;
   config.readGroup(*cfg, filename);
 
   if (!QFile::exists(filename) || QFileInfo(filename).isDir()) {
@@ -320,7 +320,7 @@
     bool done = false;
 
     QRegExp commentRE, dataRE;
-    if (config._columnType == AsciiSource::Config::Custom && !config._columnDelimiter.value().isEmpty()) {
+    if (config._columnType == AsciiSourceConfig::Custom && !config._columnDelimiter.value().isEmpty()) {
       commentRE.setPattern(QString("^[%1]*[%2].*").arg(QRegExp::escape(config._columnDelimiter)).arg(config._delimiters));
       dataRE.setPattern(QString("^[%1]*(([Nn][Aa][Nn]|(\\-\\+)?[Ii][Nn][Ff]|[0-9\\+\\-\\.eE]+)[\\s]*)+").arg(QRegExp::escape(config._columnDelimiter)));
     } else {
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1104115:1104116
@@ -17,7 +17,7 @@
 
 
 #include "asciisource.h"
-#include "asciisource_p.h"
+#include "asciisourceconfig.h"
 
 #include "math_kst.h"
 #include "kst_inf.h"
@@ -69,7 +69,7 @@
   if (!type.isEmpty() && type != asciiTypeString) {
     return;
   }
-  _config = new AsciiSource::Config;
+  _config = new AsciiSourceConfig;
   _config->readGroup(*cfg, filename);
   if (!e.isNull()) {
     _config->load(e);
@@ -376,12 +376,12 @@
   file.seek(bufstart);
   file.read(_tmpBuf, bufread);
 
-  if (_config->_columnType == AsciiSource::Config::Fixed) {
+  if (_config->_columnType == AsciiSourceConfig::Fixed) {
     for (int i = 0; i < n; ++i, ++s) {
       // Read appropriate column and convert to double
       v[i] = atof(_tmpBuf + _rowIndex[i] - _rowIndex[0] + _config->_columnWidth * (col - 1), sep);
     }
-  } else if (_config->_columnType == AsciiSource::Config::Custom) {
+  } else if (_config->_columnType == AsciiSourceConfig::Custom) {
     for (int i = 0; i < n; ++i, ++s) {
       bool incol = false;
       int i_col = 0;
@@ -470,7 +470,7 @@
   return _numFrames < 1;
 }
 
-QStringList AsciiSource::scalarListFor(const QString& filename, AsciiSource::Config *cfg) {
+QStringList AsciiSource::scalarListFor(const QString& filename, AsciiSourceConfig *cfg) {
   Q_UNUSED(cfg)
   QStringList rc;
   QFile file(filename);
@@ -486,7 +486,7 @@
 
 }
 
-QStringList AsciiSource::stringListFor(const QString& filename, AsciiSource::Config *cfg) {
+QStringList AsciiSource::stringListFor(const QString& filename, AsciiSourceConfig *cfg) {
   Q_UNUSED(cfg)
   QStringList rc;
   QFile file(filename);
@@ -502,7 +502,7 @@
 
 }
 
-QStringList AsciiSource::fieldListFor(const QString& filename, AsciiSource::Config *cfg) {
+QStringList AsciiSource::fieldListFor(const QString& filename, AsciiSourceConfig *cfg) {
   QStringList rc;
   QFile file(filename);
 
@@ -519,9 +519,9 @@
       int r = readFullLine(file, line);
       if (l-- == 0) {
         if (r >= 0) {
-          if (cfg->_columnType == AsciiSource::Config::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
+          if (cfg->_columnType == AsciiSourceConfig::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
             rc += QString(line).trimmed().split(QRegExp(QString("[%1]").arg(QRegExp::escape(cfg->_columnDelimiter))), QString::SkipEmptyParts);
-          } else if (cfg->_columnType == AsciiSource::Config::Fixed) {
+          } else if (cfg->_columnType == AsciiSourceConfig::Fixed) {
             int cnt = line.length() / cfg->_columnWidth;
             for (int i = 0; i < cnt; ++i) {
               QString sub = line.mid(i * cfg->_columnWidth).left(cfg->_columnWidth);
@@ -538,7 +538,7 @@
   }
 
   QRegExp re;
-  if (cfg->_columnType == AsciiSource::Config::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
+  if (cfg->_columnType == AsciiSourceConfig::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
     re.setPattern(QString("^[%1]*[%2].*").arg(QRegExp::escape(cfg->_columnDelimiter)).arg(cfg->_delimiters));
   } else {
     re.setPattern(QString("^\\s*[%1].*").arg(cfg->_delimiters));
@@ -573,9 +573,9 @@
       if (curscan >= nextscan) {
         if (r > 1 && !re.exactMatch(line)) {
           line = line.trimmed();
-          if (cfg->_columnType == AsciiSource::Config::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
+          if (cfg->_columnType == AsciiSourceConfig::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
             cnt = QString(line).split(QRegExp(QString("[%1]").arg(QRegExp::escape(cfg->_columnDelimiter))), QString::SkipEmptyParts).count();
-          } else if (cfg->_columnType == AsciiSource::Config::Fixed) {
+          } else if (cfg->_columnType == AsciiSourceConfig::Fixed) {
             cnt = line.length() / cfg->_columnWidth;
           } else {
             cnt = QString(line).split(QRegExp("\\s"), QString::SkipEmptyParts).count();
@@ -593,9 +593,9 @@
     }
     if (r > 1 && !re.exactMatch(line)) { //at desired line, find count
       line = line.trimmed();
-      if (cfg->_columnType == AsciiSource::Config::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
+      if (cfg->_columnType == AsciiSourceConfig::Custom && !cfg->_columnDelimiter.value().isEmpty()) {
         maxcnt = QString(line).split(QRegExp(QString("[%1]").arg(QRegExp::escape(cfg->_columnDelimiter))), QString::SkipEmptyParts).count();
-      } else if (cfg->_columnType == AsciiSource::Config::Fixed) {
+      } else if (cfg->_columnType == AsciiSourceConfig::Fixed) {
         maxcnt = line.length() / cfg->_columnWidth;
       } else {
         maxcnt = QString(line).split(QRegExp("\\s"), QString::SkipEmptyParts).count();
@@ -627,19 +627,19 @@
 
 
 bool AsciiSource::supportsTimeConversions() const {
-  return false; //fieldList().contains(_config->_indexVector) && _config->_indexInterpretation != AsciiSource::Config::Unknown && _config->_indexInterpretation != AsciiSource::Config::INDEX;
+  return false; //fieldList().contains(_config->_indexVector) && _config->_indexInterpretation != AsciiSourceConfig::Unknown && _config->_indexInterpretation != AsciiSourceConfig::INDEX;
 }
 
 
 int AsciiSource::sampleForTime(double ms, bool *ok) {
   switch (_config->_indexInterpretation) {
-    case AsciiSource::Config::Seconds:
+    case AsciiSourceConfig::Seconds:
       // FIXME: make sure "seconds" exists in _indexVector
       if (ok) {
         *ok = true;
       }
       return 0;
-    case AsciiSource::Config::CTime:
+    case AsciiSourceConfig::CTime:
       // FIXME: make sure "seconds" exists in _indexVector (different than above?)
       if (ok) {
         *ok = true;
@@ -658,13 +658,13 @@
 
 int AsciiSource::sampleForTime(const QDateTime& time, bool *ok) {
   switch (_config->_indexInterpretation) {
-    case AsciiSource::Config::Seconds:
+    case AsciiSourceConfig::Seconds:
       // FIXME: make sure "time" exists in _indexVector
       if (ok) {
         *ok = true;
       }
       return time.toTime_t();
-    case AsciiSource::Config::CTime:
+    case AsciiSourceConfig::CTime:
       // FIXME: make sure "time" exists in _indexVector (different than above?)
       if (ok) {
         *ok = true;
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1104115:1104116
@@ -21,6 +21,8 @@
 #include "datasource.h"
 #include "dataplugin.h"
 
+
+class AsciiSourceConfig;
 class QFile;
 
 class AsciiSource : public Kst::DataSource
@@ -68,10 +70,9 @@
 
     static const QString asciiTypeKey();
 
-    class Config;
-    static QStringList fieldListFor(const QString& filename, Config *cfg);
-    static QStringList scalarListFor(const QString& filename, Config *cfg);
-    static QStringList stringListFor(const QString& filename, Config *cfg);
+    static QStringList fieldListFor(const QString& filename, AsciiSourceConfig *cfg);
+    static QStringList scalarListFor(const QString& filename, AsciiSourceConfig *cfg);
+    static QStringList stringListFor(const QString& filename, AsciiSourceConfig *cfg);
 
   private:
     int *_rowIndex;
@@ -79,7 +80,7 @@
     int _numFrames;
     int _byteLength;
     friend class ConfigWidgetAscii;
-    mutable Config *_config;
+    mutable AsciiSourceConfig *_config;
     char *_tmpBuf;
     uint _tmpBufSize;
     bool _haveHeader;


More information about the Kst mailing list