Skip to content

Commit

Permalink
show ascii file reading progress only while initial read
Browse files Browse the repository at this point in the history
  • Loading branch information
syntheticpp committed Jan 17, 2014
1 parent a569d30 commit f4e8926
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/datasources/ascii/asciisource.cpp
Expand Up @@ -68,7 +68,8 @@ AsciiSource::AsciiSource(Kst::ObjectStore *store, QSettings *cfg, const QString&
_read_count_max(-1),
_read_count(0),
is(new DataInterfaceAsciiString(*this)),
iv(new DataInterfaceAsciiVector(*this))
iv(new DataInterfaceAsciiVector(*this)),
_showProgress(false)
{
setInterface(is);
setInterface(iv);
Expand Down Expand Up @@ -218,7 +219,7 @@ Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate(bool read_complete

// Emit status message if there is more than 100 MB to parse
if (file.size() - _fileSize > 100 * 1024 * 1024 && read_completely) {
_emitProgress = true;
_emitProgress = true && _showProgress;
} else {
_emitProgress = false;
}
Expand Down Expand Up @@ -293,10 +294,11 @@ int AsciiSource::readField(double *v, const QString& field, int s, int n)
if (_emitProgress) {
updateProgress(tr("reading field"));
} else {
emit progress(0, tr("Reading field: ") + field);
emitProgress(0, tr("Reading field: ") + field);
}

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

if (isTime(field)) {
if (_config._indexInterpretation == AsciiSourceConfig::FixedRate ) {
Expand Down Expand Up @@ -364,6 +366,7 @@ void AsciiSource::prepareRead(int count)
_read_count = 0;
_progress = 0;
_progressSteps = 0;
_showProgress = true;
}

//-------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -537,7 +540,7 @@ int AsciiSource::parseWindowMultithreaded(QVector<AsciiFileData>& window, int co
//-------------------------------------------------------------------------------------------
void AsciiSource::emitProgress(int percent, const QString& message)
{
if (_read_count_max != -1) {
if (_showProgress && _read_count_max != -1) {
emit progress(percent, message);
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
Expand All @@ -546,7 +549,7 @@ void AsciiSource::emitProgress(int percent, const QString& message)
//-------------------------------------------------------------------------------------------
void AsciiSource::updateProgress(const QString& message)
{
if (_progressSteps != 0 && _read_count_max != -1) {
if (_showProgress && _progressSteps != 0 && _read_count_max != -1) {
emitProgress(50 + 50 * _progress / _progressSteps, _actualField + ": " + message);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/datasources/ascii/asciisource.h
Expand Up @@ -94,6 +94,7 @@ class AsciiSource : public Kst::DataSource
bool _haveWarned;
double _fileCreationTime_t;
bool _emitProgress;
bool _showProgress;
double _progress;
double _progressSteps;
void updateProgress(const QString&);
Expand Down

0 comments on commit f4e8926

Please sign in to comment.