1 change: 0 additions & 1 deletion cmake/src/datasources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@


kst_init_plugin(src/datasources datasource)
kst_include_directories(app)

if(MSVC OR MINGW)
add_definitions(-DKST_USE_KST_ATOF)
Expand Down
7 changes: 3 additions & 4 deletions src/datasources/ascii/asciisource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate(bool read_complete
_reader._progress = &_progressValue;
_reader._progressObj = this;
_reader._updateRowProgress = &AsciiSource::rowProgress;
kstApp->mainWindow()->progressBar()->show();
emit progress(0, "Searching for rows");
QFuture<bool> future = QtConcurrent::run(&_reader, &AsciiDataReader::findAllDataRows, read_completely, &file, _fileSize, col_count);
bool busy = true;
while (busy) {
if (future.isFinished()) {
new_data = future;
busy = false;
kstApp->mainWindow()->progressBar()->hide();
emit progress(100, "Searching for rows finished");
} else {
ms::sleep(500);
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
Expand All @@ -250,8 +250,7 @@ void AsciiSource::rowProgress(QObject* obj)
//-------------------------------------------------------------------------------------------
void AsciiSource::updateRowProgress()
{
kstApp->mainWindow()->progressBar()->setValue(_progressValue);
kstApp->mainWindow()->setStatusMessage(QString("%1: %2 rows found.").arg(_filename).arg(QString::number(_progressRows)));
emit progress(_progressValue, QString("%1: %2 rows found.").arg(_filename).arg(QString::number(_progressRows)));
}

//-------------------------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions src/datasources/ascii/asciisource.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#ifndef ASCII_SOURCE_H
#define ASCII_SOURCE_H

#include "application.h"

#include "asciidatareader.h"
#include "asciisourceconfig.h"

Expand Down
1 change: 1 addition & 0 deletions src/libkst/datasource.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class KSTCORE_EXPORT DataSource : public Object

Q_SIGNALS:
void sourceUpdated(ObjectPtr sourceObject);
void progress(int percent, const QString& message);


protected:
Expand Down
10 changes: 7 additions & 3 deletions src/libkstapp/datawizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void DataWizardPageDataSource::sourceValid(QString filename, int requestID) {
_pageValid = true;

_dataSource = DataSourcePluginManager::findOrLoadSource(_store, filename);
connect(_dataSource, SIGNAL(progress(int, QString)), this, SIGNAL(progress(int, QString)));
_fileType->setText(_dataSource->fileType());

_dataSource->readLock();
Expand Down Expand Up @@ -708,16 +709,19 @@ int DataWizardPageDataPresentation::nextId() const {
DataWizard::DataWizard(QWidget *parent, const QString& fileToOpen)
: QWizard(parent), _document(0) {

if (MainWindow *mw = qobject_cast<MainWindow*>(parent)) {
_document = mw->document();
} else {
MainWindow *mw = qobject_cast<MainWindow*>(parent);
if (!mw) {
// we need a document
// not sure that this can ever happen.
qFatal("ERROR: can't construct a DataWizard without a document");
return;
}

_document = mw->document();
Q_ASSERT(_document);

_pageDataSource = new DataWizardPageDataSource(_document->objectStore(), this, fileToOpen);
connect(_pageDataSource, SIGNAL(progress(int, QString)), mw, SLOT(updateProgress(int, QString)));
_pageVectors = new DataWizardPageVectors(this);
_pageDataPresentation = new DataWizardPageDataPresentation(_document->objectStore(), this);
_pageFilters = new DataWizardPageFilters(this);
Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/datawizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class DataWizardPageDataSource : public QWizardPage, Ui::DataWizardPageDataSourc

Q_SIGNALS:
void dataSourceChanged();
void progress(int, const QString&);

private:
bool _pageValid;
Expand Down
11 changes: 11 additions & 0 deletions src/libkstapp/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,17 @@ QProgressBar *MainWindow::progressBar() const {
return _progressBar;
}

void MainWindow::updateProgress(int percent, const QString& message)
{
if (percent > 0 && percent < 100) {
_progressBar->setValue(percent);
_progressBar->show();
} else {
_progressBar->hide();
}
setStatusMessage(message);
}

void MainWindow::readFromEnd() {
int nf = 0;
int skip;
Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class MainWindow : public QMainWindow
void reload();

void updateViewItems(qint64 serial);
void updateProgress(int percent, const QString& message);

void save();
void saveAs();
Expand Down