[Kst] branches/work/kst/kst1kde4/kst/src/datasources

Zongyi Zhang freebody.kst at gmail.com
Tue Apr 13 20:12:41 CEST 2010


SVN commit 1114479 by zhang:

replace kconfig with qsettings

 M  +30 -28    ascii/ascii.cpp  
 M  +2 -2      ascii/ascii.h  
 M  +4 -4      dirfile/dirfile.cpp  
 M  +1 -1      dirfile/dirfile.h  
 M  +9 -7      libfitstools/fitstools.cpp  
 M  +2 -2      libfitstools/fitstools.h  
 M  +5 -5      qimagesource/qimagesource.cpp  
 M  +1 -1      qimagesource/qimagesource.h  


--- branches/work/kst/kst1kde4/kst/src/datasources/ascii/ascii.cpp #1114478:1114479
@@ -58,29 +58,31 @@
       _fieldsLine = 0;
     }
 
-    void read(KConfig *cfg, const QString& fileName = QString::null) {
-      cfg->setGroup("ASCII General");
-      _fileNamePattern = cfg->readEntry("Filename Pattern", QString::null);
-      _delimiters = cfg->readEntry("Comment Delimiters", "#/c!;").latin1();
-      _indexInterpretation = (Interpretation)cfg->readNumEntry("Default INDEX Interpretation", Unknown);
-      _columnType = (ColumnType)cfg->readNumEntry("Column Type", Whitespace);
-      _columnDelimiter = cfg->readEntry("Column Delimiter", QString::null).latin1();
-      _columnWidth = cfg->readNumEntry("Column Width", DEFAULT_COLUMN_WIDTH);
-      _dataLine = cfg->readNumEntry("Data Start", 0);
-      _readFields = cfg->readBoolEntry("Read Fields", false);
-      _fieldsLine = cfg->readNumEntry("Fields Line", 0);
+    void read(QSettings *cfg, const QString& fileName = QString::null) {
+      cfg->beginGroup("ASCII General");
+      _fileNamePattern = cfg->value("Filename Pattern", QString::null).toString();
+      _delimiters = cfg->value("Comment Delimiters", "#/c!;").toString().toLatin1();
+      _indexInterpretation = (Interpretation)cfg->value("Default INDEX Interpretation", Unknown).toInt();
+      _columnType = (ColumnType)cfg->value("Column Type", Whitespace).toInt();
+      _columnDelimiter = cfg->value("Column Delimiter", QString::null).toString().toLatin1();
+      _columnWidth = cfg->value("Column Width", DEFAULT_COLUMN_WIDTH).toInt();
+      _dataLine = cfg->value("Data Start", 0).toInt();
+      _readFields = cfg->value("Read Fields", false).toBool();
+      _fieldsLine = cfg->value("Fields Line", 0).toInt();
+	  cfg->endGroup();
       if (!fileName.isEmpty()) {
-        cfg->setGroup(fileName);
-        _delimiters = cfg->readEntry("Comment Delimiters", _delimiters).latin1();
-        _indexInterpretation = (Interpretation)cfg->readNumEntry("Default INDEX Interpretation", _indexInterpretation);
-        _columnType = (ColumnType)cfg->readNumEntry("Column Type", _columnType);
-        _columnDelimiter = cfg->readEntry("Column Delimiter", _columnDelimiter).latin1();
-        _columnWidth = cfg->readNumEntry("Column Width", _columnWidth);
-        _dataLine = cfg->readNumEntry("Data Start", _dataLine);
-        _readFields = cfg->readBoolEntry("Read Fields", _readFields);
-        _fieldsLine = cfg->readNumEntry("Fields Line", _fieldsLine);
+        cfg->beginGroup(fileName);
+        _delimiters = cfg->value("Comment Delimiters", _delimiters).toString().toLatin1();
+        _indexInterpretation = (Interpretation)cfg->value("Default INDEX Interpretation", _indexInterpretation).toInt();
+        _columnType = (ColumnType)cfg->value("Column Type", _columnType).toInt();
+        _columnDelimiter = cfg->value("Column Delimiter", _columnDelimiter).toString().toLatin1();
+        _columnWidth = cfg->value("Column Width", _columnWidth).toInt();
+        _dataLine = cfg->value("Data Start", _dataLine).toInt();
+        _readFields = cfg->value("Read Fields", _readFields).toBool();
+        _fieldsLine = cfg->value("Fields Line", _fieldsLine).toInt();
+        cfg->endGroup();
       }
-      _delimiters = QRegExp::escape(_delimiters).latin1();
+      _delimiters = QRegExp::escape(_delimiters).toLatin1();
     }
 
     QCString _delimiters;
@@ -129,7 +131,7 @@
              }
            } else if (e.tagName() == "comment") {
              if (e.hasAttribute("delimiters")) {
-               _delimiters = e.attribute("delimiters").latin1();
+               _delimiters = e.attribute("delimiters").toLatin1();
              }
            } else if (e.tagName() == "columns") {
              if (e.hasAttribute("type")) {
@@ -139,7 +141,7 @@
                _columnWidth = e.attribute("width").toInt();
              }
              if (e.hasAttribute("delimiters")) {
-               _columnDelimiter = e.attribute("delimiters").latin1();
+               _columnDelimiter = e.attribute("delimiters").toLatin1();
              }
            } else if (e.tagName() == "header") {
              if (e.hasAttribute("start")) {
@@ -156,7 +158,7 @@
 };
 
 
-AsciiSource::AsciiSource(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e)
+AsciiSource::AsciiSource(QSetttings *cfg, const QString& filename, const QString& type, const QDomElement& e)
 : KstDataSource(cfg, filename, type), _rowIndex(0L), _config(0L), _tmpBuf(0L), _tmpBufSize(0) {
   _valid = false;
   _haveHeader = false;
@@ -988,11 +990,11 @@
 
 
 extern "C" {
-KstDataSource *create_ascii(KConfig *cfg, const QString& filename, const QString& type) {
+KstDataSource *create_ascii(QSettings *cfg, const QString& filename, const QString& type) {
   return new AsciiSource(cfg, filename, type);
 }
 
-KstDataSource *load_ascii(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e) {
+KstDataSource *load_ascii(QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e) {
   return new AsciiSource(cfg, filename, type, e);
 }
 
@@ -1002,7 +1004,7 @@
   return rc;
 }
 
-int understands_ascii(KConfig *cfg, const QString& filename) {
+int understands_ascii(QSettings *cfg, const QString& filename) {
   AsciiSource::Config config;
   config.read(cfg, filename);
 
@@ -1067,7 +1069,7 @@
 }
 
 
-QStringList fieldList_ascii(KConfig *cfg, const QString& filename, const QString& type, QString *typeSuggestion, bool *complete) {
+QStringList fieldList_ascii(QSettings *cfg, const QString& filename, const QString& type, QString *typeSuggestion, bool *complete) {
   if ((!type.isEmpty() && !provides_ascii().contains(type)) ||
       0 == understands_ascii(cfg, filename)) {
     if (complete) {
--- branches/work/kst/kst1kde4/kst/src/datasources/ascii/ascii.h #1114478:1114479
@@ -18,13 +18,13 @@
 #ifndef ASCII_H
 #define ASCII_H
 
-#include <qfile.h>
+#include <QFile>
 
 #include <kstdatasource.h>
 
 class AsciiSource : public KstDataSource {
   public:
-    AsciiSource(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e = QDomElement());
+    AsciiSource(QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e = QDomElement());
     ~AsciiSource();
 
     static int readFullLine(QFile &file, QString &str);
--- branches/work/kst/kst1kde4/kst/src/datasources/dirfile/dirfile.cpp #1114478:1114479
@@ -33,7 +33,7 @@
 #include "kstdebug.h"
 
 
-DirFileSource::DirFileSource(KConfig *cfg, const QString& filename, const QString& type)
+DirFileSource::DirFileSource(QSettings *cfg, const QString& filename, const QString& type)
 : KstDataSource(cfg, filename, type) {
   if (init()) {
     _valid = true;
@@ -218,7 +218,7 @@
 //#include <kdebug.h>
 
 extern "C" {
-KstDataSource *create_dirfile(KConfig *cfg, const QString& filename, const QString& type) {
+KstDataSource *create_dirfile(QSettings *cfg, const QString& filename, const QString& type) {
   return new DirFileSource(cfg, filename, type);
 }
 
@@ -228,7 +228,7 @@
   return rc;
 }
 
-int understands_dirfile(KConfig*, const QString& filename) {
+int understands_dirfile(QSettings*, const QString& filename) {
   // FIXME: GetNFrames causes a memory error here.  I think it is due to
   // the lfilename parameter.
   int err = 0;
@@ -242,7 +242,7 @@
 }
 
 
-QStringList fieldList_dirfile(KConfig*, const QString& filename, const QString& type, QString *typeSuggestion, bool *complete) {
+QStringList fieldList_dirfile(QSettings*, const QString& filename, const QString& type, QString *typeSuggestion, bool *complete) {
   Q_UNUSED(type)
   int err = 0;
   struct FormatType *ft = GetFormat(filename.toLatin1(), &err);
--- branches/work/kst/kst1kde4/kst/src/datasources/dirfile/dirfile.h #1114478:1114479
@@ -23,7 +23,7 @@
 
 class DirFileSource : public KstDataSource {
   public:
-    DirFileSource(KConfig *cfg, const QString& filename, const QString& type);
+    DirFileSource(QSettings *cfg, const QString& filename, const QString& type);
 
     ~DirFileSource();
 
--- branches/work/kst/kst1kde4/kst/src/datasources/libfitstools/fitstools.cpp #1114478:1114479
@@ -16,6 +16,8 @@
  ***************************************************************************/
 
 #include "fitstools.h"
+//Added by qt3to4:
+#include <Q3ValueList>
 
 
 char **fitsSarrayAlloc(size_t nstring)
@@ -253,14 +255,14 @@
   fields.append("INDEX");
   for (int i = 0; i < nString; i++) {
     if (names[i].contains("IMAGE")) {
-      cur.sprintf("%d - %s Data", i, names[i].latin1());
+      cur.sprintf("%d - %s Data", i, names[i].toLatin1());
     } else {
-      cur.sprintf("%d - %s", i, names[i].latin1());
+      cur.sprintf("%d - %s", i, names[i].toLatin1());
     }
     if (units[i].isEmpty()) {
-      cur.sprintf("%s (Unknown Units)", cur.latin1());
+      cur.sprintf("%s (Unknown Units)", cur.toLatin1());
     } else {
-      cur.sprintf("%s (%s)", cur.latin1(), units[i].latin1());
+      cur.sprintf("%s (%s)", cur.toLatin1(), units[i].toLatin1());
     }
     fields.append(cur);
   }
@@ -285,7 +287,7 @@
   matrices.append("INDEX");
   
   if (names[0].contains("IMAGE")) {
-    cur.sprintf("1 - %s", names[0].latin1());
+    cur.sprintf("1 - %s", names[0].toLatin1());
   } else {    
     cur.sprintf("1 - TABLE");
   }
@@ -295,9 +297,9 @@
 }
 
 
-QValueList<int> fitsDim( fitsfile *fp, int HDU ) {
+Q3ValueList<int> fitsDim( fitsfile *fp, int HDU ) {
   
-  QValueList<int> dims;
+  Q3ValueList<int> dims;
   
   // move to desired HDU
   int ret = 0;
--- branches/work/kst/kst1kde4/kst/src/datasources/libfitstools/fitstools.h #1114478:1114479
@@ -22,7 +22,7 @@
 #include <fitsio.h>
 #include <qpair.h>
 #include <qstring.h>
-#include <qvaluelist.h>
+#include <q3valuelist.h>
 #include <qstringlist.h>
 #include <qmap.h>
 
@@ -44,7 +44,7 @@
     
 QStringList fitsMatrices( fitsfile *fp, int HDU );
 
-QValueList<int> fitsDim( fitsfile *fp, int HDU );
+Q3ValueList<int> fitsDim( fitsfile *fp, int HDU );
 
 // read data from file
 
--- branches/work/kst/kst1kde4/kst/src/datasources/qimagesource/qimagesource.cpp #1114478:1114479
@@ -16,11 +16,11 @@
  ***************************************************************************/
 
 #include "qimagesource.h"
-#include <qcolor.h>
+#include <QColor>
 #include <QTextStream>
 
 
-QimagesourceSource::QimagesourceSource(KConfig *cfg, const QString& filename, const QString& type)
+QimagesourceSource::QimagesourceSource(QSettings *cfg, const QString& filename, const QString& type)
 : KstDataSource(cfg, filename, type) {
   _image = QImage();
   if (init()) {
@@ -231,7 +231,7 @@
 
 
 extern "C" {
-KstDataSource *create_qimagesource(KConfig *cfg, const QString& filename, const QString& type) {
+KstDataSource *create_qimagesource(QSettings *cfg, const QString& filename, const QString& type) {
   return new QimagesourceSource(cfg, filename, type);
 }
 
@@ -242,7 +242,7 @@
 }
 
 
-int understands_qimagesource(KConfig*, const QString& filename) {
+int understands_qimagesource(QSettings*, const QString& filename) {
   QImage image(filename);
   QString ftype( image.format() );
 
@@ -258,7 +258,7 @@
 }
 
 
-QStringList fieldList_qimagesource(KConfig*, const QString& filename, const QString& type, QString *typeSuggestion, bool *complete) {
+QStringList fieldList_qimagesource(QSettings*, const QString& filename, const QString& type, QString *typeSuggestion, bool *complete) {
   Q_UNUSED(type)
   QStringList fieldList;
   QImage image(filename);
--- branches/work/kst/kst1kde4/kst/src/datasources/qimagesource/qimagesource.h #1114478:1114479
@@ -25,7 +25,7 @@
 
 class QimagesourceSource : public KstDataSource {
   public:
-    QimagesourceSource(KConfig *cfg, const QString& filename, const QString& type);
+    QimagesourceSource(QSettings *cfg, const QString& filename, const QString& type);
     ~QimagesourceSource();
 
     bool init();


More information about the Kst mailing list