[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Thu Sep 30 16:22:43 CEST 2004


CVS commit by staikos: 

- proper fix for the psd editting bug (very tricky stuff :))
- add support for "time" unit conversion to data sources


  M +51 -0     kstdatasource.cpp   1.35
  M +16 -0     kstdatasource.h   1.19
  M +3 -0      kstequation.cpp   1.6
  M +10 -0     kstpsd.cpp   1.7
  M +1 -9      kstpsddialog_i.cpp   1.63


--- kdeextragear-2/kst/kst/kstdatasource.cpp  #1.34:1.35
@@ -470,3 +470,54 @@ bool KstDataSource::hasMetaData(const QS
 
 
+bool KstDataSource::supportsTimeConversions() const {
+  return false;
+}
+
+
+bool KstDataSource::supportsTimeConversions(const QString& field) const {
+  Q_UNUSED(field)
+  return false;
+}
+
+
+int KstDataSource::sampleForTime(const QDateTime& time, bool *ok) {
+  Q_UNUSED(time)
+  if (ok) {
+    *ok = false;
+  }
+  return 0;
+}
+
+
+
+int KstDataSource::sampleForTime(int milliseconds, bool *ok) {
+  Q_UNUSED(milliseconds)
+  if (ok) {
+    *ok = false;
+  }
+  return 0;
+}
+
+
+
+QDateTime KstDataSource::timeForSample(int sample, bool *ok) {
+  Q_UNUSED(sample)
+  if (ok) {
+    *ok = false;
+  }
+  return QDateTime::currentDateTime();
+}
+
+
+
+int KstDataSource::relativeTimeForSample(int sample, bool *ok) {
+  Q_UNUSED(sample)
+  if (ok) {
+    *ok = false;
+  }
+  return 0;
+}
+
+
+
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kstdatasource.h  #1.18:1.19
@@ -19,4 +19,5 @@
 #define KSTDATASOURCE_H
 
+#include <qdatetime.h>
 #include <qdom.h>
 #include <qguardedptr.h>
@@ -119,4 +120,19 @@ class KstDataSource : public KstObject {
     virtual bool hasMetaData(const QString& key) const;
 
+    /** Does it support time conversion of sample numbers, in general? */
+    virtual bool supportsTimeConversions() const;
+
+    /** Does it support time conversion of sample numbers for this field? */
+    virtual bool supportsTimeConversions(const QString& field) const;
+
+    virtual int sampleForTime(const QDateTime& time, bool *ok = 0L);
+
+    virtual int sampleForTime(int milliseconds, bool *ok = 0L);
+
+    virtual QDateTime timeForSample(int sample, bool *ok = 0L);
+
+    // in (ms)
+    virtual int relativeTimeForSample(int sample, bool *ok = 0L);
+
   protected:
     virtual void virtual_hook(int id, void *data);

--- kdeextragear-2/kst/kst/kstequation.cpp  #1.5:1.6
@@ -244,4 +244,7 @@ void KstEquation::setExistingXVector(Kst
   KstVectorPtr v = _inputVectors[XVECTOR];
   if (v) {
+    if (v == in_xv) {
+      return;
+    }
     v->writeUnlock();
   }

--- kdeextragear-2/kst/kst/kstpsd.cpp  #1.6:1.7
@@ -388,4 +388,14 @@ QString KstPSD::getVTag() const {
 
 void KstPSD::setVector(KstVectorPtr new_v) {
+  KstVectorPtr v = _inputVectors[INVECTOR];
+  if (v) {
+    if (v == new_v) {
+      return;
+    }
+    v->writeUnlock();
+  }
+
+  _inputVectors.erase(INVECTOR);
+  new_v->writeLock();
   _inputVectors[INVECTOR] = new_v;
 }

--- kdeextragear-2/kst/kst/kstpsddialog_i.cpp  #1.62:1.63
@@ -227,5 +227,5 @@ bool KstPsdDialogI::edit_I() {
   }
 
-  //DP->writeLock();
+  DP->writeLock();
 
   KST::vectorList.lock().readLock();
@@ -233,12 +233,4 @@ bool KstPsdDialogI::edit_I() {
   KST::vectorList.lock().readUnlock();
 
-  DP->writeLock(); // FIXME: the lock should be above the setVector,
-  // but if we do this it crashes (at least for cbn!!?)
-  // with the following message: 
-  // QMutex::unlock: unlock from different thread than locker
-  //              was locked by 16386, unlock attempt from 16384
-  // the same code appears in the hsdialog, but appears to work there.
-  // ?
-
   DP->setTagName(_tagName->text());
 





More information about the Kst mailing list