r14716 by fschmid - Scrapbook: Added a ProgressDialog when loading scrapbooks (not on application startup).
scribus-commit
scribus-commit at lists.scribus.net
Sun Feb 14 15:00:20 CET 2010
Revision: 14716
Author: fschmid
Date: 2010-02-14T13:50:06.956495Z
Commit message: Scrapbook: Added a ProgressDialog when loading scrapbooks (not on application startup).
Changeset:
M /trunk/Scribus/scribus/ui/scrapbookpalette.cpp
Diffs:
Index: scribus/ui/scrapbookpalette.cpp
===================================================================
--- scribus/ui/scrapbookpalette.cpp (revision 14715)
+++ scribus/ui/scrapbookpalette.cpp (revision 14716)
@@ -36,12 +36,14 @@
#include <QMessageBox>
#include <QToolTip>
#include <QPainter>
+#include <QProgressDialog>
#include "commonstrings.h"
#include "prefsfile.h"
#include "prefsmanager.h"
#include "query.h"
#include "scpreview.h"
+#include "scribuscore.h"
#include "stencilreader.h"
#include "fileloader.h"
#include "loadsaveplugin.h"
@@ -488,11 +490,36 @@
QString nd;
if (name.endsWith(QDir::convertSeparators("/")))
nd = name.left(name.length()-1);
+ int fileCount = 0;
+ int readCount = 0;
QDir d(name, "*.sce", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
+ fileCount += d.count();
+ QDir d2(name, "*.sml", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
+ fileCount += d2.count();
+ QDir d3(name, "*.shape", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
+ fileCount += d3.count();
+ QStringList vectorFiles = LoadSavePlugin::getExtensionsForPreview(FORMATID_ODGIMPORT);
+ for (int v = 0; v < vectorFiles.count(); v++)
+ {
+ QString ext = "*." + vectorFiles[v];
+ QDir d4(name, ext, QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
+ fileCount += d4.count();
+ }
+ QProgressDialog *pgDia = NULL;
+ if (ScCore->initialized())
+ {
+ pgDia = new QProgressDialog("Reading Files...", QString(), 0, fileCount, this);
+ pgDia->setWindowModality(Qt::WindowModal);
+ }
if ((d.exists()) && (d.count() != 0))
{
for (uint dc = 0; dc < d.count(); ++dc)
{
+ if (pgDia)
+ {
+ pgDia->setValue(readCount);
+ readCount++;
+ }
QPixmap pm;
QByteArray cf;
if (!loadRawText(QDir::cleanPath(QDir::convertSeparators(name + "/" + d[dc])), cf))
@@ -517,11 +544,15 @@
AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d[dc])), pm);
}
}
- QDir d2(name, "*.sml", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
if ((d2.exists()) && (d2.count() != 0))
{
for (uint dc = 0; dc < d2.count(); ++dc)
{
+ if (pgDia)
+ {
+ pgDia->setValue(readCount);
+ readCount++;
+ }
QPixmap pm;
QByteArray cf;
if (!loadRawText(QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])), cf))
@@ -542,11 +573,15 @@
AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])), pm);
}
}
- QDir d3(name, "*.shape", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
if ((d3.exists()) && (d3.count() != 0))
{
for (uint dc = 0; dc < d3.count(); ++dc)
{
+ if (pgDia)
+ {
+ pgDia->setValue(readCount);
+ readCount++;
+ }
QPixmap pm;
QByteArray cf;
if (!loadRawText(QDir::cleanPath(QDir::convertSeparators(name + "/" + d3[dc])), cf))
@@ -576,7 +611,6 @@
AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d3[dc])), pm);
}
}
- QStringList vectorFiles = LoadSavePlugin::getExtensionsForPreview(FORMATID_ODGIMPORT);
for (int v = 0; v < vectorFiles.count(); v++)
{
QString ext = "*." + vectorFiles[v];
@@ -585,6 +619,11 @@
{
for (uint dc = 0; dc < d4.count(); ++dc)
{
+ if (pgDia)
+ {
+ pgDia->setValue(readCount);
+ readCount++;
+ }
QPixmap pm;
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
@@ -612,6 +651,11 @@
}
}
}
+ if (pgDia)
+ {
+ pgDia->setValue(fileCount);
+ delete pgDia;
+ }
QMap<QString,Elem>::Iterator itf;
for (itf = objectMap.begin(); itf != objectMap.end(); ++itf)
{
More information about the scribus-commit
mailing list