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

Peter Kümmel syntheticpp at gmx.net
Thu Jan 27 19:48:08 CET 2011


SVN commit 1217519 by kuemmel:

line numbers start at 1 in the dialog, internal we start at 0

 M  +15 -12    asciiconfig.ui  
 M  +8 -43     asciiplugin.cpp  
 M  +1 -2      asciiplugin.h  
 M  +1 -9      asciisourceconfig.cpp  
 M  +0 -3      asciisourceconfig.h  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfig.ui #1217518:1217519
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>355</width>
+    <width>357</width>
     <height>532</height>
    </rect>
   </property>
@@ -142,7 +142,7 @@
         </property>
        </widget>
       </item>
-      <item row="0" column="1">
+      <item row="0" column="2">
        <widget class="QSpinBox" name="_startLine">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -151,13 +151,13 @@
          </sizepolicy>
         </property>
         <property name="minimum">
-         <number>0</number>
+         <number>1</number>
         </property>
         <property name="maximum">
          <number>9999999</number>
         </property>
         <property name="value">
-         <number>0</number>
+         <number>1</number>
         </property>
        </widget>
       </item>
@@ -168,7 +168,7 @@
         </property>
        </widget>
       </item>
-      <item row="1" column="1">
+      <item row="1" column="2">
        <widget class="QSpinBox" name="_fieldsLine">
         <property name="enabled">
          <bool>false</bool>
@@ -180,13 +180,13 @@
          </sizepolicy>
         </property>
         <property name="minimum">
-         <number>0</number>
+         <number>1</number>
         </property>
         <property name="maximum">
          <number>9999999</number>
         </property>
         <property name="value">
-         <number>0</number>
+         <number>1</number>
         </property>
        </widget>
       </item>
@@ -197,7 +197,7 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="1">
+      <item row="2" column="2">
        <widget class="QSpinBox" name="_unitsLine">
         <property name="enabled">
          <bool>false</bool>
@@ -208,18 +208,21 @@
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
+        <property name="minimum">
+         <number>1</number>
+        </property>
         <property name="maximum">
          <number>9999999</number>
         </property>
         <property name="value">
-         <number>0</number>
+         <number>1</number>
         </property>
        </widget>
       </item>
-      <item row="3" column="1">
-       <widget class="QCheckBox" name="_zeroStart">
+      <item row="3" column="2">
+       <widget class="QLabel" name="label">
         <property name="text">
-         <string>Start with 0 </string>
+         <string>Line numbers start at 1</string>
         </property>
        </widget>
       </item>
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiplugin.cpp #1217518:1217519
@@ -30,7 +30,11 @@
 
 
 
-ConfigWidgetAsciiInternal::ConfigWidgetAsciiInternal(QWidget *parent) : QWidget(parent), Ui_AsciiConfig() {
+ConfigWidgetAsciiInternal::ConfigWidgetAsciiInternal(QWidget *parent) : 
+    QWidget(parent), 
+    Ui_AsciiConfig(),
+    _index_offset(1)
+{
   setupUi(this);
 
   QButtonGroup* bgroup = new QButtonGroup(this);
@@ -38,39 +42,9 @@
   bgroup->addButton(_custom, AsciiSourceConfig::Custom);
   bgroup->addButton(_fixed, AsciiSourceConfig::Fixed);
   connect(bgroup, SIGNAL(buttonClicked(int)), this, SLOT(columnLayoutChanged(int)));
-
-  connect(_zeroStart, SIGNAL(stateChanged(int)), this, SLOT(zeroStartChanged(int)));
 }
 
-void ConfigWidgetAsciiInternal::zeroStartChanged(int state)
-{
-  int adjust_index = 0;
-  if (state == Qt::Checked) {
-    _index_offset = 0;
-    if (_startLine->minimum() == 1) {
-      adjust_index = -1;
-    }
-  } else {
-    _index_offset = 1;
-    if (_startLine->minimum() == 0) {
-      adjust_index = +1;
-    }
-  }
 
-  _startLine->setMinimum(0);
-  _fieldsLine->setMinimum(0);
-  _unitsLine->setMinimum(0);
-
-  _startLine->setValue(_startLine->value() + adjust_index);
-  _fieldsLine->setValue(_fieldsLine->value() + adjust_index);
-  _unitsLine->setValue(_unitsLine->value() + adjust_index);
-
-  _startLine->setMinimum(_index_offset);
-  _fieldsLine->setMinimum(_index_offset);
-  _unitsLine->setMinimum(_index_offset);
-}
-
-
 void ConfigWidgetAsciiInternal::columnLayoutChanged(int idx)
 {
   if (idx == AsciiSourceConfig::Fixed) {
@@ -107,8 +81,6 @@
   config._fieldsLine = _fieldsLine->value() - _index_offset;
   config._unitsLine = _unitsLine->value() - _index_offset;
 
-  config._zeroStart = _zeroStart->isChecked();
-
   return config;
 }
 
@@ -125,17 +97,10 @@
   _useDot->setChecked(config._useDot);
   _useComma->setChecked(!config._useDot);
   
-  _index_offset = 0;
-  _startLine->setMinimum(0);
-  _fieldsLine->setMinimum(0);
-  _unitsLine->setMinimum(0);
-  _startLine->setValue(config._dataLine);
-  _fieldsLine->setValue(config._fieldsLine);
-  _unitsLine->setValue(config._unitsLine);
+  _startLine->setValue(config._dataLine + _index_offset);
+  _fieldsLine->setValue(config._fieldsLine + _index_offset);
+  _unitsLine->setValue(config._unitsLine + _index_offset);
 
-  _zeroStart->setChecked(config._zeroStart);
-  zeroStartChanged(config._zeroStart ? Qt::Checked : Qt::Unchecked);
-
   AsciiSourceConfig::ColumnType ct = (AsciiSourceConfig::ColumnType) config._columnType.value();
   if (ct == AsciiSourceConfig::Fixed) {
     _fixed->setChecked(true);
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiplugin.h #1217518:1217519
@@ -90,10 +90,9 @@
 
   private Q_SLOTS:
     void columnLayoutChanged(int);
-    void zeroStartChanged(int state);
 
   private:
-    int _index_offset;
+    const int _index_offset;
 
 };
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.cpp #1217518:1217519
@@ -57,8 +57,6 @@
 const char AsciiSourceConfig::Tag_fieldsLine[] = "fields";
 const char AsciiSourceConfig::Key_unitsLine[] = "Units Line";
 const char AsciiSourceConfig::Tag_unitsLine[] = "units";
-const char AsciiSourceConfig::Key_zeroStart[] = "Line number start at 0";
-const char AsciiSourceConfig::Tag_zeroStart[] = "zerostart";
 
 AsciiSourceConfig::AsciiSourceConfig() :
   _delimiters(DEFAULT_COMMENT_DELIMITERS),
@@ -74,8 +72,7 @@
   _readUnits(false),
   _fieldsLine(0),
   _unitsLine(0),
-  _useDot(true),
-  _zeroStart(false)
+  _useDot(true)
 {
 }
 
@@ -96,7 +93,6 @@
   _columnWidthIsConst >> cfg;
   _readUnits >> cfg;
   _unitsLine >> cfg;
-  _zeroStart >> cfg;
 }
 
 
@@ -128,7 +124,6 @@
   _columnWidthIsConst << cfg;
   _readUnits << cfg;
   _unitsLine << cfg;
-  _zeroStart << cfg;
 }
 
 
@@ -167,7 +162,6 @@
   _columnWidthIsConst >> s;
   _readUnits >> s;
   _unitsLine >> s;
-  _zeroStart >> s;
 
   s.writeEndElement();
 }
@@ -188,7 +182,6 @@
   _columnWidthIsConst << attributes;
   _readUnits << attributes;
   _unitsLine << attributes;
-  _zeroStart << attributes;
 }
 
 
@@ -212,7 +205,6 @@
         _columnWidthIsConst << elem;
         _readUnits << elem;
         _unitsLine << elem;
-        _zeroStart << elem;
       }
     }
     n = n.nextSibling();
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.h #1217518:1217519
@@ -53,8 +53,6 @@
     static const char Tag_fieldsLine[];
     static const char Key_unitsLine[];
     static const char Tag_unitsLine[];
-    static const char Key_zeroStart[];
-    static const char Tag_zeroStart[];
 
   public:
     AsciiSourceConfig();
@@ -84,7 +82,6 @@
     NamedParameter<bool, Key_readUnits, Tag_readUnits> _readUnits;
     NamedParameter<int, Key_unitsLine, Tag_unitsLine> _unitsLine;
     NamedParameter<bool, Key_useDot, Tag_useDot> _useDot;
-    NamedParameter<bool, Key_zeroStart, Tag_zeroStart> _zeroStart;
 
 
   private:


More information about the Kst mailing list