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

Peter Kümmel syntheticpp at gmx.net
Fri Oct 19 09:23:18 UTC 2012


SVN commit 1321331 by kuemmel:

only run an internal update when neccessary

 M  +4 -0      asciiconfigwidget.cpp  
 M  +1 -0      asciiconfigwidget.h  
 M  +49 -2     asciisourceconfig.cpp  
 M  +6 -2      asciisourceconfig.h  
 M  +9 -1      namedparameter.h  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfigwidget.cpp #1321330:1321331
@@ -183,6 +183,7 @@
   _ac = new AsciiConfigWidgetInternal(this);
   layout->addWidget(_ac, 0, 0);
   layout->activate();
+  _oldConfig = _ac->config();
 }
 
 
@@ -224,6 +225,7 @@
     }
   }
   _ac->_indexVector->setEnabled(hasInstance());
+  _oldConfig = _ac->config();
 }
 
 
@@ -238,11 +240,13 @@
     // Update the instance from our new settings
     if (src->reusable()) {
       src->_config.readGroup(settings(), src->fileName());
+      if (_ac->config().isUdateNecessary(_oldConfig)) {
       src->reset();
       src->internalDataSourceUpdate();
     }
   }
 }
+}
 
 bool AsciiConfigWidget::isOkAcceptabe() const {
   AsciiSourceConfig config = _ac->config();
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfigwidget.h #1321330:1321331
@@ -56,6 +56,7 @@
     void setFilename(const QString& filename);
 
     AsciiConfigWidgetInternal *_ac;
+    AsciiSourceConfig _oldConfig;
 };
 
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.cpp #1321330:1321331
@@ -81,7 +81,7 @@
 
 
 
-void AsciiSourceConfig::save(QSettings& cfg) {
+void AsciiSourceConfig::save(QSettings& cfg) const {
   _fileNamePattern >> cfg;
   _indexVector >> cfg;
   _delimiters >> cfg;
@@ -102,7 +102,7 @@
 }
 
 
-void AsciiSourceConfig::saveGroup(QSettings& cfg, const QString& fileName) {
+void AsciiSourceConfig::saveGroup(QSettings& cfg, const QString& fileName) const {
   cfg.beginGroup(AsciiSource::asciiTypeKey());
   if (fileName.isEmpty()) {
     save(cfg);
@@ -229,3 +229,50 @@
   }
 }
 
+
+bool AsciiSourceConfig::operator==(const AsciiSourceConfig& rhs) const
+{
+  return _fileNamePattern == rhs._fileNamePattern &&
+      _indexVector == rhs._indexVector &&
+      _delimiters == rhs._delimiters &&
+      _indexInterpretation == rhs._indexInterpretation &&
+      _columnType == rhs._columnType &&
+      _columnDelimiter == rhs._columnDelimiter &&
+      _columnWidth == rhs._columnWidth &&
+      _dataLine == rhs._dataLine &&
+      _readFields == rhs._readFields &&
+      _useDot == rhs._useDot &&
+      _fieldsLine == rhs._fieldsLine &&
+      _columnWidthIsConst == rhs._columnWidthIsConst &&
+      _readUnits == rhs._readUnits &&
+      _unitsLine == rhs._unitsLine &&
+      _limitFileBuffer == rhs._limitFileBuffer &&
+      _limitFileBufferSize == rhs._limitFileBufferSize &&
+      _useThreads == rhs._useThreads;
+}
+
+bool AsciiSourceConfig::operator!=(const AsciiSourceConfig& rhs) const
+{
+  return !operator==(rhs);
+}
+
+bool AsciiSourceConfig::isUdateNecessary(const AsciiSourceConfig& rhs) const
+{
+  return _fileNamePattern != rhs._fileNamePattern ||
+      _indexVector != rhs._indexVector ||
+      _delimiters != rhs._delimiters ||
+      _indexInterpretation != rhs._indexInterpretation ||
+      _columnType != rhs._columnType ||
+      _columnDelimiter != rhs._columnDelimiter ||
+      _columnWidth != rhs._columnWidth ||
+      _dataLine != rhs._dataLine ||
+      _readFields != rhs._readFields ||
+      _useDot != rhs._useDot ||
+      _fieldsLine != rhs._fieldsLine ||
+      _columnWidthIsConst != rhs._columnWidthIsConst ||
+      _readUnits != rhs._readUnits ||
+      _unitsLine != rhs._unitsLine ;
+}
+
+
+
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.h #1321330:1321331
@@ -59,7 +59,11 @@
   public:
     AsciiSourceConfig();
 
-    void saveGroup(QSettings& cfg, const QString& fileName = QString());
+    bool operator==(const AsciiSourceConfig&) const;
+    bool operator!=(const AsciiSourceConfig& rhs) const;
+    bool isUdateNecessary(const AsciiSourceConfig& rhs) const;
+
+    void saveGroup(QSettings& cfg, const QString& fileName = QString()) const;
     void readGroup(QSettings& cfg, const QString& fileName = QString());
 
     void save(QXmlStreamWriter& s);
@@ -89,7 +93,7 @@
     NamedParameter<int, Key_useThreads, Tag_useThreads> _useThreads;
 
   private:
-    void save(QSettings& cfg);
+    void save(QSettings& cfg) const;
     void read(QSettings& cfg);
 };
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/namedparameter.h #1321330:1321331
@@ -28,7 +28,7 @@
       _value_set(false) {
   }
 
-  void operator>>(QSettings& settings) {
+  void operator>>(QSettings& settings) const {
     const QVariant var = QVariant::fromValue<T>(value());
     settings.setValue(Key, var);
   }
@@ -78,6 +78,14 @@
     return *this;
   }
 
+  bool operator==(const T& rhs) const {
+    return value() == rhs;
+  }
+
+   bool operator!=(const T& rhs) const {
+    return !operator==(rhs);
+  }
+
 private:
   T _value;
   T _default_value;


More information about the Kst mailing list