[QGIS Commit] r9737 - branches/advanced_printing_branch2/src/app/composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Dec 4 03:49:56 EST 2008


Author: mhugent
Date: 2008-12-04 03:49:56 -0500 (Thu, 04 Dec 2008)
New Revision: 9737

Modified:
   branches/advanced_printing_branch2/src/app/composer/qgscomposer.cpp
Log:
Remember last directory for composer templates

Modified: branches/advanced_printing_branch2/src/app/composer/qgscomposer.cpp
===================================================================
--- branches/advanced_printing_branch2/src/app/composer/qgscomposer.cpp	2008-12-04 08:01:15 UTC (rev 9736)
+++ branches/advanced_printing_branch2/src/app/composer/qgscomposer.cpp	2008-12-04 08:49:56 UTC (rev 9737)
@@ -820,12 +820,18 @@
 void QgsComposer::saveAsTemplate(void)
 {
   //show file dialog
-  QString saveFileName = QFileDialog::getSaveFileName( 0, tr("save template"), QString(), "*.qpt");
+  QSettings settings;
+  QString lastSaveDir = settings.value("UI/lastComposerTemplateDir", "").toString();
+  QString saveFileName = QFileDialog::getSaveFileName( 0, tr("save template"), lastSaveDir, "*.qpt");
   if(saveFileName.isEmpty())
   {
     return;
   }
 
+  //save directory
+  QFileInfo saveFileInfo(saveFileName);
+  settings.setValue("UI/LastComposerTemplateDir", saveFileInfo.absolutePath());
+
   QFile templateFile(saveFileName);
   if(!templateFile.open(QIODevice::ReadWrite))
   {
@@ -843,7 +849,18 @@
 
 void QgsComposer::loadFromTemplate(void)
 {
-  QString openFileString = QFileDialog::getOpenFileName(0, tr("Load template"), QString(), "*.qpt");
+  QSettings settings;
+  QString openFileDir = settings.value("UI/lastComposerTemplateDir", "").toString();
+  QString openFileString = QFileDialog::getOpenFileName(0, tr("Load template"), openFileDir, "*.qpt");
+
+  if(openFileString.isEmpty())
+  {
+    return; //canceled by the user
+  }
+
+  QFileInfo openFileInfo(openFileString);
+  settings.setValue("UI/LastComposerTemplateDir", openFileInfo.absolutePath());
+
   QFile templateFile(openFileString);
   if(!templateFile.open(QIODevice::ReadOnly))
   {
@@ -1340,7 +1357,7 @@
       {
         double currentWidth = mapItem->rect().width();
         double currentHeight = mapItem->rect().height();
-        if(curretWidth - 0 > 0.0) //don't divide through zero
+        if(currentWidth - 0 > 0.0) //don't divide through zero
         {
           QgsRectangle canvasExtent = mapItem->mapRenderer()->extent();
           //adapt min y of extent such that the size of the map item stays the same



More information about the QGIS-commit mailing list