Bug 110731 - Save As... doesn't remember the directory of last save
Summary: Save As... doesn't remember the directory of last save
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-13 23:57 UTC by Matthew Truch
Modified: 2005-08-15 20:00 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Truch 2005-08-13 23:57:49 UTC
Version:           1.2.0_devel (using KDE KDE 3.4.0)
OS:                Linux

kst's save as... dialog doesn't remember the directory that you were last in; each time you use it, it puts you in the CWD of the kst instance you are running.  It would make more sense if kst remembered the directory you were last saving in, at least in the same instance of kst.

Steps to Reproduce:
1. Start kst in some directory, eg your $HOME directory.
2. Plot some data or whatever.
3. Save As... the current instance as foo.kst in some other directory, like $HOME/kst/
4. Modify the plots and/or plot more data etc.
5. Save As... the current instance as bar.kst.  Note how it brought you back to $HOME, not $HOME/kst/ where you were last.

Expected behavior: 
In the same (running) instance of kst, kst remembers the directory you last saved in and that is where the save as dialog starts next time.  Also, if you start kst from some directory, and then open a .kst file from some other directory from within kst, that should be the new default location for save as... of any new .kst files saved for that kst instance.
Note that Export to Graphics File already has this behavior (of remembering the directory of last save).
Comment 1 Andrew Walker 2005-08-15 20:00:49 UTC
SVN commit 449479 by arwalker:

BUG:110731 Remember the folder that was last used for loading or saving.

 M  +13 -4     kst.cpp  
 M  +11 -0     kstdoc.cpp  
 M  +5 -0      kstdoc.h  


--- trunk/extragear/graphics/kst/kst/kst.cpp #449478:449479
@@ -1128,19 +1128,28 @@
   slotUpdateStatusMsg(i18n("Saving file with a new filename..."));
 
   while (true) {
-    QString newName=
-      KFileDialog::getSaveFileName(QDir::currentDirPath(),
+    QString folder;
+    
+    if (doc->lastFilePath().isEmpty()) {
+      folder = QDir::currentDirPath();
+    } else {
+      folder = doc->lastFilePath();
+    }
+    
+    QString newName = KFileDialog::getSaveFileName(folder,
                   i18n("*.kst|Kst Plot File (*.kst)\n*|All Files"),
                                   this, i18n("Save As"));
-    if(!newName.isEmpty()) {
+    if (!newName.isEmpty()) {
       QRegExp extension("*.kst", false, true);
       QString longName = newName;
+      
       if (!extension.exactMatch(newName)) {
         longName = newName + QString(".kst");
       }
       if (doc->saveDocument(longName)) {
+        QFileInfo saveAsInfo(longName);
+        
         addRecentFile(longName);
-        QFileInfo saveAsInfo(longName);
         doc->setTitle(saveAsInfo.fileName());
         doc->setAbsFilePath(saveAsInfo.absFilePath());
 
--- trunk/extragear/graphics/kst/kst/kstdoc.cpp #449478:449479
@@ -89,6 +89,14 @@
   return _absFilePath;
 }
 
+void KstDoc::setLastFilePath(const QString& filename) {
+  _lastFilePath = filename;
+}
+
+const QString& KstDoc::lastFilePath() const {
+  return _lastFilePath;
+}
+
 void KstDoc::setTitle(const QString& t) {
   _title = t;
 }
@@ -185,6 +193,7 @@
 
   _title = url.fileName(false);
   _absFilePath = url.path();
+  _lastFilePath = url.path();
   if (_title.isEmpty()) {
     _title = _absFilePath;
   }
@@ -664,6 +673,8 @@
   QTextStream ts(&f);
   ts.setEncoding(QTextStream::UnicodeUTF8);
 
+  _lastFilePath = KURL(filename).path();
+  
   saveDocument(ts, saveAbsoluteVectorPositions);
 
   f.close();
--- trunk/extragear/graphics/kst/kst/kstdoc.h #449478:449479
@@ -57,6 +57,8 @@
   const QString& absFilePath() const;
   /** returns the title of the document */
   const QString& title() const;
+  /** returns the pathname of the last saved/loaded document file */
+  const QString& lastFilePath() const;
 
   /** delete a curve from the curvelist and from the plots */
   RemoveStatus removeDataObject(const QString& tag);
@@ -75,6 +77,8 @@
   void setTitle(const QString& t);
   /** sets the path to the file connected with the document */
   void setAbsFilePath(const QString& filename);
+  /** sets the pathname to the last saved/loaded document file */
+  void setLastFilePath(const QString& filename);
   /** Increase the starting frame for all vectors by n_frames of the vector */
   void samplesUp();
 
@@ -101,6 +105,7 @@
 
   QString _title;
   QString _absFilePath;
+  QString _lastFilePath;
   int _lock;
 
 signals: