[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Sat Jun 21 00:52:11 CEST 2003


CVS commit by staikos: 

beginnings of session code, not done though.


  M +24 -6     kst.cpp   1.25
  M +11 -15    kstdoc.cpp   1.27


--- kdeextragear-2/kst/kst/kst.cpp  #1.24:1.25
@@ -21,5 +21,4 @@
 // include files for QT
 #include <qdir.h>
-#include <kprinter.h>
 #include <qpainter.h>
 #include <qtimer.h>
@@ -27,4 +26,6 @@
 
 // include files for KDE
+#include <kprinter.h>
+#include <kstandarddirs.h>
 #include <kiconloader.h>
 #include <kmessagebox.h>
@@ -498,4 +499,15 @@ void KstApp::readOptions() {
 void KstApp::saveProperties(KConfig *config) {
   //doc->saveDocument("/tmp/testfile");
+  QString name = doc->getAbsFilePath();
+  if (!name.isEmpty() || doc->getTitle() == i18n("Untitled")) {
+    config->writeEntry("Document", name);
+    config->writeEntry("NamedDocument", true);
+  } else {
+    QString sl = KGlobal::dirs()->saveLocation("kst", "kst/");
+    name = sl + "unsaved.kst";
+    doc->saveDocument(name);
+    config->writeEntry("Document", name);
+    config->writeEntry("NamedDocument", false);
+  }
 }
 
@@ -500,12 +512,18 @@ void KstApp::saveProperties(KConfig *con
 }
 
-
 void KstApp::readProperties(KConfig* config) {
+  QString name = config->readEntry("Document");
 
-  //doc->openDocument("/tmp/testfile");
+  if (name.isEmpty()) {
+    return;
+  }
 
-  // FILE *fp = fopen("/tmp/tmp.test","w");
-  //   fprintf(fp, "test readProps\n");
-  //   fclose(fp);
+  if (config->readBoolEntry("NamedDocument", false)) {
+    doc->openDocument(name);
+  } else {
+    doc->openDocument(name);
+    QFile::remove(name);
+    doc->setTitle(i18n("Untitled"));
+  }
 }
 

--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.26:1.27
@@ -86,23 +86,19 @@ const QString &KstDoc::getTitle() const 
 
 bool KstDoc::saveModified() {
-  bool completed=true;
+  bool completed = true;
 
-  if(modified) {
-    KstApp *win=(KstApp *) parent();
-    int want_save = KMessageBox::warningYesNoCancel(
-      win,
-      i18n("The current plot definition has been modified.\n"
-           "Do you want to save it?"),
-      i18n("Question"));
-    switch(want_save) {
+  if (modified) {
+    KstApp *win = static_cast<KstApp*>(parent());
+    int want_save = KMessageBox::warningYesNoCancel( win, i18n("The current plot definition has been modified. Do you want to save it?"), i18n("Question"));
+    switch (want_save) {
       case KMessageBox::Yes:
-           if (title == i18n("Untitled")){
+           if (title == i18n("Untitled")) {
              win->slotFileSaveAs();
            } else {
              saveDocument(getAbsFilePath());
-           };
+           }
 
            deleteContents();
-           completed=true;
+           completed = true;
            break;
 
@@ -110,13 +106,13 @@ bool KstDoc::saveModified() {
            setModified(false);
            deleteContents();
-           completed=true;
+           completed = true;
            break;
 
       case KMessageBox::Cancel:
-           completed=false;
+           completed = false;
            break;
 
       default:
-           completed=false;
+           completed = false;
            break;
     }




More information about the Kst mailing list