[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Wed May 22 21:12:49 UTC 2013
SVN commit 1356053 by netterfield:
BUG: 295502
Update the field list in config widget when field name interpretation is
changed.
M +38 -0 datasources/ascii/asciiconfigwidget.cpp
M +8 -0 datasources/ascii/asciiconfigwidget.h
M +1 -0 libkst/datasource.h
M +1 -0 libkstapp/datasourcedialog.cpp
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfigwidget.cpp #1356052:1356053
@@ -53,8 +53,13 @@
QObject::connect(_indexFreq, SIGNAL(toggled(bool)), this, SLOT(interpretationChanged(bool)));
QObject::connect(_formattedString, SIGNAL(toggled(bool)), this, SLOT(interpretationChanged(bool)));
QObject::connect(_previewButton, SIGNAL(clicked()), this, SLOT(showPreviewWindow()));
+ //QObject::connect(_timeAsciiFormatString, SIGNAL(textEdited(QString)), this, SLOT(testAsciiFormatString(QString)));
}
+void AsciiConfigWidgetInternal::testAsciiFormatString(QString format) {
+ // FIXME: add a format validator
+}
+
QString AsciiConfigWidgetInternal::readLine(QTextStream& in, int maxLength)
{
const QString line = in.readLine();
@@ -235,6 +240,8 @@
layout->addWidget(_ac, 0, 0);
layout->activate();
_oldConfig = _ac->config();
+ connect(_ac->_readFields, SIGNAL(clicked()), this, SLOT(updateIndexVector()));
+ connect(_ac->_fieldsLine, SIGNAL(valueChanged(int)), this, SLOT(updateIndexVector()));
}
@@ -253,7 +260,38 @@
_ac->setFilename(filename);
}
+void AsciiConfigWidget::updateIndexVector() {
+ save();
+ _ac->_indexVector->clear();
+ if (hasInstance()) {
+ Kst::SharedPtr<AsciiSource> src = Kst::kst_cast<AsciiSource>(instance());
+ _ac->_indexVector->addItems(src->vector().list());
+ }
+}
+
+
+void AsciiConfigWidget::cancel() {
+ // revert to _oldConfig
+ _oldConfig.saveGroup(settings());
+ _ac->setConfig(_oldConfig);
+
+ if (hasInstance()) {
+ Kst::SharedPtr<AsciiSource> src = Kst::kst_cast<AsciiSource>(instance());
+ _ac->config().saveGroup(settings(), src->fileName());
+
+ // Update the instance from our new settings
+ if (src->reusable()) {
+ src->_config.readGroup(settings(), src->fileName());
+ if (_ac->config().isUdateNecessary(_oldConfig)) {
+ src->reset();
+ src->internalDataSourceUpdate();
+ }
+ }
+ }
+}
+
+
void AsciiConfigWidget::load() {
AsciiSourceConfig config;
if (hasInstance())
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfigwidget.h #1356052:1356053
@@ -37,6 +37,7 @@
protected Q_SLOTS:
void interpretationChanged(bool enabled);
+ void testAsciiFormatString(QString format);
private:
const int _index_offset;
@@ -49,6 +50,8 @@
class AsciiConfigWidget : public Kst::DataSourceConfigWidget
{
+ Q_OBJECT
+
public:
AsciiConfigWidget(QSettings&);
~AsciiConfigWidget();
@@ -62,6 +65,11 @@
AsciiConfigWidgetInternal *_ac;
AsciiSourceConfig _oldConfig;
+
+ public Q_SLOTS:
+ void updateIndexVector();
+ virtual void cancel();
+
};
--- branches/work/kst/portto4/kst/src/libkst/datasource.h #1356052:1356053
@@ -364,6 +364,7 @@
public slots:
virtual void load() = 0;
virtual void save() = 0;
+ virtual void cancel() {return;}
private:
DataSourcePtr _instance;
--- branches/work/kst/portto4/kst/src/libkstapp/datasourcedialog.cpp #1356052:1356053
@@ -28,6 +28,7 @@
_dataSource->readLock();
_configWidget = _dataSource->configWidget();
connect(this, SIGNAL(ok()), _configWidget, SLOT(save()));
+ connect(this, SIGNAL(cancel()), _configWidget, SLOT(cancel()));
if (mode == DataDialog::Edit) {
connect(this, SIGNAL(ok()), this, SLOT(disableReuse()));
More information about the Kst
mailing list