[Kst] kdeextragear-2/kst/kst [POSSIBLY UNSAFE]

Andrew Walker arwalker at sumusltd.com
Wed Oct 27 01:02:57 CEST 2004


CVS commit by arwalker: 

Use the status bar progress indicator rather than creating your own.


  M +21 -16    kstdatacollection-gui.cpp   1.8 [POSSIBLY UNSAFE: printf]


--- kdeextragear-2/kst/kst/kstdatacollection-gui.cpp  #1.7:1.8
@@ -16,5 +16,8 @@
  ***************************************************************************/
 
-#include "kstdatacollection.h"
+// include files for Qt
+#include <qfile.h>
+
+// include files for KDE
 #include <kapplication.h>
 #include <klocale.h>
@@ -22,5 +25,7 @@
 #include <kprogress.h>
 
-#include <qfile.h>
+// application specific includes
+#include "kst.h"
+#include "kstdatacollection.h"
 
 bool KST::dataTagNameNotUnique(const QString &tag, bool warn, void *p) {
@@ -70,5 +75,5 @@ bool KST::vectorTagNameNotUnique(const Q
 
 int KST::vectorToFile(KstVectorPtr v, QFile *f, void *p) {
-  int rc = 0;
+  KstApp *app = KstApp::inst();
 #define BSIZE 128
   char buf[BSIZE];
@@ -77,25 +84,23 @@ int KST::vectorToFile(KstVectorPtr v, QF
   double *_v = v->value();
   register int modval;
-  KProgressDialog *kpd = new KProgressDialog(static_cast<QWidget*>(p), "vector save", i18n("Saving Vector"), i18n("Saving vector %1...").arg(v->tagName()));
-
-  kpd->setAllowCancel(false);
-
-  kpd->progressBar()->setTotalSteps(_size);
-  kpd->show();
+  QString saving = i18n("Saving vector %1").arg(v->tagName());
+  int l;
+  int rc = 0;
 
   modval = QMAX(_size/100, 100);
 
+  app->slotUpdateProgress(_size, 0, QString::null);
+
   for (int i = 0; i < _size; i++) {
-    int l = snprintf(buf, BSIZE, "%g\n", _v[i]);
+    l = snprintf(buf, BSIZE, "%g\n", _v[i]);
     f->writeBlock(buf, l);
-    if (i % 100 == 0) {
-      kpd->progressBar()->setProgress(i);
-      kapp->processEvents();
+    if (i % modval == 0) {
+      app->slotUpdateProgress(_size, i, saving);
     }
   }
-  kpd->progressBar()->setProgress(_size);
+
   v->readUnlock();
 
-  delete kpd;
+  app->slotUpdateProgress(0, 0, QString::null);
 
 #undef BSIZE





More information about the Kst mailing list