7 changes: 7 additions & 0 deletions src/datasources/ascii/asciidatainterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class DataInterfaceAsciiVector : public DataSource::DataInterface<DataVector>
explicit DataInterfaceAsciiVector(AsciiSource& a) : ascii(a) {}

void prepareRead(int);
void readingDone();
// read one element
int read(const QString&, DataVector::ReadInfo&);

Expand Down Expand Up @@ -72,6 +73,12 @@ void DataInterfaceAsciiVector::prepareRead(int number_of_read_calls)
ascii.prepareRead(number_of_read_calls);
}

//-------------------------------------------------------------------------------------------
void DataInterfaceAsciiVector::readingDone()
{
ascii.readingDone();
}

//-------------------------------------------------------------------------------------------
int DataInterfaceAsciiVector::read(const QString& field, DataVector::ReadInfo& p)
{
Expand Down
11 changes: 8 additions & 3 deletions src/datasources/ascii/asciisource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ int AsciiSource::readField(double *v, const QString& field, int s, int n)
}

int read = tryReadField(v, field, s, n);
_showProgress = false;

if (isTime(field)) {
if (_config._indexInterpretation == AsciiSourceConfig::FixedRate ) {
Expand Down Expand Up @@ -369,6 +368,12 @@ void AsciiSource::prepareRead(int count)
_showProgress = true;
}

//-------------------------------------------------------------------------------------------
void AsciiSource::readingDone()
{
_showProgress = false;
}

//-------------------------------------------------------------------------------------------
int AsciiSource::tryReadField(double *v, const QString& field, int s, int n)
{
Expand Down Expand Up @@ -561,14 +566,14 @@ QString AsciiSource::fileType() const
}

//-------------------------------------------------------------------------------------------
void AsciiSource::setUpdateType(UpdateCheckType updateType, const QString& file)
void AsciiSource::setUpdateType(UpdateCheckType updateType)
{
if (_config._updateType != updateType) {
Q_ASSERT(AsciiSourceConfig().readGroup(*_cfg, _filename) == _config);
_config._updateType = updateType;
_config.saveGroup(*_cfg, _filename);
}
DataSource::setUpdateType(updateType, file);
DataSource::setUpdateType(updateType);
}


Expand Down
3 changes: 2 additions & 1 deletion src/datasources/ascii/asciisource.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ class AsciiSource : public Kst::DataSource
virtual UpdateType internalDataSourceUpdate();

void prepareRead(int count);
void readingDone();
int readField(double *v, const QString &field, int s, int n);

QString fileType() const;
void setUpdateType(UpdateCheckType updateType, const QString& file = QString());
void setUpdateType(UpdateCheckType);

void save(QXmlStreamWriter &s);
void parseProperties(QXmlStreamAttributes &properties);
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/qimagesource/qimagesource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ QImageSource::QImageSource(Kst::ObjectStore *store, QSettings *cfg, const QStrin
setInterface(iv);
setInterface(im);

setUpdateType(None);
startUpdating(None);

_valid = false;
if (!type.isEmpty() && type != qimageTypeString) {
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/sampledatasource/sampledatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ be able to process the data.
SampleDatasourceSource::SampleDatasourceSource(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e)
: Kst::DataSource(store, cfg, filename, type), _config(0L) {

setUpdateType(None);
startUpdating(None);

_valid = false;
if (!type.isEmpty() && type != "Sample Datasource") {
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/sourcelist/sourcelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ SourceListSource::SourceListSource(Kst::ObjectStore *store, QSettings *cfg, cons
//setInterface(is);
//setInterface(im);

setUpdateType(None);
startUpdating(None);

_store = store;

Expand Down Expand Up @@ -189,7 +189,7 @@ bool SourceListSource::init() {
}
}

setUpdateType(Timer);
startUpdating(Timer);

registerChange();
return true; // false if something went wrong
Expand Down
10 changes: 7 additions & 3 deletions src/libkst/datasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ DataSource::DataSource(ObjectStore *store, QSettings *cfg, const QString& filena
setDescriptiveName(QFileInfo(_filename).fileName() + " (" + shortName() + ')');

// TODO What is the better default?
setUpdateType(File);
startUpdating(File);
}

DataSource::~DataSource() {
Expand Down Expand Up @@ -216,10 +216,14 @@ DataSource::UpdateCheckType DataSource::updateType() const
return _updateCheckType;
}

void DataSource::setUpdateType(UpdateCheckType updateType)
{
_updateCheckType = updateType;
}

void DataSource::setUpdateType(UpdateCheckType updateType, const QString& file)
void DataSource::startUpdating(UpdateCheckType updateType, const QString& file)
{
_updateCheckType = updateType;
setUpdateType(updateType);
resetFileWatcher();
if (_updateCheckType == Timer) {
QTimer::singleShot(UpdateManager::self()->minimumUpdatePeriod()-1, this, SLOT(checkUpdate()));
Expand Down
5 changes: 4 additions & 1 deletion src/libkst/datasource.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class KSTCORE_EXPORT DataSource : public Object
// read data. The buffer and range info are in ReadInfo
virtual int read(const QString& name, typename T::ReadInfo&) = 0;
virtual void prepareRead(int number_of_read_calls) {}
virtual void readingDone() {}

// named elements
virtual QStringList list() const = 0;
Expand Down Expand Up @@ -104,8 +105,10 @@ class KSTCORE_EXPORT DataSource : public Object
/************************************************************/

enum UpdateCheckType { Timer, File, None };
virtual void setUpdateType(UpdateCheckType updateType, const QString& file = QString());
virtual void setUpdateType(UpdateCheckType updateType);
UpdateCheckType updateType() const;
void startUpdating(UpdateCheckType updateType, const QString& file = QString());


virtual UpdateType objectUpdate(qint64 newSerial);

Expand Down
7 changes: 4 additions & 3 deletions src/libkstapp/datawizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ void DataWizardPageDataSource::updateTypeActivated(int idx)
}
_updateBox->setEnabled(true);
switch (idx) {
case 0: _dataSource->setUpdateType(DataSource::Timer); break;
case 1: _dataSource->setUpdateType(DataSource::File); break;
case 2: _dataSource->setUpdateType(DataSource::None); break;
case 0: _dataSource->startUpdating(DataSource::Timer); break;
case 1: _dataSource->startUpdating(DataSource::File); break;
case 2: _dataSource->startUpdating(DataSource::None); break;
default: break;
};
}
Expand Down Expand Up @@ -1280,6 +1280,7 @@ void DataWizard::finished() {
UpdateServer::self()->requestUpdateSignal();

_pageDataSource->setTypeActivated();
ds->vector().readingDone();
}

}
Expand Down
6 changes: 3 additions & 3 deletions src/libkstapp/vectordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ void VectorTab::updateTypeActivated(int idx)
}
switch (idx) {
_updateBox->setEnabled(true);
case 0: _dataSource->setUpdateType(DataSource::Timer); break;
case 1: _dataSource->setUpdateType(DataSource::File); break;
case 2: _dataSource->setUpdateType(DataSource::None); break;
case 0: _dataSource->startUpdating(DataSource::Timer); break;
case 1: _dataSource->startUpdating(DataSource::File); break;
case 2: _dataSource->startUpdating(DataSource::None); break;
default: break;
};
}
Expand Down