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

Mike Fenton mike at staikos.net
Wed Oct 31 16:00:06 CET 2007


SVN commit 731376 by fenton:

Enabled Edit Vector from VectorSelector and add population of values to
VectorDialog based on existing Vector.  


 M  +9 -0      libkstapp/datadialog.cpp  
 M  +31 -25    libkstapp/editmultiplewidget.ui  
 M  +53 -2     libkstapp/vectordialog.cpp  
 M  +5 -1      libkstapp/vectordialog.h  
 M  +5 -5      libkstapp/vectortab.ui  
 M  +2 -0      widgets/vectorselector.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.cpp #731375:731376
@@ -127,7 +127,16 @@
 
 
 void DataDialog::slotEditMultiple() {
+  int currentWidth = width();
+  int extensionWidth = 400;
   extensionWidget()->setVisible(!extensionWidget()->isVisible());
+  if (!extensionWidget()->isVisible()) {
+    setMaximumWidth(currentWidth - extensionWidth);
+    setMinimumWidth(currentWidth - extensionWidth);
+  } else {
+    setMinimumWidth(currentWidth + extensionWidth);
+    setMaximumWidth(currentWidth + extensionWidth);
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/editmultiplewidget.ui #731375:731376
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>325</width>
-    <height>342</height>
+    <width>383</width>
+    <height>259</height>
    </rect>
   </property>
   <property name="sizePolicy" >
@@ -15,6 +15,12 @@
     <verstretch>0</verstretch>
    </sizepolicy>
   </property>
+  <property name="minimumSize" >
+   <size>
+    <width>383</width>
+    <height>0</height>
+   </size>
+  </property>
   <property name="windowTitle" >
    <string>EditMultipleWidget</string>
   </property>
@@ -29,7 +35,7 @@
        <rect>
         <x>2</x>
         <y>18</y>
-        <width>30</width>
+        <width>51</width>
         <height>22</height>
        </rect>
       </property>
@@ -46,9 +52,9 @@
      <widget class="QLineEdit" name="_filterEdit" >
       <property name="geometry" >
        <rect>
-        <x>37</x>
-        <y>18</y>
-        <width>161</width>
+        <x>60</x>
+        <y>20</y>
+        <width>190</width>
         <height>22</height>
        </rect>
       </property>
@@ -56,10 +62,10 @@
      <widget class="QWidget" name="layoutWidget" >
       <property name="geometry" >
        <rect>
-        <x>210</x>
+        <x>260</x>
         <y>20</y>
-        <width>88</width>
-        <height>301</height>
+        <width>97</width>
+        <height>211</height>
        </rect>
       </property>
       <layout class="QGridLayout" >
@@ -93,7 +99,7 @@
          <property name="sizeHint" >
           <size>
            <width>86</width>
-           <height>160</height>
+           <height>120</height>
           </size>
          </property>
         </spacer>
@@ -109,7 +115,7 @@
          <property name="sizeHint" >
           <size>
            <width>86</width>
-           <height>160</height>
+           <height>120</height>
           </size>
          </property>
         </spacer>
@@ -128,8 +134,8 @@
        <rect>
         <x>2</x>
         <y>42</y>
-        <width>201</width>
-        <height>281</height>
+        <width>251</width>
+        <height>191</height>
        </rect>
       </property>
      </widget>
@@ -163,34 +169,34 @@
    </hints>
   </connection>
   <connection>
-   <sender>_filterEdit</sender>
-   <signal>textChanged(QString)</signal>
-   <receiver>EditMultipleWidget</receiver>
-   <slot>applyFilter(QString)</slot>
+   <sender>_selectNoneBut</sender>
+   <signal>clicked()</signal>
+   <receiver>_objectList</receiver>
+   <slot>clearSelection()</slot>
    <hints>
     <hint type="sourcelabel" >
      <x>20</x>
      <y>20</y>
     </hint>
     <hint type="destinationlabel" >
-     <x>20</x>
-     <y>20</y>
+     <x>136</x>
+     <y>142</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>_selectNoneBut</sender>
-   <signal>clicked()</signal>
-   <receiver>_objectList</receiver>
-   <slot>clearSelection()</slot>
+   <sender>_filterEdit</sender>
+   <signal>textChanged(QString)</signal>
+   <receiver>EditMultipleWidget</receiver>
+   <slot>applyFilter(QString)</slot>
    <hints>
     <hint type="sourcelabel" >
      <x>20</x>
      <y>20</y>
     </hint>
     <hint type="destinationlabel" >
-     <x>136</x>
-     <y>142</y>
+     <x>20</x>
+     <y>20</y>
     </hint>
    </hints>
   </connection>
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.cpp #731375:731376
@@ -63,6 +63,13 @@
 }
 
 
+void VectorTab::setVectorMode(VectorMode mode) {
+  _mode = mode;
+  _readFromSource->setChecked(mode == DataVector);
+  _generateX->setChecked(mode == GeneratedVector);
+}
+
+
 QString VectorTab::file() const {
   return _fileName->file();
 }
@@ -118,7 +125,11 @@
   return _numberOfSamples->value();
 }
 
+void VectorTab::setNumberOfSamples(int numberOfSamples) {
+  _numberOfSamples->setValue(numberOfSamples);
+}
 
+
 void VectorTab::readFromSourceChanged() {
 
   if (_readFromSource->isChecked())
@@ -126,12 +137,27 @@
   else
     setVectorMode(GeneratedVector);
 
-  _rvectorGroup->setEnabled(_readFromSource->isChecked());
+  _dataVectorGroup->setEnabled(_readFromSource->isChecked());
   _dataRange->setEnabled(_readFromSource->isChecked());
-  _svectorGroup->setEnabled(!_readFromSource->isChecked());
+  _generatedVectorGroup->setEnabled(!_readFromSource->isChecked());
 }
 
 
+void VectorTab::hideGeneratedOptions() {
+  _sourceGroup->setVisible(false);
+  _generatedVectorGroup->setVisible(false);
+  setMaximumHeight(300);
+}
+
+
+void VectorTab::hideDataOptions() {
+  _sourceGroup->setVisible(false);
+  _dataVectorGroup->setVisible(false);
+  _dataRange->setVisible(false);
+  setMaximumHeight(150);
+}
+
+
 void VectorTab::fileNameChanged(const QString &file) {
   QFileInfo info(file);
   if (!info.exists() || !info.isFile())
@@ -185,6 +211,9 @@
   _vectorTab = new VectorTab(_document->objectStore(), this);
   addDataTab(_vectorTab);
 
+  if (editMode() == Edit) {
+    configureTab(dataObject);
+  }
   //FIXME need to do validation to enable/disable ok button...
 }
 
@@ -215,6 +244,28 @@
 }
 
 
+void VectorDialog::configureTab(ObjectPtr vector) {
+  if (DataVectorPtr dataVector = kst_cast<DataVector>(vector)) {
+    _vectorTab->setVectorMode(VectorTab::DataVector);
+    _vectorTab->setFile(dataVector->dataSource()->fileName());
+    _vectorTab->setDataSource(dataVector->dataSource());
+    _vectorTab->setField(dataVector->field());
+    _vectorTab->dataRange()->setCountFromEnd(dataVector->countFromEOF());
+    _vectorTab->dataRange()->setReadToEnd(dataVector->readToEOF());
+    _vectorTab->dataRange()->setSkip(dataVector->skip());
+    _vectorTab->dataRange()->setDoSkip(dataVector->doSkip());
+    _vectorTab->dataRange()->setDoFilter(dataVector->doAve());
+    _vectorTab->hideGeneratedOptions();
+  } else if (GeneratedVectorPtr generatedVector = kst_cast<GeneratedVector>(vector)) {
+    _vectorTab->setVectorMode(VectorTab::GeneratedVector);
+    _vectorTab->setFrom(generatedVector->min());
+    _vectorTab->setTo(generatedVector->max());
+    _vectorTab->setNumberOfSamples(generatedVector->length());
+    _vectorTab->hideDataOptions();
+  }
+}
+
+
 ObjectPtr VectorDialog::createNewDataObject() const {
   switch(_vectorTab->vectorMode()) {
   case VectorTab::DataVector:
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.h #731375:731376
@@ -37,7 +37,7 @@
     virtual ~VectorTab();
 
     VectorMode vectorMode() const { return _mode; }
-    void setVectorMode(VectorMode mode) { _mode = mode; }
+    void setVectorMode(VectorMode mode);
 
     //DataVector mode methods...
     DataSourcePtr dataSource() const;
@@ -63,6 +63,9 @@
     int numberOfSamples() const;
     void setNumberOfSamples(int numberOfSamples);
 
+    void hideGeneratedOptions();
+    void hideDataOptions();
+
   private Q_SLOTS:
     void readFromSourceChanged();
     void fileNameChanged(const QString &file);
@@ -88,6 +91,7 @@
   private:
     ObjectPtr createNewDataVector() const;
     ObjectPtr createNewGeneratedVector() const;
+    void configureTab(ObjectPtr vector);
 
   private:
     VectorTab *_vectorTab;
--- branches/work/kst/portto4/kst/src/libkstapp/vectortab.ui #731375:731376
@@ -11,7 +11,7 @@
   </property>
   <layout class="QGridLayout" >
    <item row="0" column="0" >
-    <widget class="QGroupBox" name="sourceGroup" >
+    <widget class="QGroupBox" name="_sourceGroup" >
      <property name="title" >
       <string>Source</string>
      </property>
@@ -62,7 +62,7 @@
     </widget>
    </item>
    <item row="2" column="0" >
-    <widget class="Kst::DataRange" name="_dataRange" >
+    <widget class="Kst::DataRange" native="1" name="_dataRange" >
      <property name="sizePolicy" >
       <sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
        <horstretch>0</horstretch>
@@ -72,7 +72,7 @@
     </widget>
    </item>
    <item row="1" column="0" >
-    <widget class="QGroupBox" name="_rvectorGroup" >
+    <widget class="QGroupBox" name="_dataVectorGroup" >
      <property name="sizePolicy" >
       <sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
        <horstretch>0</horstretch>
@@ -97,7 +97,7 @@
        </widget>
       </item>
       <item row="0" column="1" >
-       <widget class="Kst::FileRequester" name="_fileName" />
+       <widget class="Kst::FileRequester" native="1" name="_fileName" />
       </item>
       <item row="0" column="0" >
        <widget class="QLabel" name="label_4" >
@@ -175,7 +175,7 @@
     </widget>
    </item>
    <item row="3" column="0" >
-    <widget class="QGroupBox" name="_svectorGroup" >
+    <widget class="QGroupBox" name="_generatedVectorGroup" >
      <property name="enabled" >
       <bool>false</bool>
      </property>
--- branches/work/kst/portto4/kst/src/widgets/vectorselector.cpp #731375:731376
@@ -128,6 +128,8 @@
 
   if (current)
     setSelectedVector(current);
+
+  _editVector->setEnabled(_vector->count() > 0);
 }
 
 }


More information about the Kst mailing list