Commit 169f1277 authored by Tomas Mecir's avatar Tomas Mecir
Browse files

Properly show progress when loading big documents.

parent 6b89611a
Pipeline #179280 passed with stage
in 29 minutes and 33 seconds
......@@ -112,7 +112,6 @@ KoFilter::ConversionStatus CSVFilter::convert(const QByteArray& from, const QByt
decimal = dialog->decimalSymbol();
thousands = dialog->thousandsSeparator();
int step = 100 / numRows * numCols;
int value = 0;
emit sigProgress(value);
......@@ -126,10 +125,16 @@ KoFilter::ConversionStatus CSVFilter::convert(const QByteArray& from, const QByt
Cell cell(sheet, 1, 1);
QFontMetrics fm(cell.style().font());
int processed = 0;
for (int row = 0; row < numRows; ++row) {
for (int col = 0; col < numCols; ++col) {
value += step;
emit sigProgress(value);
processed++;
int progress = (int) (100.0 * processed / (numRows * numCols));
if (progress != value) {
value = progress;
emit sigProgress(value);
}
const QString text(dialog->text(row, col));
// ### FIXME: how to calculate the width of numbers (as they might not be in the right format)
......@@ -185,8 +190,6 @@ KoFilter::ConversionStatus CSVFilter::convert(const QByteArray& from, const QByt
}
}
emit sigProgress(98);
for (int i = 0; i < numCols; ++i) {
if (widths[i] > defaultWidth)
sheet->columnFormats()->setColWidth(i + 1, i + 1, widths[i]);
......
......@@ -1454,6 +1454,7 @@ bool KoDocument::openFile()
d->progressUpdater = new KoProgressUpdater(progressProxy,
KoProgressUpdater::Unthreaded,
d->profileStream);
d->filterManager->setProgressUpdater(d->progressUpdater);
d->progressUpdater->setReferenceTime(d->profileReferenceTime);
d->progressUpdater->start(100, i18n("Opening Document"));
......@@ -1537,7 +1538,8 @@ bool KoDocument::openFile()
d->isLoading = false;
delete d->progressUpdater;
d->progressUpdater = 0;
d->progressUpdater = nullptr;
d->filterManager->setProgressUpdater(nullptr);
return false;
}
d->isEmpty = false;
......@@ -1602,7 +1604,8 @@ bool KoDocument::openFile()
updater->setProgress(100);
}
delete d->progressUpdater;
d->progressUpdater = 0;
d->filterManager->setProgressUpdater(nullptr);
d->progressUpdater = nullptr;
d->isLoading = false;
......
......@@ -530,6 +530,11 @@ bool KoFilterManager::getBatchMode(void) const
return d->batch;
}
void KoFilterManager::setProgressUpdater(KoProgressUpdater *updater)
{
d->progressUpdater = updater;
}
KoProgressUpdater* KoFilterManager::progressUpdater() const
{
if (d->progressUpdater.isNull()) {
......
......@@ -140,6 +140,11 @@ public:
**/
KoProgressUpdater *progressUpdater() const;
/**
* Set up a progress updater.
*/
void setProgressUpdater(KoProgressUpdater *updater);
private:
// === API for KoFilterChains === (internal)
// The friend methods are private in KoFilterChain and
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment