r16774 by fschmid - Keep progressbar alive during import.
scribus-commit
scribus-commit at lists.scribus.net
Mon Aug 8 18:21:56 UTC 2011
Author: fschmid
Date: Mon Aug 8 18:21:56 2011
New Revision: 16774
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16774
Log:
Keep progressbar alive during import.
Modified:
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16774&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Mon Aug 8 18:21:56 2011
@@ -1,5 +1,6 @@
#include "slaoutput.h"
#include <GlobalParams.h>
+#include <QApplication>
#include <QFile>
#include "commonstrings.h"
#include "loadsaveplugin.h"
@@ -32,6 +33,7 @@
m_font = 0;
firstPage = true;
pagecount = 1;
+ updateGUICounter = 0;
}
SlaOutputDev::~SlaOutputDev()
@@ -49,6 +51,7 @@
catalog = catA;
firstPage = true;
pagecount = 1;
+ updateGUICounter = 0;
m_fontEngine = new SplashFontEngine(
#if HAVE_T1LIB_H
globalParams->getEnableT1lib(),
@@ -1104,20 +1107,29 @@
ite->setLineShade(100);
ite->setFillEvenOdd(false);
ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
- ite->isInlineImage = true;
- res.save(fileName, "PNG");
- m_doc->LoadPict(fileName, z);
- ite->setImageScalingMode(false, true);
- m_doc->AdjustItemSize(ite);
- m_Elements->append(ite);
- if (m_groupStack.count() != 0)
- {
- m_groupStack.top().Items.append(ite);
- applyMask(ite);
- }
+ if (ite->tempImageFile->open())
+ {
+ QString fileName = getLongPathName(ite->tempImageFile->fileName());
+ if (!fileName.isEmpty())
+ {
+ ite->tempImageFile->close();
+ ite->isInlineImage = true;
+ res.save(fileName, "PNG");
+ m_doc->LoadPict(fileName, z);
+ ite->setImageScalingMode(false, true);
+ m_doc->AdjustItemSize(ite);
+ m_Elements->append(ite);
+ if (m_groupStack.count() != 0)
+ {
+ m_groupStack.top().Items.append(ite);
+ applyMask(ite);
+ }
+ }
+ else
+ m_doc->Items->removeAll(ite);
+ }
+ else
+ m_doc->Items->removeAll(ite);
imgStr->close();
delete imgStr;
delete image;
@@ -1219,20 +1231,29 @@
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
- ite->isInlineImage = true;
- res.save(fileName, "PNG");
- m_doc->LoadPict(fileName, z);
- ite->setImageScalingMode(false, true);
- m_doc->AdjustItemSize(ite);
- m_Elements->append(ite);
- if (m_groupStack.count() != 0)
- {
- m_groupStack.top().Items.append(ite);
- applyMask(ite);
- }
+ if (ite->tempImageFile->open())
+ {
+ QString fileName = getLongPathName(ite->tempImageFile->fileName());
+ if (!fileName.isEmpty())
+ {
+ ite->tempImageFile->close();
+ ite->isInlineImage = true;
+ res.save(fileName, "PNG");
+ m_doc->LoadPict(fileName, z);
+ ite->setImageScalingMode(false, true);
+ m_doc->AdjustItemSize(ite);
+ m_Elements->append(ite);
+ if (m_groupStack.count() != 0)
+ {
+ m_groupStack.top().Items.append(ite);
+ applyMask(ite);
+ }
+ }
+ else
+ m_doc->Items->removeAll(ite);
+ }
+ else
+ m_doc->Items->removeAll(ite);
delete imgStr;
delete[] buffer;
delete image;
@@ -1325,20 +1346,29 @@
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
- ite->isInlineImage = true;
- img.save(fileName, "PNG");
- m_doc->LoadPict(fileName, z);
- ite->setImageScalingMode(false, true);
- m_doc->AdjustItemSize(ite);
- m_Elements->append(ite);
- if (m_groupStack.count() != 0)
- {
- m_groupStack.top().Items.append(ite);
- applyMask(ite);
- }
+ if (ite->tempImageFile->open())
+ {
+ QString fileName = getLongPathName(ite->tempImageFile->fileName());
+ if (!fileName.isEmpty())
+ {
+ ite->tempImageFile->close();
+ ite->isInlineImage = true;
+ img.save(fileName, "PNG");
+ m_doc->LoadPict(fileName, z);
+ ite->setImageScalingMode(false, true);
+ m_doc->AdjustItemSize(ite);
+ m_Elements->append(ite);
+ if (m_groupStack.count() != 0)
+ {
+ m_groupStack.top().Items.append(ite);
+ applyMask(ite);
+ }
+ }
+ else
+ m_doc->Items->removeAll(ite);
+ }
+ else
+ m_doc->Items->removeAll(ite);
delete imgStr;
delete[] buffer;
delete image;
@@ -2158,6 +2188,14 @@
}
}
}
+ // Code for updating our Progressbar, needs to be called this way, as we have no
+ // possibility to get the current fileposition.
+ updateGUICounter++;
+ if (updateGUICounter > 20)
+ {
+ qApp->processEvents();
+ updateGUICounter = 0;
+ }
}
void SlaOutputDev::pushGroup(QString maskName, GBool forSoftMask, GBool alpha, bool inverted)
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16774&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h Mon Aug 8 18:21:56 2011
@@ -220,6 +220,7 @@
int importerFlags;
bool firstPage;
int pagecount;
+ int updateGUICounter;
XRef *xref; // xref table for current document
Catalog *catalog;
SplashFontEngine *m_fontEngine;
More information about the scribus-commit
mailing list