[Kst] [Bug 110731] Save As... doesn't remember the directory of last save

Andrew Walker arwalker at sumusltd.com
Mon Aug 15 20:00:51 CEST 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=110731         
arwalker sumusltd com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From arwalker sumusltd com  2005-08-15 20:00 -------
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:


More information about the Kst mailing list