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

Barth Netterfield netterfield at astro.utoronto.ca
Tue Jun 3 01:53:30 CEST 2008


SVN commit 815990 by netterfield:

Move name stuff from object into new namedObject class, so that
names can be added to view objects if we decide we want this.

Start with adding tooltip comments.  Vector selectors now have them, and
vectors now produce them.




 M  +26 -0     libkst/datavector.cpp  
 M  +2 -0      libkst/datavector.h  
 M  +7 -0      libkst/editablevector.cpp  
 M  +2 -0      libkst/editablevector.h  
 M  +5 -0      libkst/generatedvector.cpp  
 M  +1 -0      libkst/generatedvector.h  
 M  +2 -0      libkst/libkst.pro  
 A             libkst/namedobject.cpp   [License: GPL (v2+)]
 A             libkst/namedobject.h   [License: GPL (v2+)]
 M  +1 -129    libkst/object.cpp  
 M  +2 -67     libkst/object.h  
 M  +4 -0      libkst/vector.cpp  
 M  +1 -0      libkst/vector.h  
 M  +5 -0      widgets/vectorselector.cpp  


--- branches/work/kst/portto4/kst/src/libkst/datavector.cpp #815989:815990
@@ -792,5 +792,31 @@
   return field();
 }
 
+QString DataVector::description() {
+  QString IDstring;
+  QString range_string;
+
+  IDstring = i18n(
+      "Data Vector: %1\n"
+      "  %2\n"
+      "  Field: %3"
+      ).arg(Name()).arg(dataSource()->fileName()).arg(field());
+
+  if (countFromEOF()) {
+    IDstring += i18n("\n  Last %1 frames.").arg(numFrames());
+  } else if (readToEOF()) {
+    IDstring += i18n("\n  Frame %1 to end.").arg(startFrame());
+  } else {
+    IDstring += i18n("\n  %1 Frames starting at %2.").arg(numFrames()).arg(startFrame());
+  }
+  if (skip()) {
+    if (!doAve()) {
+      IDstring+=i18n("\n  Read 1 sample per %1 frames.").arg(skip());
+    } else {
+      IDstring+=i18n("\n  Average each %1 frames.").arg(skip());
+    }
+  }
+  return IDstring;
 }
+}
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkst/datavector.h #815989:815990
@@ -111,6 +111,8 @@
     /** the data source */
     DataSourcePtr dataSource() const;
 
+    virtual QString description();
+
   public Q_SLOTS:
     void sourceUpdated(ObjectPtr object);
 
--- branches/work/kst/portto4/kst/src/libkst/editablevector.cpp #815989:815990
@@ -97,5 +97,12 @@
 
   return name;
 }
+
+QString EditableVector::description() {
+    return i18n("Editable Vector: %1\n"
+      "  %2 values").arg(Name()).arg(length());
+
 }
+
+}
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkst/editablevector.h #815989:815990
@@ -35,6 +35,8 @@
 
     void setSaveData(bool save);
 
+    virtual QString description();
+
   protected:
     KST_EXPORT EditableVector(ObjectStore *store, const QByteArray& data);
     KST_EXPORT EditableVector(ObjectStore *store, int n=0);
--- branches/work/kst/portto4/kst/src/libkst/generatedvector.cpp #815989:815990
@@ -108,6 +108,11 @@
   return QString::number(_v[0])+".."+QString::number(_v[length()-1]);
 }
 
+QString GeneratedVector::description() {
+  return i18n("Generated Vector: %1\n"
+      "  %2 values from %3 to %4").arg(Name()).arg(length()).arg(_v[0]).arg(_v[length()-1]);
 }
 
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkst/generatedvector.h #815989:815990
@@ -39,6 +39,7 @@
     Object::UpdateType update();
     void setSaveData(bool save);
 
+    QString description();
   protected:
     GeneratedVector(ObjectStore *store, double x0=0, double x1=0, int n=0);
     GeneratedVector(ObjectStore *store, const QByteArray &data, double x0, double x1, int n);
--- branches/work/kst/portto4/kst/src/libkst/libkst.pro #815989:815990
@@ -33,6 +33,7 @@
     math_kst.cpp \
     matrix.cpp \
     matrixfactory.cpp \
+    namedobject.cpp \
     object.cpp \
     objectlist.cpp \
     objectmap.cpp \
@@ -81,6 +82,7 @@
     math_kst.h \
     matrix.h \
     matrixfactory.h \
+    namedobject.h \
     object.h \
     objectlist.h \
     objectmap.h \
--- branches/work/kst/portto4/kst/src/libkst/object.cpp #815989:815990
@@ -30,22 +30,10 @@
 
 Object::Object() :
   Shared(), KstRWLock(),
-  _store(0L), _manualDescriptiveName(QString()), _shortName(QString("FIXME - set _shortName"))
+  _store(0L), NamedObject()
 {
   _dirty = false;
 
-  _initial_vnum = _vnum; // vectors
-  _initial_pnum = _pnum; // plugins
-  _initial_csdnum = _csdnum; // csd
-  _initial_cnum = _cnum; // curves
-  _initial_enum = _enum; // equations
-  _initial_hnum = _hnum; // histograms
-  _initial_inum = _inum; // images
-  _initial_psdnum = _psdnum; // psd
-  _initial_xnum = _xnum; // scalars
-  _initial_tnum = _tnum; // text string
-  _initial_mnum = _mnum; // text string
-
 }
 
 
@@ -91,35 +79,6 @@
   return _store;
 }
 
-
-// new Name system
-QString Object::Name() const {
-  return descriptiveName()+":"+shortName();
-}
-
-
-QString Object::descriptiveName() const {
-  if (_manualDescriptiveName.isEmpty()) {
-      return _automaticDescriptiveName();
-  } else {
-    return _manualDescriptiveName;
-  }
-}
-
-
-QString Object::shortName() const {
-  return _shortName;
-}
-
-
-void Object::setDescriptiveName(QString new_name) {
-  _manualDescriptiveName = new_name;
-}
-
-bool Object::descriptiveNameIsManual() const {
-  return !(_manualDescriptiveName.isEmpty());
-}
-
 void Object::beginUpdate(ObjectPtr object) {
   processUpdate(object);
 }
@@ -128,93 +87,6 @@
   // Do nothing by default.
 }
 
-// to keep the size of the saved xml files smaller, 'I' 
-// should be set to only the types who are effected by the 
-// creation of the object.  (So, the type itself and any slave
-// objects which are created)  eg: Vectors: VNUM|XNUM
-// It doesn't hurt to add more (the default is all bits set)
-// except that it increases the size of the .kst file, and
-// slows loading (not much, but if you have hundreds of
-// objects....)
-void Object::saveNameInfo(QXmlStreamWriter &s, unsigned I) {
-  if (descriptiveNameIsManual()) {
-    s.writeAttribute("descriptiveNameIsManual", "true");
-    s.writeAttribute("descriptiveName", descriptiveName());
-  }
-  if (I & VNUM)
-    s.writeAttribute("initialVNum", QString::number(_initial_vnum));
-  if (I & XNUM)
-    s.writeAttribute("initialXNum", QString::number(_initial_xnum));
-  if (I & PNUM)
-    s.writeAttribute("initialPNum", QString::number(_initial_pnum));
-  if (I & CSDNUM)
-    s.writeAttribute("initialCSDNum", QString::number(_initial_csdnum));
-  if (I & CNUM)
-    s.writeAttribute("initialCNum", QString::number(_initial_cnum));
-  if (I & ENUM)
-    s.writeAttribute("initialENum", QString::number(_initial_enum));
-  if (I & HNUM)
-    s.writeAttribute("initialHNum", QString::number(_initial_hnum));
-  if (I & INUM)
-    s.writeAttribute("initialINum", QString::number(_initial_inum));
-  if (I & PSDNUM)
-    s.writeAttribute("initialPSDNum", QString::number(_initial_psdnum));
-  if (I & TNUM)
-    s.writeAttribute("initialTNum", QString::number(_initial_tnum));
-  if (I & MNUM)
-    s.writeAttribute("initialMNum", QString::number(_initial_mnum));
-
 }
 
-void Object::processShortNameIndexAttributes(QXmlStreamAttributes &attrs) {
-  QStringRef R;
-
-  R = attrs.value("initialVNum");
-  if (!R.isEmpty()) 
-    _vnum = R.toString().toInt();
-
-  R = attrs.value("initialXNum");
-  if (!R.isEmpty()) 
-    _xnum = R.toString().toInt();
-
-  R = attrs.value("initialPNum");
-  if (!R.isEmpty()) 
-    _pnum = R.toString().toInt();
-
-  R = attrs.value("initialCSDNum");
-  if (!R.isEmpty()) 
-    _csdnum = R.toString().toInt();
-
-  R = attrs.value("initialCNum");
-  if (!R.isEmpty()) 
-    _cnum = R.toString().toInt();
-
-  R = attrs.value("initialENum");
-  if (!R.isEmpty()) 
-    _enum = R.toString().toInt();
-
-  R = attrs.value("initialHNum");
-  if (!R.isEmpty()) 
-    _hnum = R.toString().toInt();
-
-  R = attrs.value("initialINum");
-  if (!R.isEmpty()) 
-    _inum = R.toString().toInt();
-
-  R = attrs.value("initialPSDNum");
-  if (!R.isEmpty()) 
-    _psdnum = R.toString().toInt();
-
-  R = attrs.value("initialTNum");
-  if (!R.isEmpty()) 
-    _tnum = R.toString().toInt();
-
-  R = attrs.value("initialMNum");
-  if (!R.isEmpty()) 
-    _mnum = R.toString().toInt();
-}
-
-
-}
-
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkst/object.h #815989:815990
@@ -27,6 +27,7 @@
 #include <QMetaType>
 #include <QXmlStreamWriter>
 
+#include "namedobject.h"
 #include "kst_export.h"
 #include "sharedptr.h"
 #include "rwlock.h"
@@ -39,32 +40,7 @@
 typedef SharedPtr<Object> ObjectPtr;
 
 
-// short name index variables
-extern int _vnum; // vectors
-extern int _pnum; // plugins
-extern int _csdnum; // csd
-extern int _cnum; // curves
-extern int _enum; // equations
-extern int _hnum; // histograms
-extern int _inum; // images
-extern int _psdnum; // psd
-extern int _xnum; // scalars
-extern int _tnum; // text string
-extern int _mnum; // matrix
-
-extern int max_vnum; // vectors
-extern int max_pnum; // plugins
-extern int max_csdnum; // csd
-extern int max_cnum; // curves
-extern int max_enum; // equations
-extern int max_hnum; // histograms
-extern int max_inum; // images
-extern int max_psdnum; // psd
-extern int max_xnum; // scalars
-extern int max_tnum; // string
-extern int max_mnum; // matrix
-
-class Object : public QObject, public Shared, public KstRWLock {
+class Object : public QObject, public Shared, public KstRWLock, public NamedObject {
   Q_OBJECT
 
   public:
@@ -72,20 +48,6 @@
 
     enum UpdateType { NO_CHANGE = 0, UPDATE };
 
-    enum ShortNameIndex {
-      VNUM = 0x0001,
-      PNUM = 0x0002,
-      CSDNUM = 0x0004,
-      CNUM = 0x0008,
-      ENUM = 0x0010,
-      HNUM = 0x0020,
-      INUM = 0x0040,
-      PSDNUM = 0x0080,
-      XNUM = 0x0100,
-      TNUM = 0x0200,
-      MNUM = 0x0400
-    };
-
     virtual UpdateType update() = 0;
 
     virtual const QString& typeString() const;
@@ -93,13 +55,6 @@
 
     ObjectStore *store() const;
 
-    // name system: see object names devel doc
-    QString Name() const; // eg GYRO1:V1
-    QString descriptiveName() const; // eg GYRO1: automatic or manual
-    QString shortName() const; // eg V1: always automatically generated
-    void setDescriptiveName(QString new_name); // auto if new_name.isEmpty()
-    bool descriptiveNameIsManual() const;
-
     // Returns count - 2 to account for "this" and the list pointer, therefore
     // you MUST have a reference-counted pointer to call this function
     virtual int getUsage() const;
@@ -116,7 +71,6 @@
 
     virtual void beginUpdate(ObjectPtr object);
     virtual void processUpdate(ObjectPtr object);
-    static void processShortNameIndexAttributes(QXmlStreamAttributes &attrs);
   protected:
     Object();
     virtual ~Object();
@@ -124,25 +78,6 @@
     friend class ObjectStore;
     ObjectStore *_store;  // set by ObjectStore
 
-    // name system: see object names devel doc
-    virtual QString _automaticDescriptiveName() const= 0;
-    QString _manualDescriptiveName;
-    QString _shortName;
-    virtual void saveNameInfo(QXmlStreamWriter &s, unsigned I = 0xffff);
-
-    // object indices used for saving/resorting shortnames
-    int _initial_vnum; // vectors
-    int _initial_pnum; // plugins
-    int _initial_csdnum; // csd
-    int _initial_cnum; // curves
-    int _initial_enum; // equations
-    int _initial_hnum; // histograms
-    int _initial_inum; // images
-    int _initial_psdnum; // psd
-    int _initial_xnum; // scalars
-    int _initial_tnum; // text string
-    int _initial_mnum; // matrix
-
   private:
     bool _dirty;
 
--- branches/work/kst/portto4/kst/src/libkst/vector.cpp #815989:815990
@@ -661,6 +661,10 @@
   }
 }
 
+QString Vector::description() {
+  return i18n("Vector: %1\n  %2 samples\n%3").arg(Name()).arg(length()).arg(_provider->description());
+}
+
 #undef ZERO_MEMORY
 #undef INITSIZE
 
--- branches/work/kst/portto4/kst/src/libkst/vector.h #815989:815990
@@ -153,6 +153,7 @@
 
     void triggerUpdateSignal(ObjectPtr object);
 
+    QString description();
   Q_SIGNALS:
     void vectorUpdated(ObjectPtr object);
 
--- branches/work/kst/portto4/kst/src/widgets/vectorselector.cpp #815989:815990
@@ -51,6 +51,11 @@
 
 
 void VectorSelector::emitSelectionChanged() {
+  if (selectedVector()) {
+    setToolTip(selectedVector()->description());
+  } else {
+    setToolTip(QString());
+  }
   emit selectionChanged(_vector->currentText());
 }
 


More information about the Kst mailing list