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

Adam Treat treat at kde.org
Mon Sep 24 23:33:42 CEST 2007


SVN commit 716545 by treat:

* We now can create new slave vectors via the gui.


 M  +11 -5     datadialog.cpp  
 M  +5 -0      datadialog.h  
 M  +57 -2     vectordialog.cpp  
 M  +24 -0     vectordialog.h  
 M  +15 -6     vectortab.ui  


--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.cpp #716544:716545
@@ -51,18 +51,24 @@
   QHBoxLayout *layout = new QHBoxLayout(box);
   layout->setContentsMargins(0, -1, 0, -1);
 
-  QLabel *name = new QLabel(tr("Unique Name:"), box);
-  QLineEdit *edit = new QLineEdit(box);
+  QLabel *label = new QLabel(tr("Unique Name:"), box);
+  _tagName = new QLineEdit(box);
 
   if (_dataObject)
-    edit->setText(_dataObject->tagName());
+    _tagName->setText(_dataObject->tagName());
 
-  layout->addWidget(name);
-  layout->addWidget(edit);
+  layout->addWidget(label);
+  layout->addWidget(_tagName);
 
   box->setLayout(layout);
 }
 
+
+QString DataDialog::tagName() const {
+  return _tagName->text();
+}
+
+
 void DataDialog::addDataTab(DialogTab *tab) {
   DialogPage *page = new DialogPage(this);
   page->setPageTitle(tab->tabTitle());
--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.h #716544:716545
@@ -18,6 +18,8 @@
 
 #include "kstdataobject.h"
 
+class QLineEdit;
+
 namespace Kst {
 
 class DialogTab;
@@ -32,6 +34,8 @@
     void addDataTab(DialogTab *tab);
 
   protected:
+    QString tagName() const;
+
     KstObjectPtr dataObject() const { return _dataObject; }
     void setDataObject(KstObjectPtr dataObject) { _dataObject = dataObject; }
 
@@ -45,6 +49,7 @@
     void createGui();
 
   private:
+    QLineEdit *_tagName;
     KstObjectPtr _dataObject;
 };
 
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.cpp #716544:716545
@@ -13,13 +13,17 @@
 
 #include "dialogpage.h"
 
+#include "kstsvector.h"
+
 namespace Kst {
 
 VectorTab::VectorTab(QWidget *parent)
-  : DialogTab(parent) {
+  : DialogTab(parent), _mode(ReadOnlyVector) {
 
   setupUi(this);
   setTabTitle(tr("Vector"));
+
+  connect(_readFromSource, SIGNAL(toggled(bool)), this, SLOT(sourceChanged()));
 }
 
 
@@ -27,6 +31,34 @@
 }
 
 
+int VectorTab::from() const {
+  return _from->value();
+}
+
+
+int VectorTab::to() const {
+  return _to->value();
+}
+
+
+int VectorTab::numberOfSamples() const {
+  return _numberOfSamples->value();
+}
+
+
+void VectorTab::sourceChanged() {
+
+  if (_readFromSource->isChecked())
+    setMode(ReadOnlyVector);
+  else
+    setMode(SlaveVector);
+
+  _rvectorGroup->setEnabled(_readFromSource->isChecked());
+  _dataRange->setEnabled(_readFromSource->isChecked());
+  _svectorGroup->setEnabled(!_readFromSource->isChecked());
+}
+
+
 VectorDialog::VectorDialog(QWidget *parent)
   : DataDialog(parent) {
 
@@ -50,8 +82,31 @@
 VectorDialog::~VectorDialog() {
 }
 
+
+void VectorDialog::setDefaults() {
+  //FIXME
+}
+
+
 KstObjectPtr VectorDialog::createNewDataObject() const {
-  qDebug() << "createNewDataObject" << endl;
+
+  if (_vectorTab->mode() == VectorTab::ReadOnlyVector) {
+
+    qDebug() << "ReadOnlyVectors not supported yet...!" << endl;
+    return 0;
+
+  } else if (_vectorTab->mode() == VectorTab::SlaveVector) {
+
+    const int from = _vectorTab->from();
+    const int to = _vectorTab->to();
+    const int numberOfSamples = _vectorTab->numberOfSamples();
+    const KstObjectTag tag = KstObjectTag(tagName(), KstObjectTag::globalTagContext);
+
+    KstSVectorPtr vector = new KstSVector(from, to, numberOfSamples, tag);
+    return static_cast<KstObjectPtr>(vector);
+
+  }
+
   return 0;
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.h #716544:716545
@@ -24,8 +24,29 @@
 class KST_EXPORT VectorTab : public DialogTab, Ui::VectorTab {
   Q_OBJECT
   public:
+    enum Mode { ReadOnlyVector, SlaveVector };
+
     VectorTab(QWidget *parent = 0);
     virtual ~VectorTab();
+
+    Mode mode() const { return _mode; }
+    void setMode(Mode mode) { _mode = mode; }
+
+    //Slave vector mode methods...
+    int from() const;
+    void setFrom(int from);
+
+    int to() const;
+    void setTo(int to);
+
+    int numberOfSamples() const;
+    void setNumberOfSamples(int numberOfSamples);
+
+  private Q_SLOTS:
+    void sourceChanged();
+
+  private:
+    Mode _mode;
 };
 
 class KST_EXPORT VectorDialog : public DataDialog {
@@ -40,6 +61,9 @@
     virtual KstObjectPtr editExistingDataObject() const;
 
   private:
+    void setDefaults();
+
+  private:
     VectorTab *_vectorTab;
 };
 
--- branches/work/kst/portto4/kst/src/libkstapp/vectortab.ui #716544:716545
@@ -229,6 +229,9 @@
         <property name="wordWrap" >
          <bool>false</bool>
         </property>
+        <property name="buddy" >
+         <cstring>N</cstring>
+        </property>
        </widget>
       </item>
       <item row="1" column="0" colspan="2" >
@@ -262,15 +265,18 @@
           <property name="wordWrap" >
            <bool>false</bool>
           </property>
+          <property name="buddy" >
+           <cstring>XMin</cstring>
+          </property>
          </widget>
         </item>
         <item>
-         <widget class="QLineEdit" name="_xMin" >
+         <widget class="QSpinBox" name="_to" >
           <property name="whatsThis" >
            <string>The minimum value of the independent variable.</string>
           </property>
-          <property name="text" >
-           <string>-10.0</string>
+          <property name="value" >
+           <number>-10.0</number>
           </property>
          </widget>
         </item>
@@ -288,15 +294,18 @@
           <property name="wordWrap" >
            <bool>false</bool>
           </property>
+          <property name="buddy" >
+           <cstring>XMax</cstring>
+          </property>
          </widget>
         </item>
         <item>
-         <widget class="QLineEdit" name="_xMax" >
+         <widget class="QSpinBox" name="_from" >
           <property name="whatsThis" >
            <string>The maximum value of the independent variable.</string>
           </property>
-          <property name="text" >
-           <string>10.0</string>
+          <property name="value" >
+           <number>10.0</number>
           </property>
          </widget>
         </item>


More information about the Kst mailing list