[QGIS Commit] r10945 - in trunk/qgis/src/plugins/grass: . modules-common

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jun 17 12:24:41 EDT 2009


Author: rugginoso
Date: 2009-06-17 12:24:40 -0400 (Wed, 17 Jun 2009)
New Revision: 10945

Modified:
   trunk/qgis/src/plugins/grass/modules-common/r.patch.qgm
   trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
   trunk/qgis/src/plugins/grass/qgsgrassmodule.h
Log:
Added the possibility to select multiple files in modules such as r.patch.
Changed the module r.patch to exploit the new feature (fixes ticket #1489)
Fixed the starting point of the selection dialog to the last directory used (fixes ticket #1362)


Modified: trunk/qgis/src/plugins/grass/modules-common/r.patch.qgm
===================================================================
--- trunk/qgis/src/plugins/grass/modules-common/r.patch.qgm	2009-06-17 14:49:47 UTC (rev 10944)
+++ trunk/qgis/src/plugins/grass/modules-common/r.patch.qgm	2009-06-17 16:24:40 UTC (rev 10945)
@@ -4,6 +4,6 @@
 <qgisgrassmodule label="Create new raster by combining other rasters" module="r.patch">
 	<option key="input"/>
 	<flag key="z" answer="off" hidden="no" />
-	<file key="input" label="Type in map names separated by a comma" />
+	<file key="input" type="multiple" />
 	<option key="output" />
 </qgisgrassmodule>

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-06-17 14:49:47 UTC (rev 10944)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-06-17 16:24:40 UTC (rev 10945)
@@ -3013,6 +3013,10 @@
   if ( qdesc.attribute( "type" ).toLower() == "new" )
   {
     mType = New;
+  } 
+  if ( qdesc.attribute( "type" ).toLower() == "multiple" )
+  {
+    mType = Multiple;
   }
 
   if ( !qdesc.attribute( "filters" ).isNull() )
@@ -3071,18 +3075,22 @@
   // TODO: unfortunately QFileDialog does not support 'new' directory
   QFileDialog *fd = new QFileDialog( this, NULL, mLineEdit->text() );
 
-  fd->setDirectory( QDir::current() );
+  static QDir currentDir = QDir::current();
+  fd->setDirectory( currentDir );
 
-  fd->setFileMode( QFileDialog::AnyFile );
-
-  if ( mType == New )
-  {
-    fd->setAcceptMode( QFileDialog::AcceptSave );
+  switch( mType ) {
+    case New:
+      fd->setFileMode( QFileDialog::AnyFile );
+      fd->setAcceptMode( QFileDialog::AcceptSave );
+      break;
+    case Multiple:
+      fd->setFileMode( QFileDialog::ExistingFiles );
+      fd->setAcceptMode( QFileDialog::AcceptOpen );
+      break;
+    default:
+      fd->setFileMode( QFileDialog::ExistingFile );
+      fd->setAcceptMode( QFileDialog::AcceptOpen );
   }
-  else
-  {
-    fd->setAcceptMode( QFileDialog::AcceptOpen );
-  }
 
   if ( mFilters.size() > 0 )
   {
@@ -3092,7 +3100,14 @@
 
   if ( fd->exec() == QDialog::Accepted )
   {
-    mLineEdit->setText( fd->selectedFiles().first() );
+    QString selectedFile = fd->selectedFiles().first();
+    QFileInfo fi = QFileInfo(selectedFile);
+    currentDir = fi.absoluteDir();
+    if (mType == Multiple)
+    {
+      selectedFile = fd->selectedFiles().join(",");   
+    }
+    mLineEdit->setText( selectedFile );
   }
 }
 

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.h
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2009-06-17 14:49:47 UTC (rev 10944)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2009-06-17 16:24:40 UTC (rev 10945)
@@ -816,7 +816,7 @@
     ~QgsGrassModuleFile();
 
     //! File type
-    enum Type { Old, New };
+    enum Type { Old, New, Multiple };
 
     // Reimplemented methods from QgsGrassModuleOptions
     QStringList options();



More information about the QGIS-commit mailing list