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

Barth Netterfield netterfield at astro.utoronto.ca
Wed Feb 2 17:06:42 CET 2011


SVN commit 1218503 by netterfield:

Improve default X vector name in data wizard.
datasource scalar model was inserting datasource strings into the tree.  Now it doesn't, and there 
is a place to add datasource scalars.



 M  +8 -6      config.h  
 M  +1 -1      src/libkstapp/datawizard.cpp  
 M  +29 -5     src/libkstapp/labeltab.cpp  
 M  +1 -0      src/libkstapp/labeltab.h  
 M  +15 -15    src/libkstapp/labeltab.ui  
 M  +0 -3      src/libkstapp/primitivemodel.cpp  
 M  +15 -0     src/libkstapp/scalarmodel.cpp  
 M  +4 -0      src/libkstapp/scalarmodel.h  
 M  +15 -0     src/libkstapp/stringmodel.cpp  
 M  +4 -0      src/libkstapp/stringmodel.h  
 M  +14 -1     src/widgets/vectorselector.cpp  
 M  +1 -1      src/widgets/vectorselector.h  


--- branches/work/kst/portto4/kst/config.h #1218502:1218503
@@ -1,11 +1,13 @@
-#ifndef KSTCONFIG_H
-#define KSTCONFIG_H
 
+#ifndef KST_CONFIG_H
+#define KST_CONFIG_H
+
+// obligatory flags
+//#define QT_NO_STL
+//#define QT_NO_KEYWORDS
+
 #define KSTVERSION "2.0.3"
-#define SVN_REVISION "unknown"
+#define INSTALL_LIBDIR "INSTALLED"
 
-/* Define if you have unsetenv */
-#define HAVE_UNSETENV 1
 
 #endif
-
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1218502:1218503
@@ -515,7 +515,7 @@
    setupUi(this);
 
   _xVectorExisting->setObjectStore(store);
-  _xVectorExisting->setToLastX();
+  _xVectorExisting->setToLastX(_dialogDefaults->value("curve/xvectorfield","INDEX").toString());
   _xAxisUseExisting->setChecked(_xVectorExisting->count()>0);
   dataRange()->loadWidgetDefaults();
   getFFTOptions()->loadWidgetDefaults();
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.cpp #1218502:1218503
@@ -47,6 +47,11 @@
   connect(_bottomLabelText, SIGNAL(textChanged(const QString &)), this, SIGNAL(modified()));
   connect(_rightLabelText, SIGNAL(textChanged(const QString &)), this, SIGNAL(modified()));
 
+  connect(_topLabelText, SIGNAL(textChanged(const QString &)), this, SLOT(_enableLabelLabels()));
+  connect(_bottomLabelText, SIGNAL(textChanged(const QString &)), this, SLOT(_enableLabelLabels()));
+  connect(_leftLabelText, SIGNAL(textChanged(const QString &)), this, SLOT(_enableLabelLabels()));
+  connect(_rightLabelText, SIGNAL(textChanged(const QString &)), this, SLOT(_enableLabelLabels()));
+
   connect(_topLabelText, SIGNAL(inFocus()), this, SLOT(labelSelected()));
   connect(_leftLabelText, SIGNAL(inFocus()), this, SLOT(labelSelected()));
   connect(_bottomLabelText, SIGNAL(inFocus()), this, SLOT(labelSelected()));
@@ -83,7 +88,6 @@
 LabelTab::~LabelTab() {
 }
 
-
 void LabelTab::update() {
 }
 
@@ -107,11 +111,12 @@
 
 
 bool LabelTab::leftLabelDirty() const {
-  return (!_leftLabelText->text().isEmpty());
+  return (_leftLabelText->isModified());
 }
 
 
 void LabelTab::setLeftLabel(const QString &label) {
+  _leftLabelLabel->setEnabled(true);
   _leftLabelText->setText(label);
 }
 
@@ -137,11 +142,12 @@
 
 
 bool LabelTab::bottomLabelDirty() const {
-  return (!_bottomLabelText->text().isEmpty());
+  return (_bottomLabelText->isModified());
 }
 
 
 void LabelTab::setBottomLabel(const QString &label) {
+  _bottomLabelLabel->setEnabled(true);
   _bottomLabelText->setText(label);
 }
 
@@ -167,11 +173,12 @@
 
 
 bool LabelTab::rightLabelDirty() const {
-  return (!_rightLabelText->text().isEmpty());
+  return (_rightLabelText->isModified());
 }
 
 
 void LabelTab::setRightLabel(const QString &label) {
+  _rightLabelLabel->setEnabled(true);
   _rightLabelText->setText(label);
 }
 
@@ -197,12 +204,13 @@
 
 
 bool LabelTab::topLabelDirty() const {
-  return (!_topLabelText->text().isEmpty());
+  return (_topLabelText->isModified());
 }
 
 
 
 void LabelTab::setTopLabel(const QString &label) {
+  _topLabelLabel->setEnabled(true);
   _topLabelText->setText(label);
 }
 
@@ -331,6 +339,16 @@
   _leftLabelText->clear();
   _rightLabelText->clear();
 
+  _topLabelText->setModified(false);
+  _bottomLabelText->setModified(false);
+  _leftLabelText->setModified(false);
+  _rightLabelText->setModified(false);
+
+  _topLabelLabel->setEnabled(false);
+  _bottomLabelLabel->setEnabled(false);
+  _leftLabelLabel->setEnabled(false);
+  _rightLabelLabel->setEnabled(false);
+
   _globalLabelColor->clearSelection();
 
   _topLabelAuto->setCheckState(Qt::PartiallyChecked);
@@ -355,6 +373,12 @@
   }
 }
 
+void LabelTab::_enableLabelLabels() {
+  _topLabelLabel->setEnabled(_topLabelText->isModified());
+  _bottomLabelLabel->setEnabled(_bottomLabelText->isModified());
+  _leftLabelLabel->setEnabled(_leftLabelText->isModified());
+  _rightLabelLabel->setEnabled(_rightLabelText->isModified());
 }
+}
 
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.h #1218502:1218503
@@ -91,6 +91,7 @@
     void labelSelected();
     void activateFields();
     void buttonUpdate();
+    void _enableLabelLabels();
 
 
 private:
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.ui #1218502:1218503
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>648</width>
+    <width>557</width>
     <height>374</height>
    </rect>
   </property>
@@ -130,7 +130,7 @@
     <widget class="Kst::StringSelector" name="_strings" native="true"/>
    </item>
    <item row="6" column="0">
-    <widget class="QLabel" name="_Label_13">
+    <widget class="QLabel" name="_topLabelLabel">
      <property name="text">
       <string>&amp;Top label:</string>
      </property>
@@ -142,13 +142,6 @@
      </property>
     </widget>
    </item>
-   <item row="6" column="1" colspan="2">
-    <widget class="Kst::LabelLineEdit" name="_topLabelText">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
    <item row="6" column="6">
     <widget class="QCheckBox" name="_topLabelAuto">
      <property name="text">
@@ -160,7 +153,7 @@
     </widget>
    </item>
    <item row="7" column="0">
-    <widget class="QLabel" name="_Label_14">
+    <widget class="QLabel" name="_bottomLabelLabel">
      <property name="text">
       <string>Botto&amp;m label:</string>
      </property>
@@ -172,7 +165,7 @@
      </property>
     </widget>
    </item>
-   <item row="7" column="1" colspan="2">
+   <item row="7" column="1" colspan="5">
     <widget class="Kst::LabelLineEdit" name="_bottomLabelText">
      <property name="enabled">
       <bool>false</bool>
@@ -190,7 +183,7 @@
     </widget>
    </item>
    <item row="8" column="0">
-    <widget class="QLabel" name="_Label_15">
+    <widget class="QLabel" name="_leftLabelLabel">
      <property name="text">
       <string>&amp;Left label:</string>
      </property>
@@ -202,7 +195,7 @@
      </property>
     </widget>
    </item>
-   <item row="8" column="1" colspan="2">
+   <item row="8" column="1" colspan="5">
     <widget class="Kst::LabelLineEdit" name="_leftLabelText">
      <property name="enabled">
       <bool>false</bool>
@@ -220,7 +213,7 @@
     </widget>
    </item>
    <item row="9" column="0">
-    <widget class="QLabel" name="_Label_16">
+    <widget class="QLabel" name="_rightLabelLabel">
      <property name="text">
       <string>&amp;Right label:</string>
      </property>
@@ -232,7 +225,7 @@
      </property>
     </widget>
    </item>
-   <item row="9" column="1" colspan="2">
+   <item row="9" column="1" colspan="5">
     <widget class="Kst::LabelLineEdit" name="_rightLabelText">
      <property name="enabled">
       <bool>false</bool>
@@ -338,6 +331,13 @@
      </property>
     </widget>
    </item>
+   <item row="6" column="1" colspan="5">
+    <widget class="Kst::LabelLineEdit" name="_topLabelText">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>
--- branches/work/kst/portto4/kst/src/libkstapp/primitivemodel.cpp #1218502:1218503
@@ -20,7 +20,6 @@
 #include <datamatrix.h>
 #include <generatedmatrix.h>
 #include <datasource.h>
-
 #include <QFileInfo>
 
 namespace Kst {
@@ -189,8 +188,6 @@
   return QVariant();
 }
 
-
-
 }
 
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.cpp #1218502:1218503
@@ -21,6 +21,8 @@
 #include <generatedmatrix.h>
 #include <datasource.h>
 
+#include <QFileInfo>
+
 namespace Kst {
 
 
@@ -42,9 +44,22 @@
   }
 }
 
+// There are not yet any per-file scalars, though things like num_frames should be constant across a datasource
+// and therefore availible as a per-file scalar... so, maybe, FIXME.
+PrimitiveTreeItem* ScalarModel::addDataSourceFileItem(DataSourcePtr dataSource, PrimitiveTreeItem* parent)
+{
 
+  QString path = dataSource->descriptiveName();
+  QFileInfo info(path);
 
+  PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << info.fileName(), parent);
+  //new PrimitiveTreeItem(QList<QVariant>() << "In directory" << info.path(), item);
 
+  return item;
 }
 
+
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.h #1218502:1218503
@@ -30,6 +30,10 @@
   }
 
   void addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent = 0);
+
+protected:
+  PrimitiveTreeItem* addDataSourceFileItem(DataSourcePtr dataSource, PrimitiveTreeItem* parent);
+
 };
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/stringmodel.cpp #1218502:1218503
@@ -21,6 +21,8 @@
 #include <generatedmatrix.h>
 #include <string_kst.h>
 
+#include <QFileInfo>
+
 namespace Kst {
 
 
@@ -42,7 +44,20 @@
   }
 }
 
+PrimitiveTreeItem* StringModel::addDataSourceFileItem(DataSourcePtr dataSource, PrimitiveTreeItem* parent)
+{
 
+  QString path = dataSource->descriptiveName();
+  QFileInfo info(path);
+
+  PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << info.fileName(), parent);
+  new PrimitiveTreeItem(QList<QVariant>() << "Name" << path, item);
+  new PrimitiveTreeItem(QList<QVariant>() << "In directory" << info.path(), item);
+
+  return item;
 }
 
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/stringmodel.h #1218502:1218503
@@ -30,6 +30,10 @@
   }
 
   void addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent = 0);
+
+protected:
+  PrimitiveTreeItem* addDataSourceFileItem(DataSourcePtr dataSource, PrimitiveTreeItem* parent);
+
 };
 
 
--- branches/work/kst/portto4/kst/src/widgets/vectorselector.cpp #1218502:1218503
@@ -152,15 +152,28 @@
 }
 
 
-void VectorSelector::setToLastX() {
+void VectorSelector::setToLastX(QString field) {
   if (!_store) {
     return;
   }
+  int match = -1;
+  VectorList vectors = _store->getObjects<Vector>();
+  int size = vectors.size();
+  for (int i = 0; i < size; ++i) {
+    if (vectors.at(i)->descriptiveName() == field) {
+      match = i;
+    }
+  }
+
+  if (match >-1) {
+    setSelectedVector(vectors.at(match));
+  } else {
   CurveList objects = _store->getObjects<Curve>();
   if (objects.count()>0) {
     setSelectedVector(objects.at(objects.count()-1)->xVector());
   }
 }
+}
 
 
 void VectorSelector::fillVectors() {
--- branches/work/kst/portto4/kst/src/widgets/vectorselector.h #1218502:1218503
@@ -42,7 +42,7 @@
     void clearSelection();
 
     void fillVectors();
-    void setToLastX();
+    void setToLastX(QString field = QString());
 
     void setIsX(bool is_x) {_isX = is_x;}
     int count() {return _vector->count();}


More information about the Kst mailing list