[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Fri Mar 18 03:09:26 CET 2005
CVS commit by staikos:
progress dialog added
M +23 -3 kstplotimagedrag.cpp 1.2
--- kdeextragear-2/kst/kst/kstplotimagedrag.cpp #1.1:1.2
@@ -19,7 +19,10 @@
#include "kst2dplot.h"
+#include <kapplication.h>
#include <kdebug.h>
#include <kimageio.h>
+#include <kprogress.h>
+#include <qeventloop.h>
#include <qpainter.h>
#include <qpixmap.h>
@@ -77,17 +80,34 @@ QByteArray KstPlotImageDrag::encodedData
pm.fill();
+ int prog = 0;
+ bool cancelled = false;
QPainter p(&pm);
p.setClipping(true);
- // FIXME: progress
+ KProgressDialog *dlg = new KProgressDialog(0, 0, QString::null, i18n("Generating and storing images of plots..."), true);
+ dlg->setAllowCancel(true);
+ dlg->progressBar()->setTotalSteps(_plots.count());
+ dlg->progressBar()->setValue(prog);
+ dlg->show();
+
for (KstViewObjectList::Iterator i = _plots.begin(); i != _plots.end(); ++i) {
// FIXME: make generic across view objects
- // FIXME: draw in proper locations
Kst2DPlotPtr pp = kst_cast<Kst2DPlot>(*i);
if (pp) {
- kdDebug() << "Geometry for " << pp->tagName() << " is " << pp->geometry() << endl;
p.setClipRect(pp->geometry());
p.setViewport(pp->geometry());
pp->draw(p, P_EXPORT);
}
+ if (dlg->wasCancelled()) {
+ cancelled = true;
+ break;
+ }
+ dlg->progressBar()->setValue(++prog);
+ kapp->eventLoop()->processEvents(QEventLoop::ExcludeSocketNotifiers);
+ }
+
+ delete dlg;
+
+ if (cancelled) {
+ return QByteArray();
}
More information about the Kst
mailing list