[Kst] kdeextragear-2/kst/kst/datasources/ascii

George Staikos staikos at kde.org
Wed Apr 13 18:55:27 CEST 2005


CVS commit by staikos: 

fix some cases of empty files not working - more to go, but they're even older
regressions than those from today.


  M +12 -5     ascii.cpp   1.51
  M +2 -1      ascii.h   1.19


--- kdeextragear-2/kst/kst/datasources/ascii/ascii.cpp  #1.50:1.51
@@ -94,4 +94,5 @@ AsciiSource::AsciiSource(KConfig *cfg, c
 : KstDataSource(cfg, filename, type), _rowIndex(0L), _config(0L), _tmpBuf(0L), _tmpBufSize(0) {
   _valid = false;
+  _haveHeader = false;
   if (!type.isEmpty() && type != "ASCII") {
     return;
@@ -101,4 +102,5 @@ AsciiSource::AsciiSource(KConfig *cfg, c
   _config->read(cfg, filename);
 
+  _valid = true;
   update();
 }
@@ -163,6 +165,11 @@ KstObject::UpdateType AsciiSource::updat
   }
 
-  if (!_valid) {
-    _valid = initRowIndex();
+  if (!_haveHeader) {
+    _haveHeader = initRowIndex();
+    if (!_haveHeader) {
+      return setLastUpdateResult(KstObject::NO_CHANGE);
+    }
+    // Re-update the field list since we have one now
+    _fields = fieldListFor(_filename, _config);
   }
 
@@ -375,5 +382,5 @@ bool AsciiSource::isEmpty() const {
 
 
-static QStringList fieldListFor(const QString& filename, AsciiSource::Config *cfg) {
+QStringList AsciiSource::fieldListFor(const QString& filename, AsciiSource::Config *cfg) {
   QStringList rc;
   QFile file(filename);
@@ -686,5 +693,5 @@ int understands_ascii(KConfig *cfg, cons
     }
   }
-  return 0;
+  return 5; // still might be ascii - ex: header with no data yet.
 }
 
@@ -706,5 +713,5 @@ QStringList fieldList_ascii(KConfig *cfg
   AsciiSource::Config config;
   config.read(cfg, filename);
-  return fieldListFor(filename, &config);
+  return AsciiSource::fieldListFor(filename, &config);
 }
 

--- kdeextragear-2/kst/kst/datasources/ascii/ascii.h  #1.18:1.19
@@ -55,4 +55,5 @@ class AsciiSource : public KstDataSource
 
     class Config;
+    static QStringList fieldListFor(const QString& filename, Config *cfg);
 
   private:
@@ -66,5 +67,5 @@ class AsciiSource : public KstDataSource
     char *_tmpBuf;
     uint _tmpBufSize;
-    QStringList _variables;
+    bool _haveHeader;
 };
 




More information about the Kst mailing list