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

Peter Kümmel syntheticpp at gmx.net
Tue Oct 16 20:37:46 UTC 2012


SVN commit 1320820 by kuemmel:

make usage of threads optional

 M  +76 -31    asciiconfig.ui  
 M  +3 -0      asciiplugin.cpp  
 M  +2 -3      asciisource.cpp  
 M  +0 -1      asciisource.h  
 M  +9 -1      asciisourceconfig.cpp  
 M  +3 -1      asciisourceconfig.h  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfig.ui #1320819:1320820
@@ -10,7 +10,7 @@
     <height>600</height>
    </rect>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
+  <layout class="QGridLayout" name="gridLayout" columnminimumwidth="2,0,0">
    <item row="0" column="0">
     <widget class="QLabel" name="_labelBeginning">
      <property name="text">
@@ -18,35 +18,32 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="0" rowspan="2">
+   <item row="1" column="0">
     <widget class="QPlainTextEdit" name="_showBeginning"/>
    </item>
-   <item row="1" column="1" rowspan="2" colspan="2">
+   <item row="1" column="1">
     <widget class="Line" name="verticalLine">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
     </widget>
    </item>
-   <item row="2" column="2">
+   <item row="1" column="2">
     <layout class="QVBoxLayout" name="verticalLayout">
      <item>
       <widget class="QGroupBox" name="headerButtonGroup">
        <property name="title">
         <string>Header</string>
        </property>
-       <layout class="QGridLayout" name="gridLayout2">
-        <property name="topMargin">
-         <number>3</number>
+       <widget class="QLabel" name="textLabel1_3">
+        <property name="geometry">
+         <rect>
+          <x>10</x>
+          <y>17</y>
+          <width>90</width>
+          <height>16</height>
+         </rect>
         </property>
-        <property name="bottomMargin">
-         <number>3</number>
-        </property>
-        <property name="verticalSpacing">
-         <number>3</number>
-        </property>
-        <item row="0" column="0">
-         <widget class="QLabel" name="textLabel1_3">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
             <horstretch>3</horstretch>
@@ -63,9 +60,15 @@
            <cstring>_startLine</cstring>
           </property>
          </widget>
-        </item>
-        <item row="0" column="2">
          <widget class="QSpinBox" name="_startLine">
+        <property name="geometry">
+         <rect>
+          <x>206</x>
+          <y>17</y>
+          <width>63</width>
+          <height>20</height>
+         </rect>
+        </property>
           <property name="sizePolicy">
            <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
             <horstretch>2</horstretch>
@@ -82,19 +85,31 @@
            <number>1</number>
           </property>
          </widget>
-        </item>
-        <item row="1" column="0">
          <widget class="QCheckBox" name="_readFields">
+        <property name="geometry">
+         <rect>
+          <x>10</x>
+          <y>41</y>
+          <width>153</width>
+          <height>17</height>
+         </rect>
+        </property>
           <property name="text">
            <string>Read field names from line:</string>
           </property>
          </widget>
-        </item>
-        <item row="1" column="2">
          <widget class="QSpinBox" name="_fieldsLine">
           <property name="enabled">
            <bool>false</bool>
           </property>
+        <property name="geometry">
+         <rect>
+          <x>206</x>
+          <y>40</y>
+          <width>63</width>
+          <height>20</height>
+         </rect>
+        </property>
           <property name="sizePolicy">
            <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
             <horstretch>2</horstretch>
@@ -111,22 +126,34 @@
            <number>1</number>
           </property>
          </widget>
-        </item>
-        <item row="2" column="0">
          <widget class="QCheckBox" name="_readUnits">
           <property name="enabled">
            <bool>false</bool>
           </property>
+        <property name="geometry">
+         <rect>
+          <x>10</x>
+          <y>64</y>
+          <width>122</width>
+          <height>17</height>
+         </rect>
+        </property>
           <property name="text">
            <string>Read units from line:</string>
           </property>
          </widget>
-        </item>
-        <item row="2" column="2">
          <widget class="QSpinBox" name="_unitsLine">
           <property name="enabled">
            <bool>false</bool>
           </property>
+        <property name="geometry">
+         <rect>
+          <x>206</x>
+          <y>63</y>
+          <width>63</width>
+          <height>20</height>
+         </rect>
+        </property>
           <property name="sizePolicy">
            <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
             <horstretch>2</horstretch>
@@ -143,9 +170,15 @@
            <number>1</number>
           </property>
          </widget>
-        </item>
-        <item row="3" column="2">
          <widget class="QLabel" name="label">
+        <property name="geometry">
+         <rect>
+          <x>206</x>
+          <y>86</y>
+          <width>114</width>
+          <height>16</height>
+         </rect>
+        </property>
           <property name="text">
            <string> Line numbers start at 1</string>
           </property>
@@ -153,8 +186,6 @@
            <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
           </property>
          </widget>
-        </item>
-       </layout>
       </widget>
      </item>
      <item>
@@ -437,16 +468,23 @@
        </item>
       </layout>
      </item>
+     <item>
+      <widget class="QCheckBox" name="_useThreads">
+       <property name="text">
+        <string>Use threads for parsing Ascii data</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
-   <item row="3" column="0" colspan="3">
+   <item row="2" column="0" colspan="3">
     <widget class="Line" name="line">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </widget>
    </item>
-   <item row="4" column="0">
+   <item row="3" column="0">
     <widget class="QCheckBox" name="_applyDefault">
      <property name="text">
       <string>Apply these settings as default</string>
@@ -454,6 +492,13 @@
     </widget>
    </item>
   </layout>
+  <zorder>_labelBeginning</zorder>
+  <zorder>_showBeginning</zorder>
+  <zorder>verticalLine</zorder>
+  <zorder>line</zorder>
+  <zorder>_applyDefault</zorder>
+  <zorder>_limitFileBuffer</zorder>
+  <zorder>_useThreads</zorder>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources/>
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiplugin.cpp #1320819:1320820
@@ -131,6 +131,8 @@
     config._limitFileBufferSize = size * 1024 * 1024;
   }
 
+  config._useThreads =_useThreads->isChecked();
+
   return config;
 }
 
@@ -172,6 +174,7 @@
   _limitFileBufferSize->setText(QString::number(config._limitFileBufferSize / 1024 / 1024));
   updateFrameBuffer(config._limitFileBuffer);
 
+  _useThreads->setChecked(config._useThreads);
 }
 
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1320819:1320820
@@ -51,7 +51,6 @@
   Kst::DataSource(store, cfg, filename, type),
   _reader(_config),
   _fileBuffer(),
-  _useThreads(true),
   is(new DataInterfaceAsciiString(*this)),
   iv(new DataInterfaceAsciiVector(*this))
 {
@@ -270,7 +269,7 @@
     }
 
     int numThreads;
-    if (!_useThreads) {
+    if (!_config._useThreads) {
       numThreads = 1;
     } else {
       numThreads = QThread::idealThreadCount();
@@ -292,7 +291,7 @@
   
 
   int sRead = 0;
-  if (_useThreads) {
+  if (_config._useThreads) {
     QFutureSynchronizer<int> readFutures;
     const QVector<AsciiFileData>& data = _fileBuffer.data();
     foreach (const AsciiFileData& chunk, data) {
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1320819:1320820
@@ -69,7 +69,6 @@
   private:
     AsciiDataReader _reader;
     AsciiFileBuffer _fileBuffer;
-    const bool _useThreads;
 
     friend class ConfigWidgetAscii;
     mutable AsciiSourceConfig _config;
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.cpp #1320819:1320820
@@ -55,6 +55,8 @@
 const char AsciiSourceConfig::Tag_limitFileBuffer[] = "limitFileBuffer";
 const char AsciiSourceConfig::Key_limitFileBufferSize[] = "Size of limited file buffer";
 const char AsciiSourceConfig::Tag_limitFileBufferSize[] = "limitFileBufferSize";
+const char AsciiSourceConfig::Key_useThreads[] = "Use threads when parsing Ascii data";
+const char AsciiSourceConfig::Tag_useThreads[] = "useThreads";
 
 AsciiSourceConfig::AsciiSourceConfig() :
   _delimiters(DEFAULT_COMMENT_DELIMITERS),
@@ -72,7 +74,8 @@
   _unitsLine(0),
   _useDot(true),
   _limitFileBuffer(false),
-  _limitFileBufferSize(128)
+  _limitFileBufferSize(128),
+  _useThreads(false)
 {
 }
 
@@ -95,6 +98,7 @@
   _unitsLine >> cfg;
   _limitFileBuffer >> cfg;
   _limitFileBufferSize >> cfg;
+  _useThreads >> cfg;
 }
 
 
@@ -128,6 +132,7 @@
   _unitsLine << cfg;
   _limitFileBuffer << cfg;
   _limitFileBufferSize << cfg;
+  _useThreads << cfg;
 }
 
 
@@ -168,6 +173,7 @@
   _unitsLine >> s;
   _limitFileBuffer >> s;
   _limitFileBufferSize >> s;
+  _useThreads >> s;
 
   s.writeEndElement();
 }
@@ -190,6 +196,7 @@
   _unitsLine << attributes;
   _limitFileBuffer << attributes;
   _limitFileBufferSize << attributes;
+  _useThreads << attributes;
 }
 
 
@@ -215,6 +222,7 @@
         _unitsLine << elem;
         _limitFileBuffer << elem;
         _limitFileBufferSize << elem;
+        _useThreads << elem;
       }
     }
     n = n.nextSibling();
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.h #1320819:1320820
@@ -53,6 +53,8 @@
     static const char Tag_limitFileBuffer[];
     static const char Key_limitFileBufferSize[];
     static const char Tag_limitFileBufferSize[];
+    static const char Key_useThreads[];
+    static const char Tag_useThreads[];
 
   public:
     AsciiSourceConfig();
@@ -84,8 +86,8 @@
     NamedParameter<bool, Key_useDot, Tag_useDot> _useDot;
     NamedParameter<bool, Key_limitFileBuffer, Tag_limitFileBuffer> _limitFileBuffer;
     NamedParameter<int, Key_limitFileBufferSize, Tag_limitFileBufferSize> _limitFileBufferSize;
+    NamedParameter<int, Key_useThreads, Tag_useThreads> _useThreads;
 
-
   private:
     void save(QSettings& cfg);
     void read(QSettings& cfg);


More information about the Kst mailing list