[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Fri Jun 4 22:44:12 CEST 2004


CVS commit by arwalker: 

Wa have KstViewWindow::immediatePrintToPng so might as well use it.


  M +1 -21     kst.cpp   1.135
  M +5 -5      kstvcurve.cpp   1.33
  M +29 -1     kstviewwindow.cpp   1.8
  M +1 -1      kstviewwindow.h   1.8


--- kdeextragear-2/kst/kst/kst.cpp  #1.134:1.135
@@ -898,7 +898,4 @@ void KstApp::immediatePrintActiveWindowT
 void KstApp::immediatePrintWindowToPng(KMdiChildView* pWindow, const QString& filename, const QString& format, int iWidth, int iHeight) {
   KstViewWindow* pView;
-  QPixmap pixmap(iWidth, iHeight);
-  QString dotFormat;
-  QString filenameNew;
   QSize sizeOld;
   QSize size(iWidth, iHeight);
@@ -908,22 +905,5 @@ void KstApp::immediatePrintWindowToPng(K
     pView = dynamic_cast<KstViewWindow*>(pWindow);
     if (pView && !pView->view()->children().isEmpty()) {
-      QPainter paint;
-
-      if (paint.begin(&pixmap)) {
-        dotFormat = i18n(".%1").arg(format);
-        iPos = filename.findRev(dotFormat, -1, FALSE);
-        if (iPos != -1 && iPos == (int)(filename.length() - dotFormat.length())) {
-          filenameNew = filename;
-        } else {
-          filenameNew = i18n("%1.%2").arg(filename).arg(format.lower());
-        }
-
-        sizeOld = pView->view()->size();
-        pView->view()->resize(size);
-        pView->view()->paint(paint);
-        pixmap.save(filenameNew, format.latin1());
-        pView->view()->resize(sizeOld);
-        paint.end();
-      }
+      pView->immediatePrintToPng(filename,size,format);
     }
   }

--- kdeextragear-2/kst/kst/kstvcurve.cpp  #1.32:1.33
@@ -15,4 +15,6 @@
  *                                                                         *
  ***************************************************************************/
+
+#include <qmessagebox.h>
 #include <klocale.h>
 #include <kdebug.h>
@@ -101,4 +102,7 @@ void KstVCurve::commonConstructor(const 
 }
 
+KstVCurve::~KstVCurve() {
+  QMessageBox::warning(NULL,"destroy","destroy");
+}
 
 bool KstVCurve::loadInputs() {
@@ -149,8 +153,4 @@ bool KstVCurve::loadInputs() {
 }
 
-
-KstVCurve::~KstVCurve() {
-}
-
 KstObject::UpdateType KstVCurve::update(int update_counter) {
   if (!VX || !VY || KstObject::checkUpdateCounter(update_counter))

--- kdeextragear-2/kst/kst/kstviewwindow.cpp  #1.7:1.8
@@ -199,5 +199,33 @@ void KstViewWindow::immediatePrintToFile
 }
 
-void KstViewWindow::immediatePrintToPng(const QString &filename) {
+void KstViewWindow::immediatePrintToPng(const QString &filename, const QSize& size, const QString &format) {
+  QPixmap pixmap(size);
+  QString dotFormat;
+  QString filenameNew;
+  QSize sizeOld;
+  int iPos;
+
+  if (!view()->children().isEmpty()) {
+    QPainter paint;
+
+    if (paint.begin(&pixmap)) {
+      dotFormat = i18n(".%1").arg(format);
+      iPos = filename.findRev(dotFormat, -1, FALSE);
+      if (iPos != -1 && iPos == (int)(filename.length() - dotFormat.length())) {
+        filenameNew = filename;
+      } else {
+        filenameNew = i18n("%1.%2").arg(filename).arg(format.lower());
+      }
+
+      sizeOld = view()->size();
+      view()->resize(size);
+      view()->paint(paint);
+      if( !pixmap.save(filenameNew, format.latin1())) {
+        KstDebug::self()->log( i18n("Failed to save image to %1").arg(filename), KstDebug::Warning);
+      }
+      view()->resize(sizeOld);
+      paint.end();
+    }
+  }
 }
 

--- kdeextragear-2/kst/kst/kstviewwindow.h  #1.7:1.8
@@ -97,5 +97,5 @@ class KstViewWindow : public KMdiChildVi
 
     /** export to png without querrying */
-    void immediatePrintToPng(const QString &filename);
+    void immediatePrintToPng(const QString &filename, const QSize& size, const QString &format = "PNG");
 
     void slotCopy();





More information about the Kst mailing list