[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Fri Mar 12 20:34:18 CET 2004


CVS commit by arwalker: 

Split up saveDocument(...) so we can save directly to a QTextStream, which is of use for the ELOG extension.


  M +24 -19    kstdoc.cpp   1.58
  M +3 -1      kstdoc.h   1.24


--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.57:1.58
@@ -284,23 +284,6 @@ bool KstDoc::openDocument(const KURL &ur
 }
 
-bool KstDoc::saveDocument(const QString &filename) {
+void KstDoc::saveDocument( QTextStream &ts ) {
   int i;
-  backupFile(filename);
-  QFile f(filename);
-
-  if (f.exists() && (filename != getAbsFilePath())) {
-    if (KMessageBox::warningYesNo(0L, i18n("%1: A file of this name already exists.").arg(filename),
-                                  i18n("Warning"),i18n("&Overwrite"),
-                                  i18n("&Cancel")) == KMessageBox::No) {
-      return false;
-    }
-  }
-
-  if (!f.open(IO_WriteOnly|IO_Truncate)) {
-    KMessageBox::sorry(0L, i18n("%1: Could not open file for saving. The plot description has not been saved. Try a different filename or directory.").arg(filename));
-    return false;
-  }
-
-  QTextStream ts(&f);
 
   ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
@@ -376,4 +359,26 @@ bool KstDoc::saveDocument(const QString 
 
   ts << "</kstdoc>" << endl;
+}
+
+bool KstDoc::saveDocument(const QString &filename) {
+  backupFile(filename);
+  QFile f(filename);
+
+  if (f.exists() && (filename != getAbsFilePath())) {
+    if (KMessageBox::warningYesNo(0L, i18n("%1: A file of this name already exists.").arg(filename),
+                                  i18n("Warning"),i18n("&Overwrite"),
+                                  i18n("&Cancel")) == KMessageBox::No) {
+      return false;
+    }
+  }
+
+  if (!f.open(IO_WriteOnly|IO_Truncate)) {
+    KMessageBox::sorry(0L, i18n("%1: Could not open file for saving. The plot description has not been saved. Try a different filename or directory.").arg(filename));
+    return false;
+  }
+
+  QTextStream ts(&f);
+
+  saveDocument(ts);
 
   f.close();

--- kdeextragear-2/kst/kst/kstdoc.h  #1.23:1.24
@@ -58,4 +58,6 @@ public:
                     int o_n = -2, int o_f = -2,
                     int o_s = -1, bool o_ave = false);
+  /** saves the document to a QTextStream */
+  void saveDocument( QTextStream &ts );
   /** saves the document under filename */
   bool saveDocument(const QString &filename);





More information about the Kst mailing list