[Kst] branches/work/kst/portto4/kst/src/datasources/ascii
Peter Kümmel
syntheticpp at gmx.net
Thu Jan 27 18:24:40 CET 2011
SVN commit 1217505 by kuemmel:
add checkbox to switch between line start 0 or 1
M +16 -3 asciiconfig.ui
M +47 -7 asciiplugin.cpp
M +4 -0 asciiplugin.h
M +11 -6 asciisourceconfig.cpp
M +3 -1 asciisourceconfig.h
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfig.ui #1217504:1217505
@@ -151,11 +151,14 @@
</sizepolicy>
</property>
<property name="minimum">
- <number>1</number>
+ <number>0</number>
</property>
<property name="maximum">
<number>9999999</number>
</property>
+ <property name="value">
+ <number>0</number>
+ </property>
</widget>
</item>
<item row="1" column="0">
@@ -177,11 +180,14 @@
</sizepolicy>
</property>
<property name="minimum">
- <number>1</number>
+ <number>0</number>
</property>
<property name="maximum">
<number>9999999</number>
</property>
+ <property name="value">
+ <number>0</number>
+ </property>
</widget>
</item>
<item row="2" column="0">
@@ -206,10 +212,17 @@
<number>9999999</number>
</property>
<property name="value">
- <number>1</number>
+ <number>0</number>
</property>
</widget>
</item>
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="_zeroStart">
+ <property name="text">
+ <string>Start with 0 </string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiplugin.cpp #1217504:1217505
@@ -37,11 +37,40 @@
bgroup->addButton(_whitespace, AsciiSourceConfig::Whitespace);
bgroup->addButton(_custom, AsciiSourceConfig::Custom);
bgroup->addButton(_fixed, AsciiSourceConfig::Fixed);
+ connect(bgroup, SIGNAL(buttonClicked(int)), this, SLOT(columnLayoutChanged(int)));
- 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) {
@@ -70,13 +99,16 @@
config._columnDelimiter = _columnDelimiter->text();
config._columnWidth = _columnWidth->value();
config._columnWidthIsConst = _columnWidthIsConst->isChecked();
- config._dataLine = _startLine->value() - 1;
config._readFields = _readFields->isChecked();
config._readUnits = _readUnits->isChecked();
config._useDot = _useDot->isChecked();
- config._fieldsLine = _fieldsLine->value() - 1;
- config._unitsLine = _unitsLine->value() - 1;
+ config._dataLine = _startLine->value() - _index_offset;
+ config._fieldsLine = _fieldsLine->value() - _index_offset;
+ config._unitsLine = _unitsLine->value() - _index_offset;
+
+ config._zeroStart = _zeroStart->isChecked();
+
return config;
}
@@ -88,13 +120,21 @@
_columnDelimiter->setText(config._columnDelimiter);
_columnWidth->setValue(config._columnWidth);
_columnWidthIsConst->setChecked(config._columnWidthIsConst);
- _startLine->setValue(config._dataLine + 1);
_readFields->setChecked(config._readFields);
_readUnits->setChecked(config._readUnits);
_useDot->setChecked(config._useDot);
- _fieldsLine->setValue(config._fieldsLine + 1);
- _unitsLine->setValue(config._unitsLine + 1);
+ _index_offset = 0;
+ _startLine->setMinimum(0);
+ _fieldsLine->setMinimum(0);
+ _unitsLine->setMinimum(0);
+ _startLine->setValue(config._dataLine);
+ _fieldsLine->setValue(config._fieldsLine);
+ _unitsLine->setValue(config._unitsLine);
+
+ _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 #1217504:1217505
@@ -90,7 +90,11 @@
private Q_SLOTS:
void columnLayoutChanged(int);
+ void zeroStartChanged(int state);
+ private:
+ int _index_offset;
+
};
#endif
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.cpp #1217504:1217505
@@ -59,6 +59,8 @@
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),
@@ -69,12 +71,13 @@
_columnDelimiter(","),
_columnWidth(DEFAULT_COLUMN_WIDTH),
_columnWidthIsConst(false),
- _dataLine(1),
+ _dataLine(0),
_readFields(false),
_readUnits(false),
- _fieldsLine(1),
- _unitsLine(2),
+ _fieldsLine(0),
+ _unitsLine(0),
_useDot(true),
+ _zeroStart(false),
_localSeparator(QLocale().decimalPoint().toAscii())
{
}
@@ -96,6 +99,7 @@
_columnWidthIsConst >> cfg;
_readUnits >> cfg;
_unitsLine >> cfg;
+ _zeroStart >> cfg;
}
@@ -127,7 +131,7 @@
_columnWidthIsConst << cfg;
_readUnits << cfg;
_unitsLine << cfg;
-
+ _zeroStart << cfg;
}
@@ -166,8 +170,8 @@
_columnWidthIsConst >> s;
_readUnits >> s;
_unitsLine >> s;
+ _zeroStart >> s;
-
s.writeEndElement();
}
@@ -187,7 +191,7 @@
_columnWidthIsConst << attributes;
_readUnits << attributes;
_unitsLine << attributes;
-
+ _zeroStart << attributes;
}
@@ -211,6 +215,7 @@
_columnWidthIsConst << elem;
_readUnits << elem;
_unitsLine << elem;
+ _zeroStart << elem;
}
}
n = n.nextSibling();
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.h #1217504:1217505
@@ -53,6 +53,8 @@
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();
@@ -82,8 +84,8 @@
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;
-
char _localSeparator;
private:
More information about the Kst
mailing list